Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solution #469

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Solution #469

wants to merge 2 commits into from

Conversation

DanuloM
Copy link

@DanuloM DanuloM commented Aug 5, 2024

No description provided.

app/main.py Outdated
for index in self.decks:
if index.column == column and index.row == row:
return index
return
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return - redundant here

app/main.py Outdated
self.ships = ships
self.field = {}

for index in range(len(ships)):
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
for index in range(len(ships)):
for start, end in ships:

app/main.py Outdated
Comment on lines 60 to 68
keys = [(key.row, key.column) for key in self.field.keys()]
if location not in keys:
return "Miss!"
for index, value in self.field.items():
if location[0] == index.row and location[1] == index.column:
value.fire(index.row, index.column)
if value.is_drowned is True:
return "Sunk!"
return "Hit!"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

try optimizing this without using a loop

@DanuloM DanuloM requested a review from vsmutok August 6, 2024 17:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants