test
This commit is contained in:
parent
bd977181e0
commit
cf94d99129
@ -33,19 +33,17 @@ class schulze
|
||||
$r = array();
|
||||
foreach($votes as $vote)
|
||||
{
|
||||
$r[] = implode($vote);
|
||||
$r[] = implode("/", $vote);
|
||||
}
|
||||
return $r;
|
||||
}
|
||||
|
||||
function votify($votes)
|
||||
function votify(&$votes)
|
||||
{
|
||||
$r = array();
|
||||
foreach($votes as $vote)
|
||||
{
|
||||
$r[] = explode($vote);
|
||||
$vote["vote"] = explode("/", $vote["vote"]);
|
||||
}
|
||||
return $r;
|
||||
}
|
||||
|
||||
function test($v)
|
||||
@ -58,21 +56,17 @@ class schulze
|
||||
print_r($v);
|
||||
for($i = 0;$i < count($v) - 1;$i++)
|
||||
{
|
||||
$s = $v[$i];
|
||||
if ($i == 0)
|
||||
{
|
||||
$w[$j]["vote"] = $v[$i];
|
||||
$w[$j]["n"] = 1;
|
||||
$j += 1;
|
||||
$w[$s] = 1;
|
||||
}
|
||||
if ($v[$i] === $v[$i+1])
|
||||
if ($s == $v[$i+1])
|
||||
{
|
||||
$x = array_search($v[$i], $w);
|
||||
$w[$x]["n"] += 1;
|
||||
$w[$s] += 1;
|
||||
}else
|
||||
{
|
||||
$w[$j]["vote"] = $v[$i+1];
|
||||
$w[$j]["n"] = 1;
|
||||
$j += 1;
|
||||
$w[$s] = 1;
|
||||
}
|
||||
}
|
||||
$w = votify($w);
|
||||
|
Reference in New Issue
Block a user