Skip to content

Instantly share code, notes, and snippets.

@qlkzy
Last active August 29, 2015 14:10
Show Gist options
  • Select an option

  • Save qlkzy/a23157e73379814a4d8e to your computer and use it in GitHub Desktop.

Select an option

Save qlkzy/a23157e73379814a4d8e to your computer and use it in GitHub Desktop.
#! /usr/bin/env perl
use strict;
use warnings;
use Getopt::Long;
local $\ = "\n";
my %target;
GetOptions('l|letters=s' => sub {
local $_ = lc $_[1];
y/a-z//dc;
$target{$_}++ for split //;
});
LINE: while (<>) {
chomp;
$_ = lc $_;
y/a-z//dc;
my %t = %target;
$t{$_}-- for split //;
for (values %t) {
next LINE if $_ < 0;
}
print;
}
./countdown.pl -l "$1" /usr/share/dict/british-english-insane | awk '{print length, $0}' | sort | cut -d' ' -f2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment