3 ms·
An even sillier bruteforce lets you reproduce the problem almost verbatim: let a and b be the daytime and nighttime prices, let x, y, and z be the number of chi
by SatvikBeri 12y ago
An even sillier bruteforce lets you reproduce the problem almost verbatim: let a and b be the daytime and nighttime prices, let x, y, and z be the number of chickens sold during the day by each farmer.
[(a, b, x, y, z) for a in xrange(1, 500) for b in xrange(1, a) for x in xrange(1, 11) for y in xrange(1, x) for z in xrange(1, y) if 3500 == a*x + b*(10 - x) == a*y + b*(16 - y) == a*z + b*(26 - z)]
- bluecalm 12y agoVery nice, I need to practice my Python one liners :) It's significantly slower though as you are iterating over 2nd price as well (and I derive it from the fact that total profit is known so daytime price and amount of sold chickens sold implies nighttime price).