bwoodhouse729

Algorithmic solution

74 posts in this topic

Not all heroes wear capes, thanks mate, will test it out soon!

1

Share this post


Link to post
Share on other sites

Since there's some interest, I updated with a simple example commented at the top of the program.  

 

WallaceErick2, it looks like you didn't make the CombinationGenerator class available to the system when you ran the program.  Make sure you downloaded that to the same directory as Energy_Balance.

1

Share this post


Link to post
Share on other sites

thanks for the answer. :D

 

For this example:

Sem-_T_tulo-1.png

 

my vars:

//  original_values  = {4, 5, -2, -3, -4, -5, -1, 3, 4, 4, 0, 1, 8}
//  addends            = {{0, 1, 2, 3}, {0, 4, 7, 9}, {3, 6, 8, 12}, {9, 10, 11, 12}}
//  sums                 = {-3, 3, 7, 9}

 

returns:

Position 0: 4 
Position 1: -2 
Position 2: -4 
Position 3: -1 
Position 4: -5 
Position 5: 1000 
Position 6: 4 
Position 7: 1 
Position 8: 0 
Position 9: 3 
Position 10: 5 
Position 11: -3 
Position 12: 4 

 

why position 5 is 1000?

 

Edited by WallaceErick2
0

Share this post


Link to post
Share on other sites

I'm in the 6th puzzle, this one: 

 

YWkHiMG.png

 

The values I put:

 

- {2, -4, 0, -3, 1, -8, 0, -6, -5, -8, -3, 4, -2, -6, -1, -2, -2, 8, -1, 8, 0, 4, -2, 5, 2, 7, 1};

- {{0, 1, 2, 3, 4}, {5, 6, 7}, {8, 9, 10}, {0,7}, {14, 15, 16, 17, 18}, {6, 11, 13, 19, 22}, {21, 22, 23}, {4, 9, 12, 17, 20, 25}, {24, 25, 26}}; 

- {2, 3, -3, 8, 14, -3, -8, -5, -12};

 

> Runs program

> No solution found 😐

 

Edited by LucasDiasC
0

Share this post


Link to post
Share on other sites

WallaceErick2, my default value for solutions was 1000 to indicate the algorithm didn't find a value for it.  Here it's because there's no constraint involving position 5.  Of course, position 5 just takes the remaining number that doesn't show up in any other position.

 

LucasDiasC, there must be a bug somewhere preventing it from considering all cases.  If it continues to be a problem I can debug further.  However, when I rearranged the constraints from smallest to largest ({0, 7} first for example, and of course move its sum to the front of the sums, then some 3-length constraints, etc.), it quickly finds a solution.

 

Position 0: 0 
Position 1: 1 
Position 2: -8 
Position 3: 4 
Position 4: 5 
Position 5: -4 
Position 6: -1 
Position 7: 8 
Position 8: 2 
Position 9: -3 
Position 10: -2 
Position 11: -2 
Position 12: -3 
Position 13: -1 
Position 14: 0 
Position 15: -5 
Position 16: 8 
Position 17: 4 
Position 18: 7 
Position 19: 1 
Position 20: -2 
Position 21: -6 
Position 22: 0 
Position 23: -2 
Position 24: -8 
Position 25: -6 
Position 26: 2 

Edited by bwoodhouse729
1

Share this post


Link to post
Share on other sites
37 minutes ago, bwoodhouse729 said:

WallaceErick2, my default value for solutions was 1000 to indicate the algorithm didn't find a value for it.  Here it's because there's no constraint involving position 5.  Of course, position 5 just takes the remaining number that doesn't show up in any other position.

 

LucasDiasC, there must be a bug somewhere preventing it from considering all cases.  If it continues to be a problem I can debug further.  However, when I rearranged the constraints from smallest to largest ({0, 7} first for example, and of course move its sum to the front of the sums, then some 3-length constraints, etc.), it quickly finds a solution.

 

Position 0: 0 
Position 1: 1 
Position 2: -8 
Position 3: 4 
Position 4: 5 
Position 5: -4 
Position 6: -1 
Position 7: 8 
Position 8: 2 
Position 9: -3 
Position 10: -2 
Position 11: -2 
Position 12: -3 
Position 13: -1 
Position 14: 0 
Position 15: -5 
Position 16: 8 
Position 17: 4 
Position 18: 7 
Position 19: 1 
Position 20: -2 
Position 21: -6 
Position 22: 0 
Position 23: -2 
Position 24: -8 
Position 25: -6 
Position 26: 2 

Yeah, I was going to try doing that, thanks man, tomorrow I'll probably use it for the remaining levels

0

Share this post


Link to post
Share on other sites
9 hours ago, bwoodhouse729 said:

WallaceErick2, my default value for solutions was 1000 to indicate the algorithm didn't find a value for it.  Here it's because there's no constraint involving position 5.  Of course, position 5 just takes the remaining number that doesn't show up in any other position.

 

 

Thanks for the solution, bro.

I will be create an web interface for this... its ok to use your code?

 

 

 

2

Share this post


Link to post
Share on other sites

How do you run Java files?

 

Command Prompt?

 

Tried Javac Energy_Balance.java from CMD stored in C Drive....but it says Javac not recognized as internal or external command.

0

Share this post


Link to post
Share on other sites

You need to install java and a development environment to help run it.  Or wait for WallaceErick2 to make it more user friendly?

1

Share this post


