Skip to content

Instantly share code, notes, and snippets.

Created May 21, 2013 00:02
Show Gist options
  • Save anonymous/e0528c363ab21ab02f94 to your computer and use it in GitHub Desktop.
Save anonymous/e0528c363ab21ab02f94 to your computer and use it in GitHub Desktop.
<?php
/*
* Coinroll.it giveaway script (https://bitcointalk.org/index.php?topic=197242.0)
* A 64-bit build of PHP is required
*/
$modulo = hexdec('ffffffffffff');
// Change this to the secret ID once it is released
$secretId = hexdec('e889acf0504e');
// Player bets go here
$data = '
358507d91c67 roomservice
345fad19b419 malevolent
b57111a357c2 durrrr
6fbe3437db32 Mooshire
74392d13bf0d ThickAsThieves
04d496980028 CurbsideProphet
f96096ca2894 Zaih
13fa3c093331 BenTuras
cbfd0400448b NLNico
3524af553adc nocube
5e90c35ccdf5 TradeFortress
cc2c87a25f41 Ferdinandreyes
7efec74ec3da pheaonix
45f504320048 Boelens
ade59f6944c3 Yurkov
085f21b67b19 iANDROID
0fe41c635033 Valle
cc5b4ebed259 MasonIII
7d533a573cd0 drakedog
feb89db5b973 magicmexican
6f41dac40bbd Rawted
add670fecfc3 uvwvj
dc92ae681ef1 icey
e395b0a65980 bapakece
8912282542e3 nocompare
a3cb15b4017b Superior
d1ab64135b6b Hfleer
265a8c475c72 arsenische
cf108077ed4f Lailoken
6b6840365b68 BitLucky
ed7381ef59e0 kuriboh
48b425a31ae9 VexDiesel
fa78ccb124e9 sisenor
c37ad4d88f76 next89
119c4e5974b0 noedaRDH
6683ddc7384f lsvpa
db31066bf835 TheD1ceMan
23696e636c75 onecoin
c9af11d3238f Jahare
199c9066d421 ixne
1c007e9ca29d Ailure
287a6bac3cfe Amph
e79bd0cec2cc Pokerfan
7f70f98d0105 Keldel
d2dc12109f06 asc366
645271b50337 Pumpkin
b01858ae334c Prattler
bbfa716dc61e sour_diesel
99016fa9e1fb GhostOfDawn
a70cdb2dccf6 D35TR0Y3R
9d74570f667e Skrapps
61ed61a8fa5f chungy
088dee346263 pandemic
e42da5481371 danieldaniel
4aaec33df448 Ivica
c1ccb033e57a MattFoster42
38fcb87f7035 fredtrader
4064b50c7b10 protokol
5e90c36ccef5 lerelerele
6ac480b50387 138bpm
9c309fd00ce4 elebit
6f4f1bec95fa BigBitz
553098633cb8 dooglus
cfb7327f9360 Emergenz
fc4aef71b103 ograyray
41d3f126f968 Ajay
7bd155ee7c66 scalar33
';
$playerDistances = array();
function arithmeticMod($x, $m)
{
if ($m < 0) $m = -$m;
$r = $x % $m;
return ($r < 0) ? $r + $m : $r;
}
function modDistance($a, $b, $m)
{
return min(arithmeticMod($a - $b, $m), arithmeticMod($b - $a, $m));
}
$players = explode("\n", $data);
foreach($players as $player)
{
if (strlen($player) < 12) continue;
list($id, $name) = explode(' ', $player, 2);
$playerDistances[$name] = modDistance(hexdec($id), $secretId, $modulo);
}
asort($playerDistances);
echo "Player Distance\n---------------------------------------------------\n";
foreach($playerDistances as $name => $distance)
{
echo str_pad($name, 25) . $distance . "\n";
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment