Skip to content

Instantly share code, notes, and snippets.

@orirawlings
Created April 23, 2020 05:24
Show Gist options
  • Select an option

  • Save orirawlings/bb66b0b5d99ebdf9fdbc305752fa5621 to your computer and use it in GitHub Desktop.

Select an option

Save orirawlings/bb66b0b5d99ebdf9fdbc305752fa5621 to your computer and use it in GitHub Desktop.

Revisions

  1. orirawlings created this gist Apr 23, 2020.
    16 changes: 16 additions & 0 deletions backronym.awk
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    BEGIN {
    while((getline < "/usr/share/dict/words") > 0) {
    first = substr($0, 1, 1)
    wordcnts[first]++
    words[first,wordcnts[first]] = $0
    }
    srand()
    }
    {
    len = length($0)
    for (i=1; i<=len; i++) {
    l = substr($0, i, 1)
    word = words[l,int(rand()*wordcnts[l])+1]
    printf "%s%s", word, (i < len ? " " : "\n")
    }
    }