Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Code Challenge: Snacky Friends, a donkey, and Apples
#24
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:
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
Reply


Messages In This Thread
RE: Code Challenge: Snacky Friends, a donkey, and Apples - by SMcNeill - 08-05-2024, 06:59 PM



Users browsing this thread: 9 Guest(s)