by nanis · 4y ago · 0 comments
Also, you really need better names for your methods and variables, starting with this bit here: https://github.com/KevinXuxuxu/wordle_machine/blob/64a8534ad...
As you think about a better way to name those, you will realize it is possible to do this in a much less convoluted way.
Hmmm, I have been using this Perl script:
#!/usr/bin/env perl
use strict;
use warnings;
use feature 'say';
my @words = grep # Add conditions below
!/^[A-Z]/,
grep length == 5,
map split, do { local $/; <> };
say for @words
Invoke it from the command line with your word list. I've been lazy, so I use `./wg /usr/share/dict/words` which means way more options than a more tailored word list would give which means I am only cheating a little. So, for example, I type "amber" as my first move and I am told "e" is in the wrong spot and none of the other letters match, I update the selection using that information: my @words = grep # Add conditions below
!/^...e/ &&
/e/ &&
!/[ambr]/ &&
!/^[A-Z]/,
grep length == 5,
map split, do { local $/; <> };These exercises are great at improving your intuition and aptitude for refactoring code in a way that makes it more maintainable, easier to read and reason about.