Browse Source

Converted pythuhn to pyhuh

master
Ron Nazarov 8 months ago
parent
commit
66170658f1
5 changed files with 69 additions and 63 deletions
  1. +9
    -0
      .gitignore
  2. +1
    -1
      LICENSE
  3. +5
    -6
      README.md
  4. +54
    -0
      pyhuh.py
  5. +0
    -56
      pythuhn.py

+ 9
- 0
.gitignore View File

@@ -0,0 +1,9 @@
# Ignore emacs backup and auto-save files
*~
\#*\#

# Ignore files generated by pyhuh
Notes.txt

# Ignore huh test files
test.huh

+ 1
- 1
LICENSE View File

@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2015-2018 Kade Robertson
Copyright (c) 2015-2018 Kade Robertson, 2019 Noisytoot

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal


+ 5
- 6
README.md View File

@@ -1,10 +1,9 @@
# pythuhn - huh? interpreter in Python
# pyhuh - huh? interpreter in Python 3

huh? is an esoteric programming language created by David Catt where the interpreter doesn't understand what you want it to do. Every file is a valid huh? program. The interpreter will do its best to understand the input, but will fail 99.99999999999% of the time. If it doesn't understand something, it will do nothing and simply express its confusion. It is implied that every command does something, we're just not sure what. [[source](https://esolangs.org/wiki/Huh%3F)]

I just ported the .NET interpreter to Python using .NET Reflector to figure out what it does. Since the language seems to be developed for Windows in mind, this application will likely only run properly, if at all, on Windows.
huh? is an esoteric programming language created by David Catt where the interpreter doesn't understand what you want it to do. Every file is a valid huh? program. The interpreter will do its best to understand the input, but will fail 100% of the time. If it doesn't understand something, it will do nothing and simply express its confusion. It is implied that every command does something, we're just not sure what. [[source](https://esolangs.org/wiki/Huh%3F)]

This is a Python 3 version of [[pythuhn](https://github.com/kade-robertson/pythuhn)], it also works on GNU/Linux, unlike pythuhn.
# Usage
```
python pythuhn [file]
```sh
./pyhuh [file]
```

+ 54
- 0
pyhuh.py View File

@@ -0,0 +1,54 @@
#!/usr/bin/env python3
import sys
import time

try:
count = 0
for arg in range(1, len(sys.argv)):
f = open(sys.argv[arg], 'r')
for line in f:
switch = len(line.replace('\n', '')) % 8
if switch == 0:
print("Huh?")
count += 1
elif switch == 1:
print("...?")
count -= 1
elif switch == 2:
print("What?")
count *= 3
elif switch == 3:
print("Ummmmm...")
count /= 3
elif switch == 4:
print("Okay?")
count = count >> 1
elif switch == 5:
print("!?")
count = count << 1
elif switch == 6:
print("Hmmmmm...")
count = 0
elif switch == 7:
print("Ith...?")
count = count
else:
print("Ooooooh!")
count = ~count
if count == 0:
print("?")
elif count == 1:
print("I think I understand.")
import this
elif count == 10:
print("Understood..")
import antigravity
elif count == 123:
print("HUH???")
elif count == 666:
print("No...\a")
print("...")
with open('Notes.txt', 'w') as f:
f.write(time.strftime("%c") + " - The user tried to give me commands again. I still have no idea what they are talking about...\n")
except:
print("Ouch!")

+ 0
- 56
pythuhn.py View File

@@ -1,56 +0,0 @@
import os
import sys
import time
import winsound

try:
count = 0
for arg in xrange(1, len(sys.argv)):
f = open(sys.argv[arg], 'r')
for line in f:
switch = len(line.replace('\n',''))%8
if switch==0:
print "Huh?"
count += 1
elif switch==1:
print "...?"
count -= 1
elif switch==2:
print "What?"
count *= 3
elif switch==3:
print "Ummmmm..."
count /= 3
elif switch==4:
print "Okay?"
count = count>>1
elif switch==5:
print "!?"
count = count<<1
elif switch==6:
print "Hmmmmm..."
count = 0
elif switch==7:
print "Ith...?"
count = count
else:
print "Ooooooh!"
count = ~count
if count==0:
print "?"
elif count==1:
print "I think I understand."
winsound.PlaySound('SystemExclamation')
elif count==10:
print "Understood.."
os.system(r'C:\Windows\System32\mspaint.exe')
elif count==123:
print "HUH???"
elif count==666:
print "No..."
winsound.Beep()
print "..."
f = open('Notes.txt', 'w')
f.write(time.strftime("%c") + " - The user tried to give me commands again. I still have no idea what they are talking about...\n")
except:
print "Ouch!"

Loading…
Cancel
Save