C
C#ā€¢7mo ago
julia

Help a noobie out with a simple hangman

Hi! New to coding and I need some help to solve this problem. Shall I save the words to a list? Any help appreciated. Thanks!
No description
17 Replies
Joschi
Joschiā€¢7mo ago
What did you already do? Do you have a plan or idea how to solve this problem?
julia
juliaā€¢7mo ago
This is what I've done so far. Don't have a plan (yet šŸ„² )
No description
julia
juliaā€¢7mo ago
I figure depending what word Im guessing there is a different outcome
Joschi
Joschiā€¢7mo ago
Maybe you could try splitting that game into multiple simple steps and plan accordingly. Don't worry about how to implement those yet. As an example 1. Define the word to guess 2. Define the alphabet permutation to use 3. ??? You already got the first two steps.
julia
juliaā€¢7mo ago
Thanks! I figure I could do a for loop that increments over the attempts, with a maximum of 10 attempts
julia
juliaā€¢7mo ago
No description
Joschi
Joschiā€¢7mo ago
That sounds like a good start. The question now would be. What will happen if the letter is in your word and what if it isn't. Then you basically got it.
julia
juliaā€¢7mo ago
Thanks, I think I got it! Almost šŸ˜„
No description
Joschi
Joschiā€¢7mo ago
Looks great. A string is just a collection of chars. So you can itterate over a string like any other collection. You are already doing that. What you need is a way to check if something is a member of a collection.
julia
juliaā€¢7mo ago
Thanks alot!
julia
juliaā€¢7mo ago
This is my final result
No description
Joschi
Joschiā€¢7mo ago
Looks like it should work, did you test it? Good job! A few technical points you could maybe improve if you are interested. Your assignment said, that the guessedWord should not be longer than 16 letters. You could check for that. Connected to that. Your ReadLines show warnings. Maybe you could look at those and adress them. Besides this assignment. Maybe you could try generating the permutation of the alphabet yourself instead of having that as an input? I can also think of a more advanced solution to this problem, in which you wouldn't need to iterate over the string. Do you know what a HashSet is? If not don't worry about it for now!
julia
juliaā€¢7mo ago
Yes, I did test it and it worked. Thank you for your input, I will look it up later šŸ˜„ I do not know what a hashset is I'm on another assignment now and it's far more worse
julia
juliaā€¢7mo ago
No description
Joschi
Joschiā€¢7mo ago
Just break it down into simple small steps again and then try to implement them. You got the last one without me having to tell you anything.
ZacharyPatten
ZacharyPattenā€¢7mo ago
Hey I don't have time to read the full context and status of this thread, but I just want to mention that I have an example of a console Hangman game on GitHub if seeing my example may help. If you would like a link to it just ask.
julia
juliaā€¢7mo ago
Thank you very much! I got some good help from Joschi. Very kind of you though šŸ˜„