This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | function pairs(items) { | |
| return items | |
| .map((item, index, items) => [item, items[(index + 1) % items.length]]); | |
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | function shuffle(items) { | |
| return items | |
| .map(item => [item, Math.random()]) | |
| .sort((a, b) => (a[1] > b[1]) - (a[1] < b[1])) | |
| .map(item => item[0]); | |
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | <?php | |
| // create whois instance | |
| $whois = Whois::create(); | |
| // load hosts from json | |
| $json = json_decode(file_get_contents('your.json'), true); | |
| // add custom servers to whois instance | |
| $servers = $whois->getServerProvider(); | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | public static function calcSquareSpiralPos( outPos:Point, iteration:int, phaseShift:int=0, CCW:Boolean=false ) : void | |
| { | |
| var n:int = (2.0 * Math.sqrt(iteration + 1) - 0.000001); | |
| var p:int = (n + phaseShift) % 4; | |
| var h:int = (0.5 * (1.0 + n + (p & 0x1))); | |
| var v:int = (0.5 * (2.0 + n - (p & 0x1))); | |
| var d:int = iteration - int(0.5 * ((h * (h - 1)) + (v * (v - 1)))); | |
| outPos.x = ((2 * ((1.5 - p) & 0x1) - 1) * int(0.5 * h) + d * ((p - 1) * ((p + 1) & 0x1))) * (1 - 2 * int(CCW)); | |
| outPos.y = ((1 - 2 * ((0.5 * p) & 0x1)) * int(0.5 * v) + d * ((p - 2) * (p & 0x1))); | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | function calc(inputNum) { | |
| var coord = spiralCoord(inputNum - 1, -1, true); | |
| return Math.abs(coord.x) + Math.abs(coord.y); | |
| } | |
| function spiralCoord(iteration, phaseShift, isCCW) { | |
| var n = Math.floor(2.0 * Math.sqrt(iteration + 1) - 0.000001); | |
| var p = (n + phaseShift) % 4; | |
| var h = Math.floor(0.5 * (1.0 + n + (p & 0x1))); | |
| var v = Math.floor(0.5 * (2.0 + n - (p & 0x1))); | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | function calc(inputNum) { | |
| var coord = spiralCoord(inputNum - 1); | |
| return Math.abs(coord.x) + Math.abs(coord.y); | |
| } | |
| function spiralCoord(index) { | |
| var coord = { x: 0, y: -1 }; | |
| var dir = 3; | |
| var vecs = { | |
| 0: { x: 1, y: 0 }, | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | function calc(input) { | |
| var checksum = 0; | |
| input.split('\n').forEach(row => { | |
| var nums = row.split('\t').map(n => parseInt(n)); | |
| checksum += findIntDivs(nums).reduce((a, b) => a + b, 0); | |
| }); | |
| return checksum; | |
| } | |
| function findIntDivs(nums) { | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | function calc(input) { | |
| var checksum = 0; | |
| input.split('\n').forEach(row => { | |
| var nums = row.split('\t').map(n => parseInt(n)); | |
| var min = nums.reduce((a, b) => Math.min(a, b)); | |
| var max = nums.reduce((a, b) => Math.max(a, b)); | |
| checksum += max - min; | |
| }); | |
| return checksum; | |
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | <?php | |
| function generate_sets($values) { | |
| $total = 1 << count($values); | |
| for ($i = 0; $i < $total; $i++) { | |
| $subset = []; | |
| foreach ($values as $j => $val) { | |
| if ($i & (1 << $j)) { | |
| $subset[] = $val; | |
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | <?php | |
| function sets_of($list) { | |
| $sets = []; | |
| $total = 1 << count($list); | |
| for ($i = 0; $i < $total; $i++) { | |
| $sub = []; | |
| foreach ($list as $j => $val) { | |
| if ($i & (1 << $j)) { | |
| $sub[] = $val; |