Skip to content

Commit aed4964

Browse files
authored
Merge pull request #14 from UBC-MDS/results_to_pattern
Results to pattern
2 parents 13ea012 + 7dcd641 commit aed4964

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

src/wordguess/result_to_pattern.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
def result_to_pattern(result: str) -> str:
2+
"""
3+
Convert a result string to a human-readable pattern of symbols.
4+
5+
This function maps each character in a result string to a corresponding colored square
6+
symbol.
7+
- The character '0' maps to a dark grey square symbol,
8+
- The character '1' maps to a yellow square symbol and,
9+
- The character '2' maps to a green square symbol.
10+
The output is a string composed of UTF-8 colored square symbols.
11+
12+
Parameters:
13+
result (str): a string consisting only of the '0', '1' or '2' characters.
14+
15+
Returns:
16+
str: The corresponding human-readable string pattern composed of UTF-8 colored symbols.
17+
18+
Example:
19+
>>> result_to_pattern("01102")
20+
Output: "⬛🟨🟨⬛🟩"
21+
>>> result_to_pattern("0001221")
22+
Output: "⬛⬛⬛🟨🟩🟩🟨"
23+
24+
"""
25+
26+
# print("\u2B1B") # ⬛ grey square
27+
# print("\U0001F7E8") # 🟨 yellow square
28+
# print("\U0001F7E9") # 🟩 green square

0 commit comments

Comments
 (0)