You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Something wrong with the function.
It should look like this:
using Random
function play_number_guess_computer()
print("Please enter a number between 1 and 50 for the computer to try and guess: ")
# Take in the user input and convert it to a number
target_number = parse(Int64, readline())
# Create an array of 50 numbers
guess_order = collect(1:50)
# Define our random seed
rng = MersenneTwister(1234)
# Shuffle the array randomly given ur seed
shuffled_guess = shuffle(rng, guess_order)
# Loop through each guess and see if it right
for guess in shuffled_guess
if guess == target_number
print("\nComputer guessed: $guess") # ---> this line should come here
print("\nThe computer cracked the code and guessed it right!")
break # Stop the for loop if we get it right
end
end
end
The text was updated successfully, but these errors were encountered:
Something wrong with the function.
It should look like this:
using Random
function play_number_guess_computer()
end
The text was updated successfully, but these errors were encountered: