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 4b08220

Browse files
Merge pull request avinashkranjan#2813 from avinashkranjan/deepsource-transform-d9215214
format code with autopep8
2 parents f1d9e01 + bd4f07b commit 4b08220

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

‎Pattern Recognition Game/pattern_recognition_game.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import random
22
import time
33

4+
45
def generate_pattern():
5-
colors = ["red", "green", "blue", "yellow", "orange", "purple", "pink", "brown", "gray", "black", "white", "cyan", "magenta"]
6+
colors = ["red", "green", "blue", "yellow", "orange", "purple",
7+
"pink", "brown", "gray", "black", "white", "cyan", "magenta"]
68
patterns = [
79
["red", "green", "blue", "yellow", "orange"],
810
["purple", "pink", "brown", "gray", "black"],
@@ -23,17 +25,21 @@ def generate_pattern():
2325
pattern = random.choice(patterns)
2426
return pattern
2527

28+
2629
def get_next_pattern(pattern):
27-
colors = set(["red", "green", "blue", "yellow", "orange", "purple", "pink", "brown", "gray", "black", "white", "cyan", "magenta"])
30+
colors = set(["red", "green", "blue", "yellow", "orange", "purple",
31+
"pink", "brown", "gray", "black", "white", "cyan", "magenta"])
2832
pattern_set = set(pattern)
2933
missing_color = list(colors - pattern_set)[0]
3034
next_pattern = pattern[1:] + [missing_color]
3135
return next_pattern
3236

37+
3338
def play_game():
3439
print("Welcome to the Pattern Recognition Game!")
3540
print("Try to identify the underlying rule of the color patterns.")
36-
print("For example, if the pattern is ['red', 'green', 'blue', 'yellow', 'orange'], the next pattern will be ['green', 'blue', 'yellow', 'orange', 'purple'] (alphabetical order).\n")
41+
print(
42+
"For example, if the pattern is ['red', 'green', 'blue', 'yellow', 'orange'], the next pattern will be ['green', 'blue', 'yellow', 'orange', 'purple'] (alphabetical order).\n")
3743

3844
score = 0
3945
max_attempts = 3
@@ -52,8 +58,9 @@ def play_game():
5258
print("Correct!")
5359
break
5460
else:
55-
print(f"Wrong! {max_attempts - attempt - 1} attempts remaining.")
56-
61+
print(
62+
f"Wrong! {max_attempts - attempt - 1} attempts remaining.")
63+
5764
else:
5865
print(f"\nGame Over! Your score: {score}\n")
5966
break
@@ -78,5 +85,6 @@ def play_game():
7885
print("\nTime's up!\n")
7986
print(f"Your score: {score}\n")
8087

88+
8189
if __name__ == "__main__":
8290
play_game()

0 commit comments

Comments
(0)

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