#!/usr/bin/perl
use POSIX;
$color{1}="R";
$color{2}="O";
$color{3}="B";
$color{4}="P";
$color{5}="Y";
$color{6}="G";

$n=0;
while($n<12 ) {
    $boardColor{1+6*$n} = "R";
    $boardColor{2+6*$n} = "P";
    $boardColor{3+6*$n} = "Y";
    $boardColor{4+6*$n} = "B";
    $boardColor{5+6*$n} = "O";
    $boardColor{6+6*$n} = "G";
    $n++;
}

$p1 =1;
$p2=1;

while ( $p1<66 && $p2<66 ) {
    #pick card
    $card = $color{floor(rand(6)+1)};
    print "You picked a $card card\n";
    
    $p1++;
    while ($boardColor{$p1} ne $card) {
   	 print "Current board color doesn't match. Keep going";
   	 $p1++;
    }
    
    $card = $color{floor(rand(6)+1)};
    print "You picked a $card card\n";
    $p2++;
    while ($boardColor{$p2} ne $card) {
   	 print "Current board color doesn't match. Keep going";
   	 $p2++;
    }
}

if ($p1>$p2) {print "Player 1 wins";}
else { print "Player 2 wins";}


















