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

Home > Logic
Quiz Results (Posted on 2004-09-02) Difficulty: 3 of 5
Five students each answered five questions on an quiz consisting of two multiple-choice questions (A, B or C) and three True-False questions. They answered the questions as follows:
Student Q1 Q2 Q3 Q4 Q5 
Alex    A  A  T  T  T 
Bert    B  B  T  F  T 
Carl    A  B  T  T  F 
Dave    B  C  T  T  F 
Eddy    C  A  F  T  T 
No two students got the same number of correct answers. Who got the most correct answers?

See The Solution Submitted by Brian Smith    
Rating: 3.2222 (9 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution VB program solution | Comment 27 of 30 |
The correct answers were B C T F F
 
Dave got 4 right
Bert got 3 right
Carl got 2 right
Alex got 1 right
Eddy got 0 right
 
The following program found this as the only result in which no two students got the same number of correct answers. 
 
Imports System
Imports System.IO
Imports System.Text
Imports System.Runtime.InteropServices
Imports System.Math
Module Module1
        Sub Main()
        Randomize()
        Dim strstarttime As String
        Dim strendtime As String
        Dim strend As String
        Dim intquiz(72, 10) As Integer
        Dim intanswers(5, 5) As Integer
        Dim intloop1 As Integer = 71
        Dim intloop2 As Integer = 9
        Dim intsub1 As Integer
        Dim intmatches As Integer
        Dim strstring As String
        strstarttime = TimeOfDay
        Console.WriteLine("Start of execution: " & strstarttime)
        For index1 As Integer = 0 To intloop1
            For index2 As Integer = 0 To intloop2
                intquiz(index1, index2) = 0
            Next
        Next
        intanswers(0, 0) = 0
        intanswers(0, 1) = 0
        intanswers(0, 2) = 1
        intanswers(0, 3) = 1
        intanswers(0, 4) = 1
        intanswers(1, 0) = 1
        intanswers(1, 1) = 1
        intanswers(1, 2) = 1
        intanswers(1, 3) = 0
        intanswers(1, 4) = 1
        intanswers(2, 0) = 0
        intanswers(2, 1) = 1
        intanswers(2, 2) = 1
        intanswers(2, 3) = 1
        intanswers(2, 4) = 0
        intanswers(3, 0) = 1
        intanswers(3, 1) = 2
        intanswers(3, 2) = 1
        intanswers(3, 3) = 1
        intanswers(3, 4) = 0
        intanswers(4, 0) = 2
        intanswers(4, 1) = 0
        intanswers(4, 2) = 0
        intanswers(4, 3) = 1
        intanswers(4, 4) = 1
        intsub1 = 0
        For indexq1 As Integer = 0 To 2
            For indexq2 As Integer = 0 To 2
                For indexq3 As Integer = 0 To 1
                    For indexq4 As Integer = 0 To 1
                        For indexq5 As Integer = 0 To 1
                            testquiz(intquiz, intanswers, _
                            indexq1, indexq2, indexq3, _
                            indexq4, indexq5, _
                            intsub1)
                        Next
                    Next
                Next
            Next
        Next
        For index1 As Integer = 0 To intloop1
            intmatches = 0
            For index2 As Integer = 5 To intloop2 - 1
                For index3 As Integer = index2 + 1 To intloop2
                    If intquiz(index1, index2) = _
                    intquiz(index1, index3) Then
                        intmatches += 1
                    End If
                Next
            Next
            If intmatches = 0 Then
                strstring = ""
                For index2 As Integer = 0 To intloop2
                    If index2 < 2 Then
                        Select Case intquiz(index1, index2)
                            Case 0
                                strstring &= "A"
                            Case 1
                                strstring &= "B"
                            Case 2
                                strstring &= "C"
                        End Select
                    ElseIf index2 < 5 Then
                        Select Case intquiz(index1, index2)
                            Case 0
                                strstring &= "F"
                            Case 1
                                strstring &= "T"
                        End Select
                    Else
                        strstring &= Str(intquiz(index1, index2))
                    End If
                    strstring &= " "
                Next
                Console.WriteLine("ANSWER: " & strstring)
            End If
        Next
        strendtime = TimeOfDay
        Console.WriteLine(" ")
        Console.WriteLine("Start of execution: " & strstarttime)
        strendtime = TimeOfDay
        Console.WriteLine("End of execution: " & strendtime)
        strend = "?"
        Console.WriteLine(" ")
        While strend <> "X"
            Console.WriteLine("Please enter X to exit program...")
            strend = UCase(Console.ReadLine())
        End While
    End Sub

    Sub testquiz(ByRef intquiz, ByRef intanswers, _
    ByRef indexq1, ByRef indexq2, ByRef indexq3, _
    ByRef indexq4, ByRef indexq5, _
    ByRef intsub1)
        intquiz(intsub1, 0) = indexq1
        intquiz(intsub1, 1) = indexq2
        intquiz(intsub1, 2) = indexq3
        intquiz(intsub1, 3) = indexq4
        intquiz(intsub1, 4) = indexq5
        For index1 As Integer = 0 To 4
            For index2 As Integer = 0 To 4
                If intanswers(index1, index2) = _
                intquiz(intsub1, index2) Then
                    intquiz(intsub1, index1 + 5) += 1
                End If
            Next
        Next
        intsub1 += 1
    End Sub
End Module
 
 

  Posted by Penny on 2005-01-01 23:33:01
Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (0)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (23)
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