golf1

#!/usr/bin/env php
<?php

$l=file('input.txt');
$r=12;
$g=13;
$b=14;

foreach ($l as $n){
    preg_match_all('/(\d+) (.)/',$n, $c);

    foreach($c[2]as$i=>$u){
        if($c[1][$i++]>$$u)continue 2;
    }

    preg_match('/\d+/',$n,$m);
    $t+=$m[0];
}

// should be 2563
echo "Sum of Game IDs: $t\n";