Private Sub Command1_Click()
Dim y, i As Integer
y = Array("1", "22", "33", "44", "55", "111", "123", "145", "155", "246", "257", "347", "356", "1122", "1133", "1144", "1155", "1245", "2222", "2233", "2244", "2345", "3333", "11111", "11123", "11145", "12223", "12234", "12333", "111122", "111133", "112222", "112233", "1111111", "1111123", "11111122")
For i = 0 To UBound(y)
If firstlose(y(i)) = False Then Debug.Print y(i)
Next
'MsgBox firstlose("357")
'MsgBox firstlose("1234567889999")
End Sub
Function firstlose(ByVal x As String) As Boolean '先走必败,x为0123456789按升序排列,如245237先手工排成223457
firstlose = False
Dim i As Integer, j As Integer
x = Replace(x, "0", "")
x = Replace(x, "11", "")
If x = "1" Then firstlose = True: Exit Function
For i = 2 To 9
x = Replace(x, i & i, "")
Next
If x = "" Then firstlose = True: Exit Function
Dim a() As String, b(1 To 4) As String, num As Integer
num = Len(x)
ReDim a(1 To num)
For i = 1 To num
a(i) = Choose(Val(Mid(x, i, 1)), "0001", "0010", "0011", "0100", "0101", "0110", "0111", "1000", "1001")
For j = 1 To 4
b(j) = (Val(b(j)) + Val(Mid(a(i), j, 1))) Mod 2
Next
Next
If Join(b, "") = "0000" Then firstlose = True
Erase b
End Function