- Andy, Belinda, Carl, and Debbie guess at four aces and a joker.
- Each card is correctly identified by at least one person.
- Nobody gets them all right or all wrong.
- No two people make the same number of correct guesses.
The guesses are as follows:
1st Card 2nd Card 3rd Card 4th Card 5th Card
Andy Club Joker Heart Diamond Club
Belinda Diamond Joker Heart Club Spade
Carl Heart Club Spade Diamond Joker
Debbie Diamond Joker Club Club Spade
What are the five cards?
DefDbl A-Z
Dim crlf$
Private Sub Form_Load()
ChDir "C:\VB5 projects\flooble"
Text1.Text = ""
crlf$ = Chr(13) + Chr(10)
Form1.Visible = True
DoEvents
cd$ = "hdcsj": h$ = cd$
Do
ReDim score(5)
good = 1
sc = 0
For i = 1 To 5
If Mid("cjhdc", i, 1) = Mid(cd$, i, 1) Then sc = sc + 1
Next
If score(sc) > 0 Or sc = 0 Or sc = 5 Then good = 0
score(sc) = 1
sc = 0
For i = 1 To 5
If Mid("djhcs", i, 1) = Mid(cd$, i, 1) Then sc = sc + 1
Next
If score(sc) > 0 Or sc = 0 Or sc = 5 Then good = 0
score(sc) = 1
sc = 0
For i = 1 To 5
If Mid("hcsdj", i, 1) = Mid(cd$, i, 1) Then sc = sc + 1
Next
If score(sc) > 0 Or sc = 0 Or sc = 5 Then good = 0
score(sc) = 1
sc = 0
For i = 1 To 5
If Mid("djccs", i, 1) = Mid(cd$, i, 1) Then sc = sc + 1
Next
If score(sc) > 0 Or sc = 0 Or sc = 5 Then good = 0
score(sc) = 1
If good Then Text1.Text = Text1.Text & cd$ & crlf: DoEvents
permute cd$
Loop Until cd$ = h$
Text1.Text = Text1.Text & "done"
End Sub
Sub permute(a$)
x$ = ""
For i = Len(a$) To 1 Step -1
l$ = x$
x$ = Mid$(a$, i, 1)
If x$ < l$ Then Exit For
Next
If i = 0 Then
For j = 1 To Len(a$) \ 2
x$ = Mid$(a$, j, 1)
Mid$(a$, j, 1) = Mid$(a$, Len(a$) - j + 1, 1)
Mid$(a$, Len(a$) - j + 1, 1) = x$
Next
Else
For j = Len(a$) To i + 1 Step -1
If Mid$(a$, j, 1) > x$ Then Exit For
Next
Mid$(a$, i, 1) = Mid$(a$, j, 1)
Mid$(a$, j, 1) = x$
For j = 1 To (Len(a$) - i) \ 2
x$ = Mid$(a$, i + j, 1)
Mid$(a$, i + j, 1) = Mid$(a$, Len(a$) - j + 1, 1)
Mid$(a$, Len(a$) - j + 1, 1) = x$
Next
End If
End Sub
finds the sequence
cjhds
|
Posted by Charlie
on 2015-03-13 15:42:15 |