Project Euler #237: Tours on a 4 x n playing board

  • + 0 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.