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.
That was quite interesting. First I misread the condititions and thaugt m is limited by 6. So I hardcoded some data to solve the problem. When I saw my mistake I replaced the hardoded data by an algorithm which finds these data. But for 7 and 8 I timed out (in a large scale). Then I discovered that I do sparse matrix multiplications, so I optimized my code for it and managed to solve everything for m=7 and some of m=8. The worst case for m=8 needed nearly 20s. Finally I found a further optimization to solve everything n time.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Project Euler #237: Tours on a 4 x n playing board
You are viewing a single comment's thread. Return to all comments →
That was quite interesting. First I misread the condititions and thaugt m is limited by 6. So I hardcoded some data to solve the problem. When I saw my mistake I replaced the hardoded data by an algorithm which finds these data. But for 7 and 8 I timed out (in a large scale). Then I discovered that I do sparse matrix multiplications, so I optimized my code for it and managed to solve everything for m=7 and some of m=8. The worst case for m=8 needed nearly 20s. Finally I found a further optimization to solve everything n time.