Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Output does not work properly (Julia 1.7.2) #11

Open
gameCoder101 opened this issue Jun 27, 2022 · 0 comments
Open

Output does not work properly (Julia 1.7.2) #11

gameCoder101 opened this issue Jun 27, 2022 · 0 comments

Comments

@gameCoder101
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant