Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
If this was solved on your own and not via GPT Chat, you are a genius.
Approved.
You're mutating the input list. That was the reason why it failed. I've approved the fork below so tampering with it won't be a problem anymore.
Manually checked the log, solution is correct.
Random tests always fail with:
I agree this should be explained in the kata better. Knowing this helped me solve this much faster.
Cheater! :) j/k. Clever
Ah, the interepretation here is that the element to be returned is the digit not the number.
Manually writing out the list:
[1, 12, 123, 1234, 12345, 123456, 1234567, 12345678, 123456789, 12345678910, 1234567891011, 123456789101112, 12345678910111213, 1234567891011121314]
Note that the 100-th element is the
9
in the1234567891011121314
group, whose last element (14
) is 105-th position in the "master" combined sequence.Note sure why
Assert::That(solve(100),Equals(1));
expects the 100-th element to be1
.What is missing in this interpretation ?
Cool! I did calc for squares only one time. Where do you store the sequences? Tuples or sets or...? My time for 10M is 17 sec for now, but I did start from 25 sec ))) Your results is awesome!
Just avoid list and repeated calc of the squares. Both is taking a lot of time. My results in sec:
n = 1.000: 0.0002543900000091 sec
n = 10.000: 0.0019760499999847 sec
n = 100.000: 0.0156731199999967 sec
n = 1.000.000: 0.1389633400000093 sec
n = 10.000.000: 1.4097446399999853 sec
I've just found that the last test will take v=10E7...))) on 5 mln I had the best time 9 sec. I am in stuck! it's pretty upsetting me!
I have been working on this kata 2 days. First algorithm I've made for 10 min and it goes through simple tests, but for big test (n=5 mln) I can't made it faster then 10 sec. I will improve it and I like this task, but I think this kata is harder then 5kyu. Also it would be good to accent in the task on test for really big sequences.
Thanks for the response.
The clarification is with the description. I wasn't sure if, for example, {2^2} is a valid sequence (sum of 1 elements). The min length of the sequence is not specified.
Either way, if min length of valid sequence is 2, then the test cases hold.
Cheers.
Please see description and example test cases.
for n = 100, there are only 3 numbers that meet the requirement. They are
5, 55, 77
.for n = 1000, there are only 11 numbers.
Loading more items...