Find the solution from a word search game
up vote
0
down vote
favorite
I have a file with a matrix that is my wordsearch and some words that i need to find in it.
O T N E G R A S A E
R N N C O R A L L O
O A I B L U E E V G
U T O R E N T I I A
V I O L E T T O O R
O C R A R I A E L O
D A B I M A L V A P
I P C I E L O G L R
C O R P O S O U A O
A P I E N O M I L P
ACIDO
ARGENTO
BLU
CIELO
CORALLO
CORPOSO
ELETTRICO
LATTE
LIMONE
MALVA
NERO
OCRA
OPACITA
ORO
PAGLIERINO
PIENO
PORPORA
PRIMITIVO
VIOLA
VIOLETTO
For the solution I have thought about something like that:
with open('cp5_Colori.txt', 'r') as f:
import pprint
data=f.read().replace("t","")
A=
B=set()
data=data.split("nn")
word_list=data[1].split()
lista_orizzontale=data[0].split()
puzzle=[list(row) for row in lista_orizzontale]
for parola in word_list:
for lista in puzzle:
x=puzzle.index(lista)
for carattere in lista:
y=lista.index(carattere)
if carattere.upper() == parola[0]:
for direction in [(1,0),(1,1),(0,1),(-1,1),(-1,0),(-1,-1),(0,-1),(1,-1)]:
(dx, dy) = direction
for i in range(len(parola)):
if ((x+dx*i)<len(puzzle)) and ((y+dy*i)<len(lista)) == True:
if puzzle[x+dx*i][y+dy*i].upper()== parola[i]:
puzzle[x+dx*i][y+dy*i]=puzzle[x+dx*i][y+dy*i].lower()
pprint.pprint(puzzle)
To solve the puzzle you need to search and then delete from the wordsearch all the OCCURRENCES (if multiple) of the words in the list.
The letters of the diagram that will remain, taken all in their order by rows and by columns, they will form the solution of the game.
I don't know how to continue and how to find the solution that is "SANGUEBLU"
python
add a comment |
up vote
0
down vote
favorite
I have a file with a matrix that is my wordsearch and some words that i need to find in it.
O T N E G R A S A E
R N N C O R A L L O
O A I B L U E E V G
U T O R E N T I I A
V I O L E T T O O R
O C R A R I A E L O
D A B I M A L V A P
I P C I E L O G L R
C O R P O S O U A O
A P I E N O M I L P
ACIDO
ARGENTO
BLU
CIELO
CORALLO
CORPOSO
ELETTRICO
LATTE
LIMONE
MALVA
NERO
OCRA
OPACITA
ORO
PAGLIERINO
PIENO
PORPORA
PRIMITIVO
VIOLA
VIOLETTO
For the solution I have thought about something like that:
with open('cp5_Colori.txt', 'r') as f:
import pprint
data=f.read().replace("t","")
A=
B=set()
data=data.split("nn")
word_list=data[1].split()
lista_orizzontale=data[0].split()
puzzle=[list(row) for row in lista_orizzontale]
for parola in word_list:
for lista in puzzle:
x=puzzle.index(lista)
for carattere in lista:
y=lista.index(carattere)
if carattere.upper() == parola[0]:
for direction in [(1,0),(1,1),(0,1),(-1,1),(-1,0),(-1,-1),(0,-1),(1,-1)]:
(dx, dy) = direction
for i in range(len(parola)):
if ((x+dx*i)<len(puzzle)) and ((y+dy*i)<len(lista)) == True:
if puzzle[x+dx*i][y+dy*i].upper()== parola[i]:
puzzle[x+dx*i][y+dy*i]=puzzle[x+dx*i][y+dy*i].lower()
pprint.pprint(puzzle)
To solve the puzzle you need to search and then delete from the wordsearch all the OCCURRENCES (if multiple) of the words in the list.
The letters of the diagram that will remain, taken all in their order by rows and by columns, they will form the solution of the game.
I don't know how to continue and how to find the solution that is "SANGUEBLU"
python
Rather than.read()
, I wold look into using numpy's loadtxt to get the characters into an actual array, then you can use slicing to get the rows and columns and check whether they contain the words
– G. Anderson
Nov 19 at 17:25
1
Mind not vandalising your question?
– Adriaan
Nov 19 at 19:20
2
Please don't make more work for other people by vandalizing your posts. By posting on the Stack Exchange (SE) network, you've granted a non-revocable right, under the CC BY-SA 3.0 license, for SE to distribute that content (i.e. regardless of your future choices). By SE policy, the non-vandalized version of the post is the one which is distributed. Thus, any vandalism will be reverted. If you want to know more about deleting a post please see: How does deleting work? ...
– Makyen
Nov 19 at 19:26
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I have a file with a matrix that is my wordsearch and some words that i need to find in it.
O T N E G R A S A E
R N N C O R A L L O
O A I B L U E E V G
U T O R E N T I I A
V I O L E T T O O R
O C R A R I A E L O
D A B I M A L V A P
I P C I E L O G L R
C O R P O S O U A O
A P I E N O M I L P
ACIDO
ARGENTO
BLU
CIELO
CORALLO
CORPOSO
ELETTRICO
LATTE
LIMONE
MALVA
NERO
OCRA
OPACITA
ORO
PAGLIERINO
PIENO
PORPORA
PRIMITIVO
VIOLA
VIOLETTO
For the solution I have thought about something like that:
with open('cp5_Colori.txt', 'r') as f:
import pprint
data=f.read().replace("t","")
A=
B=set()
data=data.split("nn")
word_list=data[1].split()
lista_orizzontale=data[0].split()
puzzle=[list(row) for row in lista_orizzontale]
for parola in word_list:
for lista in puzzle:
x=puzzle.index(lista)
for carattere in lista:
y=lista.index(carattere)
if carattere.upper() == parola[0]:
for direction in [(1,0),(1,1),(0,1),(-1,1),(-1,0),(-1,-1),(0,-1),(1,-1)]:
(dx, dy) = direction
for i in range(len(parola)):
if ((x+dx*i)<len(puzzle)) and ((y+dy*i)<len(lista)) == True:
if puzzle[x+dx*i][y+dy*i].upper()== parola[i]:
puzzle[x+dx*i][y+dy*i]=puzzle[x+dx*i][y+dy*i].lower()
pprint.pprint(puzzle)
To solve the puzzle you need to search and then delete from the wordsearch all the OCCURRENCES (if multiple) of the words in the list.
The letters of the diagram that will remain, taken all in their order by rows and by columns, they will form the solution of the game.
I don't know how to continue and how to find the solution that is "SANGUEBLU"
python
I have a file with a matrix that is my wordsearch and some words that i need to find in it.
O T N E G R A S A E
R N N C O R A L L O
O A I B L U E E V G
U T O R E N T I I A
V I O L E T T O O R
O C R A R I A E L O
D A B I M A L V A P
I P C I E L O G L R
C O R P O S O U A O
A P I E N O M I L P
ACIDO
ARGENTO
BLU
CIELO
CORALLO
CORPOSO
ELETTRICO
LATTE
LIMONE
MALVA
NERO
OCRA
OPACITA
ORO
PAGLIERINO
PIENO
PORPORA
PRIMITIVO
VIOLA
VIOLETTO
For the solution I have thought about something like that:
with open('cp5_Colori.txt', 'r') as f:
import pprint
data=f.read().replace("t","")
A=
B=set()
data=data.split("nn")
word_list=data[1].split()
lista_orizzontale=data[0].split()
puzzle=[list(row) for row in lista_orizzontale]
for parola in word_list:
for lista in puzzle:
x=puzzle.index(lista)
for carattere in lista:
y=lista.index(carattere)
if carattere.upper() == parola[0]:
for direction in [(1,0),(1,1),(0,1),(-1,1),(-1,0),(-1,-1),(0,-1),(1,-1)]:
(dx, dy) = direction
for i in range(len(parola)):
if ((x+dx*i)<len(puzzle)) and ((y+dy*i)<len(lista)) == True:
if puzzle[x+dx*i][y+dy*i].upper()== parola[i]:
puzzle[x+dx*i][y+dy*i]=puzzle[x+dx*i][y+dy*i].lower()
pprint.pprint(puzzle)
To solve the puzzle you need to search and then delete from the wordsearch all the OCCURRENCES (if multiple) of the words in the list.
The letters of the diagram that will remain, taken all in their order by rows and by columns, they will form the solution of the game.
I don't know how to continue and how to find the solution that is "SANGUEBLU"
python
python
edited Nov 19 at 19:22
Adriaan
12.4k63160
12.4k63160
asked Nov 19 at 17:15
lucamasepo
64
64
Rather than.read()
, I wold look into using numpy's loadtxt to get the characters into an actual array, then you can use slicing to get the rows and columns and check whether they contain the words
– G. Anderson
Nov 19 at 17:25
1
Mind not vandalising your question?
– Adriaan
Nov 19 at 19:20
2
Please don't make more work for other people by vandalizing your posts. By posting on the Stack Exchange (SE) network, you've granted a non-revocable right, under the CC BY-SA 3.0 license, for SE to distribute that content (i.e. regardless of your future choices). By SE policy, the non-vandalized version of the post is the one which is distributed. Thus, any vandalism will be reverted. If you want to know more about deleting a post please see: How does deleting work? ...
– Makyen
Nov 19 at 19:26
add a comment |
Rather than.read()
, I wold look into using numpy's loadtxt to get the characters into an actual array, then you can use slicing to get the rows and columns and check whether they contain the words
– G. Anderson
Nov 19 at 17:25
1
Mind not vandalising your question?
– Adriaan
Nov 19 at 19:20
2
Please don't make more work for other people by vandalizing your posts. By posting on the Stack Exchange (SE) network, you've granted a non-revocable right, under the CC BY-SA 3.0 license, for SE to distribute that content (i.e. regardless of your future choices). By SE policy, the non-vandalized version of the post is the one which is distributed. Thus, any vandalism will be reverted. If you want to know more about deleting a post please see: How does deleting work? ...
– Makyen
Nov 19 at 19:26
Rather than
.read()
, I wold look into using numpy's loadtxt to get the characters into an actual array, then you can use slicing to get the rows and columns and check whether they contain the words– G. Anderson
Nov 19 at 17:25
Rather than
.read()
, I wold look into using numpy's loadtxt to get the characters into an actual array, then you can use slicing to get the rows and columns and check whether they contain the words– G. Anderson
Nov 19 at 17:25
1
1
Mind not vandalising your question?
– Adriaan
Nov 19 at 19:20
Mind not vandalising your question?
– Adriaan
Nov 19 at 19:20
2
2
Please don't make more work for other people by vandalizing your posts. By posting on the Stack Exchange (SE) network, you've granted a non-revocable right, under the CC BY-SA 3.0 license, for SE to distribute that content (i.e. regardless of your future choices). By SE policy, the non-vandalized version of the post is the one which is distributed. Thus, any vandalism will be reverted. If you want to know more about deleting a post please see: How does deleting work? ...
– Makyen
Nov 19 at 19:26
Please don't make more work for other people by vandalizing your posts. By posting on the Stack Exchange (SE) network, you've granted a non-revocable right, under the CC BY-SA 3.0 license, for SE to distribute that content (i.e. regardless of your future choices). By SE policy, the non-vandalized version of the post is the one which is distributed. Thus, any vandalism will be reverted. If you want to know more about deleting a post please see: How does deleting work? ...
– Makyen
Nov 19 at 19:26
add a comment |
2 Answers
2
active
oldest
votes
up vote
1
down vote
accepted
Given the following initialization:
puzzle = [l.split() for l in '''O T N E G R A S A E
R N N C O R A L L O
O A I B L U E E V G
U T O R E N T I I A
V I O L E T T O O R
O C R A R I A E L O
D A B I M A L V A P
I P C I E L O G L R
C O R P O S O U A O
A P I E N O M I L P'''.splitlines()]
word_list = '''ACIDO
ARGENTO
BLU
CIELO
CORALLO
CORPOSO
ELETTRICO
LATTE
LIMONE
MALVA
NERO
OCRA
OPACITA
ORO
PAGLIERINO
PIENO
PORPORA
PRIMITIVO
VIOLA
VIOLETTO'''.splitlines()
The following code will solve your problem:
from itertools import product
removals =
for word in word_list:
for row in range(len(puzzle)):
for col in range(len(puzzle[row])):
for dr, dc in product(range(-1, 2), repeat=2):
if dr or dc:
removal =
for i in range(len(word)):
r = row + dr * i
c = col + dc * i
if not (0 <= r < len(puzzle) and 0 <= c < len(puzzle[row])) or puzzle[r][c] != word[i]:
break
removal.append((r, c))
else:
removals.append(removal)
for removal in removals:
for row, col in removal:
puzzle[row][col] = None
print(''.join(char for row in puzzle for char in row if char))
This outputs:
SANGUEBLU
add a comment |
up vote
0
down vote
Once you downcased the letter using your code, you can get the result by:
crossed = [['o', 't', 'n', 'e', 'g', 'r', 'a', 'S', 'a', 'e'], ['r', 'n', 'n', 'c', 'o', 'r', 'a', 'l', 'l', 'o'], ['o', 'a', 'i', 'b', 'l', 'u', 'e', 'e', 'v', 'g'], ['U', 't', 'o', 'r', 'e', 'n', 't', 'i', 'i', 'a'], ['v', 'i', 'o', 'l', 'e', 't', 't', 'o', 'o', 'r'], ['o', 'c', 'r', 'a', 'r', 'i', 'a', 'e', 'l', 'o'], ['d', 'a', 'b', 'i', 'm', 'a', 'l', 'v', 'a', 'p'], ['i', 'p', 'c', 'i', 'e', 'l', 'o', 'G', 'l', 'r'], ['c', 'o', 'r', 'p', 'o', 's', 'o', 'U', 'a', 'o'], ['a', 'p', 'i', 'e', 'n', 'o', 'm', 'i', 'l', 'p']]
import re
result = ''.join([ ''.join(line) for line in crossed ])
print(result)
hidden_word = ''.join(re.findall(r'[A-Z]', result))
print (hidden_word) #=> SUGU
But it seems you code downcased too many words.
thank you sir.. yeah i need also diagonals... but i alredy know how to find the words.. my problem is to find the remaining characters that is the solution of the game ,after deleting all the found words
– lucamasepo
Nov 19 at 17:47
Smart downcase found letters, here is how to retrieve the result, but somehing is wrong.
– iGian
Nov 19 at 18:12
thank you for your help , but the solution should be "SANGUEBLU" not "SUGU".. what's wrong in my code? how can i fix it?
– lucamasepo
Nov 19 at 18:15
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
Given the following initialization:
puzzle = [l.split() for l in '''O T N E G R A S A E
R N N C O R A L L O
O A I B L U E E V G
U T O R E N T I I A
V I O L E T T O O R
O C R A R I A E L O
D A B I M A L V A P
I P C I E L O G L R
C O R P O S O U A O
A P I E N O M I L P'''.splitlines()]
word_list = '''ACIDO
ARGENTO
BLU
CIELO
CORALLO
CORPOSO
ELETTRICO
LATTE
LIMONE
MALVA
NERO
OCRA
OPACITA
ORO
PAGLIERINO
PIENO
PORPORA
PRIMITIVO
VIOLA
VIOLETTO'''.splitlines()
The following code will solve your problem:
from itertools import product
removals =
for word in word_list:
for row in range(len(puzzle)):
for col in range(len(puzzle[row])):
for dr, dc in product(range(-1, 2), repeat=2):
if dr or dc:
removal =
for i in range(len(word)):
r = row + dr * i
c = col + dc * i
if not (0 <= r < len(puzzle) and 0 <= c < len(puzzle[row])) or puzzle[r][c] != word[i]:
break
removal.append((r, c))
else:
removals.append(removal)
for removal in removals:
for row, col in removal:
puzzle[row][col] = None
print(''.join(char for row in puzzle for char in row if char))
This outputs:
SANGUEBLU
add a comment |
up vote
1
down vote
accepted
Given the following initialization:
puzzle = [l.split() for l in '''O T N E G R A S A E
R N N C O R A L L O
O A I B L U E E V G
U T O R E N T I I A
V I O L E T T O O R
O C R A R I A E L O
D A B I M A L V A P
I P C I E L O G L R
C O R P O S O U A O
A P I E N O M I L P'''.splitlines()]
word_list = '''ACIDO
ARGENTO
BLU
CIELO
CORALLO
CORPOSO
ELETTRICO
LATTE
LIMONE
MALVA
NERO
OCRA
OPACITA
ORO
PAGLIERINO
PIENO
PORPORA
PRIMITIVO
VIOLA
VIOLETTO'''.splitlines()
The following code will solve your problem:
from itertools import product
removals =
for word in word_list:
for row in range(len(puzzle)):
for col in range(len(puzzle[row])):
for dr, dc in product(range(-1, 2), repeat=2):
if dr or dc:
removal =
for i in range(len(word)):
r = row + dr * i
c = col + dc * i
if not (0 <= r < len(puzzle) and 0 <= c < len(puzzle[row])) or puzzle[r][c] != word[i]:
break
removal.append((r, c))
else:
removals.append(removal)
for removal in removals:
for row, col in removal:
puzzle[row][col] = None
print(''.join(char for row in puzzle for char in row if char))
This outputs:
SANGUEBLU
add a comment |
up vote
1
down vote
accepted
up vote
1
down vote
accepted
Given the following initialization:
puzzle = [l.split() for l in '''O T N E G R A S A E
R N N C O R A L L O
O A I B L U E E V G
U T O R E N T I I A
V I O L E T T O O R
O C R A R I A E L O
D A B I M A L V A P
I P C I E L O G L R
C O R P O S O U A O
A P I E N O M I L P'''.splitlines()]
word_list = '''ACIDO
ARGENTO
BLU
CIELO
CORALLO
CORPOSO
ELETTRICO
LATTE
LIMONE
MALVA
NERO
OCRA
OPACITA
ORO
PAGLIERINO
PIENO
PORPORA
PRIMITIVO
VIOLA
VIOLETTO'''.splitlines()
The following code will solve your problem:
from itertools import product
removals =
for word in word_list:
for row in range(len(puzzle)):
for col in range(len(puzzle[row])):
for dr, dc in product(range(-1, 2), repeat=2):
if dr or dc:
removal =
for i in range(len(word)):
r = row + dr * i
c = col + dc * i
if not (0 <= r < len(puzzle) and 0 <= c < len(puzzle[row])) or puzzle[r][c] != word[i]:
break
removal.append((r, c))
else:
removals.append(removal)
for removal in removals:
for row, col in removal:
puzzle[row][col] = None
print(''.join(char for row in puzzle for char in row if char))
This outputs:
SANGUEBLU
Given the following initialization:
puzzle = [l.split() for l in '''O T N E G R A S A E
R N N C O R A L L O
O A I B L U E E V G
U T O R E N T I I A
V I O L E T T O O R
O C R A R I A E L O
D A B I M A L V A P
I P C I E L O G L R
C O R P O S O U A O
A P I E N O M I L P'''.splitlines()]
word_list = '''ACIDO
ARGENTO
BLU
CIELO
CORALLO
CORPOSO
ELETTRICO
LATTE
LIMONE
MALVA
NERO
OCRA
OPACITA
ORO
PAGLIERINO
PIENO
PORPORA
PRIMITIVO
VIOLA
VIOLETTO'''.splitlines()
The following code will solve your problem:
from itertools import product
removals =
for word in word_list:
for row in range(len(puzzle)):
for col in range(len(puzzle[row])):
for dr, dc in product(range(-1, 2), repeat=2):
if dr or dc:
removal =
for i in range(len(word)):
r = row + dr * i
c = col + dc * i
if not (0 <= r < len(puzzle) and 0 <= c < len(puzzle[row])) or puzzle[r][c] != word[i]:
break
removal.append((r, c))
else:
removals.append(removal)
for removal in removals:
for row, col in removal:
puzzle[row][col] = None
print(''.join(char for row in puzzle for char in row if char))
This outputs:
SANGUEBLU
answered Nov 19 at 18:14
blhsing
27.8k41335
27.8k41335
add a comment |
add a comment |
up vote
0
down vote
Once you downcased the letter using your code, you can get the result by:
crossed = [['o', 't', 'n', 'e', 'g', 'r', 'a', 'S', 'a', 'e'], ['r', 'n', 'n', 'c', 'o', 'r', 'a', 'l', 'l', 'o'], ['o', 'a', 'i', 'b', 'l', 'u', 'e', 'e', 'v', 'g'], ['U', 't', 'o', 'r', 'e', 'n', 't', 'i', 'i', 'a'], ['v', 'i', 'o', 'l', 'e', 't', 't', 'o', 'o', 'r'], ['o', 'c', 'r', 'a', 'r', 'i', 'a', 'e', 'l', 'o'], ['d', 'a', 'b', 'i', 'm', 'a', 'l', 'v', 'a', 'p'], ['i', 'p', 'c', 'i', 'e', 'l', 'o', 'G', 'l', 'r'], ['c', 'o', 'r', 'p', 'o', 's', 'o', 'U', 'a', 'o'], ['a', 'p', 'i', 'e', 'n', 'o', 'm', 'i', 'l', 'p']]
import re
result = ''.join([ ''.join(line) for line in crossed ])
print(result)
hidden_word = ''.join(re.findall(r'[A-Z]', result))
print (hidden_word) #=> SUGU
But it seems you code downcased too many words.
thank you sir.. yeah i need also diagonals... but i alredy know how to find the words.. my problem is to find the remaining characters that is the solution of the game ,after deleting all the found words
– lucamasepo
Nov 19 at 17:47
Smart downcase found letters, here is how to retrieve the result, but somehing is wrong.
– iGian
Nov 19 at 18:12
thank you for your help , but the solution should be "SANGUEBLU" not "SUGU".. what's wrong in my code? how can i fix it?
– lucamasepo
Nov 19 at 18:15
add a comment |
up vote
0
down vote
Once you downcased the letter using your code, you can get the result by:
crossed = [['o', 't', 'n', 'e', 'g', 'r', 'a', 'S', 'a', 'e'], ['r', 'n', 'n', 'c', 'o', 'r', 'a', 'l', 'l', 'o'], ['o', 'a', 'i', 'b', 'l', 'u', 'e', 'e', 'v', 'g'], ['U', 't', 'o', 'r', 'e', 'n', 't', 'i', 'i', 'a'], ['v', 'i', 'o', 'l', 'e', 't', 't', 'o', 'o', 'r'], ['o', 'c', 'r', 'a', 'r', 'i', 'a', 'e', 'l', 'o'], ['d', 'a', 'b', 'i', 'm', 'a', 'l', 'v', 'a', 'p'], ['i', 'p', 'c', 'i', 'e', 'l', 'o', 'G', 'l', 'r'], ['c', 'o', 'r', 'p', 'o', 's', 'o', 'U', 'a', 'o'], ['a', 'p', 'i', 'e', 'n', 'o', 'm', 'i', 'l', 'p']]
import re
result = ''.join([ ''.join(line) for line in crossed ])
print(result)
hidden_word = ''.join(re.findall(r'[A-Z]', result))
print (hidden_word) #=> SUGU
But it seems you code downcased too many words.
thank you sir.. yeah i need also diagonals... but i alredy know how to find the words.. my problem is to find the remaining characters that is the solution of the game ,after deleting all the found words
– lucamasepo
Nov 19 at 17:47
Smart downcase found letters, here is how to retrieve the result, but somehing is wrong.
– iGian
Nov 19 at 18:12
thank you for your help , but the solution should be "SANGUEBLU" not "SUGU".. what's wrong in my code? how can i fix it?
– lucamasepo
Nov 19 at 18:15
add a comment |
up vote
0
down vote
up vote
0
down vote
Once you downcased the letter using your code, you can get the result by:
crossed = [['o', 't', 'n', 'e', 'g', 'r', 'a', 'S', 'a', 'e'], ['r', 'n', 'n', 'c', 'o', 'r', 'a', 'l', 'l', 'o'], ['o', 'a', 'i', 'b', 'l', 'u', 'e', 'e', 'v', 'g'], ['U', 't', 'o', 'r', 'e', 'n', 't', 'i', 'i', 'a'], ['v', 'i', 'o', 'l', 'e', 't', 't', 'o', 'o', 'r'], ['o', 'c', 'r', 'a', 'r', 'i', 'a', 'e', 'l', 'o'], ['d', 'a', 'b', 'i', 'm', 'a', 'l', 'v', 'a', 'p'], ['i', 'p', 'c', 'i', 'e', 'l', 'o', 'G', 'l', 'r'], ['c', 'o', 'r', 'p', 'o', 's', 'o', 'U', 'a', 'o'], ['a', 'p', 'i', 'e', 'n', 'o', 'm', 'i', 'l', 'p']]
import re
result = ''.join([ ''.join(line) for line in crossed ])
print(result)
hidden_word = ''.join(re.findall(r'[A-Z]', result))
print (hidden_word) #=> SUGU
But it seems you code downcased too many words.
Once you downcased the letter using your code, you can get the result by:
crossed = [['o', 't', 'n', 'e', 'g', 'r', 'a', 'S', 'a', 'e'], ['r', 'n', 'n', 'c', 'o', 'r', 'a', 'l', 'l', 'o'], ['o', 'a', 'i', 'b', 'l', 'u', 'e', 'e', 'v', 'g'], ['U', 't', 'o', 'r', 'e', 'n', 't', 'i', 'i', 'a'], ['v', 'i', 'o', 'l', 'e', 't', 't', 'o', 'o', 'r'], ['o', 'c', 'r', 'a', 'r', 'i', 'a', 'e', 'l', 'o'], ['d', 'a', 'b', 'i', 'm', 'a', 'l', 'v', 'a', 'p'], ['i', 'p', 'c', 'i', 'e', 'l', 'o', 'G', 'l', 'r'], ['c', 'o', 'r', 'p', 'o', 's', 'o', 'U', 'a', 'o'], ['a', 'p', 'i', 'e', 'n', 'o', 'm', 'i', 'l', 'p']]
import re
result = ''.join([ ''.join(line) for line in crossed ])
print(result)
hidden_word = ''.join(re.findall(r'[A-Z]', result))
print (hidden_word) #=> SUGU
But it seems you code downcased too many words.
edited Nov 19 at 18:11
answered Nov 19 at 17:40
iGian
2,8442622
2,8442622
thank you sir.. yeah i need also diagonals... but i alredy know how to find the words.. my problem is to find the remaining characters that is the solution of the game ,after deleting all the found words
– lucamasepo
Nov 19 at 17:47
Smart downcase found letters, here is how to retrieve the result, but somehing is wrong.
– iGian
Nov 19 at 18:12
thank you for your help , but the solution should be "SANGUEBLU" not "SUGU".. what's wrong in my code? how can i fix it?
– lucamasepo
Nov 19 at 18:15
add a comment |
thank you sir.. yeah i need also diagonals... but i alredy know how to find the words.. my problem is to find the remaining characters that is the solution of the game ,after deleting all the found words
– lucamasepo
Nov 19 at 17:47
Smart downcase found letters, here is how to retrieve the result, but somehing is wrong.
– iGian
Nov 19 at 18:12
thank you for your help , but the solution should be "SANGUEBLU" not "SUGU".. what's wrong in my code? how can i fix it?
– lucamasepo
Nov 19 at 18:15
thank you sir.. yeah i need also diagonals... but i alredy know how to find the words.. my problem is to find the remaining characters that is the solution of the game ,after deleting all the found words
– lucamasepo
Nov 19 at 17:47
thank you sir.. yeah i need also diagonals... but i alredy know how to find the words.. my problem is to find the remaining characters that is the solution of the game ,after deleting all the found words
– lucamasepo
Nov 19 at 17:47
Smart downcase found letters, here is how to retrieve the result, but somehing is wrong.
– iGian
Nov 19 at 18:12
Smart downcase found letters, here is how to retrieve the result, but somehing is wrong.
– iGian
Nov 19 at 18:12
thank you for your help , but the solution should be "SANGUEBLU" not "SUGU".. what's wrong in my code? how can i fix it?
– lucamasepo
Nov 19 at 18:15
thank you for your help , but the solution should be "SANGUEBLU" not "SUGU".. what's wrong in my code? how can i fix it?
– lucamasepo
Nov 19 at 18:15
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53379637%2ffind-the-solution-from-a-word-search-game%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Rather than
.read()
, I wold look into using numpy's loadtxt to get the characters into an actual array, then you can use slicing to get the rows and columns and check whether they contain the words– G. Anderson
Nov 19 at 17:25
1
Mind not vandalising your question?
– Adriaan
Nov 19 at 19:20
2
Please don't make more work for other people by vandalizing your posts. By posting on the Stack Exchange (SE) network, you've granted a non-revocable right, under the CC BY-SA 3.0 license, for SE to distribute that content (i.e. regardless of your future choices). By SE policy, the non-vandalized version of the post is the one which is distributed. Thus, any vandalism will be reverted. If you want to know more about deleting a post please see: How does deleting work? ...
– Makyen
Nov 19 at 19:26