Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Code Challenge: Snacky Friends, a donkey, and Apples
#19
See if this holds up.  These guys may eat a few less than you think:

Code: (Select All)
FOR i = 1 TO 1000
total = i
Guy1 = Eat(total) 'late night snack
guy2 = Eat(total)
guy3 = Eat(total)
morning = (total - 1) / 3
donkey = 4
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, donkey
END IF
NEXT

'51
'friend 1 ate 17... donkey gets 1... 33 left
'friend 2 ate 11... donkey gets 1... 21 left
'friend 3 ate 7 ... donkey gets 1... 13 left
'morning everyone ate 4, donkey gets 1


FUNCTION Eat (Total)
Ate = 1 / 3 * Total
Donkey = 1
Total = Total - Ate - Donkey
Eat = Ate
END FUNCTION

'51
'friend 1 ate 17... donkey gets 1... 33 left
'friend 2 ate 11... donkey gets 1... 21 left
'friend 3 ate 7 ... donkey gets 1... 13 left
'morning everyone ate 4, donkey gets 1
Reply


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



Users browsing this thread: 6 Guest(s)