Skip to content

Instantly share code, notes, and snippets.

@MajickTek
Last active March 11, 2022 06:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MajickTek/2e1d263a3b8189eedab992680d221b75 to your computer and use it in GitHub Desktop.
Save MajickTek/2e1d263a3b8189eedab992680d221b75 to your computer and use it in GitHub Desktop.
Implementation of "Albabet", an esoteric "programming language" by Threesodas

Albabet

https://esolangs.org/wiki/Albabet

Command Table:

Character Description
a Increments cell
b Decrements cell
c Sets cell to 0
d Sets multiplier to cell value and sets cell to 0
e Sets multiplier to cell value
f Sets multiplier to 0
g Multiplies cell by multiplier
h Squares cell value (cell * cell)
i Prints cell value as ASCII character
j Adds cell value to multiplier

Example Program Breakdown

aahhdaagdaagjdaji

  • aa Sets cell to 2
  • hh Squares cell twice, so now cell is 16
  • d Sets multiplier to 16 and sets cell to 0
  • aa Sets cell to 2
  • g Multiplies cell by multiplier: 2 * 16 is 32
  • daag Repeating the action: cell is now 64, multiplier is now 32
  • j Adds cell to multiplier: 32 + 64 is 96
  • daji
    • Sets multiplier to 96 and cell to 0
    • Sets cell to 1
    • Adds 96 + 1 and stores the result in cell. Cell is now 97
    • Print 97 as an ASCII character: a
public class Albabet {
private static int cell = 0;
private static int multiplier = 0;
public static void main(String[] args) {
/*
* The string of characters below prints the letter 'a' from its ASCII code.
*/
String code = "aahhdaagdaagjdaji";
code.chars().forEach(c -> {
switch(c) {
case 'a':
cell++;
debug(c);
break;
case 'b':
cell--;
debug(c);
break;
case 'c':
cell = 0;
debug(c);
break;
case 'd':
multiplier = cell;
cell = 0;
debug(c);
break;
case 'e':
multiplier = cell;
debug(c);
break;
case 'f':
multiplier = 0;
debug(c);
break;
case 'g':
int multiplied = cell * multiplier;
cell = multiplied;
debug(c);
break;
case 'h':
int squared = cell * cell;
cell = squared;
debug(c);
break;
case 'i':
System.out.print((char)cell);
break;
case 'j':
int result = cell + multiplier;
cell = result;
debug(c);
break;
}
});
}
private static void debug(int c) {
System.out.printf("[CODE: %s; CELL: %d; MULTIPLIER %d]%n", (char) c, cell, multiplier);
}
}
@MajickTek
Copy link
Author

MajickTek commented Mar 11, 2022

Here is a "Hello World" program:

aahhdaagdaaaajdaagicfaahhdaaaagjjaaaaaicfaahhdaaaagjjaaaaadaaaaaaajicfaahhdaaaagjjaaaaadaaaaaaajicfaahhdaaaagjjaaaaadaaaaaaaaaajicfaahhdaagicfaadaaggjgggdaaaaaaajicfaahhdaaaagjjaaaaadaaaaaaaaaajicfaahhdaaaagjjaaaaadaaaaaaaaaaaaajicfaahhdaaaagjjaaaaadaaaaaaajicfaaaaadaaaaajjjjjjjjjdaagicf

Each letter is separated by cf to clear the cell and multiplier.

Obviously, it could be optimized.

Here is each character and the code to join them:

String H = "aahhdaagdaaaajdaagi";
String e = "aahhdaaaagjjaaaaai";
String l = "aahhdaaaagjjaaaaadaaaaaaaji";
String o = "aahhdaaaagjjaaaaadaaaaaaaaaaji";
String space = "aahhdaagi";
String W = "aadaaggjgggdaaaaaaaji";
String r = "aahhdaaaagjjaaaaadaaaaaaaaaaaaaji";
String d = "aaaaadaaaaajjjjjjjjjdaagi";

String code = String.format("%scf%scf%scf%scf%scf%scf%scf%scf%scf%scf%scf", H, e, l, l, o, space, W, o, r, l, d);

p.s The exact output is Hello World. No comma or exclamation mark. Also, the output will not display correctly when used in the code above unless you comment out the debug(c); lines; they clutter up the output.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment