Link.FYI

Pastebin

Create New My Pastes

Code (PHP) pasted on 2024-10-03, 22:14 Raw Source

  1. <?php
  2. $result=array(); // Empty array for your result
  3. $array=range(111,888); // Make an array with every number between 1117 and 7777
  4. foreach ($array as $k=>$v) {  // Loop through numbers
  5.     if ((preg_match('/[90]/',$v) === 0) && (array_sum(str_split($v, 1)) === 10)) {
  6.         // If number does not contain 8,9 or 0 and sum of all 4 numbers is 10
  7.         // Apply function to multiply each number by 10 and add to result array
  8.         $result[] = array_map("magnitude", str_split($v, 1));
  9.     }
  10. }
  11. function magnitude($val) { // function to multiply by 10 for array map
  12.     return($val * 10);
  13. }