Skip to content

Instantly share code, notes, and snippets.

@malted
Last active August 13, 2022 21:48
Show Gist options
  • Save malted/7461a591d9b0566276ce6bc6d2f21d1a to your computer and use it in GitHub Desktop.
Save malted/7461a591d9b0566276ce6bc6d2f21d1a to your computer and use it in GitHub Desktop.
A minifier for Brainfuck scripts.
import sys
def main():
min_file_name = sys.argv[1].split('.')
min_file_name.insert(len(sys.argv) - 1, "min")
min_file_name = '.'.join(min_file_name)
with open(min_file_name, "w+") as min_file:
final = ""
with open(sys.argv[1]) as src_file:
for c in src_file.read():
if c in "<>.,+-[]":
final += c
min_file.write(final)
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment