6 kyu
Increment with iterations
98 of 192Sicely
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.
I don't understand this kata. What are we supposed to do in terms of steps when the number gets bigger?
Ok, we have to synchronize our current position.
Ok so maybe this isn't a worthy question but. How do i iterate through the number, because when i increment the index it gets out of range. So like number[i+spacer] is out of range.
This comment has been hidden.
This comment has been hidden.
I got caught up on the position moving to the right if the number of digits increases for ages! Good puzzle though - definitely one of the better 6 kata ones.
Thx! Glad to hear it. You can upvote this puzzle if you like it.
It always passes?
Please specify a language.
python tests always pass
Thanks for your comment, i tryed to fix that. But im not familiar with Python. Can you say or it work good now?
yes it works now
Haskell translation
Can you explain, in your translation run not only 3 tests,right? He has a loop with many tests, but if one test of loop failed, all will too be failed? Thx, for translation!
If any individual test fails, the solution fails. If all tests pass, the solution passes.
This is shown as
3
tests, but114
are run in total (3
example tests,11
fixed tests,100
random tests ).Hi,
missing an edge case like this:
still some typos in the first sentence:
aN algorithm
,increaseS number in THE way
Thx for typo. Fix that. But i dont undestend what you mean about your edge case. I wrote randoms tests where number < 10000, step and iteration < 100. So big number like in your example not a real in my problem. Please explain more detail. Thx for help to upgrade my problem.
it's a "just in case" test. Not sure it would invalidate anything, but there aren't that many tests with the step bigger than the number, and the number growing in size (number of digits) at the same time. Here, it's growing a lot, with the step being a lot longer that the number itself, but this one varying. Basically, it's supposed to forbid bad ways to handle a step longer than the number it'self. Hopefully... x)
I am realy newbie in JS and Codewars, so me need just add this case
assert.deepEqual(increment(9,9000,100), 1854892466545716 );
to basic test? Before i have a problem with max save int, so i rewrite cata with limitations(10000 for num, and 100 for other), and check all solution in this interval(all be fine). So, if you clealy know your test is needed in this cata, you can contribute him. Becouse i havent so exp to make right decision. Thanks for your help. Sorry if i spend your time.just add it to the "Common tests", yes. the expected value is still below the MAX_SAFE_INTEGER, so it won't cause troubles (I just checked against other solution using different approaches and it passed).
Ready, thx for advice :)
Are you using the user solution for the random tests? That'll always pass! :D
You should be using a reference ( known good ) solution to calculate the expected answer.
You right. Fix that. Thx!
Python still has the same problem.
Apparently fixed.
Can we have
Node v10.x
? I want nativeBigInt
s.Also, if we have to return an exact number with full precision, native
Number
s are not ideal. ConsiderString
s orBigInt
s.Resolved now. Delete test with number greater then max safe int, and add some random test. Thx for help :)
There was something weird with the language version, so I republished with default version set to
Node 10
. That seemed to work. Then I fixed the description for a couple of spelling errors. Hope you don't mind.When leading nines overflow into a longer number, does the current position get shifted to the right?
This is not clear from the description.
Yes,position shifted. Edit it tomorrow. Thank for issue
Resolved now. Add this to description. Thx for help :)
Random tests should be added. More tests with big numbers should be added.
That my first try to write a problem. I full agree about big numbers, but where i can read about random tests?
If fiddling with ridiculous numbers is intended, mention it in the description.
Estimating this as a
4kyu
does not adequately convey that message.Dont clearly undestend what you mean. And can you explain what is
2.2199998899646556e+53
in your solution?The
2.2199998899646556e+53
in everybody's solution is due to the loss of precision. Without it, my (and probably everybody else's) solution returns2.2199998899646555e+53
. Hence the mentions about using BigInt.EDIT: link for info -> https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER
Oh, thank you very much! ix that as fast as possible.
Resolved. Thx for help :)