Skip to content

Instantly share code, notes, and snippets.

@emad-elsaid
Created February 11, 2011 13:22
Show Gist options
  • Select an option

  • Save emad-elsaid/822328 to your computer and use it in GitHub Desktop.

Select an option

Save emad-elsaid/822328 to your computer and use it in GitHub Desktop.
<?php
$input = trim(file_get_contents('A-large-practice.in'));
$input = explode("\n",$input);
$input = array_slice($input,1);
for( $i=0; $i<count($input); $i+=3)
{
$c = intval($input[$i]);
$inputs = array_map('intval',explode(' ',$input[$i+2]));
$found = false;
foreach( $inputs as $k=>$v )
{
$x = $k+1;
for( ; $x<count($inputs) and !$found; $x++ )
{
if( $inputs[$x]+$v==$c )
{
echo 'Case #'.($i/3+1);
echo ': '.($k+1).' '.($x+1);
echo "\n";
$found = true;
}
}
if( $found )
break;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment