This is my result based on your function:
triple_double( 24352999999,3299)
True
However, according to the question, they only want "999" to match "99". For your answer, this example "continually number: 999999" can be regarded as a correct answer, which 999999 matchs 99.
Yes, this iterates through every element of the list. I don't think the perfomance gained from returning after 5 results is worth it in this case, the algorithm is still of the same time complexity, and I think it looks cleaner this way.
I don't think the perfomance gained from returning after 5 results is worth it in this case, the algorithm is still of the same time complexity, and I think it looks cleaner this way.
I am really interested in the regex, and this is a smart logic. However, if the "num1" is any number which has continually numers, such as 2354999999, the '(\d)(\1){3}' will match any number 24352999999. Apparently, this is not a correct answer for this problem, but good for kata.
You don't even need the
list(input_)
, it can just beinput_
because strings already behave the same as lists!Imo;
O(N) vs O(N) - in worst case where autocomplete words are at the end of the list, runtime is same for both.
Ω(N) vs Ω(1) - in the best case where the autocomplete words are at the start of the list, it may be worth it to stop looping when we have found 5.
Is it? O(n) versus O(1)? Not?
This comment is hidden because it contains spoiler information about the solution
See my fork for a more compact version :-)
This is my result based on your function:
triple_double( 24352999999,3299)
True
However, according to the question, they only want "999" to match "99". For your answer, this example "continually number: 999999" can be regarded as a correct answer, which 999999 matchs 99.
Yes, this iterates through every element of the list. I don't think the perfomance gained from returning after 5 results is worth it in this case, the algorithm is still of the same time complexity, and I think it looks cleaner this way.
I don't think the perfomance gained from returning after 5 results is worth it in this case, the algorithm is still of the same time complexity, and I think it looks cleaner this way.
What do you mean by 'continually numbers' ? Can you give me a test case where the solution fails ?
Solution is elegant but what about performance? Does this iterate through every element in the list even after 5 are found?
I am really interested in the regex, and this is a smart logic. However, if the "num1" is any number which has continually numers, such as 2354999999, the '(\d)(\1){3}' will match any number 24352999999. Apparently, this is not a correct answer for this problem, but good for kata.
Thanks!
One of my favorite kata I have solved on the site, really fun and educational one. Thanks!
Ah that makes sense, thanks for the clarification.
This comment is hidden because it contains spoiler information about the solution
Loading more items...