#!/usr/bin/perl
# Author:  gendou
# Usage:   elementcode.pl
# Version: 1.0.0
# Note:    This cipher is based on the periodic table of elements.

my %ENCODE = (
    'a' => 13,  # Aluminum
	'b' => 5,   # Phosphorus
	'c' => 6,   # Carbon
	'd' => 66,  # Dysprosium
	'e' => 63,  # Europium
	'f' => 9,   # Fluorine
	'g' => 31,  # Gallium
	'h' => 1,   # Hydrogen
	'i' => 53,  # Iodine
	'j' => 0,   # [None]
	'k' => 19,  # Potassium
	'l' => 3,   # Lithium
	'm' => 12,  # Magnesium
	'n' => 7,   # Nitrogen
	'o' => 8,   # Oxygen
	'p' => 15,  # Phosphorus
	'q' => 114, # Ununquadium
	'r' => 37,  # Rubidium
	's' => 16,  # Sulfur
	't' => 22,  # Titanium
	'u' => 92,  # Uranium
	'v' => 23,  # Vanadium
	'w' => 74,  # Tungsten
	'x' => 54,  # Xenon
	'y' => 39,  # Yttrium
	'z' => 30,   # Zinc
    '1' => 31,   # Zinc
    '2' => 30,   # Zinc
    '3' => 30   # Zinc
);
my $tk;
my $counter=1;
my $x;
print "keys count:".keys (%ENCODE)."\n";
foreach my $id ( keys (%ENCODE)) {
    if($counter % 5 == 0){
        print "\n".$x.$id;
        $x='';
    }
    else{
        $x.=$id.',';
    }
    $tk.=$id.',';
    $counter++;
}
#Process the remainder
print "\nRemainder: ";
print substr($x, 0, length($x)-1);

print "\n".substr($tk,0,length($tk)-1);

my $str="XX y?1";
$str=~s/\?/$x/g;
print "\n".$str;