Created
March 24, 2018 21:40
-
-
Save jes/af884ad21d5fb2e063c1c00aab08371b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use strict; | |
use warnings; | |
use bytes; | |
my $input = 'BYGRBLBYBLBLBYBRBLGYBYYYBLBYBYBLBYFYBLGYBGRGBGRRBGFRBLBFBLBYBYFLBLBGBYYBBLYYBGRLBYYFBYGRBYFRBLBFBGYFBYRRBGRYBGYFBGRRBLGG'; | |
for my $b (0 .. 5) { | |
for my $y (0 .. 5) { | |
next if $y == $b; | |
for my $g (0 .. 5) { | |
next if $g == $b or $g == $y; | |
for my $r (0 .. 5) { | |
next if $r == $b or $r == $g or $r == $y; | |
for my $l (0 .. 5) { | |
next if $l == $b or $l == $g or $l == $y or $l == $r; | |
ORDERING: for my $f (0 .. 5) { | |
next if $f == $b or $f == $g or $f == $y or $f == $r or $f == $l; | |
my %map = ( | |
#B => 0, | |
#Y => 1, | |
#G => 2, | |
#R => 4, | |
#L => 3, | |
#F => 5, | |
B => $b, | |
Y => $y, | |
G => $g, | |
R => $r, | |
L => $l, | |
F => $f, | |
); | |
my $n = 4; | |
my $val = 0; | |
my $output = ''; | |
for my $c (split //, $input) { | |
$val = $val*6 + $map{$c}; | |
$n--; | |
if ($n == 0) { | |
#print sprintf("%02x", $val); | |
next ORDERING if $val < 32 || $val > 128; | |
$output .= chr($val); | |
$n = 4; | |
$val = 0; | |
} | |
} | |
print "$output\n"; | |
} | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment