10 playing cards are placed face-down on a table, forming a circle.
Your are allowed to turn over simultaneously 4 cards that either:
a.)all 4 are consecutive,
or
b.) 2 are on the left and 2 on the right of any specific card chosen by you (i.e. out of 5 consecutive cards only the middle one remains unturned) .
By executing a final number of the above (a. or b.) procedures can you reach an "all face-up" state?
If yes, explain how.
Otherwise, prove why not.
DefDbl A-Z
Dim crlf$, used(1023), state, h(260), sth(260), mask(20), maxlvl
Private Sub Form_Load()
ChDir "C:Program Files (x86)DevStudioVBprojectslooble"
Text1.Text = ""
crlf$ = Chr(13) + Chr(10)
Form1.Visible = True
Text1.Text = Text1.Text & base$(1023, 2) & crlf
DoEvents
For i = 0 To 9
v = 15 * Int(2 ^ i + 0.5)
If v > 1023 Then
xs = v 1024
v = v Mod 1024 + xs
End If
mask(i + 1) = v
Next
For i = 0 To 9
v = 27 * Int(2 ^ i + 0.5)
If v > 1023 Then
xs = v 1024
v = v Mod 1024 + xs
End If
mask(i + 11) = v
Next
seq = 1
used(0) = 1
addOn seq
For i = 0 To 1023
If used(i) Then
Text1.Text = Text1.Text & " " & base$(i, 2) & " "
uct = uct + 1
End If
DoEvents
Next
Text1.Text = Text1.Text & crlf & maxlvl & Str(uct) & " done"
End Sub
Sub addOn(wh)
For i = 1 To 20
state = state Xor mask(i)
If used(state) = 0 Then
used(state) = 1
h(wh) = mask(i)
sth(wh) = state
If state = 2047 Then
For j = 1 To wh
Text1.Text = Text1.Text & base$(h(j), 2) & " " & base$(sth(j), 2) & crlf
Next j
Text1.Text = Text1.Text & crlf
DoEvents
Exit Sub
Else
If wh > maxlvl Then maxlvl = wh
If wh < 260 Then
addOn wh + 1
End If
End If
End If
state = state Xor mask(i)
Next
End Sub
Function base$(n, b)
v$ = ""
n2 = n
Do
d = n2 Mod b
n2 = n2 b
v$ = LTrim(Str(d)) + v$
Loop Until Len(v$) > 9 And n2 = 0
base$ = v$
End Function
finds only sets where the number of upturned cards is even, and not all of those either: only 256 of the 2^10 possible configurations are achievable:
0000000000 0000000101 0000001010 0000001111 0000010001 0000010100 0000011011 0000011110 0000100010 0000100111 0000101000 0000101101 0000110011 0000110110 0000111001 0000111100 0001000001 0001000100 0001001011 0001001110 0001010000 0001010101 0001011010 0001011111 0001100011 0001100110 0001101001 0001101100 0001110010 0001110111 0001111000 0001111101 0010000010 0010000111 0010001000 0010001101 0010010011 0010010110 0010011001 0010011100 0010100000 0010100101 0010101010 0010101111 0010110001 0010110100 0010111011 0010111110 0011000011 0011000110 0011001001 0011001100 0011010010 0011010111 0011011000 0011011101 0011100001 0011100100 0011101011 0011101110 0011110000 0011110101 0011111010 0011111111 0100000001 0100000100 0100001011 0100001110 0100010000 0100010101 0100011010 0100011111 0100100011 0100100110 0100101001 0100101100 0100110010 0100110111 0100111000 0100111101 0101000000 0101000101 0101001010 0101001111 0101010001 0101010100 0101011011 0101011110 0101100010 0101100111 0101101000 0101101101 0101110011 0101110110 0101111001 0101111100 0110000011 0110000110 0110001001 0110001100 0110010010 0110010111 0110011000 0110011101 0110100001 0110100100 0110101011 0110101110 0110110000 0110110101 0110111010 0110111111 0111000010 0111000111 0111001000 0111001101 0111010011 0111010110 0111011001 0111011100 0111100000 0111100101 0111101010 0111101111 0111110001 0111110100 0111111011 0111111110 1000000010 1000000111 1000001000 1000001101 1000010011 1000010110 1000011001 1000011100 1000100000 1000100101 1000101010 1000101111 1000110001 1000110100 1000111011 1000111110 1001000011 1001000110 1001001001 1001001100 1001010010 1001010111 1001011000 1001011101 1001100001 1001100100 1001101011 1001101110 1001110000 1001110101 1001111010 1001111111 1010000000 1010000101 1010001010 1010001111 1010010001 1010010100 1010011011 1010011110 1010100010 1010100111 1010101000 1010101101 1010110011 1010110110 1010111001 1010111100 1011000001 1011000100 1011001011 1011001110 1011010000 1011010101 1011011010 1011011111 1011100011 1011100110 1011101001 1011101100 1011110010 1011110111 1011111000 1011111101 1100000011 1100000110 1100001001 1100001100 1100010010 1100010111 1100011000 1100011101 1100100001 1100100100 1100101011 1100101110 1100110000 1100110101 1100111010 1100111111 1101000010 1101000111 1101001000 1101001101 1101010011 1101010110 1101011001 1101011100 1101100000 1101100101 1101101010 1101101111 1101110001 1101110100 1101111011 1101111110 1110000001 1110000100 1110001011 1110001110 1110010000 1110010101 1110011010 1110011111 1110100011 1110100110 1110101001 1110101100 1110110010 1110110111 1110111000 1110111101 1111000000 1111000101 1111001010 1111001111 1111010001 1111010100 1111011011 1111011110 1111100010 1111100111 1111101000 1111101101 1111110011 1111110110 1111111001 1111111100
The program would have gone 2047 levels deep, but always found a repetition after 255 levels of flips.
Edited on October 2, 2014, 10:53 am
|
Posted by Charlie
on 2014-10-01 11:21:11 |