Jump to content

Algorithmic solution


bwoodhouse729

Recommended Posts

Pushed another commit to https://github.com/xuyiqi/EnergyBalance/tree/FixPermatureExit

Now the code runs at least 50 times faster. The diff is the elimination of unnecessary memcpys (arraycopy).

In some cases the original run time is 2 min 11 s with an invalid output. My first fix reduced it to 11.x second. My second fix further reduced it to 0.2s. Just grab the latest code.

 

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

real    0m0.206s
user    0m0.103s
sys    0m0.021s

 

  • Like 2
Link to comment
Share on other sites

19 hours ago, DuDuXu said:

Pushed another commit to https://github.com/xuyiqi/EnergyBalance/tree/FixPermatureExit

Now the code runs at least 50 times faster. The diff is the elimination of unnecessary memcpys (arraycopy).

In some cases the original run time is 2 min 11 s with an invalid output. My first fix reduced it to 11.x second. My second fix further reduced it to 0.2s. Just grab the latest code.

 

 

Nice work!

Link to comment
Share on other sites

For anyone who doesnt really familiar with java stuff like me , here some way to run them, hope its help

 

Tools required

Step

  1. Instal Java SDK and Notepad++
  2. Place Energy_Balance.java & CombinationGenerator.java in same folder, i put mine in C:/EB/
  3. With Notepad++ modify Energy_Balance.java, yo can read some explanation in line 200 ,244, 252 , after done editing ,save the file
  4. Go to folder which you have put Energy_Balance.java & CombinationGenerator.java
  5. Hold SHIFT and right click, choose "Open Command Window Here"
  6. input this to CMD 
    javac Energy_Balance.java

    Press ENTER , if you get error check your Energy_Balance.java again maybe you miss bracket or comma while editing, if no error, input :

    java Energy_Balance

    Press ENTER, now brute force will start OR you get "No Solution Found" message, if you get the latter you may check Energy_Balance.java again or restart the level to get new value 

Trouble shooting :

'javac' is not recognized as an internal or external command,
operable program or batch file.
'java' is not recognized as an internal or external command,
operable program or batch file.

if you get both error while inputing comman in step 6 you need to input whole java.exe or javac.exe adress instead only java or javac

example

"C:\Program Files\Java\jdk1.8.0_131\bin\javac.exe" Energy_Balance.java

"C:\Program Files\Java\jdk1.8.0_131\bin\java.exe" Energy_Balance

Also found this solver from steam, its C++ version and seems have better user interface but have no luck to compile and test it yet

Edited by KillLaGil
found C++ version
  • Like 4
Link to comment
Share on other sites

  • 4 weeks later...
  • 2 weeks later...
9 hours ago, al7mrane said:

Hi all,

 

I'm not familiar with Java or this coding stuff. please can anyone do it for me ??

 

if anyone want to help me, I will appreciate it.

 

add me ( al7mrane ) and I will give you my numbers.

 

Hi,

 

To pass all phases takes some time.
You can easily do it by yourself, just follow the raisins below

I made an adjustment in the bwoodhouse code.

Now it can be run ONLINE without the need to install java / eclipse or others.

 

Access the website http://www.browxy.com/ copy and paste the code below modifying the values of the:

Code adapted to run online is in https://github.com/jsantosrocha/energy_balance/blob/master/Energy_Balance.java

 

Values that should be modified:

original_values in line 14

addends in line 19

sums in line 26

 

For this example I used the image below, make the adaptations as the game gives you new challenges:

exemplo.jpg

 

  • Like 3
Link to comment
Share on other sites

The Energy Balance Solver is a great asset, it helped me with some difficult levels especially Hardcore levels. I would recommend using the solver if you're having trouble, as it'll help you get through the levels. That being said, Square levels are much easier so you should be able to solve them on your own if you solve from the top right first, go down then solve from bottom right and go left, that's the tip that I got from LightSp33d1987 and it helped me get through the levels easily. 

  • Like 2
Link to comment
Share on other sites

On 8/15/2017 at 5:20 PM, jsantosrocha said:

 

Hi,

 

To pass all phases takes some time.
You can easily do it by yourself, just follow the raisins below

I made an adjustment in the bwoodhouse code.

Now it can be run ONLINE without the need to install java / eclipse or others.

 

Access the website http://www.browxy.com/ copy and paste the code below modifying the values of the:

Code adapted to run online is in https://github.com/jsantosrocha/energy_balance/blob/master/Energy_Balance.java

 

Values that should be modified:

original_values in line 14

addends in line 19

sums in line 26

 

For this example I used the image below, make the adaptations as the game gives you new challenges:

exemplo.jpg

 

thank you for your response. I followed what you said step by step, but it is not working. see what I did below

 

http://imgur.com/a/qzwMz

 

 

Link to comment
Share on other sites

1 hour ago, al7mrane said:

thank you for your response. I followed what you said step by step, but it is not working. see what I did below

 

http://imgur.com/a/qzwMz

 

 

 

In the variable "addends" there can be no negative values.
See in my image, in the variable "addends" you should put the index of your sum. In my image it is represented by the numbers in yellow that I put myself.
The index should always start from zero, top to bottom, left to right.
If you make a mistake again send me the image that the game has made available for me to analyze.

Link to comment
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.
×
×
  • Create New...