We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Finally passed all tests with my Python3 implementation without timing out. Some lessons learned:
Casting is very expensive, so instead of doing divide + cast to int, try doing shift
Python dictionaries are insanely expensive compared to lists
Lists are expensive compared to storing state in the framestack, aka recursion
Getting fancy with pre-computing low-hanging fruit results usually doesn't pay off, just keep it simple. Exhaustive search with memoization is fast enough.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Project Euler #14: Longest Collatz sequence
You are viewing a single comment's thread. Return to all comments →
Finally passed all tests with my Python3 implementation without timing out. Some lessons learned: