From df58836107deaee46ebe5975305371742cd9e4e7 Mon Sep 17 00:00:00 2001 From: Abigail Date: Tue, 10 Nov 2020 19:26:34 +0100 Subject: Be more lenient in what the accept. We know also accept letters 'A' .. 'Z' as clues. They will be mapped to 10 .. 35. --- challenge-086/abigail/perl/ch-2.pl | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/challenge-086/abigail/perl/ch-2.pl b/challenge-086/abigail/perl/ch-2.pl index ce25f5dcab..7d36800cd7 100644 --- a/challenge-086/abigail/perl/ch-2.pl +++ b/challenge-086/abigail/perl/ch-2.pl @@ -11,10 +11,15 @@ use experimental 'lexical_subs'; # -# Read the puzzle; set unsolved squares to 0. -# This read any sized sudoku. +# Read the puzzle; we're liberal in what we accept: +# - A sequence of one or more underscores is a square we must solve +# - Capital letters 'A' .. 'Z' map to 10 .. 35 +# - Numbers are taken 'as is'. # -my @sudoku = map {[map {/_/ ? 0 : $_} /\b(?:_|[1-9][0-9]*)\b/g]} <>; +my @sudoku = map {[map {/_/ ? 0 + : /[A-Z]/ ? 10 + ord ($_) - ord ('A') + : $_} + /\b(?:_+|[1-9][0-9]*|[A-Z])\b/g]} <>; my $SIZE = @sudoku; my @INDICES = (0 .. $SIZE - 1); my @ELEMENTS = (1 .. $SIZE); -- cgit