Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Code Challenge: Snacky Friends, a donkey, and Apples
#11
(08-04-2024, 01:36 PM)bplus Wrote: LOL! oh man I had to think about that for more than second, then all the funnier! Smile

The other one that cracks me up:

Eagles may soar, but weasels don't get sucked into jet engines.
Reply
#12
My friends and I aren't as gluttonous as you and your friends!  Here's my solution, which doesn't necessarily work from the premise that they began with a whole number of apples -- I worked from the back end up, assuming that coming morning time, each person had at least full 1 apple and the donkey had 1.

Code: (Select All)
'x = numbers of apples per person
'In the morning there were:
'3x + 1 apples.  (Each person got an equal share, the donkey got one.)

'In the night, the third friend ate 1/3 of the apples and gave the donkey one.  (There were 2/3 remaining)
'that means before that, there were:
'  1.5 * (3x+ 1) + 1

'Before that, the 2nd friend did the same:
'  1.5 * (1.5 * (3x + 1) + 1) + 1

'Before that, the 1st friend did the same:
' 1.5* (1.5 * (1.5 * (3x + 1) + 1) + 1) +1

PRINT "#1", "#2", "#3,", "Donkey", "Total"

FOR x = 1 TO 10
    PRINT 1.5 * (1.5 * (1.5 * (3 * x + 1) + 1) + 1) + 1 ,_
          1.5 * (1.5 * (3*x + 1) + 1) + 1 ,_
          1.5 * (3*x+ 1) + 1,_
          4,_
          1.5 * (1.5 * (1.5 * (3 * x + 1) + 1) + 1) + 1 + _
          1.5 * (1.5 * (3*x + 1) + 1) + 1 + _
          1.5 * (3*x+ 1) + 1 +_
          4
NEXT


Quote:#1      #2        #3,      Donkey    Total
18.25    11.5      7        4        40.75
28.375  18.25    11.5      4        62.125
38.5    25        16        4        83.5
48.625  31.75    20.5      4        104.875
58.75    38.5      25        4        126.25
68.875  45.25    29.5      4        147.625
79      52        34        4        169
89.125  58.75    38.5      4        190.375
99.25    65.5      43        4        211.75
109.375 72.25    47.5      4        233.125
Reply
#13
See 40.75 apples, that's those worm laden apples Steve's got on his farm, feeds humans and birds Smile
b = b + ...
Reply
#14
(08-05-2024, 03:35 PM)bplus Wrote: See 40.75 apples, that's those worm laden apples Steve's got on his farm, feeds humans and birds Smile

That 0.25 is the part where they cut out around the worms the day before.  Big Grin

Is mine actually right though?  My brain tells me it is, but I'm wondering why my numbers don't match any of yours at any point.  The logic seems sound... I think?
Reply
#15
There was an underlying assumption of whole numbers I am pretty sure.

This problem is so similar to Rosetta Codes:
https://rosettacode.org/wiki/Sailors,_co...ey_problem

You can compare results 3 friends to 5 sailors, apples to coconuts and monkey to donkey.
b = b + ...
Reply
#16
(08-05-2024, 03:45 PM)bplus Wrote: There was an underlying assumption of whole numbers I am pretty sure.

This problem is so similar to Rosetta Codes:
https://rosettacode.org/wiki/Sailors,_co...ey_problem

You can compare results 3 friends to 5 sailors, apples to coconuts and monkey to donkey.

Pah!  I always like to work at it with an out-out-the-box thinking.  Always impresses the suits looking to hire you.  "Gosh, this guy seems like he might find solutions for us nobody else can!  Quick, hire him and give him a raise!"

2nd bonus?  Since it's non-standard solutions, the guys in charge of hiring can't usually point out your mistakes and prove you wrong.   Big Grin
Reply
#17
1 + 1 = bigger 1. I didn't last to long at my job in the states with that solution, but did find life-long employment in North Korea.

Pete Big Grin

- Never think outside the box that's filled with cookies.
Shoot first and shoot people who ask questions, later.
Reply
#18
I like creative outside-the-box ideas too, why I am here all the time! I like first to try the challenge before I check anyone else solution though. You can really appreciate others views after trying it yourself.

More than one way to skin a cat, just an expression @PETA

I would look at THE SOLUTION and assume I blundered usually from NOT reading carefully the rules.

Steve looks at solution and says I am amazing to find this outside-the-box solution that nobody else has found! Big Grin
b = b + ...
Reply
#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
#20
When I need answers to difficult programming approaches, I consult Clippy... then do the opposite. Works every time! Clippy, the Anti-Maze.

Pete Big Grin
Shoot first and shoot people who ask questions, later.
Reply




Users browsing this thread: 5 Guest(s)