Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function thing(chickens,l,h)
- return (35-chickens*h)/(l-h)
- end
- math.randomseed(os.time())
- bestErr = math.huge
- for i = 1, 100000000 do
- priceBefore = math.ceil(math.random()*100*100)/100
- priceAfter = math.ceil(math.random()*priceBefore*100)/100
- a1 = thing(10,priceBefore,priceAfter)
- a2 = thing(16,priceBefore,priceAfter)
- a3 = thing(26,priceBefore,priceAfter)
- err = math.abs(a1-math.floor(a1))+math.abs(a2-math.floor(a2))+math.abs(a3-math.floor(a3))
- if err < bestErr and (a1>=0) and ((10-a1)>=0) and (a2>=0) and ((16-a2)>=0) and (a3>=0) and ((26-a3)>=0) then
- bestErr = err
- bestPriceBefore = priceBefore
- bestPriceAfter = priceAfter
- end
- end
- print(bestPriceBefore, bestPriceAfter)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement