Anybody have a solution to code coach q-sequence challenge without using recursion? | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
+ 5

Anybody have a solution to code coach q-sequence challenge without using recursion?

I think the code coach new problem q-sequence can't be solved, it requires numerous recursion and sololearn don't support that.

27th Dec 2019, 1:37 AM
CASOY
CASOY - avatar
10 Respostas
+ 6
Mihai Apostol In this šŸ case memoization is enough ā€¼ļøšŸ¤” You haven't change recursion limitā€¼ļøšŸ¤”
28th Dec 2019, 12:20 PM
Janusz Bujak šŸ‡µšŸ‡± šŸ‡ŗšŸ‡¦
Janusz Bujak šŸ‡µšŸ‡± šŸ‡ŗšŸ‡¦ - avatar
+ 5
John Bryan Pit Acaso In Python standard recursion limit is 1000. Use, let's say: import sys sys.setrecursionlimit (10 ** 6) Then use memoization. It is how I solved it with recursion.
27th Dec 2019, 10:48 AM
Mihai Apostol
Mihai Apostol - avatar
+ 5
John Bryan Pit Acaso Don't show your Code Coach solutions in public ā€¼ļø
28th Dec 2019, 10:59 AM
Janusz Bujak šŸ‡µšŸ‡± šŸ‡ŗšŸ‡¦
Janusz Bujak šŸ‡µšŸ‡± šŸ‡ŗšŸ‡¦ - avatar
+ 5
John Bryan Pit Acaso Never mind, these solutions even didn't pass because of deep recursionā‰ļøšŸ¤”
28th Dec 2019, 11:31 AM
Janusz Bujak šŸ‡µšŸ‡± šŸ‡ŗšŸ‡¦
Janusz Bujak šŸ‡µšŸ‡± šŸ‡ŗšŸ‡¦ - avatar
+ 5
Recursion is too inefficient in this case. I created an array (size of the input). So a pointer to a dynamic array. Then used a loop.
28th Dec 2019, 5:01 PM
Michele
Michele - avatar
+ 2
woaahh!! I did it! thanks a lot Alexandr.
27th Dec 2019, 3:05 AM
CASOY
CASOY - avatar
+ 2
Janusz Bujak šŸ‡µšŸ‡± Actualy I did. Only with memoization I wasn't passing test #6
28th Dec 2019, 12:30 PM
Mihai Apostol
Mihai Apostol - avatar
+ 1
Sorry about that, I just thought its fine, it's wrong anyway.
28th Dec 2019, 11:17 AM
CASOY
CASOY - avatar
+ 1
It only passed case 1 and 2. I tried to pass 32 and above as input and it returned nothing. Then I found memoization as answer.
28th Dec 2019, 11:34 AM
CASOY
CASOY - avatar
+ 1
In my opinion recursion is inefficient in most cases. It's only from time to time more elegant.
29th Dec 2019, 12:00 AM
JaScript
JaScript - avatar