Skip to content

Instantly share code, notes, and snippets.

@sanketmaru
Created August 5, 2015 02:26
Show Gist options
  • Save sanketmaru/f120a5cd9018eefdd3a1 to your computer and use it in GitHub Desktop.
Save sanketmaru/f120a5cd9018eefdd3a1 to your computer and use it in GitHub Desktop.
Solution to weight puzzle.
(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