XKCD

From Esolang
Jump to navigation Jump to search
XKCD
Paradigm(s) accumulator-based
Designed by User:Simoteam
Appeared in 2025
Computational class Unknown
Major implementations Python, JS

XKCD is accumulator-based esolang for XKCD Random Number

Overwiev

XKCD can output XKCD Random Number, input XKCD Random Number, increment by XKCD Random Number, decrement by XKCD Random Number, and output the number at end. Commands list:

X output XKCD Random Number
K Input XKCD Random Number, and save it
C Increment by XKCD Random Number
D Decrement by XKCD Random Number
4 Output the accumulator (Optional, because accumulator output at the end)
. Output the last input (Optional)

Interpretators

Python 3+ (With optional)

n=0
for c in input:
	if c=="X":
		print("4")
	elif c=="K":
		i=input("4")
	elif c=="C":
		n+=4
	elif c=="D":
		n-=4
	elif c=="4":
		print(n)
	elif c==".":
		print(i)
print(n)

JS (idk the version), (With optional)

let n = 0, i;
let inputStr = prompt();
for (let c of inputStr) {
    if (c === "X") console.log(4);
    else if (c === "K") i = prompt("4");
    else if (c === "C") n += 4;
    else if (c === "D") n -= 4;
    else if (c === "4") console.log(n);
    else if (c === ".") console.log(i);
}
console.log(n);

Examples

XKCD Random Number

X

XKCD Random Number without X

C4

Echo

K.