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.
Was having trouble with the use of brauer chain (wasn't sure brauer chain necessarily contains one of the shortest chains for every , but it satisfies the input contraint here). Implemented some sort of breadth first search with deque and got Runtime Error #2.
With a bit of tweaking, I found that for certain input range there must be a shortest chain starting with [1, 2, 4, 8, 16], and some smaller range [1, 2, 4, 8]. This reduces the queue significantly. Then it passed. Smells like cheating.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Project Euler #122: Efficient exponentiation
You are viewing a single comment's thread. Return to all comments →
Was having trouble with the use of brauer chain (wasn't sure brauer chain necessarily contains one of the shortest chains for every , but it satisfies the input contraint here). Implemented some sort of breadth first search with
deque
and got Runtime Error #2.With a bit of tweaking, I found that for certain input range there must be a shortest chain starting with
[1, 2, 4, 8, 16]
, and some smaller range[1, 2, 4, 8]
. This reduces the queue significantly. Then it passed. Smells like cheating.