back to article 50 lines of Bash to bring a Wordle fan out of their shell

We are delighted to note that a version of the word game the New York Times bought for seven figures can now be played via a 50-line Bash script. GitHub user "huytd" uploaded the code initially as "less than 50 lines of Bash", although once others got stuck in the script size stood at the magic half century. By our reckoning, …

  1. bpfh Silver badge
    Joke

    Quit vim

    Esc :q! Enter

    Or press the power button for 10 seconds.

    1. Hubert Cumberdale Silver badge

      Re: Quit vim

      What could be simpler!

      1. Munchausen's proxy
        Devil

        Re: Quit vim

        Use Emacs instead:

        Ctrl-C,Meta-Bucky-M, "(close-this-buffer-and-the-other-buffers-and-exit-while-saving-probably)"

        Not only simple, but totally intuitive!

        1. JBowler

          Re: Quit emasc

          >Not only simple, but totally intuitive!

          Indeed. I just used method B of the OP's post; pull the power. (More accurately I sent emasc SIGHUP [still politically correct] by closing its window.)

      2. Jonathan Richards 1 Silver badge

        Re: Quit vim

        Alt-SysRq-B

    2. b0llchit Silver badge
      Boffin

      Re: Quit vim

      Esc ZZ

      or

      Esc ZQ

      First saves and quits (must have a filename). Second just quits.

    3. Cubical Drone

      Re: Quit vim

      :x

    4. jake Silver badge

      Re: Quit vim

      Or, for you Windows converts using the GUI version:

      Click File on the menu, then Exit. The keyboard shortcut also works:

      <alt>F x

      Ever so difficult, that.

      1. anothercynic Silver badge

        Re: Quit vim

        No Alt+F4? Shameful.

    5. Gene Cash Silver badge

      Re: Quit vim

      "killall -11 vim" is how I do it...

    6. Gene Cash Silver badge

      Re: Quit vim

      Old saw: vi has two modes: "beeping" and "destroy everything"

    7. Dave559 Silver badge

      Re: Quit vim

      Bah. If for some reason, you're tired of vim, you can always just go to sleep…

      <esc> ZZ

      :-P

      [edit: Ah, beaten to it. :( ]

    8. JBowler

      Re: Quit vim

      I would agree, except the other posters quoted additional methods of getting out of vim. How about the problem to your solution; how to get out of vi?

      1. jake Silver badge

        Re: Quit vim

        I prefer ZZ ... However, here's a short list:

        :w to write, :w! to force a write, :q to quit (with prompt to save changes), :q! to force quit with no save, :wq or ZZ to write and quit, :wq! to force a write and quit. Note that ZZ doesn't need the :, nor does it have an option to force a write if you're editing a so-called "read only" file, making it somewhat safer than :wq! in day-to-day life.

        HTH

    9. This post has been deleted by its author

    10. Number6

      Re: Quit vim

      I remember opening another terminal, finding the PID and killing it that way. Then I learned the easy way.

  2. Ben Tasker Silver badge

    > We'll also draw a discreet veil over the likes of Sweardle, a four-letter guessing game that is as potty-mouthed as you would expect.

    I'm disappointed.

    Really struggled with it, couldn't think of a 4 letter swear word that ends with E.

    The answer was "lube" - I don't care what you do with it, that's not a fucking swear word

    1. KittenHuffer Silver badge
      1. Kane Silver badge
        Joke

        var01, var02 as string

        var01 = "lube"

        var02 = "arse"

        var02 & "-" & var01 =

    2. Anonymous Coward
      Anonymous Coward

      @Ben Tasker

      Oh how I agree with you. The swear version is way harder than the original one. And you only get 4 tries!

      I have yet to win..

      1. EricB123 Bronze badge

        Swear Words 101

        You do know porn is free on the internet these days, right?

        1. Jedit Silver badge
          Joke

          "You do know porn is free on the internet these days, right?"

          Thanks, I'll make that my first guess next time.

    3. Pantagoon
      Stop

      @ Ben

      It depends where you shove it.

  3. Charlie Clark Silver badge

    This isn't the IP you're looking for

    Wordle is basically a hangman variant, of which there must be many versions in almost every programming language out there – in Haiku you can even play hangman in the kernel debugger! But the NYT has bought the brand and copyright, and that's what will be the target of any enforcement actions.

    1. unimaginative
      Facepalm

      Re: This isn't the IP you're looking for

      My interpretation of this:

      "The UK's IP system is not currently very well equipped to protect studios from clone games"

      is

      "You can only get given a monoploy on the implementation of a trivial idea, not the trivial idea itself"

      1. This post has been deleted by its author

      2. Anonymous Coward
        Anonymous Coward

        Re: This isn't the IP you're looking for

        Limey here - when I first saw Wordle, my first thought is that it's a rip off off a TV game show called "Lingo". So not sure they can claim the moral high ground on copyright.

    2. EricB123 Bronze badge

      Re: This isn't the IP you're looking for

      As George Carlin used to say, "Nail two boards together in a way that hasn't been done before and some schmuck will buy it from you".

    3. Annihilator Silver badge

      Re: This isn't the IP you're looking for

      More of a combination of hangman and the old boardgame version of Mastermind.

    4. Androgynous Cow Herd

      Re: This isn't the IP you're looking for

      Thanks for that - I remember playing HANGMAN on a teletype terminal connected to DECISION...in 1976

      BSD olde skool!

      1. jake Silver badge

        Re: This isn't the IP you're looking for

        The old hangman is still included in the BSD games package. Also trek and wumpus.

  4. archwn

    /usr/share/dict/words clearly contains some doozies. Of the first five words I tried, I utterly failed to get three of them; kwela, sparm and ebbie.

    1. BenDwire Silver badge
      Linux

      Usually /usr/share/dict/words is a symlink to the locale of your machine. For some odd reason my locale is set to left pondian, whereas I live on the right. That's about to get fixed.

      If nothing else, this script has improved my life! /s

      1. Anonymous Coward
        Anonymous Coward

        > For some odd reason my locale is set to left pondian, whereas I live on the right. That's about to get fixed.

        You moving?

        1. David 132 Silver badge
          Coat

          Moving the Atlantic across so it's no longer in the way between UK and US.

          AKA "defragging the planet".

          1. jake Silver badge

            And then we'll move the Rockies and all parts West back to where it belongs ... you lot can keep the East Coast, with our compliments,

            1. I ain't Spartacus Gold badge

              Does that mean you're planning to move California and say swap positions with Japan?

              You are Max Zorin, and I claim my £5..

              1. jake Silver badge

                Nah. We'll leave California right here ... I much prefer our strike-slip fault to Japan's tsunami inducing subduction zone variety.

    2. Anonymous Coward Silver badge
      Facepalm

      Which is why Wardle chose to use the most common ~2500 words as possible answers (although the possible guesses list is much longer)

      1. Doctor Syntax Silver badge

        They're built in? That means the NYT paid about $400 a word. Their regular journalists must be fuming.

        1. Blane Bramble

          They're in the javascript file.

        2. TeeCee Gold badge
          Facepalm

          One of their more famous articles, that got copied over here, was the exclusive on how O'Barmy had given Sweaty Gordon a load of DVDs he couldn't play ('cos you can't have a multiregion player in the USA, they don't exist - obviously).

          Considering that, those words probably deserve the higher rate of pay.

          Then again, as every British paper repeated that load of cobblers verbatim, the NYT mob aren't the really dumb bastards here.

    3. Anonymous Coward
      Anonymous Coward

      kwela, sparm and ebbie

      The best midfield trio that Arsenal ever fielded if you ask me.

    4. archwn

      Replying to one's own comment seems bad form, akin to quoting one's own poetry. But the edit window's closed, so here we are.

      The readme that accompanies linux.words is quite enlightening, and reveals myriad sources that any scrabble player would bristle at. Fortunately, scrabble word lists abound on the internet, and bring the list down from 25105 words to 12972 (based on what's in fedora 35's list and the 2019 Collins list I grabbed). Caveat: you may have to dos2unix the list before it works as a replacement.

    5. Manolo
      Paris Hilton

      That's why I just adjusted wordle.sh to use the previously downloaded wordlelist instead.

      EDIT: Or at least that's what I tried.

      Any idea why changing

      words=($(grep '^\w\w\w\w\w$' /usr/share/dict/words | tr '[a-z]' '[A-Z]'))

      to

      words=($(grep '^\w\w\w\w\w$' /home/manolo/Games/words | tr '[a-z]' '[A-Z]'))

      results in the game no longer functioning?

      1. Manolo

        Never mind. Turns out my favourite opening "orate" is not in the wordelist.

      2. jake Silver badge

        I know you said "never mind", but just in case anybody else is trying this, make sure the downloaded list complies with the expected EOL character(s).

      3. Manolo

        What you will want to do is use the limited list from Wordle to pick the words from, but an extended list of words (/usr/share/dict/words) to check your guesses against.

        Otherwise you'll be typing perfectly valid guesses and the script will tell you they are incorrect and not give you any information.

        Let's see if my bash skills are sufficient to achieve that....

  5. Alien Doctor 1.1

    Prior art?

    Is this just not a "modern" version of the old Mastermind coloured peg game from the 70's? I seem to remember having an electronic calculator-shaped variant as well many, many, many years back.

    1. Hans Neeson-Bumpsadese Silver badge

      Re: Prior art?

      Pretty close. Only differences I see is 26 letters versus a smaller number of colours, and Wordle tells you exactly which items correspond to black or white pegs whereas you had to figure that out for yourself in old-school Mastermind

    2. Peter Mount
      Happy

      Re: Prior art?

      TechTangents released a video yesterday showing both Mastermind and an electronic game which does look like a calculator.

      Link should show the calculator in that video

      https://www.youtube.com/watch?v=rLUmER9dn9A&t=1s&ab_channel=TechTangents&t=309

    3. noboard

      Re: Prior art?

      You know that, I know that and the NYT legal department know that. Will that stop them though?

      I think we all know the answer to that as well.

      1. Dave559 Silver badge

        Re: Prior art?

        "You know that, I know that and the NYT legal department know that. Will that stop them though?"

        If only there were a hyperintelligent evil genius with a classy assistant [1] (and optional fluffy white cat, dammit, I was sure there was a fluffy white cat on the cover pic) somewhere, who could take appropriate corrective action…

        [1] Of course, it's entirely possible that the well-groomed smartly-dressed bearded gentleman was really just a diversionary, uhh, beard, and the glamorous East Asian lady was, after all, the real genius/assassin behind the operation…

        1. jake Silver badge

          Re: Prior art?

          "the glamorous East Asian lady was, after all, the real genius/assassin behind the operation…"

          Don't be silly. The real genius/assassin was the cat.

        2. Dan 55 Silver badge
          Black Helicopters

          Re: Prior art?

          Rumours that her custom-built banking software installed around the world had anything to do with the 2007-08 financial crash are neither confirmed or denied.

          Landmark Reunion for Mastermind Box Models

        3. Joe W Silver badge

          Re: Prior art?

          There's a "The Laundry" book (Charles Stross), where there are some confusions about who is the "Bond" and who is the "Bond Girl" - worth a read :-) The books are a crossover between spy novels and Lovecraftian mythos, with a twist (and a dose of bureaucrcy, they are working for the government after all).

          1. Jedit Silver badge
            Headmaster

            Re: Prior art?

            Also the main character is Bob Oliver Francis Howard, and his junior assistant is Peter Frederick Young.

            Apparently, however, Simon Travaglia is not Charles Stross despite his name translating as "Witness to Troubles". If it is true that this is not a pseudonymous false identity, it's definitely one of the strongest cases of nominative determinism that I've ever seen.

    4. Flocke Kroes Silver badge

      Re: Prior art?

      The artwork, music and software are protectable with copyright. The game mechanics might be copyrightable but if that is possible then the rights belong to the creator of the word variant of mastermind from decades ago.

      Prior art is a term from patent law. I have no idea if game mechanics can be patented. Depending on jurisdiction, the prior art may not be a problem: some jurisdictions specifically legalise ripping off other people's ideas if they go with "first to file a patent". Other jurisdictions go with "first to invent" so a patent can be ruled invalid with prior art and a large pile of money.

      Software is a branch of mathematics so it is not patentable subject matter according to WIPO. The implementation is protected by copyright but not the idea. In theory someone can legally create their own implementation and distribute it. Patent offices are skilled in ignoring patent treaties and will grant patents for the idea for some software. In the EU you have to call a software patent a "computer implemented invention" in the filing but you don't even need to pretend in the US. Although software computer implemented invention patents are granted they may or may not be valid. That does not matter at all as the cost of litigation convinces many defendants to settle without a fight.

      1. Anonymous Coward
        Anonymous Coward

        Re: Prior art?

        The mighty Wikipedia claims that all countries now use a "first-to-file" system. Canada, the Philippines and the USA have all switched, apparently.

        https://en.wikipedia.org/wiki/First_to_file_and_first_to_invent

        The USA (which I thought was still first-to-invent as well) switched in 2013.

        Even in first-to-file countries patents can still be ruled invalid with prior art (and money), since an invenstion must be novel to be patentable. An example in the UK (a first-to-file country) would be Windsurfing International vs Tabur Marine, which you can read about at:

        https://en.wikipedia.org/wiki/Peter_Chilvers

    5. AnotherName

      Re: Prior art?

      There's been a TV game show 'Lingo' based on the same principles since 2020 already here. It doesn't stop at 5 letters, but increases the length as the player gets further. Hardly makes Wordle a unique game anyway, unless you use the Apple definition and add the magic words '...on a mobile device'.

      1. hj

        Re: Prior art?

        This has been a TV show for more than 30 years!

        https://en.wikipedia.org/wiki/Lingo_(Dutch_game_show)

    6. Anonymous Coward
      Anonymous Coward

      Re: Prior art?

      Prior art? Just take "game where you guess a combination of symbols after being told number of correct symbols in correct it incorrect place after each turn" and add the magic formula "... on a mobile device" and you've got a new "invention" ... though there is prior art for this idea so might get sued for doing that

  6. Doctor Syntax Silver badge

    "And if we really fancy a text-based challenge, perhaps we'll fire up Vim."

    Easier than getting out of a Windows update according to https://www.tomshardware.com/news/windows-update-needs-eight-hours

    1. Dan 55 Silver badge
      Trollface

      But is getting out of Windows Update easier than exiting Emacs?

  7. Natalie Gritpants Jr Silver badge

    "may wish to consider reforming copyright .. for the age of the metaverse"

    Do they mean that copyright terms should be shortened now that we're in the metaverse and everything moves faster?

    1. Cederic Silver badge

      Re: "may wish to consider reforming copyright .. for the age of the metaverse"

      As someone with published photographs, videos and books (some of which are commercially available) I thoroughly support dropping copyrights to 12 years, extendable by fee to 20. Then stop. Public domain, and have at it.

  8. Howard Sway Silver badge

    First try

    You lose! The word is:

    NAURU

    How the fuck was I supposed to get that?

    1. tonique
      Holmes

      Re: First try

      You were clearly playing with a Finnish wordlist and got a regular word that happens to mean 'laughter'.

    2. Anonymous Coward
      Anonymous Coward

      Re: First try

      Here: 'BATTA'

  9. fl095789

    50 lines of Bash

    How long lines are we talking about?

    1. jake Silver badge

      Re: 50 lines of Bash

      As long as necessary, of course.

  10. Oliver Knill

    bash version has a much smaller voacbulary

    It is great to have this programmed so effectively. It uses the /usr/share/dict/words

    database of words. I just tried it out. It did not recognize words

    like Maser or Aleph. The simplicity of the game will make it hard to

    protect from copying as it is essentially the mastermind game with

    a different alphabet and a restricted set of 370 thousand words. Which gets

    me back to /usr/share/dict/words. On my linux machine, that file contains 102

    thousand words and these are also shorter and longer ones. So, the Bash

    game is much more restricted than the actual wordle game.

    1. Joe W Silver badge

      Re: bash version has a much smaller voacbulary

      The wordle-word-list has 2316 entries. Reading the discussions on Github tells me that the /usr/share/dict/words list contains in fact too many words, many of which are actually... let's say the sources of what is considered a word are disputable.

      The thread (in this forum? in the github discussions?) suggests looking for a scrabble word list and use that.

      And you might want to make sure your line breaks are configured correctly, apparently CR and LF are too much for the ElReg forum.... ;)

  11. Ian Johnston Silver badge

    I hadn't heard of Wordle till yesterday, but as far as I can see it's just the old "Word Mastermind" game from the 70s, played in easy mode.

    Readers will recall that in easy mode you get a black pin in the position of any correct letter in the right place and a white pin in the position of a correct letter in the wrong place. In standard mode the black and white pegs were sorted in order, so you didn't know which applied to each letter.

    Any patent attempt in the UK should die instantly of prior art.

    https://boardgamegeek.com/boardgame/5662/word-mastermind

  12. John Brown (no body) Silver badge

    reforming copyright

    "reforming copyright more generally to make it more fit for the age of the metaverse and the iPhone rather than Telex and Teletext."

    Considering the lifespan of the vast majority of computer games, or software in general, maybe the copyright could be reduced to 10 years, or even 5. If it's still viable as a program after that, or has spawned a series/franchise/whatever, then the copyright holder gets first dibs at a 5-10 year renewal for a fee. After all, if it's still generating revenue, then a renewal fee every 5-10 years ought to be no hardship for the copyright holder. For that matter, why not apply that across the board? If the IP has value for life of author + 70 years, then it's valuable enough to incur a renewal fee. If not, then let it lapse into the public domain. Possibly retain the the rights for use in other media, eg old books, no longer in print thus generating no income, but later being used as the basis for a TV show or film.

  13. Fruit and Nutcase Silver badge

    6 letter version

    Expanding the Bash script to handle 6 letters allows the word Bishop

    1. phuzz Silver badge
      Trollface

      Re: 6 letter version

      I'm sure someone will give that a bash

  14. redpola

    Die, filthy vimmers.

    https://github.com/progfolio/wordel

  15. Christoph

    So who is going to rewrite it as 3 lines of APL - which can't then be improved because even the author won't be able to understand it.

    1. Peter Gathercole Silver badge

      Don't joke. It's probably possible!

      For my first year project at University, I wrote a program to replace the APL special characters with mnemonics so that they could be printed on ordinary line printers, The original version, which I wrote like a normal programming language, with a loop or two (the ultimate no-no in APL) was several hundred lines long and took a significant part of my weekly computing budget to run.

      After learning some more APL, I reduced this to about a dozen lines, plus some pre-made data structures containing the mnemonic strings (which took more time to create than the program, and actually was created with a program larger than the main one). The actual code that did the work was just two lines, and ran about as fast as the terminal could print the prompt.

      When I submitted it for marking, I was told that it was really too short to be a valid project and got marked down for it. And I thought that the purpose of the project was to be a learning exercise, which I actually demonstrated in the project by writing up almost all of the journey I had been through creating it! And it worked.

      If I remembered enough APL, I might actually have accepted the 3 line APL challenge, but it was a long time ago.

      In case you ask what University taught APL. it was Durham, which I attended between 1978 and 1981.

  16. Aristotles slow and dimwitted horse Silver badge

    chmod 777

    I just want to rwx the world!!!!!!!

  17. Jason Bloomberg
    Alien

    I welcome our new Wordle overloards

    The best thing about Wordle for me is how it has brought back the "I can do that" spirit which kick-started the home computer revolution.

    So, many thanks Josh Wardle, and I hope you and your partner enjoy the NYT's dosh.

  18. edkalrio

    Wordle.sh

    I also did a Wordle version in 50 lines of Bash... 4 weeks ago. My code is hosted at github. Just look for wordle.sh

POST COMMENT House rules

Not a member of The Register? Create a new account here.

  • Enter your comment

  • Add an icon

Anonymous cowards cannot choose their icon

Other stories you might like

Biting the hand that feeds IT © 1998–2022