+ 1

Odd error! (Never seen)

This code runs perfectly on the local machine. But shows an odd error on the Sololearn's code playground. Why this code shows such type of error? https://code.sololearn.com/c4WLVCm78Rzt/?ref=app

28th Dec 2019, 10:24 AM
Ishmam
Ishmam - avatar
4 Antworten
+ 6
Hi, the reason of the issue is that this code generates permutations from the elements of the list. With these number of elements (12) you will generate millions of permutations, and this will crash the programm, and, depending on which OS your device is running, may be also the memory management. I have reduced the number of elements, so it runs without problems. But I have a question: Why do you create permutations if you never use them? As nothing is returned from function, the finla print statement outputs "None". Here is the "reworked" code: https://code.sololearn.com/cYgyuCcLzFda/?ref=app
28th Dec 2019, 11:40 AM
Lothar
Lothar - avatar
+ 3
The line which is creating an error is list(p(lst)) Sololearn uses a playground in backend and sends the code to that particular language's Playground and gets back the output Like our code compilers, Playgrounds also have built in modules but there are not as we use them in our personal compilers They have modules and functions defined differently so that they could not pose a threat to Server security and performance and in order to achieve this Some functions and sometimes even the whole modules can be removed at runtime like for example you cannot import tkinter at here because android is not an ideal platform to run tkinter and also a gui window thus created by tkinter cannot be sent back by the server as it had to be rendered on client machine The main problem in your code is that it uses tooo much memory by creating tooo much permutations
28th Dec 2019, 11:15 AM
GodSpeed
GodSpeed - avatar
+ 3
Lothar I was working for the shuffler assignment. Thanks for the answer. 😄😄
28th Dec 2019, 12:28 PM
Ishmam
Ishmam - avatar