esolang
Learn · LessonsLesson 14 of 18

Lesson 14

Loops and choices in the kernel

The kernel steers a program three ways. A loop that counts, a choice, and a loop that runs until a condition is true.

The lesson

n TIMES ... END runs its body n times, and I is the loop counter. cond IF ... ELSE ... THEN chooses. BEGIN ... cond UNTIL repeats until the condition is true.

LT, EQ and NOT make conditions, 1 or 0. LEFT is how many input bytes are left.

The kernel reference in the Docs lists every instruction. The example's Step button runs it in the Studio one instruction at a time.

Example

Output


Exercise 1

Print the lowercase alphabet abc...z.

Run tries your program on the input below. Check runs it on every test.

The tests it must pass
InputExpected output
(empty)abcdefghijklmnopqrstuvwxyz

Output


A hint

a is 97; I counts from 0.

One answer

Answer: Print the lowercase alphabet abc...z.

Expected output

abcdefghijklmnopqrstuvwxyz
The tests it must pass
InputExpected output
(empty)abcdefghijklmnopqrstuvwxyz

Output


Exercise 2

Print the input with every lowercase letter in uppercase.

Run tries your program on the input below. Check runs it on every test.

The tests they must pass
InputExpected output
hello worldHELLO WORLD
Shibboleth 3SHIBBOLETH 3
abc-XYZABC-XYZ
a`z{@A`Z{@

Output


A hint

For each byte, test whether it is at least 97 and below 123. Multiply the two tests for "and".

One answer

Answer: Print the input with every lowercase letter in uppercase.

Expected output

HELLO WORLD
The tests they must pass
InputExpected output
hello worldHELLO WORLD
Shibboleth 3SHIBBOLETH 3
abc-XYZABC-XYZ
a`z{@A`Z{@

Output


Read more