Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Help!!!
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
jeffery1204




PostPosted: Thu Feb 26, 2015 10:25 am   Post subject: Help!!!

Initialize an array with 26 single character elements to be the 26 letters of the alphabet. Randomly generate integers from 1 to 26 to indicate which of the letters you will be using. For example if 2 is generated you would use the letter b. Use this method to make a series of four-letter words. Find which ones of these words are in the file ?words.txt? and output them to the file ?words1.txt?. Play a short song ( minimum 10 notes ) every time the random word matches one from the list. Run this algorithm 100 times.


I know this is from turing introduction, but this question is just super hard for me, and i don't know what to do, can someone plz help, i will be really thankful
Sponsor
Sponsor
Sponsor
sponsor
jeffery1204




PostPosted: Thu Feb 26, 2015 10:27 am   Post subject: Re: Help!!!

And here is the word.txt






I've been meaning to write about my beautiful surprise birthday party for, oh, over a month now... but you know, busy-ness and the holidays and excuses excuses excuses. On this dreary Monday morning, however, I've finally gotten to it, and I'm having such a nice time reliving this oh-so-sweet evening.

On Decemeber 5th, I turned 28, which is weird all unto itself, seeing as how my twenties are creeping to a close and in some ways I still feel so young and others I feel so old. In some ways I feel so accomplished, and others I feel so panicky for not being further along. But that's another post for another day.

Also on December 5th, a few friends threw me a surprise birthday party, which was, indeed, an actual surprise! In the last year or two, I've grown close to a beauty named Brittany who started her own event rentals company (Birch & Brass Vintage Rentals) here in Austin, of which I've helped to photograph the inventory over the course of many sweaty photo shoots and hundreds of beautiful pieces. Brittany is so, so good at styling perfect tablescapes and vignettes, and I always wished I knew her before our wedding or some other excuse to have her style an event for me.

Well now, thanks to her expertise and kindness, I have this incredibly perfect little party to look back on fondly, much thanks to Shalyn's gorgeous photos of the evening. I was so in shock that night, I barely took in all the details. Another reason that photography is so important: to capture and freeze time so you can go back and enjoy special moments over and over again.

There was fried chicken and other southern-style comfort foods (my absolute favorites), rum punch (another fave), cake and cupcakes and doughnuts (because you KNOW I love my sweets), a ridiculous pi?ata I had to whack about 47 times before it finally broke, and karaoke and quality time with sweet friends I was so grateful to for taking the time out of their Friday night to attend.

Thank you so much, Brittany, for one of the most thoughtful things anyone has ever done for me, and to Celine & Justin for hosting and for handling all of the mess that comes with that, and to Shay for taking the most beautiful photos and creating the most gorgeous little placecards, and to Kelsey & Jona, John & Kirsten, Kate, Emilie, Federico, and of course Matthew, all for attending.
Tony




PostPosted: Thu Feb 26, 2015 3:08 pm   Post subject: Re: Help!!!

jeffery1204 @ Thu Feb 26, 2015 10:25 am wrote:
don't know what to do, can someone plz help, i will be really thankful

The question is "hard" in a way that it's long and has many parts, but it's also "easy" in a way that it tells you exactly what to do, step by step. So that's what you should do -- follow the steps.

The very first sentence is telling you to make an array of a type that can hold characters, and size it to hold 26 elements. That seems like a good place to start.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
abc1997




PostPosted: Mon Mar 02, 2015 11:44 pm   Post subject: Re: Help!!!

Tony @ Thu Feb 26, 2015 3:08 pm wrote:
jeffery1204 @ Thu Feb 26, 2015 10:25 am wrote:
don't know what to do, can someone plz help, i will be really thankful

The question is "hard" in a way that it's long and has many parts, but it's also "easy" in a way that it tells you exactly what to do, step by step. So that's what you should do -- follow the steps.

The very first sentence is telling you to make an array of a type that can hold characters, and size it to hold 26 elements. That seems like a good place to start.




Hi, I don't know how to do this question either, I tried by myself and it does not work.

Here is my code and it always say "assert condition is false", I cant get it, can you help me please?

for a : 1 .. 100

% Initialize an array with 26 single letters
var letter : array 1 .. 26 of string
var number, number1, number2, number3 : int
var word, word1, word2, word3, word4 : string (4)


% Run this algorithm 100 times
for i : 1 .. 1 % make four-letter word
randint (number, 1, 26) % Randomly generate integers from 1 to 26
letter (number) := chr (number + 96) %chr(97)=a
randint (number1, 1, 26) % Randomly generate integers from 1 to 26
letter (number1) := chr (number1 + 96) %chr(97)=a
randint (number2, 1, 26) % Randomly generate integers from 1 to 26
letter (number2) := chr (number2 + 96) %chr(97)=a
randint (number3, 1, 26) % Randomly generate integers from 1 to 26
letter (number3) := chr (number3 + 96) %chr(97)=a
word := letter (number)
word1 := letter (number1)
word2 := letter (number2)
word3 := letter (number3)
word4 := word + word1 + word2 + word3
put word4
end for

var words : int
open : words, "words.txt", get
assert words > 0
var words1 : int
open : words1, "words1.txt", put
assert words1 > 0
var filewords : string

loop
get : words, skip
exit when eof (words)
get : words, filewords
if word4 = filewords then % Find which ones of these words are in the file "words.txt"
put : words1, filewords
end if
if word4 = filewords then
play ("4EDCDEE2E4DD2D4EG2G")
end if
end loop

end for
Tony




PostPosted: Wed Mar 04, 2015 1:42 pm   Post subject: Re: Help!!!

abc1997 @ Mon Mar 02, 2015 11:44 pm wrote:
"assert condition is false", I cant get it, can you help me please?

On which line? (You have multiple assert statements). What does this asset suggest (that is, how can you rewrite the statement for it to evaluate to "true" instead of "false")?
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 5 Posts ]
Jump to:   


Style:  
Search: