my $newmask = ( $old ^ $word ) =~ tr/\0/\xff/cr;
$flip and ( $board, $heights ) = flip $board, $heights;
substr $board, $pos, length $word, $word;
#say "new mask is $newmask";
substr $heights, $pos, length $highs,
( $highs & $newmask ) =~ tr/0-4/1-5/r | ( $highs & ~$newmask );
$flip and ( $board, $heights ) = flip $board, $heights;
my $tiles = join '', @tiles;
say "word is $word";
$tiles =~ s/$_// for split //, $word & $newmask;
####
my $newmask = ( $old ^ $word ) =~ tr/\0/\xff/cr;
##
##
$flip and ( $board, $heights ) = flip $board, $heights;
substr $board, $pos, length $word, $word;
#say "new mask is $newmask"; # $newmask has unprintable characters, use something like Data::Dump that will show them.
substr $heights, $pos, length $highs,
( $highs & $newmask ) =~ tr/0-4/1-5/r | ( $highs & ~$newmask );
##
##
$flip and ( $board, $heights ) = flip $board, $heights;
my $tiles = join '', @tiles;
say "word is $word";
$tiles =~ s/$_// for split //, $word & $newmask;