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.
Project Euler #209: Circular Logic
Project Euler #209: Circular Logic
Sort by
recency
|
12 Discussions
|
Please Login in order to post a comment
This problem can be framed as special kind graph coloring problem. The vertices are inputs of truth table. We omit input values to 2 truth tables that are the same. Input values to truth table are the outputs of function F and G. Problem can be solved using recursion. For a given vertex we have 2 choices. We mark as 0 or 1. In the first case case we mark the vertex as visited and not count it. In the second case we mark the vertex and all its neigbours as visited and they are not included in the next count. Often the graph can be split into separate components. For them total count is just the product aff all counts of all components. There are 2 base cases. We have a graph wwith all marked vertices - count is 1 then or we have graph with one vertex which can have 0 or 1 valu, that is count is 2.
Can someone describe the problem more properly?
A few test cases for n=5 or n=6 would have been nice.
My solution works for 1-22, and then fails for all else mostly with wrong answer (just a few with timeout). But it seems my solution gives the right answer for the original Project Euler 209 problem (n=6). So I really dont know where to go from here.
Can someone tell me how to read input in java
I keep failing to parse the last test case. Does anyone have a clue about what's strange with it? I used the grammar in the description directly to generate my parser.