// Copyright Amruth N. Kumar, amruth@computer.org // This is the master plan for the for loops // [Single Loop] // Skip - Zero Iteration // // PassThrough - One Iteration // // Infinite // // [Many Iterations] - Normal case, not mentioned // Initialization // No // Assignment // [Single] // [Multiple] // Declaration // [Single] // [Multiple] // Same variable declared both before and in header, // and printed both in and after loop // // Condition // No // [Exists] // Arithmetic // [True] // [False] // Logical // [Short Circuit + Side Effect] // [No Short Circuit] // Assignment // [True] // [False] // Relational // Boundary does not change // Boundary changes // Declaration // [Single] // [Multiple] // Same variable declared both before and in header, // and printed both in and after loop // // // Action // Empty [statement] // Simple [statement] // Compound [statement] // Revises [LoopVar] // Before [Action] // After [Action] // [Does not revise LoopVar] // // Update // None // Up [Counting] // One // Many // Down [Counting] // One // Many // // PostLoop [Resume after loop] // // // Multiple [Back to back] // Dependent // [2 loop problems] - degrees of hardness // [3 loop problems] - degrees of hardness // [All loops of same type] - degrees of hardness // [Loops of different types] - degrees of hardness // Up [Counting] // Down [Counting] // // Independent // [2 loop problems] - degrees of hardness // [3 loop problems] - degrees of hardness // [All loops of same type] - degrees of hardness // [Loops of different types] - degrees of hardness // Up [Counting] // Down [Counting] // // Nested // Dependent // [2 loop problems] - degrees of hardness // [3 loop problems] - degrees of hardness // [All loops of same type] - degrees of hardness // [Loops of different types] - degrees of hardness // Up [Counting] // Down [Counting] // // Independent // [2 loop problems] - degrees of hardness // [3 loop problems] - degrees of hardness // [All loops of same type] - degrees of hardness // [Loops of different types] - degrees of hardness // Up [Counting] // Down [Counting] // // ------------------------------------------------------------------- // Other factors that affect template hardness: // Loop body: // Just a print statement // a constant // the loop counter // a simple expression involving the loopvar // the loopvar, boundary value (when boundary is a variable or expression) // an expression involving the loopvar and boundary value (when // it is a variable) - No, too complicated // an if-else statement with different variables in the two clauses // // Note that the type of operator, and its subtypes determine hardness, // not learning objectives. // Number of iterations: // Zero iterations // < > // far off value // boundary value // <= >= // far off value // == // far off value // != // same value // Only One iteration // Multiple iterations // < > // far off value // <= >= // far off value // boundary value // == // same value // != // n-removed value // ---------------------------------------------------- // 100 // Iteration.Counter.Skip // Iteration.Counter.PassThrough // 150 // Iteration.Counter.Initialization.No // Iteration.Counter.Initialization.Assignment // Iteration.Counter.Initialization.Declaration // 225 // Iteration.Counter.Condition.No // Iteration.Counter.Condition.Arithmetic // Iteration.Counter.Condition.Logical // Iteration.Counter.Condition.Assignment // Iteration.Counter.Condition.Relational // Iteration.Counter.Condition.Declaration // Iteration.Counter.Condition.Changing // 400 // Iteration.Counter.Action.Empty // Iteration.Counter.Action.Simple // Iteration.Counter.Action.Compound // Iteration.Counter.Action.Changing.Before // Iteration.Counter.Action.Changing.After // 525 // Iteration.Counter.Update.No // Iteration.Counter.Update.Up.One // Iteration.Counter.Update.Up.Many // Iteration.Counter.Update.Down.One // Iteration.Counter.Update.Down.Many // 650 // Iteration.Counter.PostLoop // 675 // Iteration.Counter.Multiple.Dependent // [Up Counting] // [Down Counting] // Iteration.Counter.Multiple.Independent // [Up Counting] // [Down Counting] // // Iteration.Counter.Nested.Dependent // [Up Counting] // [Down Counting] // Iteration.Counter.Nested.Independent // [Up Counting] // [Down Counting] // break 800 // continue 825 // Iteration.Counter.Infinite 900 // // Up.One, Up.Many, Down.One, Down.Many are intertwined with the templates of most other learning objectives. // Could either // 1) elilminate all but Up.One for all other learning objectives and introduce them as templates for // Up.Many, Down.One, Down.Many // 2) Add a few token learning objectives for Up.One, Up.Many, Down.One, Down.Many, and // either designate the other learning objectives as meeting these objectives, are // provide credit for these learning objectives alongside the other learning objectives. // In Fall 2004, not creating any templates for or giving credit for these learning objectives. // // // Visual Basic works only with templates such that // condition is of the type var <= value or var >= value // update is of the type var = var op value // //************** FOR LOOPS ************************************************ // ------------------------------------------------------------------------ // Counter.Skip ************************************ 100 //Empty Loops *************************** 100 # 100 Counter.Skip > {(){;for( = ; > ; = - 1){<<;}}} > Type: output Hardness: 50 # 101 Counter.Skip > {(){;for( = ; == ; = + 1){<<;<<;}}} > Type: output Hardness: 50 # 102 Counter.Skip > {(){;for( = ; < ; = + 1){<<;<<;}}} > Type: output Hardness: 50 # 103 Counter.Skip > {(){;for( = ; >= ; = - 1){<<;<<;}}} > Type: output Hardness: 50 # 104 Counter.Skip > {(){;for( = ; != ; = + 1){<<;<<;}}} > Type: output Hardness: 50 # 105 Counter.Skip > {(){;for( = ; <= ; = + 1){<<;<<;}}} > Type: output Hardness: 50 # 106 Counter.Skip > {(){;=;for( = ; > ; = - 1){<<;<<;}}} > Type: output Hardness: 50 # 107 Counter.Skip > {(){;=;for( = ; == ; = + 1){<<;<<;}}} > Type: output Hardness: 50 # 108 Counter.Skip > {(){;=;for( = ; < ; = + 1){<<;<<;}}} > Type: output Hardness: 50 # 109 Counter.Skip > {(){;=;for( = ; >= ; = - 1){<<;<<;}}} > Type: output Hardness: 50 # 110 Counter.Skip > {(){;=;for( = ; != ; = + 1){<<;<<;}}} > Type: output Hardness: 50 # 111 Counter.Skip > {(){;=;for( = ; <= ; = + 1){<<;<<;}}} > Type: output Hardness: 50 # 112 Counter.Skip > {(){;for( = ; > ; = - 1){<<;}}} > Type: output Hardness: 60 # 113 Counter.Skip > {(){;for( = ; < ; = + 1){<<;}}} > Type: output Hardness: 60 # 114 Counter.Skip > {(){;for( = ; != ; = + 1){<<;}}} > Type: output Hardness: 60 // Introduced for the sake of Visual Basic # 115 Counter.Skip > {(){;=;for( = ; >= ; = - ){<<;<<;}}} > Type: output Hardness: 50 # 116 Counter.Skip > {(){;=;for( = ; <= ; = + ){<<;<<;}}} > Type: output Hardness: 50 // ------------------------------------------------------------------------ // Counter.PassThrough ************************************ 125 # 125 Counter.PassThrough > {(){=;for( = - 1; < ; = + 1){<<;}}} > Type: output Hardness: 50 # 126 Counter.PassThrough > {(){=;for( = + 1; > ; = - 1){<<;}}} > Type: output Hardness: 50 # 127 Counter.PassThrough > {(){;for( = ; == ; = + 1){<<;}}} > Type: output Hardness: 50 # 128 Counter.PassThrough > {(){;for( = ; <= ; = + 1){<<;}}} > Type: output Hardness: 60 # 129 Counter.PassThrough > {(){;for( = ; >= ; = - 1){<<;}}} > Type: output Hardness: 60 # 130 Counter.PassThrough > {(){;for( = ; != ; = ){<<;}}} > Type: output Hardness: 50 # 131 Counter.PassThrough > {(){;for( = ; < ; = ){<<;}}} > Type: output Hardness: 50 # 132 Counter.PassThrough > {(){;for( = ; > 0; = - ){<<;}}} > Type: output Hardness: 60 # 133 Counter.PassThrough > {(){=;;for( = ; == ; = - 1){<<;<<;}}} > Type: output Hardness: 50 # 134 Counter.PassThrough > {(){;for( = ; <= ; = * 2){<<;}}} > Type: output Hardness: 50 # 135 Counter.PassThrough > {(){;=;for( = ; >= ; = - 1){<<;}}} > Type: output Hardness: 50 # 136 Counter.PassThrough > {(){;=; = + 1;for( = ; != ; = + 1){<<;<<;}}} > Type: output Hardness: 50 # 137 Counter.PassThrough > {(){;=; = + 1;for( = ; < ; = + 1){<<;<<;}}} > Type: output Hardness: 50 # 138 Counter.PassThrough > {(){;=; = - 1;for( = ; > ; = - 1){<<;<<;}}} > Type: output Hardness: 50 # 139 Counter.PassThrough > {(){=;;for( = ; == ; = ){<<;<<;}}} > Type: output Hardness: 50 # 140 Counter.PassThrough > {(){;=;for( = ; <= ; = + 1){<<;}}} > Type: output Hardness: 60 # 141 Counter.PassThrough > {(){;=;for( = ; >= ; = - 1){<<;}}} > Type: output Hardness: 50 # 142 Counter.PassThrough > {(){=;;for( = ; != ; = ){<<;<<;}}} > Type: output Hardness: 50 # 143 Counter.PassThrough > {(){;=;for( = ; <= ; = + 1){<<;}}} > Type: output Hardness: 60 # 144 Counter.PassThrough > {(){;=;for( = ; >= ; = - 1){<<;}}} > Type: output Hardness: 50 # 145 Counter.PassThrough > {(){;=;for( = ; <= ; = + ){<<;}}} > Type: output Hardness: 60 # 146 Counter.PassThrough > {(){;=;for( = ; >= ; = - ){<<;}}} > Type: output Hardness: 50 // ------------------------------------------------------------------------ // Counter.Initialization.No ************************************ 150 // ------------------------------------------------------------------------ // Counter.Initialization.Assignment ************************************ 175 // ------------------------------------------------------------------------ // Counter.Initialization.Declaration ************************************ 200 // ------------------------------------------------------------------------ // Counter.Condition.No ************************************ 225 // ------------------------------------------------------------------------ // Counter.Condition.Arithmetic ************************************ 250 // ------------------------------------------------------------------------ // Counter.Condition.Logical ************************************ 275 // ------------------------------------------------------------------------ // Counter.Condition.Assignment ************************************ 300 // ------------------------------------------------------------------------ // Counter.Condition.Relational ************************************ 325 // Using a constant as boundary value, update by one # 325 Counter.Condition.Relational ? Counter.Update.After > {(){;for( = ; < ; = + 1){<<;}}} > Type: output Hardness: 20 # 326 Counter.Condition.Relational ? Counter.Update.After > {(){;for( = ; > ; = - 1){<<;}}} > Type: output Hardness: 50 # 327 Counter.Condition.Relational ? Counter.Update.After > {(){;for( = ; <= ; = + 1){<<;}}} > Type: output Hardness: 20 # 328 Counter.Condition.Relational ? Counter.Update.After > {(){;for( = ; >= ; = - 1){<<;}}} > Type: output Hardness: 50 # 329 Counter.Condition.Relational ? Counter.Update.After > {(){;for( = ; != ; = + 1){<<;}}} > Type: output Hardness: 50 // Using a variable to hold boundary value, update by one # 330 Counter.Condition.Relational ? Counter.Update.After > {(){;=;for( = ; < ; = + 1){<<;}}} > Type: output Hardness: 50 # 331 Counter.Condition.Relational ? Counter.Update.After > // {(){=;;for( = ; > ; = + 1){<<;}}} {(){;=;for( = ; > ; = - 1){<<;}}} > Type: output Hardness: 50 # 332 Counter.Condition.Relational ? Counter.Update.After > {(){;=;for( = ; <= ; = + 1){<<;}}} // {(){=;;for( = ; <= ; = - 1){<<;}}} > Type: output Hardness: 60 # 333 Counter.Condition.Relational ? Counter.Update.After > {(){;=;for( = ; >= ; = - 1){<<;}}} > Type: output Hardness: 60 # 334 Counter.Condition.Relational ? Counter.Update.After > {(){;=;for( = ; != ; = + 1){<<;}}} // {(){;=;for( = ; != ; = + 1){<<;<<;}}} // Simplified for S08 > Type: output Hardness: 50 # 335 Counter.Condition.Relational ? Counter.Update.After > {(){=;;for( = ; != ; = - 1){<<;}}} // {(){=;;for( = ; != ; = - 1){<<;<<;}}} // Simplified for S08 > Type: output Hardness: 50 // Using a constant to hold boundary value, update by more than one # 336 Counter.Condition.Relational ? Counter.Update.After > {(){;for( = ; < ; = + ){<<;}}} > Type: output Hardness: 20 # 337 Counter.Condition.Relational ? Counter.Update.After > {(){;for( = ; > ; = - ){<<;}}} > Type: output Hardness: 50 # 338 Counter.Condition.Relational ? Counter.Update.After > {(){;for( = ; <= ; = + ){<<;}}} > Type: output Hardness: 20 # 339 Counter.Condition.Relational ? Counter.Update.After > {(){;for( = ; >= ; = - ){<<;}}} > Type: output Hardness: 50 // Using a variable to hold boundary value, update by more than one # 340 Counter.Condition.Relational ? Counter.Update.After > {(){; = ;for( = ; < ; = + ){<<;}}} > Type: output Hardness: 50 # 341 Counter.Condition.Relational ? Counter.Update.After > {(){;=;for( = ; > ; = - ){<<;}}} > Type: output Hardness: 50 # 342 Counter.Condition.Relational ? Counter.Update.After > // {(){=;;for( = ; <= ; = - ){<<;}}} {(){; = ;for( = ; <= ; = + ){<<;}}} > Type: output Hardness: 60 # 343 Counter.Condition.Relational ? Counter.Update.After > {(){;=;for( = ; >= ; = - ){<<;}}} // {(){=;;for( = ; >= ; = + ){<<;}}} > Type: output Hardness: 60 # 344 Counter.Condition.Relational ? Counter.Update.After > {(){;; = + * ;for( = ; != ; = + ){<<;}}} > Type: output Hardness: 70 # 345 Counter.Condition.Relational ? Counter.Update.After > // {(){=;;for( = + * ; != ; = - ){<<;}}} [,,,]{(){=;;for( = ; != ; = - ){<<;}}} > Type: output Hardness: 70 # 346 Counter.Condition.Relational ? Counter.Update.After > {(){;=;for( = ; < ; = + ){<<;}}} > Type: output Hardness: 70 # 347 Counter.Condition.Relational ? Counter.Update.After > {(){;=;for( = ; <= ; = + ){<<;}}} > Type: output Hardness: 70 // ------------------------------------------------------------------------ // Counter.Condition.Declaration ************************************ 350 // ------------------------------------------------------------------------ // Counter.Condition.Changing ************************************ 375 // NOT simplified for S08 since multiple outputs in the loop help student correctly understand behavior of loop // Loop variable and Boundary variable changing in the opposite directions by 1 # 375 Counter.Condition.Changing > {(){;=;for( = ; < ; = + 1){<<;<<; = - 1;}}} > Type: output Hardness: 60 # 376 Counter.Condition.Changing > {(){;=;for( = ; > ; = - 1){<<;<<; = + 1;}}} > Type: output Hardness: 60 # 377 Counter.Condition.Changing > {(){;=;for( = ; <= ; = + 1){<<;<<; = - 1;}}} > Type: output Hardness: 70 # 378 Counter.Condition.Changing > {(){;=;for( = ; >= ; = - 1){<<;<<; = + 1;}}} > Type: output Hardness: 70 # 379 Counter.Condition.Changing > // {(){=;=;for( = + 6 * ; != ; = - ){<<;<<; = + ;}}} [,]{(){=;=;for( = ; != ; = - ){<<;<<; = + ;}}} > Type: output Hardness: 60 // Loop variable and Boundary variable changing in the opposite directions by the same amount, not 1 # 380 Counter.Condition.Changing > {(){;=;for( = ; < ; = + ){<<;<<; = - ;}}} > Type: output Hardness: 70 # 381 Counter.Condition.Changing > {(){;=;for( = ; > ; = - ){<<;<<; = + ;}}} > Type: output Hardness: 70 # 382 Counter.Condition.Changing > {(){;=;for( = ; <= ; = + ){<<;<<; = - ;}}} > Type: output Hardness: 70 # 383 Counter.Condition.Changing > {(){;=;for( = ; >= ; = - ){<<;<<; = + ;}}} > Type: output Hardness: 70 # 384 Counter.Condition.Changing > // {(){=;=;for( = + 4 * ; != ; = - ){<<;<<; = + ;}}} [,,]{(){=;=;for( = ; != ; = - ){<<;<<; = + ;}}} > Type: output Hardness: 70 // Loop variable and Boundary variable changing in the same direction, but by different amounts # 385 Counter.Condition.Changing > {(){;=;for( = ; < ; = + ){<<;<<; = + 1;}}} > Type: output Hardness: 80 # 386 Counter.Condition.Changing > {(){;=;for( = ; <= ; = + ){<<;<<; = + 1;}}} > Type: output Hardness: 80 # 387 Counter.Condition.Changing > {(){;=;for( = ; > ; = - ){<<;<<; = - 1;}}} > Type: output Hardness: 80 # 388 Counter.Condition.Changing > {(){;=;for( = ; >= ; = - ){<<;<<; = - 1;}}} > Type: output Hardness: 80 // ------------------------------------------------------------------------ // Counter.Action.Empty ************************************ 400 // ------------------------------------------------------------------------ // Counter.Action.Simple ************************************ 425 // Using a constant as boundary value, update by one # 425 Counter.Action.Simple > {(){;for( = ; < ; = + 1)<<;}} > Type: output Hardness: 60 # 426 Counter.Action.Simple > {(){;for( = ; > ; = - 1)<<;}} > Type: output Hardness: 60 # 427 Counter.Action.Simple > {(){;for( = ; <= ; = + 1)<<;}} > Type: output Hardness: 60 # 428 Counter.Action.Simple > {(){;for( = ; >= ; = - 1)<<;}} > Type: output Hardness: 60 # 429 Counter.Action.Simple > {(){;for( = ; != ; = + 1)<<;}} > Type: output Hardness: 60 // Using a variable to hold boundary value, update by one # 430 Counter.Action.Simple > {(){;=;for( = ; < ; = + 1)<<; = - 1;}} > Type: output Hardness: 70 # 431 Counter.Action.Simple > {(){;=;for( = ; > ; = - 1)<<; = + 1;}} > Type: output Hardness: 70 # 432 Counter.Action.Simple > {(){;=;for( = ; <= ; = + 1)<<; = - 1;}} > Type: output Hardness: 80 # 433 Counter.Action.Simple > {(){;=;for( = ; >= ; = - 1)<<; = + 1;}} > Type: output Hardness: 80 # 434 Counter.Action.Simple ? Counter.PostLoop > {(){;=;for( = ; != ; = + 1)<<;<<;}} > Type: output Hardness: 70 # 435 Counter.Action.Simple ? Counter.PostLoop > {(){=;;for( = ; != ; = - 1)<<;<<;}} > Type: output Hardness: 70 // Using a constant to hold boundary value, update by more than one # 436 Counter.Action.Simple > {(){;for( = ; < ; = + )<<;}} > Type: output Hardness: 50 # 437 Counter.Action.Simple > {(){;for( = ; > ; = - )<<;}} > Type: output Hardness: 60 # 438 Counter.Action.Simple > {(){;for( = ; <= ; = + )<<;}} > Type: output Hardness: 50 # 439 Counter.Action.Simple > {(){;for( = ; >= ; = - )<<;}} > Type: output Hardness: 60 // Using a variable to hold boundary value, update by more than one # 440 Counter.Action.Simple > {(){;=;for( = ; < ; = + )<<; = - ;}} > Type: output Hardness: 70 # 441 Counter.Action.Simple > {(){;=;for( = ; > ; = - )<<; = + ;}} > Type: output Hardness: 70 # 442 Counter.Action.Simple > {(){;=;for( = ; <= ; = + )<<; = - ;}} > Type: output Hardness: 80 # 443 Counter.Action.Simple > {(){;=;for( = ; >= ; = - )<<; = + ;}} > Type: output Hardness: 80 # 444 Counter.Action.Simple ? Counter.PostLoop > // {(){; = + * ;for( = ; != ; = + )<<;<<;}} [,,,]{(){; = ;for( = ; != ; = + )<<;<<;}} > Type: output Hardness: 80 # 445 Counter.Action.Simple ? Counter.PostLoop > // {(){=;;for( = + * ; != ; = - )<<;<<;}} [,,,]{(){=;;for( = ; != ; = - )<<;<<;}} > Type: output Hardness: 80 # 446 Counter.Action.Simple ? Counter.PostLoop > {(){;=;for( = ; < ; = + )<<;<<;}} > Type: output Hardness: 80 # 447 Counter.Action.Simple ? Counter.PostLoop > {(){;=;for( = ; <= ; = + )<<;<<;}} > Type: output Hardness: 80 // ------------------------------------------------------------------------ // Counter.Action.Compound ************************************ 450 // ------------------------------------------------------------------------ // Counter.Action.Changing.Before ************************************ 475 // Counter loop being changed in the body, before the body // Using a constant as boundary value, update by one # 475 Counter.Action.Changing.Before > {(){;for( = ; < ; = + 1){ = + 1;<<;}}} > Type: output Hardness: 20 # 476 Counter.Action.Changing.Before > {(){;for( = ; > ; = - 1){ = - 1;<<;}}} > Type: output Hardness: 50 # 477 Counter.Action.Changing.Before > {(){;for( = ; <= ; = + 1){ = + 1;<<;}}} > Type: output Hardness: 20 # 478 Counter.Action.Changing.Before > {(){;for( = ; >= ; = - 1){ = - 1;<<;}}} > Type: output Hardness: 50 # 479 Counter.Action.Changing.Before > {(){; = + * 2;for( = ; != ; = + 1){ = + 1;<<;}}} > Type: output Hardness: 50 // Using a variable to hold boundary value, update by one # 480 Counter.Action.Changing.Before > {(){;=;for( = ; < ; = + 1){ = + 1;<<;}}} > Type: output Hardness: 50 # 481 Counter.Action.Changing.Before > {(){;=;for( = ; > ; = - 1){ = - 1;<<;}}} > Type: output Hardness: 50 # 482 Counter.Action.Changing.Before > {(){;=;for( = ; <= ; = + 1){ = + 1;<<;}}} > Type: output Hardness: 60 # 483 Counter.Action.Changing.Before > {(){;=;for( = ; >= ; = - 1){ = - 1;<<;}}} > Type: output Hardness: 60 # 484 Counter.Action.Changing.Before > // {(){; = + 2 * ;for( = ; != ; = + 1){ = + 1;<<;<<;}}} // Simplified for S08 // {(){ = ; = ; = 2 * + ;for( = ; != ; = + 1){ = + 1;<<;}}} [,,]{(){ = ; = ;for( = ; != ; = + 1){ = + 1;<<;}}} > Type: output Hardness: 50 # 485 Counter.Action.Changing.Before > // {(){=;;for( = + 2 * ; != ; = - 1){ = - 1;<<;<<;}}} // Simplified for S08 // {(){=; = ;for( = 2 * + ; != ; = - 1){ = - 1;<<;}}} [,,]{(){=;;for( = ; != ; = - 1){ = - 1;<<;}}} > Type: output Hardness: 50 // Using a constant to hold boundary value, update by more than one # 486 Counter.Action.Changing.Before > {(){;for( = ; < ; = + ){ = + ;<<;}}} > Type: output Hardness: 20 # 487 Counter.Action.Changing.Before > {(){;for( = ; > ; = - ){ = - ;<<;}}} > Type: output Hardness: 50 # 488 Counter.Action.Changing.Before > {(){;for( = ; <= ; = + ){ = + ;<<;}}} > Type: output Hardness: 20 # 489 Counter.Action.Changing.Before > {(){;for( = ; >= ; = - ){ = - ;<<;}}} > Type: output Hardness: 50 // Using a variable to hold boundary value, update by more than one # 490 Counter.Action.Changing.Before > {(){; = ;for( = ; < ; = + ){ = + ;<<;}}} > Type: output Hardness: 50 # 491 Counter.Action.Changing.Before > {(){;=;for( = ; > ; = - ){ = - ;<<;}}} > Type: output Hardness: 50 # 492 Counter.Action.Changing.Before > {(){; = ;for( = ; <= ; = + ){ = + ;<<;}}} > Type: output Hardness: 60 # 493 Counter.Action.Changing.Before > {(){;=;for( = ; >= ; = - ){ = - ;<<;}}} > Type: output Hardness: 60 # 494 Counter.Action.Changing.Before > {(){;=;for( = ; < ; = + ){ = + ;<<;}}} > Type: output Hardness: 70 # 495 Counter.Action.Changing.Before > {(){;=;for( = ; <= ; = + ){ = + ;<<;}}} > Type: output Hardness: 70 // ------------------------------------------------------------------------ // Counter.Action.Changing.After ************************************ 500 // ------------------------------------------------------------------------ // Counter.Update.No ************************************ 525 // ------------------------------------------------------------------------ // Counter.Update.Before ************************************ 550 // ------------------------------------------------------------------------ // Do we need this? This is general case // Counter.Update.Up.One ************************************ 550 // ------------------------------------------------------------------------ // Counter.PostLoop ************************************ 650 // Using a constant as boundary value, update by one # 650 Counter.PostLoop > {(){;for( = ; < ; = + 1){<<;}<<;}} > Type: output Hardness: 30 # 651 Counter.PostLoop > {(){;for( = ; > ; = - 1){<<;}<<;}} > Type: output Hardness: 40 # 652 Counter.PostLoop > {(){;for( = ; <= ; = + 1){<<;}<<;}} > Type: output Hardness: 30 # 653 Counter.PostLoop > {(){;for( = ; >= ; = - 1){<<;}<<;}} > Type: output Hardness: 40 # 654 Counter.PostLoop > {(){;for( = ; != ; = + 1){<<;}<<;}} > Type: output Hardness: 30 // Using a variable to hold boundary value, update by one # 655 Counter.PostLoop > {(){;=;for( = ; < ; = + 1){<<;}<<;}} > Type: output Hardness: 30 # 656 Counter.PostLoop > // {(){=;;for( = ; > ; = + 1){<<;}<<;}} {(){;=;for( = ; > ; = - 1){<<;}<<;}} > Type: output Hardness: 30 # 657 Counter.PostLoop > {(){;=;for( = ; <= ; = + 1){<<;}<<;}} // {(){=;;for( = ; <= ; = - 1){<<;}<<;}} > Type: output Hardness: 40 # 658 Counter.PostLoop > {(){;=;for( = ; >= ; = - 1){<<;}<<;}} > Type: output Hardness: 40 # 659 Counter.PostLoop > {(){;=;for( = ; != ; = + 1){<<;}<<;}} // {(){;=;for( = ; != ; = + 1){<<;<<;}<<;}} // Simplified for S08 > Type: output Hardness: 30 # 660 Counter.PostLoop > {(){=;;for( = ; != ; = - 1){<<;}<<;}} // {(){=;;for( = ; != ; = - 1){<<;<<;}<<;}} // Simplified for S08 > Type: output Hardness: 40 // Using a constant to hold boundary value, update by more than one # 661 Counter.PostLoop > {(){;for( = ; < ; = + ){<<;}<<;}} > Type: output Hardness: 30 # 662 Counter.PostLoop > {(){;for( = ; > ; = - ){<<;}<<;}} > Type: output Hardness: 40 # 663 Counter.PostLoop > {(){;for( = ; <= ; = + ){<<;}<<;}} > Type: output Hardness: 30 # 664 Counter.PostLoop > {(){;for( = ; >= ; = - ){<<;}<<;}} > Type: output Hardness: 40 // Using a variable to hold boundary value, update by more than one # 665 Counter.PostLoop > {(){;=;for( = ; < ; = + ){<<;}<<;}} > Type: output Hardness: 30 # 666 Counter.PostLoop > {(){;=;for( = ; > ; = - ){<<;}<<;}} > Type: output Hardness: 40 # 667 Counter.PostLoop > {(){;=;for( = ; <= ; = + ){<<;}<<;}} // {(){=;;for( = ; <= ; = - ){<<;}<<;}} > Type: output Hardness: 40 # 668 Counter.PostLoop > {(){;=;for( = ; >= ; = - ){<<;}<<;}} // {(){=;;for( = ; >= ; = + ){<<;}<<;}} > Type: output Hardness: 30 # 669 Counter.PostLoop > // {(){; = + * ;for( = ; != ; = + ){<<;}<<;}} [,,,]{(){; = ;for( = ; != ; = + ){<<;}<<;}} > Type: output Hardness: 30 # 670 Counter.PostLoop > // {(){=; = * ;for( = + ; != ; = - ){<<;}<<;}} [,,,]{(){=; = ;for( = + ; != ; = - ){<<;}<<;}} > Type: output Hardness: 40 # 671 Counter.PostLoop > {(){;=;for( = ; < ; = + ){<<;}<<;}} > Type: output Hardness: 30 # 672 Counter.PostLoop > {(){;=;for( = ; <= ; = + ){<<;}<<;}} > Type: output Hardness: 30 // ------------------------------------------------------------------------ // Counter.Multiple.Dependent ************************************ 675 // [Up Counting] // [Down Counting] // 2 loops // UpUp - Update by 1 vs many - use first loop variable's value as second loop's start value/end value // UpDown - Update by 1 vs many // DownUp - Update by 1 vs many // DownDown - Update by 1 vs many // ********************** Up X Up X update by 1 ********************** # 675 Counter.Multiple.Dependent > {(){;for( = ; < ; = + 1){<<;}for(; <= ; = + 1){<<;}}} > Type: output Hardness: 80 # 676 Counter.Multiple.Dependent > // {(){;for( = ; < ; = + 1){<<;};for( = ; <= ; = + 1){<<;}}} - Till Fall 2007 {(){;for( = ; <= ; = + 1){<<;};for( = ; <= ; = + 1){<<;}}} > Type: output Hardness: 80 // ********************** Up X Up X Update by many ********************** # 677 Counter.Multiple.Dependent > {(){;for( = ; < ; = + ){<<;}for(; <= ; = + ){<<;}}} > Type: output Hardness: 80 # 678 Counter.Multiple.Dependent > {(){;for( = ; < ; = + ){<<;};for( = ; <= ; = + ){<<;}}} > Type: output Hardness: 80 // ********************** Up X Down X update by 1 ********************** # 679 Counter.Multiple.Dependent > {(){;for( = ; < ; = + 1){<<;}for(; >= ; = - 1){<<;}}} > Type: output Hardness: 80 # 680 Counter.Multiple.Dependent > // {(){;for( = ; < ; = + 1){<<;};for( = ; >= ; = - 1){<<;}}} - Till Fall 2007 {(){;for( = ; <= ; = + 1){<<;};for( = ; >= ; = - 1){<<;}}} > Type: output Hardness: 80 // ********************** Up X Down X Update by many ********************** # 681 Counter.Multiple.Dependent > {(){;for( = ; < ; = + ){<<;}for(; >= ; = - ){<<;}}} > Type: output Hardness: 80 # 682 Counter.Multiple.Dependent > {(){;for( = ; < ; = + ){<<;};for( = ; >= ; = - ){<<;}}} > Type: output Hardness: 80 // ********************** Down X Up X Update by 1 ********************** # 683 Counter.Multiple.Dependent > {(){;for( = ; > ; = - 1){<<;}for(; <= ; = + 1){<<;}}} > Type: output Hardness: 80 # 684 Counter.Multiple.Dependent > // {(){;for( = ; >= ; = - 1){<<;};for( = ; < ; = + 1){<<;}}} - Till Fall 2007 {(){;for( = ; >= ; = - 1){<<;};for( = ; <= ; = + 1){<<;}}} > Type: output Hardness: 80 // ********************** Down X Up X Update by many ********************** # 685 Counter.Multiple.Dependent > {(){;for( = ; > ; = - ){<<;}for(; <= ; = + ){<<;}}} > Type: output Hardness: 80 # 686 Counter.Multiple.Dependent > {(){;for( = ; >= ; = - ){<<;};for( = ; < ; = + ){<<;}}} > Type: output Hardness: 80 // ********************** Down X Down X Update by 1 ********************** # 687 Counter.Multiple.Dependent > {(){;for( = ; > ; = - 1){<<;}for(; >= ; = - 1){<<;}}} > Type: output Hardness: 80 # 688 Counter.Multiple.Dependent > // {(){;for( = ; > ; = - 1){<<;};for( = ; >= ; = - 1){<<;}}} - Till Fall 2007 {(){;for( = ; >= ; = - 1){<<;};for( = ; >= ; = - 1){<<;}}} > Type: output Hardness: 80 // ********************** Down X Down X Update by many ********************** # 689 Counter.Multiple.Dependent > {(){;for( = ; > ; = - ){<<;}for(; >= ; = - ){<<;}}} > Type: output Hardness: 80 # 690 Counter.Multiple.Dependent > {(){;for( = ; > ; = - ){<<;};for( = ; >= ; = - ){<<;}}} > Type: output Hardness: 80 // ********************** 3-levels ********************** # 691 Counter.Multiple.Dependent > {(){;for( = ; < ; = + 1){<<;}for(; < ; = + 2){<<;}for(; < ; = + 3){<<;}}} > Type: output Hardness: 90 # 692 Counter.Multiple.Dependent > {(){;for( = ; > ; = - 3){<<;}for(; > ; = - 2){<<;}for(; > ; = - 1){<<;}}} > Type: output Hardness: 90 // ***************** Introduced for the benefit of Visual Basic ******************** // Trivial modification of 677 # 693 Counter.Multiple.Dependent > {(){;for( = ; <= ; = + ){<<;};for( = ; <= ; = + ){<<;}}} > Type: output Hardness: 80 // Trivial modification of 681 # 694 Counter.Multiple.Dependent > {(){;for( = ; <= ; = + ){<<;};for( = ; >= ; = - ){<<;}}} > Type: output Hardness: 80 // Trivial modification of 685 # 695 Counter.Multiple.Dependent > {(){;for( = ; >= ; = - ){<<;};for( = ; <= ; = + ){<<;}}} > Type: output Hardness: 80 // Trivial modification of 689 # 696 Counter.Multiple.Dependent > {(){;for( = ; >= ; = - ){<<;};for( = ; >= ; = - ){<<;}}} > Type: output Hardness: 80 // ------------------------------------------------------------------------ // Counter.Multiple.Independent ************************************ 700 // [Up Counting] // [Down Counting] // ------------------------------------------------------------------------ // Counter.Nested.Dependent ************************************ 725 // [Up Counting] // [Down Counting] // 2 loops nested // UpUp - Update by 1 vs many - use outside loop variable's value as inside loop's start value/end value/update value // UpDown - Update by 1 vs many // DownUp - Update by 1 vs many // DownDown - Update by 1 vs many // Up X Up X update by 1 # 725 Counter.Nested.Dependent > // {(){;;for( = ; < ; = + 1){<<;for( = ; <= ; = + 1){<<;}}}} - Till Fall 2007 {(){;;for( = ; <= ; = + 1){<<;for( = ; <= ; = + 1){<<;}}}} > Type: output Hardness: 80 # 726 Counter.Nested.Dependent > {(){;;for( = ; < ; = + 1){<<;for( = ; <= ; = + 1){<<;}}}} > Type: output Hardness: 80 // Up X Up X Update by many # 727 Counter.Nested.Dependent > {(){;;for( = ; < ; = + ){<<;for( = ; <= ; = + ){<<;}}}} > Type: output Hardness: 80 # 728 Counter.Nested.Dependent > // {(){;;for( = ; < ; = + ){<<;for( = ; <= ; = + ){<<;}}}} - Till Fall 2007 {(){;;for( = ; <= ; = + ){<<;for( = ; <= ; = + ){<<;}}}} > Type: output Hardness: 80 # 729 Counter.Nested.Dependent > {(){;;for( = ; < ; = + ){<<;for( = ; <= ; = + ){<<;}}}} > Type: output Hardness: 90 // Up X Down X update by 1 # 730 Counter.Nested.Dependent > // {(){;;for( = ; < ; = + 1){<<;for( = ; >= ; = - 1){<<;}}}} - Till Fall 2007 {(){;;for( = ; <= ; = + 1){<<;for( = ; >= ; = - 1){<<;}}}} > Type: output Hardness: 80 # 731 Counter.Nested.Dependent > {(){;;for( = ; < ; = + 1){<<;for( = ; >= ; = - 1){<<;}}}} > Type: output Hardness: 80 // Up X Down X Update by many # 732 Counter.Nested.Dependent > {(){;;for( = ; < ; = + ){<<;for( = ; >= ; = - ){<<;}}}} > Type: output Hardness: 80 # 733 Counter.Nested.Dependent > {(){;;for( = ; < ; = + ){<<;for( = ; >= ; = - ){<<;}}}} > Type: output Hardness: 80 # 734 Counter.Nested.Dependent > // {(){;;for( = ; < ; = + ){<<;for( = ; >= ; = - ){<<;}}}} {(){;;for( = ; <= ; = + ){<<;for( = ; >= ; = - ){<<;}}}} > Type: output Hardness: 90 // Down X Up X Update by 1 # 735 Counter.Nested.Dependent > {(){;;for( = ; > ; = - 1){<<;for( = ; <= ; = + 1){<<;}}}} > Type: output Hardness: 80 # 736 Counter.Nested.Dependent > // {(){;;for( = ; > ; = - 1){<<;for( = ; <= ; = + 1){<<;}}}} - Till Fall 2007 {(){;;for( = ; >= ; = - 1){<<;for( = ; <= ; = + 1){<<;}}}} > Type: output Hardness: 80 // Down X Up X Update by many # 737 Counter.Nested.Dependent > {(){;;for( = ; > ; = - ){<<;for( = ; <= ; = + ){<<;}}}} > Type: output Hardness: 80 # 738 Counter.Nested.Dependent > {(){;;for( = ; > ; = - ){<<;for( = ; <= ; = + ){<<;}}}} > Type: output Hardness: 80 # 739 Counter.Nested.Dependent > // {(){;;for( = ; > ; = - ){<<;for( = ; <= ; = + ){<<;}}}} - Till Fall 2007 {(){;;for( = ; >= ; = - ){<<;for( = ; <= ; = + ){<<;}}}} > Type: output Hardness: 90 // Down X Down X Update by 1 # 740 Counter.Nested.Dependent > {(){;;for( = ; > ; = - 1){<<;for( = ; >= ; = - 1){<<;}}}} > Type: output Hardness: 80 # 741 Counter.Nested.Dependent > // {(){;;for( = ; > ; = - 1){<<;for( = ; >= ; = - 1){<<;}}}} - Till Fall 2007 {(){;;for( = ; >= ; = - 1){<<;for( = ; >= ; = - 1){<<;}}}} > Type: output Hardness: 80 // Down X Down X Update by many # 742 Counter.Nested.Dependent > {(){;;for( = ; > ; = - ){<<;for( = ; >= ; = - ){<<;}}}} > Type: output Hardness: 80 # 743 Counter.Nested.Dependent > {(){;;for( = ; > ; = - ){<<;for( = ; >= ; = - ){<<;}}}} > Type: output Hardness: 80 # 744 Counter.Nested.Dependent > // {(){;;for( = ; > ; = - ){<<;for( = ; >= ; = - ){<<;}}}} - Till Fall 2007 {(){;;for( = ; >= ; = - ){<<;for( = ; >= ; = - ){<<;}}}} > Type: output Hardness: 90 //3-levels # 745 Counter.Nested.Dependent > {(){;;;for( = ; < ; = + 1){<<;for( = ; < ; = + 1){<<;for( = ; < ; = + 1){<<;}}}}} // {(){;;;for( = ; < ; = + 1){for( = ; < ; = + 1){for( = ; < ; = + 1){<<;<<;<<;}}}}} // Simplified for S08 > Type: output Hardness: 90 # 746 Counter.Nested.Dependent > {(){;;;for( = ; > ; = - 1){<<;for( = ; > ; = - 1){<<;for( = ; > ; = - 1){<<;}}}}} // {(){;;;for( = ; > ; = - 1){for( = ; > ; = - 1){for( = ; > ; = - 1){<<;<<;<<;}}}}} // Simplified for S08 > Type: output Hardness: 90 // ------------------------------------------------------------------------ // Counter.Nested.Independent ************************************ 750 // [Up Counting] // [Down Counting] // 2 loops nested // UpUp - Update by 1 vs many - 2 constants for bounds, same constant for bounds, 2 variables for bounds both same // UpDown - Update by 1 vs many // DownUp - Update by 1 vs many // DownDown - Update by 1 vs many // Up X Up X update by 1 # 750 Counter.Nested.Independent > // {(){;;for( = ; < ; = + 1){<<;for( = ; <= ; = + 1){<<;}}}} - Till Fall 2007 {(){;;for( = ; <= ; = + 1){<<;for( = ; <= ; = + 1){<<;}}}} > Type: output Hardness: 80 # 751 Counter.Nested.Independent > {(){;;for( = ; < ; = + 1){<<;for( = ; <= ; = + 1){<<;}}}} > Type: output Hardness: 80 # 752 Counter.Nested.Independent > {(){;;=;for( = ; < ; = + 1){<<;for( = ; < ; = + 1){<<;}}}} > Type: output Hardness: 80 // Up X Up X Update by many # 753 Counter.Nested.Independent > {(){;;for( = ; < ; = + ){<<;for( = ; <= ; = + ){<<;}}}} > Type: output Hardness: 80 # 754 Counter.Nested.Independent > // {(){;;for( = ; < ; = + ){<<;for( = ; <= ; = + ){<<;}}}} - Till Fall 2007 {(){;;for( = ; <= ; = + ){<<;for( = ; <= ; = + ){<<;}}}} > Type: output Hardness: 80 # 755 Counter.Nested.Independent > {(){;;=;=;for( = ; < ; = + ){<<;for( = ; <= ; = + ){<<;}}}} > Type: output Hardness: 80 // Up X Down X update by 1 # 756 Counter.Nested.Independent > {(){;;for( = ; < ; = + 1){<<;for( = ; >= ; = - 1){<<;}}}} > Type: output Hardness: 80 # 757 Counter.Nested.Independent > {(){;;for( = ; < ; = + 1){<<;for( = ; >= ; = - 1){<<;}}}} > Type: output Hardness: 80 # 758 Counter.Nested.Independent > // {(){;;=;=;for( = ; < ; = + 1){<<;for( = ; >= ; = - 1){<<;}}}} - Till Fall 2007 {(){;;=;=;for( = ; <= ; = + 1){<<;for( = ; >= ; = - 1){<<;}}}} > Type: output Hardness: 80 // Up X Down X Update by many # 759 Counter.Nested.Independent > {(){;;for( = ; < ; = + ){<<;for( = ; >= ; = - ){<<;}}}} > Type: output Hardness: 80 # 760 Counter.Nested.Independent > // {(){;;for( = ; < ; = + ){<<;for( = ; >= ; = - ){<<;}}}} - Till Fall 2007 {(){;;for( = ; <= ; = + ){<<;for( = ; >= ; = - ){<<;}}}} > Type: output Hardness: 80 # 761 Counter.Nested.Independent > {(){=;=;=;;;for( = ; < ; = + ){<<;for( = ; >= ; = - ){<<;}}}} > Type: output Hardness: 80 // Down X Up X Update by 1 # 762 Counter.Nested.Independent > // {(){;;for( = ; > ; = - 1){<<;for( = ; <= ; = + 1){<<;}}}} - Till Fall 2007 {(){;;for( = ; >= ; = - 1){<<;for( = ; <= ; = + 1){<<;}}}} > Type: output Hardness: 80 # 763 Counter.Nested.Independent > {(){;;for( = ; > ; = - 1){<<;for( = ; <= ; = + 1){<<;}}}} > Type: output Hardness: 80 # 764 Counter.Nested.Independent > {(){;;=;=;for( = ; > ; = - 1){<<;for( = ; <= ; = + 1){<<;}}}} > Type: output Hardness: 80 // Down X Up X Update by many # 765 Counter.Nested.Independent > {(){=;;for( = ; > ; = - ){<<;for( = ; <= ; = + ){<<;}}}} > Type: output Hardness: 80 # 766 Counter.Nested.Independent > // {(){;;for( = ; > ; = - ){<<;for( = ; <= ; = + ){<<;}}}} - Till Fall 2007 {(){;;for( = ; >= ; = - ){<<;for( = ; <= ; = + ){<<;}}}} > Type: output Hardness: 80 # 767 Counter.Nested.Independent > {(){=;=;=;;;for( = ; > ; = - ){<<;for( = ; <= ; = + ){<<;}}}} > Type: output Hardness: 80 // Down X Down X Update by 1 # 768 Counter.Nested.Independent > {(){;;for( = ; > ; = - 1){<<;for( = ; >= ; = - 1){<<;}}}} > Type: output Hardness: 80 # 769 Counter.Nested.Independent > {(){;;for( = ; > ; = - 1){<<;for( = ; >= ; = - 1){<<;}}}} > Type: output Hardness: 80 # 770 Counter.Nested.Independent > // {(){;;=;=;for( = ; > ; = - 1){<<;for( = ; >= ; = - 1){<<;}}}} - Till Fall 2007 {(){;;=;=;for( = ; >= ; = - 1){<<;for( = ; >= ; = - 1){<<;}}}} > Type: output Hardness: 80 // Down X Down X Update by many # 771 Counter.Nested.Independent > {(){;;for( = ; > ; = - ){<<;for( = ; >= ; = - ){<<;}}}} > Type: output Hardness: 80 # 772 Counter.Nested.Independent > // {(){;;for( = ; > ; = - ){<<;for( = ; >= ; = - ){<<;}}}} - Till Fall 2007 {(){;;for( = ; >= ; = - ){<<;for( = ; >= ; = - ){<<;}}}} > Type: output Hardness: 80 # 773 Counter.Nested.Independent > {(){=;=;=;;;for( = ; > ; = - ){<<;for( = ; >= ; = - ){<<;}}}} > Type: output Hardness: 80 //3-levels # 774 Counter.Nested.Independent > {(){;;;for( = ; < ; = + 1){<<;for( = ; < ; = + 1){<<;for( = ; < ; = + 1){<<;}}}}} // {(){;;for( = ; < ; = + 1){;for( = ; < ; = + 1){for( = ; < ; = + 1){<<;<<;<<;}}}}} // Simplified for S08 > Type: output Hardness: 90 //3-levels # 775 Counter.Nested.Independent > {(){;;;for( = ; > ; = - 1){<<;for( = ; > ; = - 1){<<;for( = ; > ; = - 1){<<;}}}}} // {(){;;for( = ; > ; = - 1){;for( = ; > ; = - 1){for( = ; > ; = - 1){<<;<<;<<;}}}}} // Simplified for S08 > Type: output Hardness: 90 // ------------------ Parsons Puzzles -------------------------------------------------------- // DESIGN PRINCIPLES: // Simple counting exercises // Learning objectives: // Counter.Parsons.Single - 2000 // Counter.Parsons.Multiple.Independent - 2025 // Counter.Parsons.Multiple.Dependent - 2050 (TO DO) // Counter.Parsons.Nested.Independent - 2075 // Counter.Parsons.Nested.Dependent - 2100 (TO DO) // ------------------------------------------------------------------------ // Counter.Parsons.Single - 2000 // Instructions, Comments, Code OK - Test Distracters # 2000 Counter.Parsons.Single > "It reads a number, and prints all the numbers from 1 up to that number, e.g., if it reads 5, it prints 1,2,3,4,5." {(){ /* Declare */ ; /* Declare */ ; /* Read and print from 1 up to */ << "Enter the number up to which to count"; >> ; for( = 1; <= ; ++ ) { << ; } }} > Type: parsons Hardness: 10 // Instructions, Comments, Code OK - Test Distracters # 2001 Counter.Parsons.Single > "It reads a number, and prints all the numbers from that number down to 1, e.g., if it reads 5, it prints 5,4,3,2,1." {(){ /* Declare */ ; /* Declare */ ; /* Read and print from down to 1 */ << "Enter the number from which to count down"; >> ; for( = ; >= 1; -- ) { << ; } }} > Type: parsons Hardness: 10 // Instructions, Comments, Code OK - Test Distracters # 2002 Counter.Parsons.Single > "It reads a number, and prints all the odd numbers from 1 up to that number, e.g., if it reads 8, it prints 1,3,5,7." {(){ /* Declare */ ; /* Declare */ ; /* Read and print odd numbers from 1 up to */ << "Enter the number up to which to print odd numbers"; >> ; for( = 1; <= ; += 2 ) { << ; } }} > Type: parsons Hardness: 20 // Instructions, Comments, Code OK - Test Distracters # 2003 Counter.Parsons.Single > "It reads a number, and prints every third number from that number down to 1, e.g., if it reads 10, it prints 10,7,3,1." {(){ /* Declare */ ; /* Declare */ ; /* Read and print every third number from down to 1 */ << "Enter the number down from which to print every third number"; >> ; for( = ; >= 1; -= 3 ) { << ; } }} > Type: parsons Hardness: 20 // // THIS IS INCORRECT! FIX IT!! // # 2004 // Counter.Parsons.Single // > // "It reads a number, repeatedly divides it by 2 and prints it, e.g., if it reads 13, it prints 6,3,1,0." // {(){ // /* Declare */ // ; // /* Declare */ // ; // /* Read and print after repeatedly dividing it by 2 */ // << "Enter the number that should be printed repeatedly divided by 2"; // >> ; // for( = ; >= 0; /= 2 ) // { // << ; // } // }} // > // Type: parsons // Hardness: 30 // Instrn, Comments, Code - OK; Test Distracters // DemoParsons // Reads a number, calculates it factorial and prints it # 2010 Counter.Parsons.Single > "It reads a number, calculates its factorial and prints it, e.g., if it reads 4, it prints 24, which is the product of 4,3,2 and 1." {(){ /* Declare */ ; /* Declare */ ; /* Declare */ ; /* Read */ << "Enter the number whose factorial is desired"; >> ; /* Compute factorial of in and print it*/ = 1; for( = 1; <= ; ++ ) { = * ; } << "Factorial of " << << " is " << ; }} > Type: parsons Hardness: 20 // Instrn, Comments, Code - OK; Test Distracters // pretest // Read TWO numbers, calculates the sum of all the numbers between them and print it # 2011 Counter.Parsons.Single > "It reads two numbers, calculates the sum of all the numbers between the two and prints it, e.g., if it reads 4 and 7, it prints 22, which is the sum of 4,5,6 and 7." {(){ /* Declare */ ; /* Declare */ ; /* Declare */ ; /* Declare */ ; /* Read */ << "Enter the strating number"; >> ; /* Read */ << "Enter the ending number"; >> ; /* Compute the sum of through in and print it*/ = 0; for( = ; <= ; ++ ) { = + ; } << "The sum of " << << " through " << << " is " << ; }} > Type: parsons Hardness: 30 // Instrn, Comments, Code - OK; Test Distracters // posttest # 2012 Counter.Parsons.Single > "It reads a base number and a power, calculates the base raised to the power and prints it, e.g., if it reads 3 as base number and 2 as power, it prints 9, which is 3 squared." {(){ /* Declare */ ; /* Declare */ ; /* Declare */ ; /* Declare */ ; /* Read */ << "Enter the base number"; >> ; /* Read */ << "Enter the power"; >> ; /* Compute raised to in and print it */ = 1; for( = 1; <= ; ++ ) { = * ; } << << " raised to " << << " is " << ; }} > Type: parsons Hardness: 30 // Instrn, Comments, Code - OK; Test Distracters # 2013 Counter.Parsons.Single > "It reads a number n, computes nth Fibonacci number and prints it. The first two Fibonacci numbers are 1 and 1. Each subsequent Fibonacci number is the sum of the previous two Fibonacci numbers, e.g., 3rd number is 2 (1+1), 4th number is 3 (1+2) and 5th number is 5 (2+3)." {(){ /* Declare */ ; /* Declare */ ; /* Declare */ ; /* Declare */ ; /* Declare */ ; /* Read */ << "Enter the Fibonacci number desired"; >> ; /* Compute -th Fibonacci number in and print it */ = 1; = 1; for( = 3; <= ; ++ ) { = + ; = ; = ; } << "Fibonacci number " << << " is " << ; }} > Type: parsons Hardness: 30 // Instrn, Comments, Code - OK; Test Distracters // Read a week's temperatures, calculate average and print it # 2014 Counter.Parsons.Single > "It reads the number of days, reads daily temperatures for those many days, calculates the average temperature and prints it." {(){ /* Declare */ ; /* Declare */ ; /* Declare */ ; /* Declare */ ; /* Read */ << "Enter the number of days"; >> ; /* Read temperatures for all days, calculate average temperature and print it */ = 0; for( = 1; <= ; ++ ) { << "Enter the temperature for day " << ; >> ; = + ; } << "Average temperature of " << << " days is " << / ; }} > Type: parsons Hardness: 20 // Instrn, Comments, Code - OK; Test Distracters // Conversion from a different base to base 10 # 2015 Counter.Parsons.Single > "It converts a number from a given base to decimal, e.g., 110 in base 2 is 6 in decimal. It first reads the base (e.g., 2) and the number of digits in the number (110 has 3). Then, it reads the number (110) one digit at a time, converts it to decimal (6) and prints it." {(){ /* Declare */ ; /* Declare */ ; /* Declare */ ; /* Declare */ ; /* Declare */ ; /* Read */ << "Enter the base"; >> ; /* Read */ << "Enter the number of digits in the number"; >> ; /* Read the number one digit at a time, convert it to decimal and print it */ = 0; for( = 1; <= ; ++ ) { << "Enter the next digit in the number"; >> ; = * + ; } << "The number you entered in base " << << " is " << ; }} > Type: parsons Hardness: 20 // Could do conversion from decimal to another base, but the digits would be in reverse order. // Weighted sum? // weighted average : sigma wx / sigma x // calculation of pi = 4/1 - 4/3 + 4/5 - 4/7 + 4/9 - ... // calculation of e = 1/1 + 1/1 + 1/2 + 1/6 + 1/24 + 1/120 + ... // SImilarly, e^x // ------------------------------------------------------------------------ // Counter.Parsons.Multiple.Independent - 2025 // ------------------------------------------------------------------------ // Counter.Parsons.Multiple.Dependent - 2050 (TO DO) // DESIGN: Use accumulator of inputs as counter? // Reads a number, prints that many odd numbers from 1 up, followed by even numbers back down to 0. // TO DO All odds followed by all evens // TO DO 10th power followed by 12th power? // Instrn, Comments, Code - OK; Test Distracters # 2050 Counter.Parsons.Multiple.Dependent > "It reads a number, and prints all the numbers from 1 up to that number, followed by all the numbers back down to 1, e.g., if it reads 4, it prints 1,2,3,4,3,2,1." {(){ /* Declare */ ; /* Declare */ ; /* Read and print from 1 up to and back down to 1 */ << "Enter the number up to which to count"; >> ; for( = 1; < ; ++ ) { << ; } << ; for( = - 1; >= 1; -- ) { << ; } }} > Type: parsons Hardness: 10 // Instrn, Comments, Code - OK; Test Distracters # 2051 Counter.Parsons.Multiple.Dependent > "It reads a number, and prints all the numbers from that number down to 1, followed by all the numbers back up to that number, e.g., if it reads 4, it prints 4,3,2,1,2,3,4." {(){ /* Declare */ ; /* Declare */ ; /* Read and print from down to 1 and back up to */ << "Enter the number from which to count"; >> ; for( = ; > 1; -- ) { << ; } << ; for( = + 1; <= ; ++ ) { << ; } }} > Type: parsons Hardness: 10 // Instrn, Comments, Code - OK; Test Distracters // Calculate m^n / n^m for 2 whole real numbers m and n # 2055 Counter.Parsons.Multiple.Dependent > "It reads two real numbers m and n, calculates and prints m^n / n^m, where m^n means m raised to the power n, e.g., 5 raised to the power 2 is 25. So, if it reads 2 and 5, it calculates 2^5 / 5^2, i.e., 32 / 25 and prints it." {(){ /* Declare */ ; /* Declare */ ; /* Declare */ ; /* Declare */ ; /* Read */ << "Enter the first number"; >> ; /* Read */ << "Enter the second number"; >> ; /* Compute and print raised to / raised to */ = 1; for( = 1; <= ; ++ ) { = * ; } for( = 1; <= ; ++ ) { = / ; } << ; }} > Type: parsons Hardness: 20 // DemoParsons // Instrn, Comments, Code - OK; Test Distracters // n choose k = (n * n-1 * ... * n - k + 1)/ k! # 2056 Counter.Parsons.Multiple.Dependent > "It reads two integers n and k, and computes and prints the number of ways k items can be chosen from among n items, given by n * (n - 1) * ... * (n - k + 1 ) / k!, where k! = k * (k - 1) * ... * 1." {(){ /* Declare */ ; /* Declare */ ; /* Declare */ ; /* Declare */ ; /* Read */ << "Enter the total number of items available"; >> ; /* Read */ << "Enter the number of items to be selected"; >> ; /* Compute ways to choose items out of in and print it */ = 1; for( = ; >= - + 1; -- ) { = * ; } for( = 2; <= ; ++ ) { = / ; } << ; }} > Type: parsons Hardness: 20 // Instrn, Comments, Code - OK; Test Distracters // e^x is Sigma 0->Inf x^n / n! We calculate one term # 2057 Counter.Parsons.Multiple.Dependent > "It reads a real number x and an integer n, and computes and prints x^n / n!, where x^n is x raised to the power n and n! is n factorial, i.e., n * (n - 1) *...* 1. x^n / n! is one term used in the calculation of e^x." {(){ /* Declare */ ; /* Declare */ ; /* Declare */ ; /* Declare */ ; /* Read */ << "Enter the real number"; >> ; /* Read */ << "Enter the integer number"; >> ; /* Compute raised to / ! in and print it */ = 1; for( = 1; <= ; ++ ) { = * ; } for( = 2; <= ; ++ ) { = / ; } << ; }} > Type: parsons Hardness: 20 // Pretest // Instrn, Comments, Code - OK; Test Distracters // read income for 12 months followed by expenses # 2060 Counter.Parsons.Multiple.Dependent > "It reads the monthly income for a year, prints their sum, reads the monthly expenses for the year, and prints money left over after expenses." {(){ /* Declare */ ; /* Declare */ ; /* Declare */ ; /* Read monthly income into , print sum in */ = 0; for( = 1; <= 12; ++ ) { << "Please enter the income for month " << ; >> ; = + ; } << "Sum of monthly income is $ " << ; /* Read monthly expenses into , print balance in after expenses */ for( = 1; <= 12; ++ ) { << "Please enter the expenses for month " << ; >> ; = - ; } << "Balance after expenses is $ " << ; }} > Type: parsons Hardness: 15 // Posttest // Instrn, Comments, Code - OK; Test Distracters // read for a week for a basket of 30 stocks - appreciation percentage.. sum followed by appreciation # 2061 Counter.Parsons.Multiple.Dependent > "It reads the price of 30 stocks in Dow Jones index and calculates their average. It then reads the percentage change in the average each day for a week and prints the value of the average at the end of the week." {(){ /* Declare */ ; /* Declare */ ; /* Declare */ ; /* Declare */ ; /* Declare */ ; /* Read price of 30 stocks into , calculate their average in */ = 0; for( = 1; <= 30; ++ ) { << "Please enter the price of the next stock"; >> ; = + ; } = / 30; /* Read daily percentage change in . Print at the end of the week. */ for( = 1; <= 7; ++ ) { << "Please enter the percentage change for day " << ; >> ; = + * ; } << "Value of 30 stocks at the end of the week is $ " << ; }} > Type: parsons Hardness: 15 // Instrn, Comments, Code - OK; Test Distracters // Calculate the average of the monthly temperatures of the first year, and then // calculate the variance of the monthly temperatures of the next year # 2062 Counter.Parsons.Multiple.Dependent > "It reads the daily temperature for a week, calculates the average temperature of the week. It reads the daily temperature of the next week and calculates and prints its variance from the average of the first week." {(){ /* Declare */ ; /* Declare */ ; /* Declare */ ; /* Declare */ ; /* Declare */ ; /* Read daily temperature into , calculate its average in */ = 0; for( = 1; <= 7; ++ ) { << "Please enter the temperature on week 1, day " << ; >> ; = + ; } = / 7.0; /* Read next week's daily temperature into , calculate its variance in and print it */ = 0; for( = 1; <= 7; ++ ) { << "Please enter the temperature on week 2, day " << ; >> ; = + ( - ) * ( - ) ; } = / 6; << "Variance of second week temperatures is " << ; }} > Type: parsons Hardness: 15 // Used to test single character variable name effectiveness, same as 2060 // read income for 12 months followed by expenses # 2073 Counter.Parsons.Multiple.Dependent > "It reads the monthly income for a year, prints their sum, reads the monthly expenses for the year, and prints money left over after expenses." {(){ /* Declare */ ; /* Declare */ ; /* Declare */ ; /* Read monthly income into , print sum in */ = 0; for( = 1; <= 12; ++ ) { << "Please enter the income for month " << ; >> ; = + ; } << "Sum of monthly income is $ " << ; /* Read monthly expenses into , print balance in after expenses */ for( = 1; <= 12; ++ ) { << "Please enter the expenses for month " << ; >> ; = - ; } << "Balance after expenses is $ " << ; }} > Type: parsons Hardness: 15 // Used to test single character variable name effectiveness, same as 2050 # 2074 Counter.Parsons.Multiple.Dependent > "It reads a number, and prints all the numbers from 1 up to that number, followed by all the numbers back down to 1, e.g., if it reads 4, it prints 1,2,3,4,3,2,1." {(){ /* Declare */ ; /* Declare */ ; /* Read and print from 1 up to and back down to 1 */ << "Enter the number up to which to count"; >> ; for( = 1; < ; ++ ) { << ; } << ; for( = - 1; >= 1; -- ) { << ; } }} > Type: parsons Hardness: 10 // ------------------------------------------------------------------------ // Counter.Parsons.Nested.Independent - 2075 // print multiplication table // draw a rectangle // ------------------------------------------------------------------------ // Counter.Parsons.Nested.Dependent - 2100 // For m < n, m > n // TO DO for m..n, count up from 1 // TO DO for m..n, count up from m-n // TO DO for m..n, count down from m to 1 // TO DO for m..n, count down from n to m // TO DO for m..n, print m m times, m+1 m+1 times, and so on. // draw triangle - upside down - need endl // draw triangle - right side up - need endl // Instrn, Comments, Code - OK; Test Distracters // DemoParsons // up-up # 2100 Counter.Parsons.Nested.Dependent > "It reads a number, and prints all the numbers from 1 up to that number in the following fashion: 1 once, 2 twice, 3 three times and so on, e.g., if it reads 3, it prints 1,2,2,3,3,3." {(){ /* Declare */ ; /* Declare */ ; /* Declare */ ; /* Read , print 1 once, up to times */ << "Enter the number up to which to count"; >> ; for( = 1; <= ; ++ ) { for( = 1; <= ; ++ ) { << ; } } }} > Type: parsons Hardness: 10 // Instrn, Comments, Code - OK; Test Distracters // down-up # 2101 Counter.Parsons.Nested.Dependent > "It reads a number, say n, and prints all the numbers from 1 up to n, n-1, n-2 and so on till 1, e.g., if it reads 4, it prints 1,2,3,4,1,2,3,1,2,1." {(){ /* Declare */ ; /* Declare */ ; /* Declare */ ; /* Read , Count up to , - 1 and so on */ << "Enter the starting number up to which to count"; >> ; for( = ; >= 1; -- ) { for( = 1; <= ; ++ ) { << ; } } }} > Type: parsons Hardness: 10 // Instrn, Comments, Code - OK; Test Distracters // pretest // down-up # 2102 Counter.Parsons.Nested.Dependent > "It reads a number, say n, and for each number from n down to 1, it prints all its multiples up to its square, e.g., if it reads 4, it prints 4,8,12,16,3,6,9,2,4,1." {(){ /* Declare */ ; /* Declare */ ; /* Declare */ ; /* Read , Print all multiples up to its square for down to 1 */ << "Enter the starting number whose multiples must be printed"; >> ; for( = ; >= 1; -- ) { for( = 1; <= ; ++ ) { << * ; } } }} > Type: parsons Hardness: 10 // Instrn, Comments, Code - OK; Test Distracters // down-up # 2103 Counter.Parsons.Nested.Dependent > "It reads a number, say n, and prints all the numbers from n down to 1, following each number with as many zeroes, e.g., if it reads 3, it prints 3,0,0,0,2,0,0,1,0." {(){ /* Declare */ ; /* Declare */ ; /* Declare */ ; /* Read , Print down to 1, each followed by as many zeroes */ << "Enter the number from which to count down"; >> ; for( = ; >= 1; -- ) { << ; for( = 1; <= ; ++ ) { << 0; } } }} > Type: parsons Hardness: 10 // Instrn, Comments, Code - OK; Test Distracters // up-down # 2104 Counter.Parsons.Nested.Dependent > "It reads a number, say n, and prints all the numbers from 1 up to n in the following fashion: 1 n-times, 2 n-1 times, 3 n-2 times, and so on till it prints n once, e.g., if it reads 3, it prints 1,1,1,2,2,3." {(){ /* Declare */ ; /* Declare */ ; /* Declare */ ; /* Read , print 1 times down to once */ << "Enter the number up to which to count"; >> ; for( = 1; <= ; ++ ) { for( = ; >= ; -- ) { << ; } } }} > Type: parsons Hardness: 10 // Instrn, Comments, Code - OK; Test Distracters // down-down # 2105 Counter.Parsons.Nested.Dependent > "It reads a number, say n, and prints all the numbers down to 1 from n, n-1, n-2 and so on, e.g., if it reads 4, it prints 4,3,2,1,3,2,1,2,1,1." {(){ /* Declare */ ; /* Declare */ ; /* Declare */ ; /* Read , Count down from , - 1 and so on */ << "Enter the starting number from which to count down"; >> ; for( = ; >= 1; -- ) { for( = ; >= 1; -- ) { << ; } } }} > Type: parsons Hardness: 10 // Instrn, Comments, Code - OK; Test Distracters // posttest // up-up # 2106 Counter.Parsons.Nested.Dependent > "It reads a number, say n, and for each number from 1 up to n, it prints all its multiples up to its square, e.g., if it reads 4, it prints 1,2,4,3,6,9,4,8,12,16." {(){ /* Declare */ ; /* Declare */ ; /* Declare */ ; /* Read , Print all multiples up to its square for 1 up to */ << "Enter the last number whose multiples must be printed"; >> ; for( = 1; <= ; ++ ) { for( = 1; <= ; ++ ) { << * ; } } }} > Type: parsons Hardness: 10 // Used to test effectiveness of single character variables, same as 2104 # 2124 Counter.Parsons.Nested.Dependent > "It reads a number, say n, and prints all the numbers from 1 up to n in the following fashion: 1 n-times, 2 n-1 times, 3 n-2 times, and so on till it prints n once, e.g., if it reads 3, it prints 1,1,1,2,2,3." {(){ /* Declare */ ; /* Declare */ ; /* Declare */ ; /* Read , print 1 times down to once */ << "Enter the number up to which to count"; >> ; for( = 1; <= ; ++ ) { for( = ; >= ; -- ) { << ; } } }} > Type: parsons Hardness: 10 // -------------------------------------------------------------------------- // Templates here are for demonstration purposes // Included at the end so that regular practice does not pick up these templates // How to enter 2 outputs # 90 Demonstration > {(){=;<<;=;<<;<< - ;}} > Type: output Hardness: 10 // How to enter multiple outputs from the same line # 91 Demonstration > {(){;for( = 1; <= 2; = + 1){<<;}}} > Type: output Hardness: 10 // How to enter multiple outputs from alternate lines # 92 Demonstration > {(){;; = 5;for( = 1; <= 2; = + 1){<<;<<;}}} > Type: output Hardness: 10 // --------------------------------------------------------------------------