**A=B** is a game where you write programs in an esolang called a=b. There are only two instructions and a way programs are executed. Each program takes in an input string, which I'll call `string`. - `string1=string2` - When this command is executed, **if** there is an instance of the string `string1` in `string`, then the leftmost occurrence of `string1` will be replaced with `string2`. Otherwise, the interpreter will skip the command. - `string1=(return)string2` - When this command is executed, **if** an instance of the string `string1` is in `string`, then the program will set `string` to the value of `string2`, terminate, and return `string`. Otherwise, the interpreter will skip the command. Compiling instructions: - Start at the first line of the program. - Execute the current line. - If a command is skipped, go to the following line and repeat this step. If there is no next line, return `string`. - Otherwise, go to the first step. So, a program terminates in two possible ways: - From the `string1=(return)string2` command, the program identifies `string1` in `string` and returns `string` with value `string2`. - The compiler gets to the end of the program without executing any commands. ## Example ## Start with `string = cba` Program: ``` ba=ab cb=bc ca=ac abc=(return)Hello World ``` `string = cba` Start at the first line of the program. Execute the current line `ba=ab`. `ba` is in `string` so it is replaced with `ab`, and the program restarts `string = cab` Start at the first line of the program. Execute the current line. `ba=ab` is skipped as `ba` does not appear in `string`. Go to the next line. Execute the current line. `cb=bc` is skipped as `cb` does not appear in `string`. Go to the next line. Execute the current line. `ca` is in `string` so it is replaced with `ac`, and the program restarts `string = acb` Start at the first line of the program. Execute the current line. `ba=ab` is skipped as `ba` does not appear in `string`. Go to the next line. Execute the current line. `cb` is in `string` so it is replaced with `bc`, and the program restarts. `string = abc` Start at the first line of the program. Execute the current line. `ba=ab` is skipped as `ba` does not appear in `string`. Go to the next line. Execute the current line. `cb=bc` is skipped as `cb` does not appear in `string`. Go to the next line. Execute the current line. `ca=ac` is skipped as `ca` does not appear in `string`. Go to the next line. Execute the current line. `abc` shows up in `string` so `string` is set to `Hello World` and the program returns `string`, which is `Hello World`. ### FAQ ### - Yes `string1` can be empty, but this will just generate whatever you put at `string2` in the beginning of the string. - Yes `string2` can be empty and this introduces a notion of "deletion." - Matching is case-sensitive - Whitespace matters. *I starred the problems I thought were particularly interesting.*