2022

From Esolang
Jump to navigation Jump to search

2022 is a string-rewriting esolang by User:BoundedBeans. It is not a derivative of 2014. 2022 is different from other string-rewriting esolangs in that it only has one rewriting rule, but what varies is where that rule is applied. The rule is that 2 is replaced with 2022.

Syntax

The first line of any 2022 program is the initial state, made only out of 2's and 0's

All subsequent lines follow one of a few formats, inspired by SMETANA:

Step (n): Go to Step (o).
Step (n): Swap Step (o) and Step (p).
Step (n): Replace "2" (q) with "2022".
Step (n): Remove "0" (q).
Step (n): Destroy characters (q)-(r).
Step (n): Increment argument (s) in Step (o).
Step (n): Decrement argument (s) in Step (o).
Step (n): Replace argument (s) in Step (o) with user input.
Step (n): Output argument (s) in Step (o) as a number.
Step (n): Output argument (s) in Step (o) as a character.
Step (n): Replace argument (s) in Step (o) by the number of 2's in range (q)-(r).
Step (n): Print the string.
Comment: (whatever)

Negative values for q go from the right, and value 0 or out of range values do nothing.

The program always starts from Step 1, but Step 0 can be used for testing if zero.

An example of a program:

202002
Step 1: Replace "2" 3 with "2022".
Step 2: Remove "0" 4.
Step 3: Go to Step 1.

Here's how the string evolves:

202002
202002022
20200222
20200202222
2020022222
2020020222222

Here's a self-modifying program:

0020
Step 1: Replace "2" 1 with "2022".
Step 2: Replace "2" 2 with "2022"
Step 3: Increment argument 1 in Step 1
Step 4: Go to Step 1

Here's how the string evolves: 5

0020
0020220
0020202220
0020202202220
0020202202202220
0020202022202202220
0020202202022202202220
0020202202202022202202220
0020202202022202022202202220
0020202202202022202022202202220
0020202202202202022202022202202220
0020202202202022202022202022202202220
0020202202202202022202022202022202202220
0020202202202202202022202022202022202202220
0020202202202202202202022202022202022202202220
0020202202202202022202202022202022202022202202220
0020202202202202202022202202022202022202022202202220
0020202202202202202202022202202022202022202022202202220
0020202202202202202202202022202202022202022202022202202220
0020202202202202202022202202022202202022202022202022202202220
0020202202202202202202022202202022202202022202022202022202202220
0020202202202202202202202022202202022202202022202022202022202202220

It appears to be creating some sort of sequence on the right, starting with 3, 2, 3, 1, 3, 1, 3, 1, 2, 3, 1, 2, 3, 1 (if I didn't make any mistakes).

Addition program without using the string (if the sum is more than 24 it breaks):

0
Step 0: Go to Step 31.
Step 1: Go to Step 27.
Step 2: Go to Step 27.
Step 3: Go to Step 27.
Step 4: Go to Step 27.
Step 5: Go to Step 27.
Step 6: Go to Step 27.
Step 7: Go to Step 27.
Step 8: Go to Step 27.
Step 9: Go to Step 27.
Step 10: Go to Step 27.
Step 11: Go to Step 27.
Step 12: Go to Step 27.
Step 13: Go to Step 27.
Step 14: Go to Step 27.
Step 15: Go to Step 27.
Step 16: Go to Step 27.
Step 17: Go to Step 27.
Step 18: Go to Step 27.
Step 19: Go to Step 27.
Step 20: Go to Step 27.
Step 21: Go to Step 27.
Step 22: Go to Step 27.
Step 23: Go to Step 27.
Step 24: Go to Step 27.
Step 25: Replace argument 1 in Step 29 with user input.
Step 26: Replace argument 1 in Step 30 with user input.
Step 27: Decrement argument 1 in Step 29.
Step 28: Increment argument 1 in Step 30.
Step 29: Go to Step 0.
Step 30: Go to Step 0.
Step 31: Output argument 1 of Step 30 as a number.