This file contains 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
import math | |
(start, stop) = (109900, 126901) | |
composites = [] | |
for pos in range(2, int(math.sqrt(stop))): | |
if not pos in composites: | |
composites.extend([i for i in range(pos * pos, stop, pos)]) | |
filtered = [p for p in range(start, stop, 17) if p in composites] |
This file contains 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
/* | |
* pairwise takes an array of numbers and a target number as arguments, and | |
* searches for pairs of array elements that sum to the target number. It sums | |
* the indices of each pair that add to the target, and returns that sum. | |
* | |
* Caveats: | |
* - Each index can only be used once | |
* - Given a choice between two indices that can pair to the target, the | |
* lowest index should be used. For example, passing ([5, 6, 6], 11) to | |
* pairwise, the resulting sum should be 1, since index 0 (the 5) and |
This file contains 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<style> | |
#map { | |
height: 400px; | |
width: 100%; | |
} | |
</style> | |
</head> |
This file contains 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 MiddleMasker(leadNumChars, trailNumChars, replaceChar) { | |
var re = new RegExp('(^.{' + leadNumChars + '})?.(?=.{' + trailNumChars + '})', 'g'); | |
this.mask = function(str) { | |
return str.replace(re, '$1' + replaceChar) | |
} | |
} | |
var m = new MiddleMasker(6, 4, 'X'); | |
m.mask('4111123456789012'); // "411112XXXXXX9012" |
This file contains 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 iterate(arr, callback) { | |
var fac = [1, 1, 2, 6, 24, 120, 720, 5040, 40320, 362880, 3628800, 39916800]; | |
function swap(a, b) { | |
var tmp = arr[a]; | |
arr[a] = arr[b]; | |
arr[b] = tmp; | |
} | |
callback(arr); | |
for (var iter = 1, last = fac[arr.length]; iter < last; iter++) { |