mirror of
https://github.com/coding-horror/basic-computer-games.git
synced 2026-01-16 23:12:08 -08:00
MAINT: Apply pre-commit
Remove byte-order-marker pre-commit check as there would be many adjustments necessary
This commit is contained in:
@@ -91,4 +91,4 @@ namespace Stars
|
||||
Console.WriteLine($"Sorry, that's {_maxGuessCount} guesses. The number was {target}.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -239,4 +239,4 @@ public class Stars {
|
||||
return (int) (Math.random()
|
||||
* (HIGH_NUMBER_RANGE) + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,10 +12,10 @@ function input()
|
||||
{
|
||||
var input_element;
|
||||
var input_str;
|
||||
|
||||
|
||||
return new Promise(function (resolve) {
|
||||
input_element = document.createElement("INPUT");
|
||||
|
||||
|
||||
print("? ");
|
||||
input_element.setAttribute("type", "text");
|
||||
input_element.setAttribute("length", "50");
|
||||
@@ -71,7 +71,7 @@ async function main()
|
||||
var loss = true;
|
||||
|
||||
print("\nOK, I AM THINKING OF A NUMBER, START GUESSING.\n\n");
|
||||
|
||||
|
||||
for(var guessNum=1; guessNum <= guesses; guessNum++) {
|
||||
|
||||
// Input guess
|
||||
@@ -105,4 +105,4 @@ async function main()
|
||||
}
|
||||
}
|
||||
|
||||
main();
|
||||
main();
|
||||
|
||||
@@ -56,8 +56,7 @@ def get_guess():
|
||||
if guess.isdigit():
|
||||
valid_response = True
|
||||
guess = int(guess)
|
||||
return(guess)
|
||||
|
||||
return guess
|
||||
|
||||
|
||||
# Display intro text
|
||||
@@ -69,7 +68,7 @@ print("\n\n")
|
||||
response = input("Do you want instructions? ")
|
||||
if response.upper()[0] == "Y":
|
||||
print_instructions()
|
||||
|
||||
|
||||
still_playing = True
|
||||
while still_playing:
|
||||
|
||||
@@ -82,33 +81,32 @@ while still_playing:
|
||||
player_has_won = False
|
||||
while (guess_number < MAX_GUESSES) and not player_has_won:
|
||||
|
||||
print("")
|
||||
guess = get_guess()
|
||||
guess_number += 1
|
||||
print("")
|
||||
guess = get_guess()
|
||||
guess_number += 1
|
||||
|
||||
if guess == secret_number:
|
||||
# "*** We have a winner"
|
||||
player_has_won = True
|
||||
print("*************************" +
|
||||
"*************************!!!")
|
||||
print("You got it in %d guesses!!!" % guess_number)
|
||||
if guess == secret_number:
|
||||
# "*** We have a winner"
|
||||
player_has_won = True
|
||||
print("*************************" + "*************************!!!")
|
||||
print("You got it in %d guesses!!!" % guess_number)
|
||||
|
||||
else:
|
||||
print_stars(secret_number, guess)
|
||||
else:
|
||||
print_stars(secret_number, guess)
|
||||
|
||||
# End of guess loop
|
||||
# End of guess loop
|
||||
|
||||
# "*** Did not guess in [MAX_GUESS] guesses"
|
||||
if not player_has_won:
|
||||
print("\nSorry, that's %d guesses, number was %d" %
|
||||
(guess_number, secret_number))
|
||||
print(
|
||||
"\nSorry, that's %d guesses, number was %d" % (guess_number, secret_number)
|
||||
)
|
||||
|
||||
# Keep playing?
|
||||
response = input("\nPlay again? ")
|
||||
if response.upper()[0] != "Y":
|
||||
still_playing = False
|
||||
|
||||
|
||||
|
||||
######################################################################
|
||||
#
|
||||
@@ -132,10 +130,3 @@ while still_playing:
|
||||
# Hard = 6 guesses, 1 to 200
|
||||
#
|
||||
######################################################################
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
520 PRINT
|
||||
530 NEXT K
|
||||
540 REM *** DID NOT GUESS IN M GUESSES
|
||||
550 PRINT
|
||||
550 PRINT
|
||||
560 PRINT "SORRY, THAT'S";M;"GUESSES. THE NUMBER WAS";X
|
||||
580 GOTO 650
|
||||
590 REM *** WE HAVE A WINNER
|
||||
|
||||
Reference in New Issue
Block a user