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

This problem is similar to 5 Sailors, Coconuts and a Monkey at Rosetta Code. Find the minimum number to satisfy the conditions set by problem, I learned later at Syntax Bomb.
b = b + ...
Reply


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



Users browsing this thread: 7 Guest(s)