eXorithm – Execute Algorithm: View / Run Algorithm namePrefix

function namePrefix ($number
{
  //Similar scrip in jquery https://jsfiddle.net/ayn_/z2677vs5/
  
  $currentNum = $number
  
  $currentNum = preg_replace'{/s|,|$|h}'''$currentNum);
  
  
  if ($currentNum > 999 && $currentNum < 999999) {
    $newNum = ($currentNum / 1000);
    $newNum = floor$newNum*100)/100 . 'k'
  } else if ($currentNum > 999999) {
    $newNum = ($currentNum / 1000000);
    $newNum = floor$newNum*100)/100  . 'M'
  } else {
    $newNum = 'Error, number format is invalid'
  }
  
  
  return $newNum

Hailstone

<?php

/**
 * hailstone
 *
 * Calculates a hailstone sequence.
http://en.wikipedia.org/wiki/Collatz_conjecture
 *
 * @version 0.3
 * @author Contributors at eXorithm
 * @link /algorithm/view/hailstone Listing at eXorithm
 * @link /algorithm/history/hailstone History at eXorithm
 * @license /home/show/license
 *
 * @param number $number number to start with
 * @return array
 */
function hailstone($number=17)
{
	$result = array();
	
	while ($number > 1) {
		$result[] = $number;
		if ($number & 1)
			$number = 3 * $number + 1;
		else
			$number = $number / 2;
	}
	
	$result[] = $number;
	
	return $result;
}

?>

eXorithm – Execute Algorithm: View / Run Algorithm allocate_color

function allocate_color ($image$color$transparency
{
  if (preg_match'/[0-9ABCDEF]{6}/i'$color)==0) {
    throw new Exception"Invalid color code.");
  }
  if ($transparency<0 || $transparency>127) {
    throw new Exception"Invalid transparency.");
  }
  
  $r  = hexdecsubstr$color, 0, 2));
  $g  = hexdecsubstr$color, 2, 2));
  $b  = hexdecsubstr$color, 4, 2));
  if ($transparency>127) $transparency = 127;
  
  if ($transparency<=0)
    return imagecolorallocate$image$r$g$b);
  else
    return imagecolorallocatealpha$image$r$g$b$transparency);

eXorithm – Execute Algorithm: View / Run Algorithm unity

function unity ($passkey
{
  $ubn = array();
  
  while ($passkey > 9) {
    if (strlen$passkey) > 1)
      $passkey = array_sumstr_split$passkey));
    else
      $passkey = $passkey
  } 
  
  $ubn[] = $passkey
  
  return end$ubn);
} 

eXorithm – Execute Algorithm: View / Run Algorithm rounded_rectangle

function rounded_rectangle ($height$width$corner_radius$rectangle_color$background_color$background_transparent
{
  if (($corner_radius>($height/2)) || ($corner_radius>($width/2))) {
    throw new Exception'Corner radius may not exceed half the length of any of the sides.');
  }
  
  $image = image_create_alpha$width$height);
  
  if (!$background_transparent) {
    $background_color = allocate_color$image$background_color);
    imagefilledrectangle$image, 0, 0, $width$height$background_color);
  }
  
  $rectangle_color = allocate_color$image$rectangle_color);
  
  // draw 2 rectangles that overlap (making an image like the cross on the Swiss flag)
  imagefilledrectangle$image$corner_radius, 0, $width$corner_radius-1, $height$rectangle_color);
  imagefilledrectangle$image, 0, $corner_radius$width$height$corner_radius-1, $rectangle_color);
  
  // draw 4 circles for the corners
  imagefilledellipse$image$corner_radius$corner_radius$corner_radius*2, $corner_radius*2, $rectangle_color);
  imagefilledellipse$image$width$corner_radius-1, $corner_radius$corner_radius*2, $corner_radius*2, $rectangle_color);
  imagefilledellipse$image$corner_radius$height$corner_radius-1, $corner_radius*2, $corner_radius*2, $rectangle_color);
  imagefilledellipse$image$width$corner_radius-1, $height$corner_radius-1, $corner_radius*2, $corner_radius*2, $rectangle_color);
  
  return $image

eXorithm – Execute Algorithm: Embed Algorithm weather_forecast


Embed This Algorithm

This page will help you embed the algorithm weather_forecast 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.

  1. 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.
  2. You can add only the output of the algorithm to your website. There will be no argument inputs or run button.

location Argument info
units Argument info
header color Argument info
day header color Argument info
day color Argument info
Embed the form Embed only the output