Instantly share code, notes, and snippets.

# Curtis Auteryceautery

• Sort options
Last active Jan 2, 2018
Advent of Code 2017, Day 23
View composite-counter.py
 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]
Last active May 21, 2017
Solution to the https://www.freecodecamp.com/challenges/pairwise with lengthy explanation
View pairwise.js
 /* * 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
Created Oct 21, 2016
Lookup latitude/longitude coordinates of cities using Google's Geocode API
View test.html

Created Apr 20, 2016
Mask the middle part of credit card numbers
View gist:5b32a46ac4ed6c1df5d63281df90ccd9
 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"
Created Dec 23, 2015
Non-recursive Heap's Algorithm in JavaScript, with a callback
View gist:4240087f1bfbcebc6cb7
 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++) {
You can’t perform that action at this time.