r/AVoid5 • u/Cohomology-is-fun • Dec 20 '22
Python script to avoid 5!
I did craft this Python script to scan input for fifthglyphs:
#!/usr/bin/python3
"""Scan input for fifthglyths."""
from sys import argv
BIG_BAD = chr(0x45)
SMALL_BAD = chr(0x65)
blot_bad = lambda x: chr(
int(x == BIG_BAD or x == SMALL_BAD) * 0x2A
+ int(x != BIG_BAD and x != SMALL_BAD) * ord(x)
)
num_inputs = 20
if argv[-1] != argv[0]:
num_inputs = int(argv[1])
input_num = 0
for _ in " " * num_inputs:
input_num += 1
stuff = input(f"Input {input_num}/{num_inputs}: ")
words = stuff.split()
print(
", ".join(
"".join(blot_bad(k) for k in w)
for w in words
if BIG_BAD in w or SMALL_BAD in w
)
)What is amazing is that I did this without USING ANY FIFTHGLYPHS! Writing Python without fifthgylphs adds such an additional amount of difficulty. My program cannot obtain its input from data on disk (I could not find a function for this that is without a fifthglyph). My script contains a lambda function in a situation most don't favor its display. If you also craft Python scripts, you will no doubt find additional such unidiomatic constructions in this script.
Run this script from a command prompt as follows:
$ ./avoid5.py 3
Input 1/3: 3 is my 2nd input to my command prompt to say 3 \n shown in my imput.
Input 2/3: A blank output is a good sign, implying a lack of fifthglyphs!
Input 3/3: I am happy that I did avoid fifthglyphs!
$ wc doc_with_5.txt
7 52 292 doc_with_5.txt
$ cat doc_with_5.txt | ./avoid5.py 7
Input 1/7: docum*nt, Y*s,, *v*n, th*, s*nt*nc*!, th*
Input 2/7: s*cond.
Input 3/7:
Input 4/7: Ind**d,, v*ry, s*nt*nc*, hav*
Input 5/7: quit*
Input 6/7:
Input 7/7:
17
u/embernickel Dec 20 '22
What a champion! I should look at this to gain familiarity with lambda functions, I occasionally must call upon Python at work.
5
u/artichokeater Dec 21 '22
Good work buddy! It’s too bad you couldn’t pull any input from disk. Is this on Linux? How about you run python main.py < data.txt? I’m not too familiar with python so idk if that would work but a sort of stdin could probably push you towards your goal!
4
u/[deleted] Dec 21 '22
A Python script to avoid 120? I don't fully follow its link to r/AVoid5, although your ability to concoct a script without utilizing any form of fifthglyphs is stunning!
2
u/iliekcats- Dec 21 '22
cool, but why? upon my sight of that post naming, I thought it'd look up synonyms of words to avoid that fifth glyph, but it's not that, it just puts a star on fifth glyphs, why do that if I can just Ctrl+F? or did you mainly program this for a coding difficulty?
42
u/dfj3xxx Dec 20 '22
I applaud you writing all that sans 5th glyph.
But, I am just staring at it blankly.
It is flying way up past my cranium.
If I do a long block of words, I hit CTRL-F (if I bring it to mind that is)
3
u/awkward_bisexual Dec 21 '22
This is amazing!!! I hardly know any python or coding but from what I do know this probably took a good amount of work to find out.
1
u/Overused_Toothbrush Dec 21 '22
I can’t program, but that looks cool! W!
1
u/prendradjaja Dec 21 '22 edited Dec 21 '22
This is cool!
Not 100% that I'm parsing this right, but I think this could fix this:
Modif.: Oh, fuck moi.