6 kyu
Number Sequence Rabbit Hole
62 of 84amir650
Loading description...
Puzzles
Mathematics
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.
Mathy challenge in fact.
for each generator call, it must produce one number from the sequence?????
Yes, that's how a generator works.
is there a solution in python? I think there is a time limit (12 secs) when you attempt. my code pass the small and medium sized smoke test but no luck with large dataset. I just wanna check if there is a solution, I don't ask for the soultion itself.
There are currently 34 solutions in Python.
Tests go up to ~
500 000
. Your solution is horribly inefficient. Try to do less work.LC translation
this translation modifies the description ( LC needs some more information than other languages )
JavaScript translation
approved by
Haskell translation
approved by
You are currently running only one huge test (length 500k...1M). You should have a few fixed tests of smaller length (10, 20, 50, ...) so people can debug their code without a huge error message.
Oh, and a hardcoded solution fits easily into 1000 bytes... even 300 :-)
I can easily address the first issue. I have no idea what to do about the second issue after seeing your solution.
Admire it? :P
I mean, he had to calculate it in another program, and encode it, right? Seems like a legit solution to me, lol.
Unless there's internet resources that have a million values ( which is doubtful ).
Also, the task specifies "infinite", not "a million". Any test limitations are real world resource limitations, and approximating
Infinity
with1 000 000
is at your own risk.Approved + cleaned up description
Seemed interesting at first, but turned out to be just another one of those katas where you calculate the first few elements, search for it, then copy-paste a magic formula...
There are further exercises with this sequence that make it interesting. I was going to make a series out of it.
Tests can compare specific ranges, no need to compare the sequence from beginning every time.
Random tests should compare the entire range in a single assert to avoid long sequences of
1 should equal 2
,2 should equal 1
, ...For example:
Running the same sequence for every test run is very inefficient. Probably better to
tee
one each time.Incorporated!
Make it clearer that when a number is both square and triangular (36, 1225, 41616, ...), squares always precede tringles (
(28,'t'), (36,'s'), (36,'t'), (45,'t')
and not(28,'t'), (36,'t'), (36,'s'), (45,'t')
).You can put a limit on code size to avoid precoded sequences.
Done!
How do I put a limit on the code size? I saw your clever solution! :)
@amir650 - you can reuse/adapt some code I have used for a similar purpose. See below.
You add it as a separate fixed test within the main
test.describe
block. It just scans the users solution and counts how many characters are in it.Here I have used
1000
character limit, obviously you can change this as you see fit - just adjust until @mauro-1 's example solution fails for the given range of your kata tests:Nice kata @amir650 !
Just 2 small things: you have 3 different spellings of
Hofstadter
in Discourse - the correct one isHofstadter
(it's not an easy name to spell that's for sure)Also, I'd make it clearer that the "magic derived sequence" mentioned in the Task that you want people to produce for the kata is in fact the "2,1,2..." one rather than the "squares + triangle numbers in order".
I know it's clear from the tests, but just adding something like "...for the magic derived sequence 2, 1, 2...." or something.
This comment has been hidden.
Sample test is broken:
Initial code also seems to be incorrect:
Also,
test_second_oldest_first
? There are many things left over from kata sample template that should be cleaned up.i wonder how someone completed this kata with so many bugs...and gave it 100% satisfaction 🤔
I'm not sure. This is the first time I've created a Kata. I just fixed the issues reported. Please try again and let me know?
Addressed. Thank you for finding this. This is my first Kata - I apologise for noob errors.
Typo in initial code:
inifinite
->infinite
Thank you!