Link to post
Share on other sites

Yes you need to 'set path' to java JDK in command prompt. Only then you can run the 'javac' command. 

 

@bwoodhouse729, thank you very much for the work you have put in to the program. It helped me out on a few of the puzzle which I could not figure out on my own!

1

Share this post


Link to post
Share on other sites

I just got the Platinum with no computer help, so now my brain really hurts.  Nothing some beers and Rocket League can't cure!!  WEEEEEEEEEEEEEEEEEEEEEEEEE!!!!

3

Share this post


Link to post
Share on other sites

Took me a while to figure out how to get this to work. A slightly more detailed explanation would have saved me quite a bit of time, but I did my research and got it sorted.

 

Doesn't seem to work for some of the later puzzles. I couldn't get a solution for Hard 3, so I solved it manually. Now I'm stuck on Hard 4. I've tried several resets, and re-entered the data to make sure it wasn't user error, but I never get a solution. Has anyone successfully used it for the more complex levels?

0

Share this post


Link to post
Share on other sites
14 minutes ago, diskdocx said:

Took me a while to figure out how to get this to work. A slightly more detailed explanation would have saved me quite a bit of time, but I did my research and got it sorted.

 

Doesn't seem to work for some of the later puzzles. I couldn't get a solution for Hard 3, so I solved it manually. Now I'm stuck on Hard 4. I've tried several resets, and re-entered the data to make sure it wasn't user error, but I never get a solution. Has anyone successfully used it for the more complex levels?

 

I used it for every single one except the last square one. Hard 4 was one of the ones that took me the longest, just took a lot of resetting and rearranging the order of the solutions to get it to work. Pretty sure it was one of the ones I let get to a couple million flag calls before it actually worked. 

2

Share this post


Link to post
Share on other sites

There can be a very large number of possibilities for Hard 4 and Square 4, especially if you were unlucky in puzzle generation, so the program probably keeps computing without finding a solution.  All I can offer without overhauling the program is to make sure you list the row and column constraints in decreasing order, then if it's still not fast enough, try initially arranging the values based roughly on the row sums and column sums (larger sums use larger values, etc.)

1

Share this post


Link to post
Share on other sites
3 hours ago, Gage said:

 

I used it for every single one except the last square one. Hard 4 was one of the ones that took me the longest, just took a lot of resetting and rearranging the order of the solutions to get it to work. Pretty sure it was one of the ones I let get to a couple million flag calls before it actually worked. 

 

3 hours ago, bwoodhouse729 said:

There can be a very large number of possibilities for Hard 4 and Square 4, especially if you were unlucky in puzzle generation, so the program probably keeps computing without finding a solution.  All I can offer without overhauling the program is to make sure you list the row and column constraints in decreasing order, then if it's still not fast enough, try initially arranging the values based roughly on the row sums and column sums (larger sums use larger values, etc.)

Thanks both, I finally got it.  I left it runners get and it finally solved it, but I had reset the puzzle. Tried a couple more, then one popped almost immediately.

 

Just square 4 left, and I'm holding that for the weekend plat party 😉

1

Share this post


Link to post
Share on other sites

I don't understand how the the code works can someone explain or show where to find a simple way to do this? 

2

Share this post


Link to post
Share on other sites

I've been trying to get the code to work with Notepad but fail. I haven't used Java in years. I forgot how to use Netbeans as well. 

0

Share this post


Link to post
Share on other sites
1 hour ago, Leo_the_Lion25 said:

I've been trying to get the code to work with Notepad but fail. I haven't used Java in years. I forgot how to use Netbeans as well. 

 

use eclipse, its easy.

 

---------

 

i've finished the interface... integration with backend is coming son...

http://www.platinas.com.br/energy-balance/

 

anyone have a vps server to host?

its very expensive.

 

1

Share this post


Link to post
Share on other sites
2 hours ago, WallaceErick2 said:

 

use eclipse, its easy.

 

---------

 

i've finished the interface... integration with backend is coming son...

http://www.platinas.com.br/energy-balance/

 

anyone have a vps server to host?

its very expensive.

 

I've tried using your link, but I keep getting an error and doesn't work can you help out with a sample/explanation.  

0

Share this post


Link to post
Share on other sites

i made a example picture for our trophy community at facebook.

 

 

i have to say, that the java program took realtive long sometimes. sometimes so long, that i solved the puzzle in the meantime. if you use lesser rows, you can get an idea how to solve the puzzle and do the rest on your own. you have to adjust the parameter in the .java file and than compile it with javac. you can run the compiled code with java. it helps alot but it didnt solve everything for you.

0

Share this post


Link to post
Share on other sites

I'm trying to run the program on this site: http://www.browxy.com/

 

If we can get it running on their all we have to do is simply click on the get URL option and we can all use the same program. The issue I have is that I cannot get both programs to find each other's locations. 

 

 

My errors reading this

 

Quote

Compilation Errors Detected

Line: 182
cannot find symbol
  symbol:   class CombinationGenerator
  location: class Energy_Balance

Line: 182
cannot find symbol
  symbol:   class CombinationGenerator
  location: class Energy_Balance
 

 

Edited by Leo_the_Lion25
0

Share this post


Link to post
Share on other sites
4 hours ago, zombie_ninja_X said:

I've tried using your link, but I keep getting an error and doesn't work can you help out with a sample/explanation.  

 

 

i dont have finished yet. :D

0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.