Count, or sometimes called The Count, is a stack-based language with 16 commands. Each command is represented by a single hexadecimal digit. This means that a string of code in Count can be thought of as a number represented in hexadecimal read from left to right.
There are 16 commands in Count each represented by a different hex simbol.
|0||Do nothing and move on to the next command.|
|1||Push 0 onto the stack.|
|2||Pop and output the top value on the stack.|
|3||Take an input in the form of an integer and push it onto the stack.|
|4||Pop the top value off the stack.|
|5||Pop the top two values x, and y off the stack. If y>x a third value off the stack.|
|6||Pop the top two values x and y off the stack, then push the y back the stack x times.|
|7||Swap the top two values on the stack.|
|8||Pop the top 3 values x, y, and z. Then push z[x]y. This is the xth hyperoperation of y and z.|
|9||Pop the top 3 values x, y, and z. Then push the value t that satisfies t[x]y = z. If t is negative push 0 and if t is a decimal push it's floor.|
|a||Pop the top 3 values x, y, and z. Then push the value t that satisfies y[x]t =z. If t is negative push 0 and if t is a decimal push it's floor.|
|b||Pop the top values x and y off the stack. Then send y to the xth position on the stack. if the stack is too small put it at the bottum|
|c||Pop the top values x and y off the stack. If either of them are non 0 pop the next value off the stack as well.|
|d||Empty the stack and then push the number of items that were on it.|
|e||Pop a value off the top of the stack and translate it to hexadecimal then remove all 0 digits and chunk the hex characters into pairs. From now on the interpreter should switch the commands associated with each pair of symbols. This process is done sequentially from left to right. If there is an odd number of hex digits then the one's place is ignored.|
|f||Pop a value off the top of the stack, translate it to hexadecimal and run it as a series of commands on the main stack.|
It is also important to note that when an empty stack is popped it will return the value 0 in Count.
Hyper operations are a useful way to use recursion to get big values. This is one way to define them in Python:
def HyperOperation(x,y,z): if x==0: return z+1 else: temp = z for i in range(y-1): temp = HyperOperation(x-1,z,temp) return temp
Here are some common operators wrote out in Count.
|Increment the top value on the stack||118||280|
|Decrement the top value on the stack||119||281|
|Square the top value on the stack||111811811181181188||315328958496756994440|
|If the top of the stack is 0 preform the operation under it else do the operation under that one||15f||351|
Although Count can only output numbers if we treat those numbers as ASCII values we can write a naive hello world program:
This program outputs hello world but it is far from optimized. This program can also be thought of as a single hexadecimal number. When we convert it to decimal we see it is:
Count golf is similar to regular coding golf. The goal of Count golf is to write code in Count to complete a task with the smallest hex value. This will most times be equivalent to the code with the smallest number of commands. What makes Count golf interesting is the f command. If codes associated hex value can be pushed to a stack then the f command can be used to run the code. This combined with the use of hyper operations to generate large numbers gives golfers many levels of abstraction to work with.