Computer Science Canada

Wordle Project In Turing - Difficult task

Author:  Toodles [ Wed Jun 02, 2010 12:04 pm ]
Post subject:  Wordle Project In Turing - Difficult task

What is it you are trying to achieve?
a turing program that will load a text file. it will have to keep track of how many times a word comes up in the file.
the more the word comes up in the file the larger that word should appear.
its called WORDLE


What is the problem you are having?
im too damned stupid to get very far

Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)


Turing:


var number : string := ""
var needed : int
var words : array 1..10 of string % these arrays dont really do anything - but i know i need 1 for a string
var letters: array 1..10 of int % and the ither for integers


open : needed, "test.txt", get

loop
    exit when eof (needed)
    get : needed, number
    put number
end loop



Please specify what version of Turing you are using
version 4.0.5

Author:  Tony [ Wed Jun 02, 2010 12:44 pm ]
Post subject:  Re: Wordle Project In Turing - Difficult task

Toodles @ Wed Jun 02, 2010 12:04 pm wrote:

im too damned stupid to get very far

Not true. You express yourself much clearer than some other students around here. Writing code comes easier with practice.

You already have a loop that will read the text file. Awesome!

Now have you have just read the first word from a file, you need to record a +1 somewhere. What kind of a variable can you use for that?

Author:  Toodles [ Mon Jun 07, 2010 11:58 am ]
Post subject:  Re: Wordle Project In Turing - Difficult task

boolean right?

Author:  Tony [ Mon Jun 07, 2010 12:01 pm ]
Post subject:  RE:Wordle Project In Turing - Difficult task

Well the boolean true/false can be used to mark that you've seen a word at least once; but it seems that we'd want to know how many times a word appears in total -- so something that can hold more information ("word appeared 42 times").

Author:  Cezna [ Tue Jun 08, 2010 5:41 am ]
Post subject:  RE:Wordle Project In Turing - Difficult task

You would also need a way to do this for more than one word, so you will need a variable type that is a combination of two types (sort of... I'm trying not to give it away, Tony)

Author:  Toodles [ Tue Jun 08, 2010 11:59 am ]
Post subject:  Re: Wordle Project In Turing - Difficult task

hmm... i'm not sure i know what that would be. my class hasnt gone over that.

Author:  Insectoid [ Tue Jun 08, 2010 2:55 pm ]
Post subject:  RE:Wordle Project In Turing - Difficult task

OR you could just have two arrays, of two different types. Not quite as pretty but it doesn't use anything you haven't learned.

Author:  Cezna [ Tue Jun 08, 2010 5:07 pm ]
Post subject:  RE:Wordle Project In Turing - Difficult task

You would need an array of integers, and an array of strings.
Every time a certain word comes up that matches a word in the string array, you add one to the corresponding integer array.

Author:  Toodles [ Thu Jun 10, 2010 11:56 am ]
Post subject:  RE:Wordle Project In Turing - Difficult task

hmm allright good stuff Smile although what would the code look like with the line that add's one to the corresponding integer array?

Author:  Cezna [ Thu Jun 10, 2010 12:02 pm ]
Post subject:  RE:Wordle Project In Turing - Difficult task

You're gonna have to figure that one out for yourself.
Wink

Author:  Toodles [ Thu Jun 10, 2010 12:10 pm ]
Post subject:  RE:Wordle Project In Turing - Difficult task

thats what ive been trying, look where it's gotten me Razz

Author:  Toodles [ Fri Jun 11, 2010 12:10 pm ]
Post subject:  RE:Wordle Project In Turing - Difficult task

can i pleeease have the code? i simply just don't know it or how to get it

Author:  Tony [ Fri Jun 11, 2010 1:10 pm ]
Post subject:  Re: RE:Wordle Project In Turing - Difficult task

Toodles @ Fri Jun 11, 2010 12:10 pm wrote:
can i pleeease have the code? i simply just don't know it or how to get it

If you are just given the code, you will continue to not understand it; which will make it really difficult in next assignments/exams/projects which will assume that you did understand it.

So lets try to get it. We've already established that we need some arrays. You've used some in the first piece of code that you've posted -- but lets confirm just how familiar you are with arrays. If you want to read up more on arrays, there are tutorials available through The Turing Walkthrough

In short, an array can be though of as a list of similar elements; each element addressable by an integer index. So you can get to the variable for the 5th word or 42nd word, etc.

Author:  Toodles [ Mon Jun 14, 2010 12:11 pm ]
Post subject:  RE:Wordle Project In Turing - Difficult task

hmm yeah i was allready looking theough the walkthrough but i still couldnt quite get it.
though i have a new question
when turing is displaying the text file it
displayes 1 word per line, is there anyway i
can change that so theres a proper sentence structure? (multiple words per line)

Author:  Tony [ Mon Jun 14, 2010 12:20 pm ]
Post subject:  RE:Wordle Project In Turing - Difficult task

code:

get my_variable:*

will fetch everything up to the end of the line, instead of words being delimited by whitespace.


: