5 kyu
Fouriest transformation
20 of 98myxoh
Loading description...
Algorithms
View
This comment has been reported as {{ abuseKindText }}.
Show
This comment has been hidden. You can view it now .
This comment can not be viewed.
- |
- Reply
- Edit
- View Solution
- Expand 1 Reply Expand {{ comments?.length }} replies
- Collapse
- Spoiler
- Remove
- Remove comment & replies
- Report
{{ fetchSolutionsError }}
-
-
Your rendered github-flavored markdown will appear here.
-
Label this discussion...
-
No Label
Keep the comment unlabeled if none of the below applies.
-
Issue
Use the issue label when reporting problems with the kata.
Be sure to explain the problem clearly and include the steps to reproduce. -
Suggestion
Use the suggestion label if you have feedback on how this kata can be improved.
-
Question
Use the question label if you have questions and/or need help solving the kata.
Don't forget to mention the language you're using, and mark as having spoiler if you include your solution.
-
No Label
- Cancel
Commenting is not allowed on this discussion
You cannot view this solution
There is no solution to show
Please sign in or sign up to leave a comment.
JavaScript: the native
BigInt
type should be used for inputs and for results.Strings could be returned. But it is easier to keep the current output format unchanged.
If the inputs are changed to
BigInt
then the solution setup will be simplified. Right now, it is not even specified that the argument could be a string for large inputs.It is fine to invalidate existing solutions. But if the output format is not changed, then it will be possible to keep some existing solutions.
fork
Thank you for fixing this issue.
Description still refers to the previous
BigInt
implementation.fixed
Ruby
Expected: "58220 is the fouriest (44) in base 14554", instead got: "58220 is the fouriest (3330340) in base 5"
real output: "44 is the fouriest (44) in base 10"
The random tests are not consistent (in Python at least). Several times I got an expected base of
>1e6
, and after a few submissions my solution, which checks every base up to~500
, passed.'35353 is the fouriest (2112403) in base 5' should equal '35353 is the fouriest (431401) in base 6' - wrong test
language... (edit: not yours, the one of your code! x) )
I guess python -- and the test is taken from the description, and it's correct.
Yes, python. I now understand, but its written gramaticaly incorrect.
Python translation kumited -- please check and approve
Thanks
Approved!
Thank you!
I think it should be "in base"?
This is with Ruby? Cannot reproduce in Haskell or JavaScript.
In expected return values:
30 is the fouriest (42) on base 7
You are right. It will require adjusting all the examples :(
Done. Also introduced some performance improvements
It still appears in the description.
Sorry. MIssed 2
Random tests almost always generate numbers with relatively small results. https://www.codewars.com/kata/reviews/59e12567060c8a98db000024/groups/5c0822fd10e90f716000167a
This is by design ( the random generator is
(do e <- choose (2,6 :: Int) ; choose (9,10^e))
).Solutions should be able to handle humongous numbers, but they may take time. They're allowed that time, same as in the original. There's only one fixed ridiculous test.
If you still consider this an issue, it's with the original testing; I'm just channeling the author here. But he's alive, so this can be figured out I guess.
I was assuming this was with Haskell. But your other issue seems to be with Ruby. With which language(s) do you have this problem?
In Ruby. Built-in convertions with base not above 36 can be used with hardcoding 1 value that's bigger than that.
It's not trivial to produce a random example with a base higher than 36. I guess I could have a whole group dedicated to hard-coded examples, but I can't think of a way of doing that with random examples.
While I was saying this, I've thought of a way haha. I'll give it a try
I've added some code that will produce a random example, with a random base higher than 36
Haskell translation
JavaScript translation
Bump.
Original author has left; any power user?
Bump.
Is there anybody out there ?!?
Approved one of the translations. the other one requires merging first!
D*mmit! I thought I took care to have identical descriptions. The merge system s*cks!
I've made a new fork. Try that one.
Done
Add random test cases.
This comment has been hidden.
Thanks for the suggestion, I've since added random cases and a more difficult case that can't be solved by just relying on .to_s(b)
Thanks. Upvoted!
Also made some format edits.