+ 4

Improving an algorithm

I am currently working on a code which can find isomers given the amount of carbon, hydrogen and oxygen atoms. The algorithm works, but is very slow... My algorithm: 1. Make a molecule with a C 2. Add it to the stack 3. While the stack is not empty -> get the first element of the stack -> if it's a valid molecule add it to a list -> add all possible paths from it to the stack 4.print list I hope somebody can improve it or find interesting ways to find isomers (rearrangements of molecules)

11th Jun 2019, 1:44 PM
Anton Böhler
Anton Böhler - avatar
5 Answers
+ 15
Although the task is different, it reminds me of this: https://www.sololearn.com/post/65146/?ref=app You can propose it as a challenge there: https://www.sololearn.com/Discuss/1270852/?ref=app try to give precise rules (atoms possible associations), and some solved test cases to put us on the way. It sounds interesting.
11th Jun 2019, 2:55 PM
CĂ©pagrave
CĂ©pagrave - avatar
+ 2
Can you share also the actual code?
11th Jun 2019, 2:23 PM
Maneren
Maneren - avatar
+ 2
https://code.sololearn.com/WK2JjDoYhYTi/?ref=app ... it works on my editor on my phone and computer but not on sololearn...
11th Jun 2019, 5:18 PM
Anton Böhler
Anton Böhler - avatar
0
Learning seems simple but coding seems difficult
12th Jun 2019, 5:47 AM
Gaurav Adhikari
Gaurav Adhikari - avatar
0
Any views about it??
12th Jun 2019, 5:48 AM
Gaurav Adhikari
Gaurav Adhikari - avatar