Can I use a better solution that I found online?

Hi,

I don’t have much experience with recursion and while working on the Roman Numeral Converter problem in the Intermediate Algorithm Scripting, I felt that it could be solved in a much more elegant way than what I had done (first convert the number to string array, then create an array of the numbers that need to be converted to roman numerals etc). I knew this problem could be solved more elegantly so I was looking around on Stack Overflow and found a beautiful way of solving the problem with recursion and does not require converting to string etc.

Given that I am learning, is it ok to use more elegant solutions that I learn online or is it considered plagiarism?

When you’re learning a new concept in a course like FCC, while it’s fine to absorb the ideas of others, your written solution should ultimately be from scratch. Reading others’ code is one of the best ways to learn, if not the best. By all means, read someone else’s solution, preferably after trying on your own first.

The most important thing when using someone else’s solution is to understand it. You might copy it and run it a few times, but for the final answer, delete the code and rewrite the same solution yourself. Your solution should be in your own words, so to speak, so you understand it better.

3 Likes

@chuckadams, that helps. Thanks! I always look online only after solving the problem in my own way, but it is amazing to see how people come up with such elegant and neat solutions.

Have you seen Codewars yet? The whole function of the site is to solve algorithm challenges, and then once you’ve solved an algorithm, you can see other users’ algorithms, rated by cleverness and adherence to best practices. It’s been a big help for me to practice JavaScript functions so I don’t have to keep returning to the documentation to remember how to use each function.

I just want to make sure you know that you’re not being graded on these, and no one will see your solution if you don’t want them to. You totally should read and learn from other people’s code, and that includes the algorithm challenges, but the purpose is to get you to think about problem solving and not create the most mind-blowing algorithm ever conceived.

There’s nothing wrong with what you’re asking, but I don’t want you to feel anxious about your own code, especially by comparing it to people on Stack Overflow. You should feel good feel good about what you write, even if it’s not “elegant”.

2 Likes