Deaf Calculus

Hey, I am trying a variation of Deaf Grandma program that takes off of
Tintin’s Character Professor Calculus. I tried to make it… But it did
not work very well. Any help/advice?

Luke K. wrote:
Okay, I just figured one thing out:
Instead of putting .capitalize, you put .upcase
What I would like to know is how to put in a random sentence, like you
make 7 different sentences, how could you make the program put a
sentence at random instead of a date?

On Thu, Jun 4, 2009 at 1:08 PM, Luke K. [email protected] wrote:

Luke K. wrote:
Okay, I just figured one thing out:
Instead of putting .capitalize, you put .upcase
What I would like to know is how to put in a random sentence, like you
make 7 different sentences, how could you make the program put a
sentence at random instead of a date?

Just a hint.

‘daygs’ used for “Snatch” reference :)…

array = [“Ya like daygs?”, “Do I like daygs?”, “Yeah, d’ya like
daygs”, “Oh, ‘do I like dahgs.’”, “Yeah, I like dahgs.”]
puts array[rand(array.size - 1)]

Todd

On Thu, Jun 4, 2009 at 3:56 PM, Brian C. [email protected]
wrote:

Todd B. wrote:

array = [“Ya like daygs?”, “Do I like daygs?”, “Yeah, d’ya like
daygs”, “Oh, ‘do I like dahgs.’”, “Yeah, I like dahgs.”]
puts array[rand(array.size - 1)]

I think you want puts array[rand(array.size)], otherwise the last
element won’t ever be used.

Yes, yes; must read the docs before responding :slight_smile:

Todd B. wrote:

array = [“Ya like daygs?”, “Do I like daygs?”, “Yeah, d’ya like
daygs”, “Oh, ‘do I like dahgs.’”, “Yeah, I like dahgs.”]
puts array[rand(array.size - 1)]

I think you want puts array[rand(array.size)], otherwise the last
element won’t ever be used.

------------------------------------------------------------ Kernel#rand
rand(max=0) => number

 Converts _max_ to an integer using max1 = max+.to_i.abs+. If the
 result is zero, returns a pseudorandom floating point number
 greater than or equal to 0.0 and less than 1.0. Otherwise, returns
 a pseudorandom integer greater than or equal to zero and less than
 max1.