Post by FRPython has pretty printing modules but I would not touch Python with
a 10-foot hotstick.
It's not for everyone. Insecure fucking idiots who like to waste MAJOR
time with C for no good reason should stay away.
This took all of 10 minutes to write and test (it worked right the very
first time).
---------------------------------------------------------------
def getanagrams(words, anaword):
anacount = 0
lenanaword = len(anaword)
sortedana = sorted(anaword)
for word in words:
if len(word) == lenanaword:
if sorted(word) == sortedana:
if word != anaword:
anacount += 1
print(word,end=' ')
getanagrams(words,'players')
asperly parleys parsley pyrales replays sparely splayer
7 anagrams found in 0.089 seconds
---------------------------------------------------------------
Look at it. It's almost like writing pseudocode. Great stuff.
Do you know what a hassle it is to do this in C? I do because I've done
it more than once. It's a real hassle.
How about getting a list of files in the current directory with C?
Another pain.
------------------------------------
import os
for entry in os.scandir('.'):
if entry.is_file():
print(entry.name)
------------------------------------
Try it at the python command line.
I just parsed the set of English dictionary files from
https://www.mso.anu.edu.au/~ralph/OPTED/
About a half-hour to get the code exactly right so the .csv data will
cleanly import into a db. Now I have a text dictionary of 176049 (word,
category, definition). Code ran in about 3 seconds. Very satisfying!
A: 11616 lines
B: 9877 lines
C: 16736 lines
D: 10806 lines
E: 7520 lines
F: 7419 lines
G: 5417 lines
H: 6269 lines
I: 7783 lines
J: 1338 lines
K: 1283 lines
L: 5814 lines
M: 8846 lines
N: 3034 lines
O: 4461 lines
P: 15429 lines
Q: 1043 lines
R: 8910 lines
Error in letter S: line 12935
), a game played with such pieces; pushpin
S: 21504 lines
T: 9285 lines
U: 3358 lines
V: 2796 lines
W: 4457 lines
X: 147 lines
Y: 486 lines
Z: 415 lines
Total lines: 176049
pwned