+ 3

New Challenge [answer with a code] (02)

Just tell me the output of the code. https://code.sololearn.com/c89PKXBkRhp3/?ref=app

31st May 2017, 9:15 PM
Ulisses Cruz
Ulisses Cruz - avatar
10 Respuestas
+ 5
waiting for validation :] 38078 [edit] i will be waiting to see your own solution for this :) https://code.sololearn.com/cfAgnENRso4H/?ref=app
31st May 2017, 10:04 PM
Burey
Burey - avatar
+ 7
thanks ^_^ but is this the approach you had in mind for the solution tho? converting recursive to iterative?
31st May 2017, 10:17 PM
Burey
Burey - avatar
+ 6
Aye it's not about the speed of the language, but of the algorithm! See if you can figure this solution out. https://code.sololearn.com/cOI9b5cWv1Yz/#py
31st May 2017, 10:52 PM
Schindlabua
Schindlabua - avatar
+ 5
ohh oh i see....
31st May 2017, 10:27 PM
Burey
Burey - avatar
+ 3
Just a different idea. Since your algorithm adds differences in a mod-7-like cycle, you can convert the bulk to a straight multiply (and add the remainder). The code below the ##### line generates the lookup table (instead of hardcoding it) and adds a debug explanation...it could all be omitted. https://code.sololearn.com/c9oezEh8G1P7/?ref=app
1st Jun 2017, 5:22 AM
Kirk Schafer
Kirk Schafer - avatar
+ 2
Please show your optimized code. EDITED: this is a requirement.
31st May 2017, 9:23 PM
Ulisses Cruz
Ulisses Cruz - avatar
+ 2
Yes I knew about that aproach. But I thought that someone would just convert the code to C++. EDITED: I thought that the C++ programmers would have advantage in this challenge.
31st May 2017, 10:23 PM
Ulisses Cruz
Ulisses Cruz - avatar
+ 1
Good work @Burey.
31st May 2017, 10:13 PM
Ulisses Cruz
Ulisses Cruz - avatar
31st May 2017, 11:32 PM
Ulisses Cruz
Ulisses Cruz - avatar
0
@Schindlabua very good work of optimization. Very good indeed. You used a lookup table. EDITED: I just did not mark your answer as winner because the challenge was for who would get the answer first.
31st May 2017, 11:21 PM
Ulisses Cruz
Ulisses Cruz - avatar