Find the solution from a word search game
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 |
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 '18 at 17:25
1
Mind not vandalising your question?
– Adriaan
Nov 19 '18 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 '18 at 19:26
add a comment |
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 '18 at 19:22
Adriaan
12.7k63160
12.7k63160
asked Nov 19 '18 at 17:15
lucamasepolucamasepo
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 '18 at 17:25
1
Mind not vandalising your question?
– Adriaan
Nov 19 '18 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 '18 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 '18 at 17:25
1
Mind not vandalising your question?
– Adriaan
Nov 19 '18 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 '18 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 '18 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 '18 at 17:25
1
1
Mind not vandalising your question?
– Adriaan
Nov 19 '18 at 19:20
Mind not vandalising your question?
– Adriaan
Nov 19 '18 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 '18 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 '18 at 19:26
add a comment |
2 Answers
2
active
oldest
votes
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 |
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 '18 at 17:47
Smart downcase found letters, here is how to retrieve the result, but somehing is wrong.
– iGian
Nov 19 '18 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 '18 at 18:15
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
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
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
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 |
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 |
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 '18 at 18:14
blhsingblhsing
31.5k41336
31.5k41336
add a comment |
add a comment |
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 '18 at 17:47
Smart downcase found letters, here is how to retrieve the result, but somehing is wrong.
– iGian
Nov 19 '18 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 '18 at 18:15
add a comment |
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 '18 at 17:47
Smart downcase found letters, here is how to retrieve the result, but somehing is wrong.
– iGian
Nov 19 '18 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 '18 at 18:15
add a comment |
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 '18 at 18:11
answered Nov 19 '18 at 17:40
iGianiGian
3,9932623
3,9932623
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 '18 at 17:47
Smart downcase found letters, here is how to retrieve the result, but somehing is wrong.
– iGian
Nov 19 '18 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 '18 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 '18 at 17:47
Smart downcase found letters, here is how to retrieve the result, but somehing is wrong.
– iGian
Nov 19 '18 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 '18 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 '18 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 '18 at 17:47
Smart downcase found letters, here is how to retrieve the result, but somehing is wrong.
– iGian
Nov 19 '18 at 18:12
Smart downcase found letters, here is how to retrieve the result, but somehing is wrong.
– iGian
Nov 19 '18 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 '18 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 '18 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.
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 '18 at 17:25
1
Mind not vandalising your question?
– Adriaan
Nov 19 '18 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 '18 at 19:26