31
Andrey Solomatin
Last seen 1 year ago
Member for 11 years, 2 months, 8 days
Difficulty Normal
I made my solution "second" based on your solution.
line 26: http://www.checkio.org/forum/post/1618/proper-way-to-check-if-sequence-is-empty/
Converting cells form set to frozenset will give you advantage to make check\_list a set and replace line 47-48 with **check\_list.add((new\_cells, new_
More
This solution passes test suggested by [natsuki](http://www.checkio.org/mission/minesweeper/publications/natsuki/python-3/second/#comment-outer-10252)
I update check_solution section with **print\_map** to have visible representation of fail.
More
Are you really need variable **cell** and **mine**? Why not just return?
You choose randomly from list, convert result to list with one element and take first value, Why so complicated?
More
No need to set w1:
python docs: Note, the non-operator versions of union(), intersection(), difference(), and symmetric_difference() will accept any iterable as an argument.
More
It is bad pattern to recreate string with string concatenation (line 26)
On each cycle you make a copy of full string.
More
**t.find(w, start)** is O(n), better not to call it twice.
you can remove **key=itemgetter(0),** in line 42, default key do the same.
More
[Efficient String Concatenation in Python](http://skymind.com/~ocrow/python_string/)
More
It is hard to read your code.
[Efficient String Concatenation in Python](http://skymind.com/~ocrow/python_string/)
More
If you calculate value a lot of time, you should store it to variable.
# for word in words.split():
# while True:
# p = text.lower().find(word.lower(), p+1) # copy text M times
text_for_search = text.lower()
for word in words.lower().split():
w
More
You store number of steps twice, in **queue** and in **d**.
You can drop line 20, condition never be True. Same with second condition in line 24. BFS guaranty it.
More
This code is not good, you can use **continue** instead of **raise**:
except notGood:
pass
More
**You dont need lambda 1**: just call you code in place
**You dont need lambda 2** push = stack.appned
More
You not need first list, map return list.
You can convert all values to strings
def checkio(G):
lines = G + [G[0][a] + G[1][a] + G[2][a] for a in [0, 1, 2]] + [G[0][0] + G[1][1] + G[2][2]] + [G[0][2] + G[1][1] + G[2][0]]
return 'X' if 'X' * 3 in lines else 'O' if 'O' * 3 in lines els
More