split by
letter to turn their message string into a list of characters. Of course, since they don’t know how to process lists yet, the next things that they did were all over the place. Some worked in an ugly way; some didn’t work at all; all were probably just what we’d rather not see. One, however, was so perfectly structured except for the actual encoding of each item of the list that I showed the boy map
as the solution to the one missing step. He got it and used it correctly, but we won’t know until we see him apply it elsewhere whether he’s got the idea. I don’t think anyone peeled off a character, found its unicode, processed that, turned it back to a letter, and then pasted it back into a growing string. Without lists, that would seem the "obvious" thing to do. With lists in a real way, they’d split, map a process, and combine. In their odd interim state—where did they get the idea to split?—it didn’t feel coherent at all."Open a new file.
You have a choice. Some of the problems below are about language or linguistics, some are about mathematics, and some are about art. Choose any three that interest you and do them.
clear
the stage and try ."Tableau 1" by Piet Mondrian
Mondrian wasn't at all random in his choice of colors and locations, but even some random choices can be interesting. A snap script can produce designs like these.
fill
block, you can find that version here. Although, some people have found the way that block works to be frustrating for this project. fill with random color
block is: set pen shade to 100
. You can get a good collection of colors with:
for
, length of
, letter of
, join
, the unicode
blocks.
encode
that takes a word as input, changes each letter into the next letter in the alphabet—for example, A becomes B, Y becomes Z...—and reports the result, like this: .
encode
adds 1 to the unicode for each letter. You could, instead, add 2 or 5 or.... Give encode
a second variable that lets you specify what to add to the unicode.encode
the input z
, what does it report? If that's not what you would like it to report, change it. decode
block.factorial
block (or ) that takes a positive integer n and reports the product of all whole numbers from 1 through n, in other words 1 × 2 × 3 × ... × (n - 1) × n. When the input is 4, the output should be 24 (because 1 × 2 × 3 × 4 = 24).
n!
block to report 1 if n = 0. Then fully test n!
again to make sure it works as it should. triangular number n
that adds all of the whole numbers from 1 through n:1 + 2 + 3 + \cdots + (n - 1) + n When its input is 4, your block should report 10 (that is, 1 + 2 + 3 + 4). Define your block so that triangular number 0
reports 0. n mod i
will tell you if i is a divisor of n.number-of-divisors 10
should also report 4 because, of the numbers from 1 through 10, only 1, 2, 5, and 10 are divisors of 10. Experiment to find several numbers that have an odd number of divisors.
Edit it and give it inputs that let you produce pictures like these. You don't have to use script variables.
Experiment with various inputs.
Set "flat line ends" and create a block that draws pictures like this. It will be convenient to use script variables
raise (n) to the power (b)
block to make it work for negative integer exponents. digit sum
that adds up the digits in a number. So, for example digit sum 7
should report 7, and digit sum 12
should report 3, and digit sum 126
should report 9 (the sum of 1, 2 and 6). You may find these blocks useful. repeated digit sum
, which keeps taking the digit sum
until the result is a single digit. For example, the digit sum of 238 is 2+3+8=13, which is more than a single digit. The digit sum of 13 is 1+3=4, which is a single digit. So the repeated digit sum of 238 is 4.divisible by 3?
and divisible by 9?
. A number is divisible by 3 if its repeated digit sum is 0, 3, 6, or 9; it's divisible by 9 if its digit sum is 0 or 9.
multiples of 7 algorithm
block that takes any whole number as input and then puts it through this process:
Test it first on several multiples of 7 (small and large) and make sure that, for multiples of 7, it reports only the results 14, 7, 0, -7, and -14. Also test it on several numbers that are not multiples of 7; for those numbers, it should never report 14, 7, 0, -7, or -14.
mod
, but before computers were widespread, algorithms like these greatly simplified some computations.