The checksum consists of seven characters, the first six of which may be letters or numbers. The seventh character is a number which is a check digit calculated as follows:
- take the place value in the alphabet of any letters in the code; e.g., an 'E' would have place value 5, 'k' would be 11;
- add the even-position numbers and/or place values;
- add the odd-position numbers and/or place values;
- subtract the two sums obtained above and take the absolute value of the result;
- add the digits of the result obtained in the previous step;
- repeat the last step if there is more than one digit in that sum.
---
so i made:
----
#!/usr/bin/perl
$crc = shift;
@splitup = split //, $crc if $crc =~ /^\w{6}(\d)$/;
map { $place += ord(lc($_))-ord('a')+1 } grep {/[a-zA-Z]/} @splitup;
map { $even += $_ } grep {!($splitup[$#splitup] == $_) && /[0-9]/ && $_ % 2 == 0} @splitup;
map { $odd += $_ } grep {!($splitup[$#splitup] == $_) && /[0-9]/ && $_ % 2 == 1} @splitup;
$chk = $even + $odd;
$axe = $place - $chk;
print "axe: $axe\n";
#print 1 % 2; #odd = 1, even = 0
------
but itz impossible fkn feg