Worked example · Expressive Arts · Year 4

Coding a pixel art Welsh dragon

DCF: Data and computational thinking → Problem-solving and modelling

What this is

A secure Year 4 response, annotated so you can see which success criterion each part meets. It is also the answer key. Key answers: every row makes 12; red 47, white 61, green 12, total 120 and 12 × 10 = 120; bugs: row 3 2G should be 2R, row 5 4W should be 3W, row 8 3W should be 4W.

Step 1: check the code

RowCodeTotal (must be 12)
19W 2R 1W9 + 2 + 1 = 12
28W 4R8 + 4 = 12
38W 1R 1W 2R8 + 1 + 1 + 2 = 12
43W 1R 3W 5R3 + 1 + 3 + 5 = 12
52W 3R 1W 3R 3W2 + 3 + 1 + 3 + 3 = 12
61R 1W 7R 3W1 + 1 + 7 + 3 = 12
79R 3W9 + 3 = 12
81W 7R 4W1 + 7 + 4 = 12
92W 1R 4W 1R 4W2 + 1 + 4 + 1 + 4 = 12
1012G12 = 12

Every total is shown as a number sentence, not just written as 12. Evidences criterion 2.

Step 2: the finished dragon

12345678910

The dragon faces right with its eye in row 3 (the white square), a wing on its back, a tail at the left and grass along the bottom. Each row matches its code exactly. Evidences criterion 1.

Step 3: count the pixels

ColourHow many?How I worked it out
Red47Red in each row: 2 + 4 + 3 + 6 + 6 + 8 + 9 + 7 + 2 = 47
White61White in each row: 10 + 8 + 9 + 6 + 6 + 4 + 3 + 5 + 10 = 61
Green12Row 10 is 12G
All squares12047 + 61 + 12 = 120

Check: 12 × 10 = 120. It matches, so I have not missed any squares.

Another way to find white: 120 − 47 − 12 = 61.

Adds the counts row by row and uses multiplication by 10 as a check. A total that is not 120 tells the pupil to recount. Evidences criterion 3.

Step 4: bug hunt

RowGruff’s codeTotalFixed code
38W 1R 1W 2G8 + 1 + 1 + 2 = 128W 1R 1W 2R
52W 3R 1W 3R 4W2 + 3 + 1 + 3 + 4 = 132W 3R 1W 3R 3W
81W 7R 3W1 + 7 + 3 = 111W 7R 4W

Adding up did not find the bug in row 3, because 8 + 1 + 1 + 2 still makes 12. I found it by comparing with the picture: the dragon’s nose is red, not green. You have to test the picture as well as check the numbers.

Uses the total to find two bugs and testing the output to find the third. Evidences criteria 2 and 4.

Step 5: use a loop

RowLoopNumber sentence
(a) repeat 6 times [1R 1W]6 × 2 = 12
(b) repeat 3 times [3G 1W]3 × 4 = 12
(c) repeat 3 times [2R 2W]3 × 4 = 12
(d) own looprepeat 2 times [4G 2W]2 × 6 = 12

Each loop repeats a group that fits into 12 exactly, and the number sentence proves it. Other correct answers for (d): repeat 12 times [1G], repeat 4 times [1R 2W], repeat 3 times [2G 1R 1W]. Evidences criteria 2 and 5.

Step 6: own pixel art (one example)

123456

A tulip in red and green. Code: row 1 5W 2R 5W, row 2 4W 4R 4W, row 3 5W 2R 5W, row 4 6W 1G 5W, row 5 2W 2G 2W 1G 5W, row 6 4W 7G 1W. Every row makes 12. My partner drew it correctly first time.

The code is complete for every row and each row is checked. Testing it with a partner is how programmers test code. Evidences criteria 1 and 2.

If you finish early: answer

Row 7, 9R 3W, cannot be a loop that repeats the same group, because 9 red and 3 white do not make a pattern that repeats. It is already as short as it can be.

Why this response is secure