Skip to content

Instantly share code, notes, and snippets.

@tripl3dogdare
Last active July 15, 2018 21:52
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 tripl3dogdare/a8e26b9c6de4f464b778c626984011b4 to your computer and use it in GitHub Desktop.
Save tripl3dogdare/a8e26b9c6de4f464b778c626984011b4 to your computer and use it in GitHub Desktop.
Nevada Programming Language

This is a project I did a long time ago, on a road trip through Nevada. I wrote the code for this interpreter by hand in a tiny dollar store notebook with a pencil. The goal was to create an esoteric language that could be interpreted in as few LOC as possible, as few characters as possible, and still be as useful as possible. I gave myself half an hour to complete the task, and thus, Nevada was born.

  • Total LOC: 23
  • Total characters: 593 (not including trailing newline)
  • Total effectiveness: Yeah, don't bother trying to use this in production. It technically works though!
25*25**|#1!>10-+
#.48*,6625**+,1825**-,4825**+#,,6725**+,9625**+,3825**+,48*,1825**-,725**,48*,
6625**+,9625**+#,,2825**+,48*,1825**-,2825**-,48*,4825**+,2725**+,9625**+,48*,7825**+,5625**+,6725**+#,,25*,
#.48*,6625**+,1825**-,4825**+#,,6725**+,9625**+,3825**+,48*,1825**-,725**,48*,
6625**+,9625**+#,,2825**+,25*,
4825**+,5625**+,5725**+,9625**+,48*,9725**+,8725**+,9625**+,48*,8625**+,9725**+,7825**+,8725**+,4425**+,48*,
825**,5625**+,3825**+#,,48*,3725**+,4825**+,48*,5625**+,2825**+,9725**+,5825**+,8725**+,8625**+,25*,
#10-+.48*,6625**+,1825**-,4825**+#,,6725**+,9625**+,3825**+,48*,1825**-,725**,48*,
6625**+,9625**+#,,2825**+,48*,1825**-,2825**-,48*,4825**+,2725**+,9625**+,48*,7825**+,5625**+,6725**+#,,
25*#,,<|
594+*7+,594+*4+,594+*92++#,,594+*95++,48*,594+*2225**++,594+*95++,594+*98++,594+*92++,594+*3+,48*1+,25*,25*,
import sys
def m(p):
i,s=0,[]
while True:
if i>=len(p):break
c=p[i]
if c in'0123456789':s+=[int(c)]
if c=='+':s+=[s.pop()+s.pop()]
if c=='-':s+=[s.pop()-s.pop()]
if c=='*':s+=[s.pop()*s.pop()]
if c=='/':s+=[s.pop()/s.pop()]
if c=='=':i+=s.pop()==s.pop()
if c=='!':i+=s.pop()!=s.pop()
if c=='>':
while i<len(p) and p[i]!='|':i+=1
if c=='<':
while i>0 and p[i]!='|':i-=1
if c=='.':print(s.pop(),end='')
if c==',':print(chr(s.pop()),end='')
if c=='#':s+=[s.pop()]*2
i+=1
if __name__=='__main__':
with open(sys.argv[1])as f:m(f.read())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment