Results 1 to 5 of 5

Thread: How to display the solution to this challenge

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #2
    Hack code of, white mouse is in position 9 and start counting at position 2
    Private Sub CommandButton1_Click()
    
    
        Dim eatenCount As Integer
        Dim mouseCount As Integer
        Dim sheetRow As Integer
        Dim mouseColor As String
        Dim mouseStatus As String
        
        Sheet1.Range("C3:C15").Value = ""
        Sheet1.Cells(3, 4).Value = 0
        
        mouseCount = 1
        sheetRow = Sheet1.Cells(2, 6).Value
        eatenCount = 0
        
        Do While True
            mouseColor = Sheet1.Cells(sheetRow, 1).Value
            mouseStatus = Sheet1.Cells(sheetRow, 3).Value
            
            ' count only the uneaten meece
            If mouseStatus = "" Then
                If mouseCount = 13 And mouseColor = "Brown" Then
                    ' this is okay to eat
                    Sheet1.Cells(3, 4).Value = Sheet1.Cells(3, 4).Value + 1
                    Sheet1.Cells(sheetRow, 3).Value = "Eaten (" & Sheet1.Cells(3, 4).Value & ")"
                    mouseCount = 0
    
    
                ElseIf mouseCount = 13 And mouseColor = "White" Then
                    ' can't eat the white one
                    MsgBox "13th mouse is white"
                    Exit Sub
                End If
                
                sheetRow = sheetRow + 1
               
                mouseCount = mouseCount + 1
            Else
                ' still need to move the row
                sheetRow = sheetRow + 1
            End If
            
            If sheetRow = 16 Then
                sheetRow = Sheet1.Cells(2, 6).Value - 1 ' go back to the top of the list
                If sheetRow = 2 Then sheetRow = 3 ' don't start a loop on the headings
            End If
            
            If mouseCount = 14 Then Exit Do
            
        Loop
        
        MsgBox "exited loop"
        
    End Sub
    Attached Images Attached Images

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •