-2

I'm trying to brute force all the possible solution of the minesweeper game for my homework but I don't know how to pass the characters in the string inside of the list to the list of lists.

[['1', '0'], ['1', '0']]

[[' ', ' '], [' ', ' ']]

['0000', '0001', '0010', '0011', '0100', '0101', '0110', '0111', '1000', '1001', '1010', '1011', '1100', '1101', '1110', '1111']

The first one is my aim solution board, the second one is my empty board, the third one is my binary list. I want to pass all of the numbers to the empty board and if it is not equal to the aim board I have to pass the next binary number

Asnim P Ansari
  • 1,932
  • 1
  • 18
  • 41
  • can you be more specific on what you want the solution to ? Problem statement is not very clear to me. – Kumar Sourav Sep 03 '19 at 10:37
  • so I want to generate all the numbers from the third list to the second list. for example: after the first iteration the second list should look like [[' 0', ' 0'], [' 0', ' 0']] and after the second one it should look like [['0','0'],['0','1']] – Tuyen Nguyen Sep 03 '19 at 11:06

1 Answers1

0

try something like this. change the names of the variables if you wish. I just did a quick code. Please mark this as accepted answer if it works for you.

 x=['0000', '0001', '0010', '0011', '0100', '0101', '0110', '0111', '1000', '1001', '1010', '1011', '1100', '1101', '1110', '1111']

# pick one item at a time
for item in x:
    finList = []
    l1 = []
    l2 = []
    count = 1
    # get individual digits from the string, like from '0001' you will get 0 then 0 then 0 then 1
    for digit in item:
        if count<=2:
            l1.append(digit)
            count += 1
        else:
            l2.append(digit)
    finList.append(l1)
    finList.append(l2)
    print(finList)
Kumar Sourav
  • 389
  • 4
  • 17