Skip to content

Commit

Permalink
Merge pull request #916 from amjadkofahi/sourcery/main
Browse files Browse the repository at this point in the history
Sourcery/main
  • Loading branch information
coding-horror committed Sep 8, 2024
2 parents 686fbdf + a20b3ff commit 164692a
Show file tree
Hide file tree
Showing 74 changed files with 609 additions and 848 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,6 @@ venv/
**/*.rs.bk
/target
todo.md

.fake
.fake
14 changes: 8 additions & 6 deletions 00_Alternate_Languages/89_Tic-Tac-Toe/MiniScript/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@ Conversion to [MiniScript](https://miniscript.org).
Ways to play:

1. Command-Line MiniScript:
Download for your system from https://miniscript.org/cmdline/, install, and then run the program with a command such as:
Download for your system from <https://miniscript.org/cmdline/>, install, and then run the program with a command such as:

```
miniscript tictactoe.ms
miniscript tictactoe.ms
```

2. Mini Micro:
Download Mini Micro from https://miniscript.org/MiniMicro/, launch, and then click the top disk slot and chose "Mount Folder..." Select the folder containing the MiniScript program and this README file. Then, at the Mini Micro command prompt, enter:
Download Mini Micro from <https://miniscript.org/MiniMicro/>, launch, and then click the top disk slot and chose "Mount Folder..." Select the folder containing the MiniScript program and this README file. Then, at the Mini Micro command prompt, enter:

```
load "tictactoe"
run
```
load "tictactoe"
run
```
4 changes: 2 additions & 2 deletions 02_Amazing/python/amazing.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def display(self) -> None:
print(" ", end="")
print()
for col in range(self.width):
if self.walls[row][col] == 0 or self.walls[row][col] == 2:
if self.walls[row][col] in [0, 2]:
print(":--", end="")
else:
print(": ", end="")
Expand Down Expand Up @@ -148,7 +148,7 @@ def make_opening(
maze.walls[pos.row][pos.col] = maze.walls[pos.row][pos.col] + EXIT_DOWN
pos.row = pos.row + 1
maze.used[pos.row][pos.col] = count
count = count + 1
count += 1
return pos, count


Expand Down
22 changes: 9 additions & 13 deletions 03_Animal/python/animal.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,17 +104,13 @@ def parse_input(message: str, check_list: bool, root_node: Optional[Node]) -> st
list_known_animals(root_node)
print("\n")

if len(inp) > 0:
token = inp[0].lower()
else:
token = ""

token = inp[0].lower() if len(inp) > 0 else ""
return token


def avoid_void_input(message: str) -> str:
answer = ""
while answer == "":
while not answer:
answer = input(message)
return answer

Expand All @@ -134,8 +130,12 @@ def main() -> None:

# Main loop of game
print_intro()
keep_playing = parse_input("Are you thinking of an animal? ", True, root) == "y"
while keep_playing:
while (
keep_playing := parse_input(
"Are you thinking of an animal? ", True, root
)
== "y"
):
keep_asking = True
# Start traversing the tree by the root
actual_node: Node = root
Expand Down Expand Up @@ -170,17 +170,13 @@ def main() -> None:
f"for a {new_animal} the answer would be: ", False, None
)

actual_node.update_node(
new_question + "?", answer_new_question, new_animal
)
actual_node.update_node(f"{new_question}?", answer_new_question, new_animal)

else:
print("Why not try another animal?")

keep_asking = False

keep_playing = parse_input("Are you thinking of an animal? ", True, root) == "y"


########################################################
# Porting Notes
Expand Down
16 changes: 6 additions & 10 deletions 04_Awari/python/awari.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,10 @@

def draw_pit(line: str, board, pit_index) -> str:
val = board[pit_index]
line = line + " "
line += " "
if val < 10:
line = line + " "
line = line + str(val) + " "
return line
line += " "
return line + str(val) + " "


def draw_board(board) -> None:
Expand Down Expand Up @@ -148,7 +147,7 @@ def play_game(board: List[int]) -> None:
print(msg)
break
if landing_spot == home:
landing_spot, is_still_going, home, msg = computer_move(msg + " , ", board)
landing_spot, is_still_going, home, msg = computer_move(f"{msg} , ", board)
if not is_still_going:
print(msg)
break
Expand Down Expand Up @@ -248,7 +247,7 @@ def computer_move(msg: str, board) -> Tuple[int, bool, int, str]:

move_str = chr(42 + selected_move)
if msg:
msg += ", " + move_str
msg += f", {move_str}"
else:
msg = move_str

Expand Down Expand Up @@ -323,10 +322,7 @@ def execute_move(move, home: int, board) -> Tuple[int, bool, int]:
# losses.
losing_book[game_number] = losing_book[game_number] * 6 + move_digit

if player_has_stones(board) and computer_has_stones(board):
is_still_going = True
else:
is_still_going = False
is_still_going = bool(player_has_stones(board) and computer_has_stones(board))
return last_location, is_still_going, home


Expand Down
5 changes: 2 additions & 3 deletions 05_Bagels/python/bagels.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,8 @@ def pick_number() -> List[str]:
# as separate strings, not a single integer or string
numbers = list(range(10))
random.shuffle(numbers)
num = numbers[0:3]
num_str = [str(i) for i in num]
return num_str
num = numbers[:3]
return [str(i) for i in num]


def get_valid_guess(guesses: int) -> str:
Expand Down
6 changes: 2 additions & 4 deletions 06_Banner/python/banner.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,7 @@ def print_banner() -> None:

except ValueError:
print("Please enter a number greater than zero")
g1 = 0
if input("Centered ").lower().startswith("y"):
g1 = 1
g1 = 1 if input("Centered ").lower().startswith("y") else 0
character = input(
"Character (type 'ALL' if you want character being printed) "
).upper()
Expand All @@ -87,7 +85,7 @@ def print_banner() -> None:
for statement_char in statement:
s = letters[statement_char].copy()
x_str = character
if character == "ALL":
if x_str == "ALL":
x_str = statement_char
if x_str == " ":
print("\n" * (7 * horizontal))
Expand Down
Loading

0 comments on commit 164692a

Please sign in to comment.