7 kyu
Lychrel numbers
Loading description...
Fundamentals
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.
If a number with trailing zeros is reversed,are the zeros dropped.ie 700 becomes 007 which becomes 7?
This kata is almost a duplicate of this older one. The difference is essentially there we must return the palindromic number itself (or -1 if not found) and not the number of iterations. I've used the same code with very few cosmetic changes and it passes both. I don't know if this should be marked as an issue...
Node 12.x should be used
The tests should not have global variables
Is anybody able to do this without getting Exitcode 137? Why are there over 40k tests...my browser keeps shitting the bed and crashing.
Yep, I've implemented
maxIter
to terminate. I'm able to pass 44000 tests in ~3 seconds, 0 failed, yet always get Exit Code 137 and browser crash. No globals either.Does your solution pass the test case
Test.assertEquals( howManyIterationsNeeded(196),null);
correctly?yes sir.
This comment has been hidden.
That's a lie, and it's the cause of your problem ;)
Oh god damnit I feel like such a moron. Thanks hobovsky.
.
Anyway, the tets are flawed because they use a global variable too, and you can rise it as an issue.
Does optional arguments belong in 7 kyu? I wonder.
This comment has been hidden.
This comment has been hidden.
This comment has been hidden.
I don't know what to use for maxIter if it is not included as a second argument, but I'm going to tackle this anyway, and see if I can figure that out...
Yes, it's intentional that the user needs to work out what would be a 'reasonable' default value for
MaxIter
. To say how I calculated the value in my solution would be a spoiler, but let us just say that you could use a higher value, but your results wouldn't change.OK, thanks for the explanation!
Tammy the ex truffle pig reassigned to solve maths problems... That's something you don't see in Kata every day!
I suggest including a wiki link just for reference https://en.wikipedia.org/wiki/Lychrel_number
Thanks - I have included it in the notes rather than the main body since there is a lot to read on that site and also others and since the kata can be solved without reference to other sources, yet contains a sneaky twist, I didn't want users to get the impression that there might need clues from elsewhere...
.