08-05-2024, 06:59 PM
Just got back to home. Here's the answer with the "Divide by 3, with a remainder of 1", rather than my previous "Divide by 3, give 1 from the remaining".
Simplified down to 8 lines of code:
Simplified down to 8 lines of code:
Code: (Select All)
FOR i = 0 TO 1000
total = i: Guy1 = Eat(total): guy2 = Eat(total): guy3 = Eat(total): morning = (total - 1) / 3
IF Guy1 = INT(Guy1) AND guy2 = INT(guy2) AND guy3 = INT(guy3) AND morning = INT(morning) THEN PRINT i, Guy1 + morning, guy2 + morning, guy3 + morning, 4
NEXT
FUNCTION Eat (Total)
Eat = 1 / 3 * (Total - 1)
Total = Total - 1 / 3 * (Total - 1) - 1
END FUNCTION