Created
August 5, 2015 02:26
-
-
Save sanketmaru/f120a5cd9018eefdd3a1 to your computer and use it in GitHub Desktop.
Solution to weight puzzle.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(){ | |
var w1,w2,w3,w4; | |
//w1+w2+w3+w4 = 40; | |
// applying a brute force approach | |
for(w1=1;w1<40;w1++){ | |
for(w2=1;w1<40;w2++){ | |
for(w3=1;w3<40;w3++){ | |
for(w4=1;w3<40;w4++){ | |
// RMA to check | |
// 1. for any of conditions get w1+w2+w3+w4 = 40; | |
var sum = w1+w2+w3+w4; | |
if(sum != 40){ | |
continue; | |
} | |
// we got the total sum as 40; | |
// now get the sum of all the integers between 1 t0 40 using this integers | |
var condition = true; | |
while(condition){ | |
} | |
} | |
} | |
} | |
} | |
})(): |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment