All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars    
perplexus dot info

Home > Games
Final Scores at the PrimeBowl (Posted on 2007-11-28) Difficulty: 3 of 5
1. What is the highest score you can obtain in a standard game of bowling if your cumulative score in each of the ten frames is required to be a prime number?

2. What is the lowest score you can obtain in a standard game of bowling if your cumulative score in each of the ten frames is required to be a prime number and for each throw you knock down a prime number of pins?

The next two questions refer to 3-6-9 bowling. The difference in 3-6-9 bowling and the standard game is the 3rd, 6th and 9th frame already have strikes recorded.

3. What is the highest score you can obtain in a game of 3-6-9 bowling if your cumulative score in each of the ten frames is required to be a prime number?

4. What is the lowest score you can obtain if your cumulative score in each of the ten frames is required to be a prime number and for each throw (excluding the pre-recorded throws) you knock down a prime number of pins?

The first score sheet represents Games #1 and #2.
The second is for use with Games #3 and #4.

1

2

3

4

5

6

7

8

9

10

1

2

3

4

5

6

7

8

9

10

X

X

X

One Scoring reference is here should you need one.

See The Solution Submitted by Dej Mar    
No Rating

Comments: ( Back to comment list | You must be logged in to post comments.)
re: and just part 2. (agrees with my answer) -- also alternative formulation | Comment 5 of 10 |
(In reply to and just part 2. by Leming)


With part 2's added restriction to prime values for each throw, pruning the tree of possibilities was faster, so the program could go to completion:

(don't be fooled by the name maxScore--it contains the minimum score, but the name was held over from the first program).

Private Sub cmdStart_Click()
 maxScore = 99999

 goingBack = ""
 Play 1
 Print sCtr
 Print "ended"
 End Sub
 

Sub ReportIt()
If Frame(10) > maxScore Then Exit Sub
maxScore = Frame(10)
  Cls
  sCtr = sCtr + 1
  For I = 1 To throwNo
   If I > throwNo Then Exit For
   If Throw(I) = 10 Then Print " x    "; Else Print Throw(I);: I = I + 1: Print Throw(I);
  Next
   Print
  For I = 1 To 10
   Print Frame(I);: Print " ";
  Next
   Print: Print sCtr
End Sub

Sub Play(Fr)
  DoEvents
  spareFlag = 0
  For n = 1 To 10
    If fnIsPrime(n) Then
        throwNo = throwNo + 1
        Throw(throwNo) = n
        If n < 10 Then
          For n2 = 0 To 10 - n
          If fnIsPrime(n2) Then
           throwNo = throwNo + 1
           Throw(throwNo) = n2
           If goingBack = "xx" Then
             Frame(Fr - 2) = Frame(Fr - 2) + n
             Frame(Fr - 1) = Frame(Fr - 1) + n + n2
             Frame(Fr) = Frame(Fr - 1) + n + n2
             If n2 = 10 - n Then goingBack = "/" Else goingBack = ""
             If fnIsPrime(Frame(Fr - 2)) And fnIsPrime(Frame(Fr - 1)) Then
               If goingBack = "/" Or fnIsPrime(Frame(Fr)) Then
                 If Fr = 10 Then
                  If goingBack = "/" Then
                   For n3 = 0 To 10 - N1 - n2
                    throwNo = throwNo + 1
                    Throw(throwNo) = n3
                    Frame(Fr) = Frame(Fr) + n3
                    If fnIsPrime(Frame(Fr)) Then ReportIt
                    Frame(Fr) = Frame(Fr) - n3
                    throwNo = throwNo - 1
                   Next
                  Else
                   ReportIt
                  End If
                 Else
                   Play Fr + 1
                 End If
               End If
              End If
             Frame(Fr - 2) = Frame(Fr - 2) - n
             Frame(Fr - 1) = Frame(Fr - 1) - n - n2
             Frame(Fr) = 0
             goingBack = "xx"
           ElseIf goingBack = "x" Then
             If n2 < 10 - n Or spareFlag = 0 Then
                 Frame(Fr - 1) = Frame(Fr - 1) + n + n2
                 Frame(Fr) = Frame(Fr - 1) + n + n2
                 If n2 = 10 - n Then goingBack = "/": spareFlag = 1 Else goingBack = ""
                 If fnIsPrime(Frame(Fr - 1)) Then
                   If goingBack = "/" Or fnIsPrime(Frame(Fr)) Then
                     If Fr = 10 Then
                      If goingBack = "/" Then
                       For n3 = 0 To 10 - N1 - n2
                        throwNo = throwNo + 1
                        Throw(throwNo) = n3
                        Frame(Fr) = Frame(Fr) + n3
                        If fnIsPrime(Frame(Fr)) Then ReportIt
                        Frame(Fr) = Frame(Fr) - n3
                        throwNo = throwNo - 1
                       Next
                      Else
                       ReportIt
                      End If
                     Else
                       Play Fr + 1
                     End If
                   End If
                  End If
                 Frame(Fr - 1) = Frame(Fr - 1) - n - n2
                 Frame(Fr) = 0
                 goingBack = "x"
             End If
           ElseIf goingBack = "/" Then
             Frame(Fr - 1) = Frame(Fr - 1) + n
             Frame(Fr) = Frame(Fr - 1) + n + n2
             If n2 = 10 - n Then goingBack = "/" Else goingBack = ""
             If fnIsPrime(Frame(Fr - 1)) Then
               If goingBack = "/" Or fnIsPrime(Frame(Fr)) Then
                 If Fr = 10 Then
                  If goingBack = "/" Then
                   For n3 = 0 To 10 - N1 - n2
                    throwNo = throwNo + 1
                    Throw(throwNo) = n3
                    Frame(Fr) = Frame(Fr) + n3
                    If fnIsPrime(Frame(Fr)) Then ReportIt
                    Frame(Fr) = Frame(Fr) - n3
                    throwNo = throwNo - 1
                   Next
                  Else
                   ReportIt
                  End If
                 Else
                   Play Fr + 1
                 End If
               End If
              End If
             Frame(Fr - 1) = Frame(Fr - 1) - n
             Frame(Fr) = 0
             goingBack = "/"
           Else
             If n2 < 10 - n Or spareFlag = 0 Then
                 Frame(Fr) = Frame(Fr - 1) + n + n2
                
                 If n2 = 10 - n Then goingBack = "/": spareFlag = 1 Else goingBack = ""
                   If goingBack = "/" Or fnIsPrime(Frame(Fr)) Then
                     If Fr = 10 Then
                      If goingBack = "/" Then
                       For n3 = 0 To 10 - N1 - n2
                        throwNo = throwNo + 1
                        Throw(throwNo) = n3
                        Frame(Fr) = Frame(Fr) + n3
                        If fnIsPrime(Frame(Fr)) Then ReportIt
                        Frame(Fr) = Frame(Fr) - n3
                        throwNo = throwNo - 1
                       Next
                      Else
                       ReportIt
                      End If
                     Else
                       Play Fr + 1
                     End If
                   End If
                 Frame(Fr) = 0
                 goingBack = ""
             End If
           End If
           throwNo = throwNo - 1
          End If
          Next
        Else
          ' have a strike
          If goingBack = "xx" Then
            Frame(Fr - 2) = Frame(Fr - 2) + 10
            Frame(Fr - 1) = Frame(Fr - 1) + 10
            Frame(Fr) = Frame(Fr - 1) + 10
            If Fr = 10 Then
             If fnIsPrime(Frame(Fr - 2)) Then
              For n2 = 0 To 10
              If fnIsPrime(n2) Then
                For n3 = 0 To 10
                If fnIsPrime(n3) Then
                Frame(Fr - 1) = Frame(Fr - 1) + n2
                Frame(Fr) = Frame(Fr - 1) + 10 + n2 + n3
                 Throw(throwNo + 1) = n2: Throw(throwNo + 2) = n3
                 throwNo = throwNo + 2
                   If fnIsPrime(Frame(Fr - 1)) And fnIsPrime(Frame(Fr)) Then
                    ReportIt
                   End If
                 throwNo = throwNo - 2
                Frame(Fr - 1) = Frame(Fr - 1) - n2
                Frame(Fr) = 0
                End If
               Next
              End If
              Next
             End If
            Else
              Play Fr + 1
            End If
            Frame(Fr - 2) = Frame(Fr - 2) - 10
            Frame(Fr - 1) = Frame(Fr - 1) - 10
            Frame(Fr) = 0
          ElseIf goingBack = "x" Then
            Frame(Fr - 1) = Frame(Fr - 1) + 10
            Frame(Fr) = Frame(Fr - 1) + 10
            If Fr = 10 Then
              For n2 = 0 To 10
               If fnIsPrime(n2) Then
               For n3 = 0 To 10
                Frame(Fr - 1) = Frame(Fr - 1) + n2
                Frame(Fr) = Frame(Fr - 1) + 10 + n2 + n3
                 Throw(throwNo + 1) = n2: Throw(throwNo + 2) = n3
                 throwNo = throwNo + 2
                   If fnIsPrime(Frame(Fr - 1)) And fnIsPrime(Frame(Fr)) Then
                    ReportIt
                   End If
                 throwNo = throwNo - 2
                Frame(Fr - 1) = Frame(Fr - 1) - n2
                Frame(Fr) = 0
               Next
               End If
              Next
            Else
             goingBack = "xx"
              Play Fr + 1
             goingBack = "x"
            End If
            Frame(Fr - 1) = Frame(Fr - 1) - 10
            Frame(Fr) = 0
          ElseIf goingBack = "/" Then
            Frame(Fr - 1) = Frame(Fr - 1) + 10
            Frame(Fr) = Frame(Fr - 1) + 10
            If Fr = 10 Then
              For n2 = 0 To 10
               If fnIsPrime(n2) Then
               For n3 = 0 To 10
                If fnIsPrime(n3) Then
                Frame(Fr) = Frame(Fr - 1) + 10 + n2 + n3
                 Throw(throwNo + 1) = n2: Throw(throwNo + 2) = n3
                 throwNo = throwNo + 2
                   If fnIsPrime(Frame(Fr - 1)) And fnIsPrime(Frame(Fr)) Then
                    ReportIt
                   End If
                 throwNo = throwNo - 2
                Frame(Fr) = 0
                End If
               Next
               End If
              Next
            Else
             goingBack = "x"
              Play Fr + 1
             goingBack = "/"
            End If
            Frame(Fr - 1) = Frame(Fr - 1) - 10
            Frame(Fr) = 0
          Else
            Frame(Fr) = Frame(Fr - 1) + 10
            If Fr = 10 Then
              For n2 = 0 To 10
               If fnIsPrime(n2) Then
               For n3 = 0 To 10
                If fnIsPrime(n3) Then
                Frame(Fr) = Frame(Fr - 1) + 10 + n2 + n3
                 Throw(throwNo + 1) = n2: Throw(throwNo + 2) = n3
                 throwNo = throwNo + 2
                   If fnIsPrime(Frame(Fr)) Then
                    ReportIt
                   End If
                 throwNo = throwNo - 2
                Frame(Fr) = 0
                End If
               Next
               End If
              Next
            Else
             goingBack = "x"
              Play Fr + 1
             goingBack = ""
            End If
            Frame(Fr) = 0
          End If
        End If
        throwNo = throwNo - 1
    End If
  Next

End Sub


 Function fnIsPrime(Num)
   Select Case Num
   Case 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, _
257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401
     r = 1
   Case Else
     r = 0
  End Select
  fnIsPrime = r

 End Function

This completed and found:
 
Part 2. 192:

5 2  3 3  3 3  2 2  5 3  3 3  3 3  2 2  3 3  3 3
  7   13   19   23   31   37   43   47   53   59


 
Alternate of part 2 -- trying for highest score:

5 2  3 7  2 2  5 3  3 7  2 2  3 3  5 3  3 3  3 7  2
  7   19   23   31   43   47   53   61   67   79

  Posted by Charlie on 2007-11-28 15:52:14
Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (1)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (6)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

Chatterbox:
Copyright © 2002 - 2024 by Animus Pactum Consulting. All rights reserved. Privacy Information