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
  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-08-2024, 03:07 PM

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

Forum Jump:


Users browsing this thread: 1 Guest(s)