unity    version 1.2    Returns digit summation of any numerical value given for passkey (up to 14 digits in length)
Category: Algorithm
eXorithm – Execute Algorithm: View / Run Algorithm gcd_euclid
function gcd_euclid ($a, $b
{
  $a = abs$a);
  $b = abs$b);
 Â
  if ($a == 0)
    return $b
  elseif ($b == 0)
    return $a
  elseif ($a > $b
    return gcd_euclid$b, $a % $b);
  else
    return gcd_euclid$a, $b % $a);
}Â
eXorithm – Execute Algorithm: Embed Algorithm sort_multi_array
Embed This Algorithm
This page will help you embed the algorithm sort_multi_array on a page on your own website. Just configure the inputs, then click the generate button to get a snippet of code you can paste onto your site. You have two options.
- You can embed the entire form. Users will be able to enter their own arguments, and will need to press the run button to execute the algorithm.
- You can add only the output of the algorithm to your website. There will be no argument inputs or run button.
eXorithm – Execute Algorithm: View / Run Algorithm array_fusion
function array_fusion ($array, $type
{
switch$type) {
case 'standard'
case 'positive'
return array_sum$array);
break
case 'negative'
return -array_sum$array);
break
case 'string'
return json_encodearray_sum$array));
break
case 'duplicate'
return powarray_sum$array), array_sum$array));
break
case 'del'
$return = $array
for$i = 0; $i < count$array); $i++)
if$i % 2 == 0 || $i * 3 == count$array))
unset$return$i]);
return array_sum$return);
break
case 'med'
return array_sum$array) / count$array); //count($array);
break
case 'meded'
return array_fusionarrayarray_fusion$array, 'positive')), 'med');
break
}
}
eXorithm – Execute Algorithm: View / Run Algorithm freebase_populations
function freebase_populations ($countries
{
$query = array'type'=>'/location/country',
'name'=>null,
'query:name|='=>$countries,
'iso3166_1_alpha2!='=>''
'/location/statistical_region/population'=> arrayarray
'limit'=>1,
'number'=>null,
'year'=>null,
'sort'=>'-year'
)) );
$results = freebase_query$query);
$return = array();
foreach ($results as $result) {
if (isset$result'/location/statistical_region/population'][0]['number'])) {
$return$result'name']] = $result'/location/statistical_region/population'][0]['number'];
}
}
return $return
}
eXorithm – Execute Algorithm: View / Run Algorithm image_create_alpha
function image_create_alpha ($width, $height
{
// Create a normal image and apply required settings
$img = imagecreatetruecolor$width, $height);
imagealphablending$img, false);
imagesavealpha$img, true);
// Apply the transparent background
$trans = imagecolorallocatealpha$img, 0, 0, 0, 127);
for ($x = 0; $x < $width; $x++)
{
for ($y = 0; $y < $height; $y++)
{
imagesetpixel$img, $x, $y, $trans);
}
}
return $img
}
eXorithm – Execute Algorithm: View / Run Algorithm multicolumn
function multicolumn ($items, $type, $rows, $columns, $table_attributes, $td_attributes, $empty_attributes
{
$return = ''
$count = count$items);
// compute number of columns and rows
if (($rows=='*') && ($columns=='*')) {
$rows = roundsqrt$count));
$columns = ceil$count$rows);
} else {
if ($rows=='*'
$rows = ceil$count$columns);
else if ($columns=='*'
$columns = ceil$count$rows);
}
if ($count>0) {
$return .= "<table $table_attributes>"
$column = 0;
$row = 0;
$total = $rows * $columns
for ($i=0;$i$total$i++) {
if$column == 0)
$return .= '<tr>'
if ($type=='horizontal'
$spot = $i
else
$spot = $row$column$rows
if ($spot$count
$return .= "<td $td_attributes>$items[$spot]</td>"
else
$return .= "<td $empty_attributes></td>"
$column++;
if ($column==$columns) {
$return .= '</tr>'
$column = 0;
$row++;
}
}
$return .= '</table>'
}
return $return
}
eXorithm – Execute Algorithm: Algorithms Beginning with W
eXorithm – Execute Algorithm: View / Run Algorithm coin_change
function coin_change ($amount, $coins
{
  $change = array();
  rsort$coins);
  for$i=0; $icount$coins); $i++) {
    $change$coins$i]] = floor$amount$coins$i]);
    $amount = $amount % $coins$i];
  }
  return $change
}Â
eXorithm – Execute Algorithm: View / Run Algorithm radtodeg
function radtodeg ($radians
{
  return ($radians * (180.0/pi()));
}Â