Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 1e53943

Browse files
style: format code with autopep8
Format code with autopep8 This commit fixes the style issues introduced in 1f67e7b according to the output from Autopep8. Details: None
1 parent 1f67e7b commit 1e53943

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

‎Door Puzzle AI/Puzzle.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,27 @@
11
import random
22

3+
34
def generate_doors(num_doors):
45
doors = [False] * num_doors
56
prize_door = random.randint(0, num_doors - 1)
67
doors[prize_door] = True
78
return doors
89

10+
911
def choose_door(num_doors):
1012
return random.randint(0, num_doors - 1)
1113

14+
1215
def open_door(doors, chosen_door):
13-
reveal_door = random.choice([i for i in range(len(doors)) if i != chosen_door and not doors[i]])
16+
reveal_door = random.choice(
17+
[i for i in range(len(doors)) if i != chosen_door and not doors[i]])
1418
print(f"Door {reveal_door + 1} has no prize.")
1519

20+
1621
def switch_door(chosen_door, num_doors):
1722
return random.choice([i for i in range(num_doors) if i != chosen_door])
1823

24+
1925
def main():
2026
num_doors = 3
2127
doors = generate_doors(num_doors)
@@ -31,15 +37,17 @@ def main():
3137

3238
open_door(doors, chosen_door)
3339

34-
switch_choice = input("Do you want to switch your chosen door? (yes/no): ").lower()
40+
switch_choice = input(
41+
"Do you want to switch your chosen door? (yes/no): ").lower()
3542

3643
if switch_choice == "yes":
3744
chosen_door = switch_door(chosen_door, num_doors)
38-
45+
3946
if doors[chosen_door]:
4047
print("Congratulations! You have won the prize!")
4148
else:
4249
print("Sorry, you did not win this time. Better luck next time!")
4350

51+
4452
if __name__ == "__main__":
4553
main()

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /