Post Reply 
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.
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Challenge: sum of squares. Let's break 299 - Thomas Okken - 01-19-2018 06:48 AM



User(s) browsing this thread: 1 Guest(s)