Skip to content

Instantly share code, notes, and snippets.

@magmastonealex
Created October 29, 2013 01:05
Show Gist options
  • Save magmastonealex/7207570 to your computer and use it in GitHub Desktop.
Save magmastonealex/7207570 to your computer and use it in GitHub Desktop.
<?php
$in = file_get_contents("DATA2.txt");
$data = explode("\n", $in);
foreach ($data as $instring){
$finaldata = explode(" ", $instring);
$given = intval($finaldata[0]);
$not = intval($finaldata[1]);
$total = $given+$not;
$percent = floor((($given/$total)*100)/10)*1;
for($i=0; $i<$percent; $i++){
echo "*";
}
for($i=0; $i<10-$percent; $i++){
echo ".";
}
echo "<br>";
}
?>
<?php
$in = file_get_contents("DATA3.txt");
$data = explode("\n", $in);
$total = 0;
for($i=0; $i<count($data);$i++){
$numtoread = intval($data[$i]);
$names = array();
$conflict = array();
$conflictCost = "";
for($x=$i+1; $x<$numtoread+$i+1; $x++){
$broken = explode(" ",$data[$x]);
if ( isset($names[$broken[1]])==1){
array_push($conflict, $broken[0]);
$conflictCost=$broken[1];
}else{
$names[$broken[1]]=$broken[0];
}
}
if(count($conflict)!=0){
for ($x=0; $x < count($conflict); $x++) {
echo $conflict[$x]." ";
}
echo $names[$conflictCost];
}else{
echo "SPOOKY";
}
$i+= $numtoread;
echo "<br>";
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment