JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://getfirebug.com/firebug-lite-debug.js"></script>
JavaScript
var farmer1 = [1,2,3,4,5,6,7,8,9,10],
//this does the same as above, but up to 16
farmer2 = Array.apply(null, Array(16)).map(function (_, i) {return 1+i;}),
//this does the same as above, but up to 26
farmer3 = Array.apply(null, Array(26)).map(function (_, i) {return 1+i;}),
//this does the same as above, but up to 3500
centsPerChickenBeforeNoon = Array.apply(null, Array(3500)).map(function (_, i) {return 1+i;})
farmer1.forEach(function(f1){
farmer2.forEach(function(f2){
farmer3.forEach(function(f3){
centsPerChickenBeforeNoon.forEach(function(priceBefore){
/*for each possible price before noon, calculate the price after noon for each farmer*/
var priceAfter1 = (3500-(f1*priceBefore))/(10-f1),
priceAfter2 = (3500-(f2*priceBefore))/(16-f2),
priceAfter3 = (3500-(f3*priceBefore))/(26-f3)
//if the price after and before matches up for all three, we have a winner
if ( priceAfter1 == priceAfter2 && priceAfter2 == priceAfter3 ){
if ( priceAfter1 > 0 && priceBefore > priceAfter1 ){
console.log( "before noon: " + priceBefore + "cent/chicken," +
" after noon: " + priceAfter1 + "cent/chicken" )
}
}
})
})
})
})