logs/hcl_0211021.log

Feb 11 15:58:00 EST 2002

hail.prb

Code/Notes Sp # Utterance
T 5 Just click the "Done Reading" button when you are ready to start.
T 7 We'll start off with an example.
T 8 Let's use 12 as the initial value. Can you tell me what comes next?
S 10 6?
T 11 yep! What's after 6 then?
S 12 3
T 13 good. After that?
S 14 9
T 15 almost.... take a look back and see what you should do to odd numbers.
S 17 10
T 18 good. after 10?
S 19 5
S 20 16
T 21 good. you can keep going...
S 22 8
S 23 4
S 24 2
S 25 1
S 26 2
T 27 whoops!
T 28 1 is odd so you triple it and add 1 to get 4.
S 29 ok
S 30 should i keep going
T 31 well....
T 32 what is after 4?
S 33 2
T 34 right. Since it is no longer interesting we can stop.
T 35 4 2 1 4 2 1 has a name...do you see it above?
S 36 repeating ground state
S 37 ?
T 38 right on. Just "ground state" is good enough.
T 39 ok so let's review that series. It went...
T 40 12 6 3 10 5 16 8 4 2 1
T 41 but according to the rules we should stop once ANY value of the ground state is reached.
T 42 with that in mind can you tell me how many elements were in that sequence?
S 43 8
T 44 good. And what was the maximum?
S 45 16
T 46 right.
T 47 do you want to do another example or move on?
S 48 we can move on
T 49 sounds good to me.
T 50 So now we're going to try to write "pseudocode" to create hailstone sequences.
T 51 We'll try to spell out this process in words and write them down to the right.
T 52 So... what is the first step our program should do?
S 53 pick a positive integer
T 54 good. But we probably don't want the program to pick but rather a user. right?
S 55 yep
T 56 so can you rephrase it slightly for me?
S 57 i'm not sure
S 58 enter a positive integer?
T 59 that would be a good prompt to make
T 60 let's just say "get a positive integer from the user". Sound good?
S 61 yes
T 62 (tile created) get a positive integer from the user
T 63 just drag that tile up to near the top we'll start from there.
S 65 (tile placed)
S 66 ok got it
T 67 cool. Could you move it to the left about 3 lines? It will help us later to have that space.
S 69 (tile placed)
T 70 wonderful.
T 71 alright our program now has a postive integer. What should it do next?
S 72 it should recognize if it's odd or even
T 73 right. We need to pick one of those two which one would you like to do first?
S 74 odd
T 75 (tile created) if the number is odd then
T 77 go ahead and place that.
S 78 (tile placed)
T 83 great. What do we do in that case?
S 84 take the number times 3 and then addone
T 85 (tile created) take the number times 3 and then add one
S 87 (tile placed)
T 88 good. Now one thing programmers usually do is indent lines that are conditional.
T 90 We won't always do that line but only when we have an odd number.
S 91 (tile placed)
T 94 looks great.
T 95 if the number is not odd then what do we know for sure?
S 96 the number is even
T 97 yep. That's very easy to do here....
T 98 (tile created) else
S 100 (tile placed)
T 101 and inside that else what should it do?
S 102 divide the number by 2
T 103 (tile created) divide the number by 2
S 105 (tile placed)
T 106 great! Now take a look at the program so far.
T 107 Can you tell me what it does concisely?
S 108 figures out if the number is odd or even then follows the commands
T 109 right. In other words it gets you the next hailstone number.
T 110 ok... sorry about that.
S 111 it's ok
T 112 so what should the program do next?
T 113 any ideas?
S 114 i think that it should repeat this process until it gets to the sequence of 4 2 1
T 115 exactly. The program so far only handles ONE hailstone number we need it to handle as many as needed.
T 116 do you know the name of the programming structure we need to add in here?
S 117 hmmm
T 118 what allows you to "repeat" things?
S 119 while?
T 120 good. Most generally I was looking for you to say "loop" and "while" is a kind of loop.
T 121 Great!
T 122 Ok you said we stop when we see the sequence 4 2 1.
T 123 Can you tell me then how we know to keep going when we're generating a sequence?
T 124 So earlier when we saw 10 in that sequence how did you know to get another value?
S 125 because it wasn't a 4
T 126 excellent.
S 127 or part of 421
T 128 so we continue to get hailstone values while WHAT is true?
S 129 while the number is not equal to 4
T 130 right on. You'll need to move those tiles around before you place this next one.
T 131 (tile created) while the number is not equal to 4 do
S 133 (tile placed)
S 145 is that ok?
T 146 looks pretty good! One little thing though...
T 147 just like before we indented inside the if usually programmers indent the bodies of loops.
T 148 can you do that?
S 150 (tile placed)
S 155 how do i select the whole group
T 157 I think it is now. Draw a box around the four tiles then grab any of the yellow ones.
S 160 (tile placed)
T 164 you got it.
T 165 in pseudocode it is also usually a good idea to mark the end of a loop. Here's that.
T 167 (tile created) end while
T 169 it shoud line up with the while.
S 170 (tile placed)
T 171 like that!
T 172 this looks great. So this little program will generate an entire hailstone sequence.
T 173 If you were writing the program for real this would be a nice place to compile and run it to make sure it works.
T 174 so to remember that we'll take a snapshot.
T 176 good. Click on "stage 2" and we'll continue working.
T 179 FYI To see it work on the screen you'd need to print the number inside the loop.
T 180 make sense so far?
S 181 yep
T 182 alright. Let's move on... what should we work on next?
S 183 what to do when the number does equal 4
T 184 you mean if the user inputs it to start with?
S 185 no after the initial number
S 186 after it goes through th eloop
T 187 so what should we do when that happens? any thoughts?
S 188 i'm not sure....but somehow see if 2 and 1 follow
S 189 don't know how
T 190 well let's think about this. If we see a 4 in the sequence we KNOW we're done. There's no need to go on.
T 191 agree?
S 192 right
T 193 so instead of worrying about what comes next we need to work on the other tasks of the program.
T 194 Do you remember those from the write up above?
S 197 the number of items in the sequence and the largest #
T 198 good. let's do the number of items first it is a little bit easier.
T 199 any ideas on how we could that?
S 200 ???
T 201 that's ok it's tough to see right away.
T 202 Ok so back in our sample sequence of 12 6 3 10 5 16 8 4 you said we had 8 items.
T 203 remember?
S 204 yep
T 205 that was easy to do we just counted them up.
T 206 that won't work in our pseudocode because we don't have them "sitting" around anymore to look at.
T 207 do you have a better feel for the problem we're faced with now?
S 208 i don't know how the program will know how many numbers it went through
T 209 right. It's not easy. Let's go back to the example and do it a little differently.
T 210 Ok starting with 12. How many items are in the sequence so far?
T 211 sort of a silly question but humor me for a minute.
S 212 one
T 213 good.
T 214 ok after 12 is 6. Now how many items?
S 215 2
T 216 after 6 is 3 takes us to what?
S 217 3
T 218 good. do you see how it can be done yet?
T 219 rather than count them up at the end we count .... (you finish)
S 220 as we go along?
T 221 yep!
T 222 Relating that to our pseudocode then where should we keep track of the counting?
S 223 before the while loop?
T 224 well... we do need to do something before the loop. But think about our example we added one each time we got a new hailstone number.
S 225 so right before the end while?
T 226 good
T 227 ok so we need a variable to keep track of this as we go along. What should we call it?
S 228 anything?
T 229 I'm just asking for a good variable name.
S 230 count
T 231 great. I like that one.
T 232 Ok so inside the loop we need to update the count.
T 233 Can you tell me what we need to do to it?
T 234 one time through the loop means we made one more hailstone value which means we saw one more value for the sequence.
T 235 thus the count goes up by???
S 236 1
T 237 (tile created) add 1 to count
T 238 there you go!
S 240 (tile placed)
T 243 that is great.
T 244 Ok you mentioned something about doing something before the loop. There is something to do....
T 245 to count. Can you tell me what that is?
S 246 i forget what it's called.....initialize the variable? so the program recognizes what it is?
T 247 you got it!
T 248 initializing is just assignment so what should we put in count to start off?
S 249 put in it?
T 250 yes what value should it hold to begin with?
S 251 0
T 252 that might work but remember we need to count the user's value in the sequence.
S 253 1?
T 254 right.
T 255 If the user gave us 12 that means we've already got 1 in our sequence.
T 256 (tile created) count = 1
T 257 you'll need to move tiles around again.
S 260 (tile placed)
S 282 ok
T 283 one last thing to do then on the count.
T 284 after the loop...
T 285 we need to tell the user the answer.
T 286 can you suggest the step?
S 287 after the end while?
T 288 yep.
T 289 we need to tell the user the answer by printing what?
S 290 the total of count
T 291 good. In other words we'll just print the variable count.
T 292 (tile created) print count
S 294 (tile placed)
T 297 alright now look at the code we've just written and compare it to the original snapshot.
T 300 what did we add to it?
S 303 the first part of the problem....to find the number of items in seq
T 304 good. So enter "find the number of items in the sequence" in the description box then take the snapshot.
T 305 description box is in the upper right.
T 309 good. that is a label for what extra work that code does over the previous one.
T 310 alright. What should we work on next?
S 311 to find the largest number in seq
T 312 any ideas on how we can do that?
S 313 another loop?
T 314 that could work but it would be pretty hard.
T 315 Can you think of another way? Maybe try to use the loop we already have?
T 316 let's look at the example again and see if that will help.
T 317 when we started with 12 what was the largest at that point?
T 318 (again it's silly but useful I think)
S 319 12
T 320 right. Next was 6. What can you say about the largest now?
S 321 12
T 322 why not 6?
S 323 12 is bigger
T 324 right.
T 325 good.
T 326
T 327 ok after 6 comes 3. What's the largest now?
S 328 12
T 329 good. 3 really doesn't matter!
T 330 after 3 is 10. what's the largest now?
S 331 12
T 332 good. kind of boring.
T 333 after 10 is 5. Still 12.
T 334 what's after 5?
S 335 16
T 336 good. largeset?
S 337 16
T 338 good. How did you know that?
S 339 just by comparing the rest
T 340 you compared 16 to what?
S 341 to the rest of sequence
T 342 Maybe but you only needed to compare it 12. right?
S 343 yes
S 344 right
T 345 because you knew 12 was larger than all the others so far.
T 346 the sequence finishes up 8 and 4 so we're done and 16 is the largest.
T 347 Ok let's try to do something like that in the pseudocode.
T 348 it will work similarly to the count. Can you suggest anything?
S 349 could you use an if then/
S 350 ?
T 351 good.
T 352 what should it check?
S 353 if coun+1 is greater than.......
T 354 count?
T 355 I think the count and the largest values are unrelated aren't they?
S 356 oh ok
S 357 yes
T 358 the "greater than" part is right on track though.
T 359 what two numbers do you need to compare there?
S 360 if the second integer is greater than the first
S 361 and then the third and the second
S 362 etc
T 363 ok we're getting somewhere. What we need is a new variable.
S 364 x
T 365 Remember when we did it in our heads earlier we kept track of 12 for a while then it went to 16...
T 366 x is ok but we should pick something descriptive.
T 367 this variable holds an important number can you try for something more telling?
S 368 largest value/
S 369 ?
T 370 good. let's just go with largest.
T 371 So in our previous example largest would hold 12 for a while then it would go to 16 until completion.
T 372 ok back to your if statement you were working on. What should we compare with what?
S 373 largest with next value?
T 374 good. In our loop we've called it "number".
S 375 ok
T 376 so let's put it all together. We need to compare number to largest. Can you say it as an "if" statement?
S 377 if number>largest then number=largest
T 378 perfect!
T 379 (tile created) if number > largest then
T 381 you'll need to move a few tiles around again.
S 382 (tile placed)
T 385 uh oh! In the loop right?
T 388 you need to check each value you make.
S 393 (tile placed)
S 406 ?
T 407 looks good but let me make a few minor moves. hold on....
T 409 (tile placed)
T 416 look ok?
S 417 yep
T 418 now... I mispoke a second ago. If that is true that our current value is larger than our largest what should we do?
S 419 make the current value the largest
S 420 equal to
T 421 so when 12 was the largest and you saw 16. What happened to the largest?
S 422 it got replaced
T 423 right. So you want to change the largest.
T 424 not the current value.
T 425 Maybe that's what you meant?
S 426 yes
T 427 (tile created) largest = number
S 429 (tile placed)
T 430 could you indent it a bit for me?
S 432 (tile placed)
T 433 thanks.
T 434 this looks very good.
T 435 there is then one last little thing to do for the largest.
S 436 intitialize it at the top
T 437 good! I had actually forgotten that! Two things then.
T 438 What should we initialize it to?
S 439 hmmm
S 440 0?
S 441 or1?
S 442 not sure
T 443 that could work. but think back to our example.
T 444 what did we use for the first largest there?
S 445 first value
T 446 good. which I assume we would read into a variable "number".
S 447 ok
T 448 (tile created) largest = number
T 449 this one goes at the top then.
S 452 (tile placed)
T 467 good. and then the printing and that's it!
T 468 (tile created) print largest
S 470 (tile placed)
T 471 for this stage what did we accomplish?
S 472 largest number in the sequence
T 473 great. Enter that into the description and do the final snapshot.
T 475 that's it!
T 476 any questions?
S 477 nope
T 478 thanks!