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

Just got Internet back from Tues 4:30PM storm, here are my calcs for the 2 followup questions:
Code: (Select All)
' Charlies orig problem solution
'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

Print " What if donkey does not get apple in am? "
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 = 0 Then
                    i5 = i4 - Int(i4 / 3) '4th
                    'If i5 Mod 3 = 0 Then
                    Print i; "="; i2 / 2 + i5 / 2; "+"; i3 / 2 + i5 / 2; "+"; i4 / 2 + i5 / 2; "+"; 3
                    Exit For
                    'End If
                End If
            End If
        End If
    End If
Next

Print " What if donkey doesn't get any apples?"
For i = 1 To 4000
    If i Mod 3 = 0 Then
        i2 = i - Int(i / 3) '1st
        If i2 Mod 3 = 0 Then
            i3 = i2 - Int(i2 / 3) '2nd
            If i3 Mod 3 = 0 Then
                i4 = i3 - Int(i3 / 3) ' 3rd
                If i4 Mod 3 = 0 Then
                    i5 = i4 - Int(i4 / 3) '4th
                    'If i5 Mod 3 = 0 Then
                    Print i; "="; i2 / 2 + i5 / 2; "+"; i3 / 2 + i5 / 2; "+"; i4 / 2 + i5 / 2; "+"; 0
                    ' debug check Print "Divisions:"; i2; i3; i4; i5
                    Exit For
                    'End If
                End If
            End If
        End If
    End If
Next
b = b + ...
Reply


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



Users browsing this thread: 5 Guest(s)