Challenge: sum of squares. Let's break 299
|
01-19-2018, 06:48 AM
Post: #7
|
|||
|
|||
RE: Challenge: sum of squares. Let's break 299
(01-19-2018 06:31 AM)Paul Dale Wrote: Instead of a brute force backtracking algorithm, build a graph with the numbers as nodes and edges where they sum to a square. Then find a Hamilton walk with a backtracking search. Why would that perform any better than my algorithm? For each number, I'm already finding potential successors in O(1) time, and I'm eliminating already-visited numbers with an array lookup. Using a graph *might* be more efficient by some constant, but it won't do anything for the overall time complexity. |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)