UltraKarel
Paint by Numbers
You are using CodeHS with no account. To save your code, you can log in or sign up for an account and continue working on this program.
Switch to Code View
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
Commands
Control flow
Functions
Conditions
Comments
Paint
var colors = [Color.RED, Color.ORANGE, Color.YELLOW, Color.GREEN, Color.BLUE, Color.PURPLE];
function start() {
while (leftIsClear()) {
paintRow();
moveUp();
}
paintRow();
}
function paintRow() {
while(frontIsClear()) {
paintSquare();
move();
}
paintSquare();
}
function paintSquare() {
var color = 0;
while(ballsPresent()) {
takeBall();
color++;
}
paint(colors[color]);
}
function moveUp() {
turnAround();
while (frontIsClear()) {
move();
}
turnRight();
move();
turnRight();
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX