Snack+
Jump to navigation
Jump to search
Snack+ is SNACBIT based and a derivative of HQ9+
Command
| Command | Description |
|---|---|
S
|
Output the current snack |
n
|
Output the current snack |
a
|
Output the current snack |
c
|
Output the current snack |
k
|
Output the current snack |
+
|
Increment the current snack, wrapping around at the upper edge |
Examples
Sequential Printing
This program prints all states returns to the first one, which is again printed for endeictic purposes:
S+S+S+S+S+S+S+S+S+S+S+S+
Interpreter
An attempt of providing an interpreter in Common Lisp is offered:
(declaim (type (simple-array simple-string (11)) +SNACBIT-STATES+))
(defparameter +SNACBIT-STATES+
(make-array 11
:element-type 'string
:initial-contents
'("Peanut butter cracker"
"Cosmic brownie"
"Cheezit"
"Cheeto"
"Dorito"
"Tortilla chip"
"Cheese cracker"
"Potato chip"
"Applesauce"
"Peanut butter cup"
"Pickle")))
(defun interpret-Snack+ (code)
(declare (type string code))
(loop
with state-number of-type (integer 0 10) = 0
for token of-type character across code
if (find token "Snack" :test #'char=) do
(print (aref +SNACBIT-STATES+ state-number))
else if (char= token #\+) do
(setf state-number
(mod (1+ state-number) 11))
else do
(error "Unrecognized character: ~s." token)))
Here is also an interpreter in Python, by User:None1:
snacklist=['Peanut butter cracker', 'Cosmic brownie', 'Cheezit', 'Cheeto', 'Dorito', 'Tortilla chip', 'Cheese cracker', 'Potato chip', 'Applesauce', 'Peanut butter cup', 'Pickle']
code=input()
x=0
for i in code:
if i in "Snack":
print(snacklist[x])
if i=="+":
x=(x+1)%11
And an interpreter in C++:
#include<string>
#include<iostream>
using namespace std;
string snacklist[]={"Peanut butter cracker", "Cosmic brownie", "Cheezit", "Cheeto", "Dorito", "Tortilla chip", "Cheese cracker", "Potato chip", "Applesauce", "Peanut butter cup", "Pickle"};
int main(){
string code;
getline(cin,code);
int x=0;
for(int i=0;i<code.size();i++){
if(code[i]=='S'||i=='n'||i=='a'||i=='c'||i=='k'){
cout<<snacklist[x]<<endl;
}
if(code[i]=='+'){
x=(x+1)%11;
}
}
return 0;
}