Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Code Challenge: Snacky Friends, a donkey, and Apples
#6
Testing 79

79 / 3 = 26 R 1 79 - 26 - 1 = 52

52 / 3 = 17 R 1 52 - 17 - 1 = 34

34 / 3 = 11 R 1 34 - 11 - 1 = 22

22 / 3 = 7 R 1 so 7 more for each friend and donkey gets the 4 Remainders.

26 + 7 = 33 1st
17 + 7 = 24 2nd
11 + 7 = 18 3rd
+4 Donkey
= 79 It works alright I stand corrected

Where did I go wrong?
Code: (Select All)
For i = 1 To 4000
    If i Mod 3 = 1 Then
        i2 = i - Int(i / 3) - 1 '1st
        If i2 Mod 3 = 1 Then
            i3 = i2 - Int(i2 / 3) - 1 '2nd
            If i3 Mod 3 = 1 Then
                i4 = i3 - Int(i3 / 3) - 1 ' 3rd
                If i4 Mod 3 = 1 Then
                    i5 = i4 - Int(i4 / 3) - 1 '4th
                    'If i5 Mod 3 = 0 Then
                    Print i; "="; i2 / 2 + i5 / 2; "+"; i3 / 2 + i5 / 2; "+"; i4 / 2 + i5 / 2; "+"; 4
                    Exit For
                    'End If
                End If
            End If
        End If
    End If
Next

Aha! i5 mod 3 = 0 was not required!

Well it wouldn't be right to be first AND be correct ;-))

Quote:Friend 1 is a pig.
ha! Friend 1 was the earliest bird for the worm laden apples Smile
  724  855  599  923  575  468  400  206  147  564  878  823  652  556 bxor cross forever
Reply


Messages In This Thread
RE: Code Challenge: Snacky Friends, a donkey, and Apples - by bplus - 08-04-2024, 10:47 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Challenge for you... eoredson 61 12,977 01-11-2026, 03:48 AM
Last Post: bplus
  Correcting the code Chris 15 3,244 10-28-2023, 09:48 PM
Last Post: SMcNeill
  Summer LASER Challenge TerryRitchie 42 8,958 07-30-2023, 06:57 PM
Last Post: bplus

Forum Jump:


Users browsing this thread: 1 Guest(s)