Assignment 1: Snap, Crackle, Pop!

Due: Friday, Jan 24, 2025

Note

This problem is based on FizzBuzz, a children’s game, a drinking game, and a basic test for programming competence.

Description

In Grasshopper, create a Python3 script node that has two integer inputs (start and end) and three integer outputs (num_snap, num_crackle, and num_pop). Connect an integer slider to start, and another to end, and panels to out and the three num_xxx outputs.

Inside the script node, write Python code that will print() out each number from start (inclusive) to end (exclusive). However:

  • For numbers that are multiples of 3, instead print “Snap”.

  • For numbers that are multiples of 5, instead print “Crackle”.

  • For numbers that are multiples of 7, instead print “Pop”.

  • For numbers that are multiples of a combination of 3, 5, or 7, instead print “SnapCrackle” (3 and 5), “SnapPop” (3 and 7), “CracklePop” (5 and 7), or “SnapCracklePop” (3, 5, and 7).

Additionally, define num_snap to be the number of times that “Snap” appeared in a print statement, num_crackle to be the number of times that “Crackle” appeared, and num_pop to be the number to times that “Pop” appeared.

Edge Cases

  • If start is greater than or equal to end, nothing should print, and the output variables should be set to 0.

  • If “Snap”, “Crackle”, or “Pop” are never printed, their corresponding num_xxx outputs should be set to 0.

  • start and end can be negative numbers.

Examples

Inputs: start = 97, end = 122

out panel:

 097
 1Pop
 2Snap
 3Crackle
 4101
 5Snap
 6103
 7104
 8SnapCracklePop
 9106
10107
11Snap
12109
13Crackle
14Snap
15Pop
16113
17Snap
18Crackle
19116
20Snap
21118
22Pop
23SnapCrackle
24121

Outputs: num_snap = 8, num_crackle = 5, num_pop = 4

Example 2

Inputs: start = 11, end = 15

out panel:

011
1Snap
213
3Pop

Outputs: num_snap = 1, num_crackle = 0, num_pop = 1

Example 3

Inputs: start = -40, end = 6

out panel:

 0Crackle
 1Snap
 2-38
 3-37
 4Snap
 5CracklePop
 6-34
 7Snap
 8-32
 9-31
10SnapCrackle
11-29
12Pop
13Snap
14-26
15Crackle
16Snap
17-23
18-22
19SnapPop
20Crackle
21-19
22Snap
23-17
24-16
25SnapCrackle
26Pop
27-13
28Snap
29-11
30Crackle
31Snap
32-8
33Pop
34Snap
35Crackle
36-4
37Snap
38-2
39-1
40SnapCracklePop
411
422
43Snap
444
45Crackle

Outputs: num_snap = 15, num_crackle = 10, num_pop = 6

Example 4

Inputs: start = 10, end = 0

out panel is empty.

Outputs: num_snap = 0, num_crackle = 0, num_pop = 0

Example 5

Inputs: start = 20, end = 20

out panel is empty.

Outputs: num_snap = 0, num_crackle = 0, num_pop = 0

Rubric

Your grade for this assignment is determined by adding points for each milestone you complete:

Points

Requirements

25

Create a Python3 Script node with 2 integer inputs and 3 integer outputs (not including out)
-2 points for each input/output not marked as integers (up to -10)

15

out contains a correct printed output

15

num_snap contains the number of numbers from start (inclusive) to end (exclusive) that are divisible by 3

15

num_crackle contains the number of numbers from start (inclusive) to end (exclusive) that are divisible by 5

15

num_pop contains the number of numbers from start (inclusive) to end (exclusive) that are divisible by 7

15

All edge cases (specified above) are accounted for (-5 points for each one missed)

Important

Missing an edge case will not affect your score for prior rubric items.

Correctness is very important in this assignment because of how straightforward the problem is. Although there is no correct way to program a solution, there is only one correct solution output. I will try to be as generous as possible with partial credit, but there’s only so much I can do here.