Skip to content
Snippets Groups Projects
Commit d1d5c13d authored by Taddeüs Kroes's avatar Taddeüs Kroes
Browse files

Added Python script to generate naive text programs

parent 8117b3b4
No related branches found
No related tags found
No related merge requests found
text.py 0 → 100755
#!/usr/bin/env python
import sys
if __name__ == '__main__':
if len(sys.argv) < 2:
print >>sys.stderr, 'usage: python %s STRING' % sys.argv[0]
sys.exit(1)
def cmd(c):
return ('+' * c if c > 0 else '-' * -c) + '.'
input_string = ' '.join(sys.argv[1:]) + '\n'
ords = [0] + map(ord, input_string)
diffs = [ords[i + 1] - c for i, c in enumerate(ords[:-1])]
print '\n'.join(map(cmd, diffs))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment