From cbc950216baa14a95a14b1f52ea6b9b940ba72ff Mon Sep 17 00:00:00 2001 From: RILUCK Date: Thu, 26 Jun 2025 22:10:09 +0200 Subject: [PATCH 1/6] Testing code --- Python/3sum-closest.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Python/3sum-closest.py b/Python/3sum-closest.py index a649f2a840..cfe46b16e0 100644 --- a/Python/3sum-closest.py +++ b/Python/3sum-closest.py @@ -27,3 +27,5 @@ def threeSumClosest(self, nums, target): result = total return result + +print("Hello") \ No newline at end of file From 33c4f31ed42f73e963895c68fad6b1cb7fdf38c2 Mon Sep 17 00:00:00 2001 From: RILUCK Date: Thu, 26 Jun 2025 22:17:53 +0200 Subject: [PATCH 2/6] NOREF word guess game --- Python/word_guess.py | 59 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 Python/word_guess.py diff --git a/Python/word_guess.py b/Python/word_guess.py new file mode 100644 index 0000000000..0fd869411f --- /dev/null +++ b/Python/word_guess.py @@ -0,0 +1,59 @@ +import random + +class WordGuess: + # choices = all possible target words for the guessing game + choices = ["able", "belt", "bolt", "cast", "cash", "knot", "note", "near", "over", "salt", "wind"] + choices_set = set() + target = "" + wrong_msg = "Wrong guess! Try again:" + correct_msg = "You got it! Amazing!" + game_over = "You're out of turns, game over!" + new_game_msg = "Welcome to Word Guess! You have 5 turns to guess the word. Please enter your first guess:" + not_choice_msg = "The word you guesssed is not a possible answer." + max_turns = 5 + curr_turn = 0 + is_over = False + chars_in_tgt = [0] * 26 + + def __init__(self): + print(self.new_game_msg) + self.choices_set = set(self.choices) + + def choose_target(self): + self.target = random.choice(self.choices) + for c in self.target: + self.chars_in_tgt[ord(c) - ord('a')] += 1 + + def guess(self, guess: str): + if guess not in self.choices_set or guess == "": + print(self.not_choice_msg) + print(f"Guesses left {self.max_turns - self.curr_turn}") + return + is_correct = guess == self.target + if is_correct: + print(self.correct_msg) + self.is_over = True + return + else: + print(self.wrong_msg) + for i in range(len(guess)): + c = guess[i] + to_print = "-" + if self.chars_in_tgt[ord(c) - ord('a')] and c != self.target[i]: + to_print = "0" + elif c == self.target[i]: + to_print = "1" + print(to_print, end="") + print("") + self.curr_turn += 1 + print(f"Guesses left {self.max_turns - self.curr_turn}") + if self.curr_turn == self.max_turns: + print(self.game_over) + self.is_over = True + +wg = WordGuess() +wg.choose_target() +print(wg.target) +while not wg.is_over: + a=input() + wg.guess(a) \ No newline at end of file From 2f577e23bfe90f207f2ccbaa1da44311770a431e Mon Sep 17 00:00:00 2001 From: RILUCK Date: Thu, 26 Jun 2025 22:18:40 +0200 Subject: [PATCH 3/6] cleanup sum file --- Python/3sum-closest.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/Python/3sum-closest.py b/Python/3sum-closest.py index cfe46b16e0..5ab9ea3c10 100644 --- a/Python/3sum-closest.py +++ b/Python/3sum-closest.py @@ -26,6 +26,3 @@ def threeSumClosest(self, nums, target): min_diff = abs(total-target) result = total return result - - -print("Hello") \ No newline at end of file From 318339d1cf7ce5eb3c27ff2346e65978757ab272 Mon Sep 17 00:00:00 2001 From: RILUCK Date: Thu, 26 Jun 2025 22:20:22 +0200 Subject: [PATCH 4/6] revert file --- Python/3sum-closest.py | 1 + 1 file changed, 1 insertion(+) diff --git a/Python/3sum-closest.py b/Python/3sum-closest.py index 5ab9ea3c10..7275391382 100644 --- a/Python/3sum-closest.py +++ b/Python/3sum-closest.py @@ -26,3 +26,4 @@ def threeSumClosest(self, nums, target): min_diff = abs(total-target) result = total return result +˝ \ No newline at end of file From 82b9714f6d43f2579bd3e0027123cb2d559399b9 Mon Sep 17 00:00:00 2001 From: RILUCK Date: Thu, 26 Jun 2025 22:22:02 +0200 Subject: [PATCH 5/6] cleanup --- Python/3sum-closest.py | 1 - 1 file changed, 1 deletion(-) diff --git a/Python/3sum-closest.py b/Python/3sum-closest.py index 7275391382..5ab9ea3c10 100644 --- a/Python/3sum-closest.py +++ b/Python/3sum-closest.py @@ -26,4 +26,3 @@ def threeSumClosest(self, nums, target): min_diff = abs(total-target) result = total return result -˝ \ No newline at end of file From e279198aaecdd9c3945cc373d6e70f7186c6c51e Mon Sep 17 00:00:00 2001 From: RILUCK Date: Thu, 26 Jun 2025 22:34:43 +0200 Subject: [PATCH 6/6] Revert "cleanup" title This reverts commit 82b9714f6d43f2579bd3e0027123cb2d559399b9. --- Python/3sum-closest.py | 1 + 1 file changed, 1 insertion(+) diff --git a/Python/3sum-closest.py b/Python/3sum-closest.py index 5ab9ea3c10..7275391382 100644 --- a/Python/3sum-closest.py +++ b/Python/3sum-closest.py @@ -26,3 +26,4 @@ def threeSumClosest(self, nums, target): min_diff = abs(total-target) result = total return result +˝ \ No newline at end of file