Read sections 9.1-9.6 in chapter 9 of the textbook Explorations in Computing.
def roll1() return rand(6) + 1 end def roll2() return rand(6) + 1 end def simple_game() strikes = 0 sum = 0 while (strikes < 3) do if roll1() == roll2() then strikes = strikes + 1 else sum = sum + roll1() + roll2() end end return sum end
Unfortunately, Homer fails again. Explain clearly what is logically wrong with this computation. (Don't just say that he should have written it our way. Instead, say what's wrong with THIS approach.)
TYPO CORRECTED: HINT: There are only FIVE possibilities where you can have a "four of a kind".
Consider a one-dimensional cellular automaton starts with a single black square and uses "Rule 250".