7 kyu
Simple Fun #129: Repeat Sequence Length
214 of 602myjinxin2015
Loading description...
Puzzles
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.
duplicate of many cycle search kata.
there is an error with examples here. Try to do it with your hands with 810,812 and 818. Here they say that 833 will be done in one iteration. Before work, we will receive 64 + 9 + 9 = 82. In the first iteration there will be 68. 68 != 82 And what is the fun of such examples?
Please read two posts below yours.
C Translation (author inactive).
approved
how 833 is 1 ?
first 833 = 64 + 9 + 9 = 82
then 82 = 64 + 4 = 68
then 68 = 36 + 84 = 100
then 1 = 1
totally 4 steps
You don't need to count the steps, you need to return the length of the repeat(ed) sequence, and 1 is the length of the repeated sequence there.
ohh thanks understood.
This comment has been hidden.
If it fails the tests, then usually that just means there's a logic error in the code. This task is about returning the length of the repeated subsection of the sequence. Your solution is missing a tiny modification in a single place to pass all tests.
C++ Translation.
Approved.
Should this have the
puzzles
tag ?!?Since there are no performance limitations, you can brute force this Kata without realizing the pattern at all; it seems this is what most solvers including myself have done, since the Kata info and the tests don't provide an incentive to figure out the puzzle.
Haskell translation
Prolog translation
JS fork Chai assertions, removed unused code
approved
I am getting lots of
expected 8 to equal 1
in random tests with my seemingly correct solution. Are you guys sure the tests and the reference solution are correct?It's the same reference solution that was there before, and my solution still seems to pass fine. I don't understand myjinxin's solution at all though, so there could be a problem with it.
@JohanWiltink You are extending the
String
prototype enumerably, and the reference solution happens to be iterating on a string with afor ... in
.Thanks. I know better than to extend
Array
this way, but this is the first time I run into trouble doing it toString
.Using
for .. of
in the reference solution would be more robust ( and not unrecommended ), but I can't really be bothered to update that.python new test framework is required. updated in this fork
Approved
It's not really clear from your example that you want the length from the first repeated element you find and not from the start of the list of elements as your example has exactly the first element repeating.
more clearly: when you get 89, you want the length back up to the first occurrence of 89 and not the whole list length, which in case of 89 is the same and therefore confusing.
Example for next users:
Replace the example 89 as 123:
if A = 123, we have:
.
Isn't this basically the same as your https://www.codewars.com/kata/simple-fun-number-23-square-digits-sequence ? I don't mind doing it twice, but I thought, what, didn't I do this one earlier today already?
Haha, sorry. I haven't noticed this.
^_^
Ah, I've checked them. They are looks similar, but their goal are different. So I'll keep them. Thanks ;-)
I've been impressed by how many you have been publishing over the last several days, it's pretty amazing.
I'm trying to reach my goal: 1000 katas Now complete:500+ katas So, I need to work harder
^_^
I think two of these myjinxins build the Great Wall of China "some" years ago, later on one of them gets the boss of Huawei and this one will fly back again to his planet next time:-))...
It is the same, the only difference is you output the length of the whole sequence in the other one, add the original n and count the repeated element twice.
This comment has been hidden.