logs/hcl_0212021.log

Feb 12 09:04:35 EST 2002

hail.prb

Code/Notes Sp # Utterance
T 6 ok sorry about that. Back to our example. Starting with 12 what comes next?
S 8 6
T 9 good. after that?
S 10 3
T 11 right. next?
S 12 10
T 13 good. Can you keep it going?
S 14 5
T 15 yep.
S 16 16
T 17 right.
S 18 8
S 19 25
T 20 oops!
T 21 8 is even....
S 22 oops
S 23 4
T 24 good. after 4?
S 25 2
S 26 1
T 27 after 1?
S 28 4
S 29 2
T 30 good. So we're in the ground state now.
T 31 it will be 4 2 1 forever.
S 32 ok
T 33 alright let's answer those questions.
T 34 To summarize our series was 12 6 3 10 5 16 8 4
T 35 how many items were there?
S 36 do we count the ground state?
T 37 the rules say to count the initial value and the first value in the ground state.
S 42 10
T 43 are you sure?
S 44 11
T 45 not quite.... let's see...
T 46 12 is the initial value that's 1.
T 47 then you have 6 3 10 5 16 and 8 that's 6 more.
T 48 up to 7. You with me?
S 49 yea
T 50 then you hit 4 and the rule (on the final web page) says to count it gives you 8.
S 51 oh i counted 2 and 1
S 52 ok i got it
T 53 I see. Good!
T 54 Let's do one more then. Let's start with 17.
T 55 HANG ON!
T 56 What was the maximum for the previous series?
S 57 16
T 58 right. Ok let's start with 17 for the next example. What is next?
S 59 8.5
S 60 oops
T 61 it's ok! I do stuff like that all the time.
S 62 i mean 35
S 63 nope that's not right
T 64 not quite. Let's try it again. 17 is odd so you triple it.
T 65 to get 51.
T 66 then add one. giving?
S 67 52
S 68 i need a calaculator
T 69 good. so we have 17 52 so far. What's next?
T 70 (they get easier from here out)
S 71 26
T 72 good. half of that?
S 73 13
T 74 after that?
S 75 40
T 76 good. next?
S 77 20
S 78 10
S 79 5
T 80 you're doing great...
S 81 16
S 82 8
S 83 4
S 84 2
T 85 and voila. Good job.
T 86 to recap 17 52 26 13 40 20 10 5 16 8 4
T 87 ok how many items?
S 88 11
T 89 good! And the maximum?
S 90 52
T 91 right on. Ok I think we're ready to write some pseudocode. Sound good?
S 92 sure
T 93 so what is the first step the program should do? (remember just say it in regular words)
S 94 have the user pick a variable
S 95 we have establish our variables first
T 96 in pseudocode it isn't really that important. We'll just assume we have them.
S 97 after they pick the variable we have to distinguish if it's even or odd
T 98 good. Can you rephrase "pick a variable" for me? What do you mean?
S 99 ask them to choose a positive integer to begin the process
T 104 excellent. Can you suggest a variable name to hold that integer?
S 105 x
T 106 that would work but let's try to pick something descriptive.
T 107 this variable will hold a hailstone value can you think of something along those lines?
S 108 ok how about h
T 109 sure!
S 110 or p
T 111 (tile created) ask user to choose a positive integer
T 112 there's a tile. Go ahead and drag it to near the top.
S 114 (tile placed)
T 115 that's good.
T 116 what does p stand for?
S 117 positive
T 118 ah. How about posint?
T 119 instead of p?
S 120 ok
S 121 that works
T 122 (tile created) read into posint
S 124 (tile placed)
T 125 alright... back to your suggestion to look at even and odd. We need to do one or the other first... which one would you like?
S 126 if it doesn't make a difference I would choose positive
T 127 well we're going to pretend the user gave us a positive number.
S 128 ok
T 129 you said earlier we need to distinguish between odd and even.
T 130 So which of those two should we handle first?
S 131 even
T 132 cool. What is it we need to check then? In our program?
S 133 if the variable is even or odd
T 134 which variable?
S 135 posint
T 136 (I know it's silly but it is sort of important to be specific)
T 137 thanks.
T 138 (tile created) if posint is even then
T 140 there's the "if" statement.
S 141 (tile placed)
T 142 ok then what do we do there?
S 143 so else it's odd
T 144 right!
T 145 (tile created) else
S 147 (tile placed)
T 148 you might want to leave an open line in there.
S 150 (tile placed)
T 151 we have to fill it in. So if posint is even what do we do?
S 152 divide it by 2
T 153 good. I'll make it slightly more precise for the pseudocode.
T 154 (tile created) divide posint by 2
S 156 (tile placed)
T 157 one thing programmers usually do is indent conditional statements.
T 159 you won't always divide by 2 of course so could you bump it in a bit?
S 160 (tile placed)
T 168 My fault!
S 169 (tile placed)
T 176 You only indent the CONDITIONAL line which is the divide line.
T 177 the if should be flush left with the others.
S 179 (tile placed)
T 182 good.
T 184 The idea here is that you will always check to see if posint is even....
T 185 but you might not always divide it by 2.
S 186 ok
T 187 ok what do we do in the else part then?
S 188 so is posint is odd we divide by 3 and add 1
T 189 (tile created) divide by 3 and add 1
S 191 (tile placed)
S 192 should i put it right beneath the else or leave a space?
T 193 you can take it up some no need for extra space here.
S 195 (tile placed)
T 197 looks good.
S 198 ok
T 199 alright what should we do next?
S 200 i am a little concerned with how we arre going to know the difference betwen even and odd... should we worry about that later?
T 201 well... that is a language specific thing really. There are lots of ways to do it.
S 202 ok
T 203 (I think Pascal has a built in "odd" function though)
S 204 oh that would be nice
T 205 you can ask your teacher or a tutor about the specifics if you can't figure something out.
S 206 ok so the next step would be to create a loop i guess so if the answer is even or odd it can go back to the beginning process
T 207 very good we need a loop. Any ideas on how to do that?
S 208 well we are not doing pascal languase so we don't have to mention the while statement here
T 209 no! A while is fine!
T 210 pseudocode has similarites to lots of real languages.
T 211 so what condition should the while statement have?
S 212 so while the answer is not 4 2 or 1... is that on the right track or not?
T 213 yes definitely the right track.
T 214 ok so when you say "answer" what do you mean?
S 215 yea should we read the answer of the products of either the even or odd posint?
S 216 before we start the loop
T 217 Ok so if I follow you here you want to reuse posint in the condition?
T 218 of the loop?
S 219 well the product of it
T 220 ok by "product" you mean the result of the operations in the if/else?
S 221 whatever the answer was when divided by either equation
S 222 yea
T 223 cool. Let's update that a bit.
S 224 ok
T 225 What we need to do is assign the result of the operations back into posint. Make sense?
T 226 we're recycling!
S 227 yea
T 228 ok here's an assignment tile you can just move the others over to the right to make room.
T 229 (tile created) posint =
S 231 (tile placed)
S 232 huh??
T 233 actually... let me show you what I meant.
T 235 (tile placed)
T 238 see?
S 239 oh ok
T 240 and we'll do it again for the odd case.
T 241 (tile created) posint =
S 243 (tile placed)
S 250 Yea that's good
T 251 very good. so if posint started at 12 what is it equal to after the if statement?
S 252 6
T 253 right. It is updated by the divide by 2 line. Awesome.
T 254 now WAY back to your while line. Here it is.
T 255 (tile created) while posint is not 4 2 or 1do
S 257 (tile placed)
T 259 ok now think about that.
S 261 (tile placed)
T 262 is that really where you want to START the loop?
S 265 (tile placed)
S 267 i don't know
T 268 you want that if statement to be done multiple times right?
S 269 yea
T 270 so your loop should start where in relation to the if?
T 271 if you put it after the loop it won't go back and repeat for you.
S 272 ok so it's up top
S 274 (tile placed)
T 275 yeah. You need to move it all down a few lines.
T 277 remember you can draw a box around all of them.
S 280 (tile placed)
T 292 hold on!
T 293 You left the even check above the loop!
T 295 that happens in the loop too.
S 296 (tile placed)
T 298 just swap those two tiles (the while and if)
S 300 (tile placed)
S 314 ok
T 315 super!
T 316 Now one thing to keep it spaced nicely.
T 317 Usually the entire body of a loop is indented.
T 319 So could you take that "if" and "else" in a line for me?
S 320 (tile placed)
T 323 not too far!
S 325 (tile placed)
T 334 you want to maintain the indentation of the if as well.
S 335 (tile placed)
T 352 you're doing fabulous.
S 356 (tile placed)
S 364 ok
T 365 alright one last thing here. In pseudocode it is important to mark the end of a loop.
T 366 (tile created) end while
S 368 (tile placed)
T 369 that's it.
T 374 ok at this point we should sit back and look at the program.
T 375 Can you try to summarize it in a few words for me? What does it accomplish?
S 376 The hailstone Series
T 377 good. It creates a hailstone series.
T 378 Go ahead and type that into the "description" box and click the snapshot button. This will help us remember the code at this point.
T 380 FYI - to do this in a real program you'd want to print posint in the loop to see it on the screen.
T 381 make sense?
S 382 hmm... not really
S 383 what do u mean?
T 384 well if you ran this program the user would see nothing on the screen.
S 385 oh ok
T 386 it would do the series but just inside.
T 387 it's just a warning really... you want to know it works so in a real program you'd probably throw a print statement in there.
T 388 then you'd see "12 6 3 10 ..." show up.
T 389 as it worked its way through.
S 390 oh so you would add in a writeln statement if we were doing pascal???
T 391 uhuh. but not here. We're focusing on the core algorithm.
S 392 ok
T 393 ok there's more work to do! Click on "stage 2" and we'll keep it going.
S 394 ok
T 397 what do you want to work on now?
S 398 what's next??
T 399 you might need to review the reading above.
S 400 ok i so we want the reader to see the progress throughout
S 401 the program
T 402 printing the sequence is not technically part of the problem.
T 404 take a look at the third page.
S 406 how many items are in the sequence
S 407 and the largest number
S 408 i forgot about that part
S 409 ok
T 410 good. which one should we do first?
S 411 how many items are in the sequence
T 412 good. Any ideas on how that should work?
S 413 i don't know how to do this
T 414 nothing at all?
S 415 so we have to keep track of how many times the program went through the while statement?
T 416 right on!
T 417 Ok so you just established that each time through the loop is one more item in the sequence.
T 418 That's not an easy observation so good job.
T 419 so what should we do inside the loop to take advantage of that observation?
S 420 so should there be something before the if statement?
T 421 sure or after it. How many items do we see each time through the loop?
T 422 For example when we go from 6 to 3 how many items did we add to the sequence?
S 423 well we need to separate it from the else statement because if not we will only get the progress of the else statements
T 424 good. keeping track of the count is distinct (and separate) from the if/else part.
T 425 so how many new items are there each time through the loop?
S 426 just 1
T 427 exactly.
T 428 So if we add one each time through we will end up with what?
S 429 the sum of the items in the sequence
T 430 good.
T 431 Ok so we need a variable to keep track of this. Can you suggest a name?
S 432 I for items
T 433 how about something more expressive?
S 434 s for sum
T 435 try to make it obvious to a naive onlooker.
S 436 Items
T 437 well... sum implies your adding up a bunch of numbers.
T 438 we're just adding 1 each time.
T 439 ok... items. but we want it to suggest more.
T 440 How about "itemcount"?
S 441 ok sounds good to me
T 442 so what do we need to do to itemcount inside the loop?
S 443 how many times the loop statement has gone through
S 444 i am not exactly sure of a formula for this
S 445 i have to think about it
T 446 I think you're making it too hard here.
T 447 one time through the loop means what?
S 448 1 item in the sequence
T 449 good. so itemcount should go up by what?
S 450 how many times through the loop
T 451 ok think just ONE time through.
T 452 you're thinking about what it should be AFTER the loop.
S 453 if there's a new posint?
T 454 maybe an example would be good here.
T 455 if we start with 12. How many items do we have so far?
S 456 ok.. I need a little hel
S 457 1
T 458 no problem we'll get it figured out!
T 459 Ok after 12 the program finds 6 as the next item (this is one time through the loop).
T 460 What is the count now?
S 461 2
T 462 good. Next time through the loop we get 3. What is the count now?
S 463 3
T 464 good. So what are you doing to the count each time through?
S 465 adding one
T 466 YAY!
S 467 ok i know
T 468 (tile created) add 1 to itemcount
S 469 do we do that i =1 then i = i+1
S 470 is that right?
T 471 good. we'll just leave it like that but you get the idea. pseudocode is typically very general like that.
T 472 go ahead and place that tile.
S 473 we do it right before the end while?
S 475 (tile placed)
T 478 sounds great. You just need to be in the loop apart from the if/else.
T 479 and idented. )
S 480 ok ok
S 482 (tile placed)
T 491 actually that makes it look like it's in the else. You don't want that.
S 492 so do we have to have another while statement in there?
S 494 (tile placed)
T 499 it's ok.... let me show you.
T 501 (tile placed)
T 504 the end while stays lined up with the while so that the end of the loop is obvious.
T 505 the add 1 just happens after the if/else so they are lined up.
S 506 so just by the indentin it will know that's it's not apart of the if statement?
T 507 in pseudocode yes.
S 508 ok
T 509 you just want to make it obvious to the reader.
T 510 your implementation will depend on the language.
S 511 ok
T 512 alright you hinted earlier that itemcount had to start off equal to something.
T 513 what was that again?
S 514 equal to 1
T 515 good. this is called "initializing". You'll need to move the whole while section down to make room here.
T 516 (tile created) itemcount = 1
S 524 (tile placed)
S 538 right?
T 539 not quite... let's think about it.
T 540 By putting it in the loop you are saying you want to set itemcount equal to 1 each time through.
S 542 (tile placed)
T 543 Is that what you meant?
S 545 (tile placed)
T 549 remember in our example it kept going up by one each time. You only STARTED it off at 1.
S 550 so do u move the whole item count statement under the end while
T 551 under?
T 552 in the example we started with 12. What was the count at that point?
S 553 so would we put it before the if
S 554 1
T 555 even earlier.
T 556 SO before the loop started we had a count of 1.
S 557 before the while
T 559 yeah. You start off with one item before you jump into the loop.
T 561 This is how an "initialization" is supposed to work.
S 563 (tile placed)
S 599 do we ident it?
T 600 did you really want to move the "add 1" line to before the loop?
T 601 Didn't you do that each time through in our example?
S 604 (tile placed)
T 624 we're getting close.
S 627 (tile placed)
S 633 how about that?
T 634 almost.
T 635 Ok where does the loop start?
S 636 give me a hint
T 637 what line in the program?
S 638 at the beginning
S 639 as soon as the user enters a posint
T 640 not quite... there is no loop there.
T 641 It starts when it sees "while".
T 642 then it will do what is inside the while hit the end then come back up to the while again.
S 643 so then what's wrong with what i have now?
T 644 Take a look at the first line in your loop and relate it to what you did in your head earlier.
T 645 Did you really reset the count to 1 each time you told me a new hailstone number?
S 646 no but doesn't that change permantely when you add one
S 647 do u put the add one at the bottom of the loop?
T 648 let's execute it starting with 12 to find out.
T 649 so the user enters 12.
S 650 yea
T 651 posint is 12.
T 652 we enter the loop and set itemcount to 1.
S 653 ok
T 654 we then add one to itemcount to get 2.
T 655 with me?
T 657 (tile placed)
S 658 yea
T 659 then we do the if/else to get posint set to 6.
T 661 (tile placed)
S 662 ok
T 663 that's the end of the while we jump back up.
T 664 is 6 equal to 4 2 or 1?
S 665 no
T 666 good so we go back in the loop.
T 669 (tile placed)
T 672 now do we really want to set itemcount back to 1 here?
T 673 it holds 2 right now.
S 674 isn't itemcount =2
T 675 yes but "itemcount = 1" will change it back to 1.
T 676 that's how assignment works.
T 677 the observation you want to make is that the assignment should only happen ONCE before the loop.
T 678 I'll show you...
T 680 (tile placed)
S 687 ok i see now
S 688 that makes sense
T 689 so now when we jump back up it will NOT reset the count. it will just increase it by 1.
T 690 which is exactly what you were doing in your head in our examples.
T 691 ok the last thing to do is to print the result.
T 692 (tile created) print itemcount
T 693 that just goes after the loop.
S 695 (tile placed)
S 698 ok
T 699 good.
T 700 ok this code counts items. Could you do the snapshot?
T 702 you forgot the title but that's ok.
T 703 ok on to the last stage!
T 704 What is left to do?
S 705 determine the largest posint in the sequence
T 706 good. any ideas on how to do this?
S 709 wait hold up
T 710 sure.
S 711 for the negative I messsed up slightly it's suppose to be multiply by 3 instead of divide
T 712 that totally slipped by me!
S 713 dumb mistake
T 714 I'll make a new tile for it and fix it.
T 716 (tile placed)
T 718 (tile created) multiply posint by 3 and add 1
T 720 (tile placed)
T 721 cool?
S 722 so for this step we have to remember the numbers along the way and then determine the largest one
T 723 exactly.
T 724 We're sort of running out of time so I'll help more here.
S 725 i am not exactly sure how to accomplis this
T 726 ok so we need a new variable to remember the largest we've seen.
T 727 In our example when you start with 12 what's the largest at that point?
T 728 just 12 right?
T 729 are you there?
T 736 (tile placed)