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 factorial(n) { | |
return n < 2 ? 1 : n * factorial(n - 1); | |
}; | |
var fastFac = (function () { | |
var memo = {}; | |
return function (n) { | |
if (memo[n]) { | |
return memo[n]; |
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 isDivisible(dividend, divisor) { | |
return dividend % divisor === 0; | |
} | |
function isPrime(n) { | |
var factor = 2; | |
n = Math.abs(n); | |
if (n <= 1) { |
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 isPalindrome(n) { | |
var str, firstDigit, lastDigit; | |
str = String(n).replace(".", "").split(""); | |
if (str.length < 2) { | |
return false; | |
} | |
firstDigit = str.shift(); |
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 findLargestPrimePalindrome(max) { | |
if (max === 0) { | |
return null; | |
} | |
if (isPalindrome(max) && isPrime(max)) { | |
return max; | |
} | |
return findLargestPrimePalindrome(max - 1); |
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
console.log("Build started"); | |
var now = new Date(); | |
var _ = require("underscore"); | |
var jsp = require("uglify-js").parser; | |
var pro = require("uglify-js").uglify; | |
var fs = require("fs"); | |
var output = "js/compiled.js"; | |
var src = [ |
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
{"startDate":1325404800000,"periods":[2012,2013,2014,2015,2016,2017,2018,2019,2020,2021],"baseDemandCaseId":"","currencyId":"USD","endDate":1638345600000,"endTime":2021,"demandTypes":[{"values":["Front-End","Back-End","QA","Sales"],"label":"Business Unit"},{"values":["Jamaica","Haiti","Costa Rica"],"label":"Geography"}],"id":"402882a8380b2fcb01380ffc23660618","startTime":2012,"timeStep":1,"alternativeWorkStyles":["Mobile","Traditional"],"propertyClasses":[],"clientName":"Nina's Model","dateFormat":"MM/dd/yy","reportDate":1338534000000,"unitsOfMeasure":"Sq. Feet","simulationPath":"/model/nina-example-copy","propertyTypes":[],"baseSupplyCaseId":"","geographies":["Jamaica","Haiti","Costa Rica"],"squareAreaDescription":1,"clientFiscalYearStartMonth":1,"clientId":"default","currentTime":2012,"supplyCaseComparisonOrder":[],"afterTaxDiscountRate":0.05,"ffeUpgradePctCapital":0,"reportTime":2012,"marketRentIndex":["","","","","","","","","",""],"opexEscalationRate":[0.34,"","","","","","","","",""],"propertyTaxRate":0 |
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
[{"data":{"model":["Mazda RX4","Mazda RX4 Wag","Datsun 710","Hornet 4 Drive","Hornet Sportabout","Valiant","Duster 360","Merc 240D","Merc 230","Merc 280","Merc 280C","Merc 450SE","Merc 450SL","Merc 450SLC","Cadillac Fleetwood","Lincoln Continental","Chrysler Imperial","Fiat 128","Honda Civic","Toyota Corolla","Toyota Corona","Dodge Challenger","AMC Javelin","Camaro Z28","Pontiac Firebird","Fiat X1-9","Porsche 914-2","Lotus Europa","Ford Pantera L","Ferrari Dino","Maserati Bora","Volvo 142E"],"mpg":[21,21,22.8,21.4,18.7,18.1,14.3,24.4,22.8,19.2,17.8,16.4,17.3,15.2,10.4,10.4,14.7,32.4,30.4,33.9,21.5,15.5,15.2,13.3,19.2,27.3,26,30.4,15.8,19.7,15,21.4],"cyl":[6,6,4,6,8,6,8,4,4,6,6,8,8,8,8,8,8,4,4,4,4,8,8,8,8,4,4,4,8,6,8,4],"disp":[160,160,108,258,360,225,360,146.7,140.8,167.6,167.6,275.8,275.8,275.8,472,460,440,78.7,75.7,71.1,120.1,318,304,350,400,79,120.3,95.1,351,145,301,121],"hp":[110,110,93,110,175,105,245,62,95,123,123,180,180,180,205,215,230,66,52,65,97,150,150,245,175,66,91,113,264,175,335,109],"drat":[3.9 |
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
# Data structure to use for household size, e.g. | |
{ | |
"northeast": { | |
"hispanic": { | |
"below 35": { | |
"under $20,000": [] | |
} | |
} |
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 parseIncompleteJSON(jsonString, stopIndex) { | |
try { | |
return { | |
json: JSON.parse(jsonString), | |
stoppedAt: stopIndex | |
}; | |
} catch (e) { | |
return parseIncompleteJSON(jsonString.substring(0, jsonString.length - 1), jsonString.length - 1); | |
} |
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
var s = new DistributedSession('my-identifier'); | |
s.on('connection', function (err, conn) { | |
conn.Parallel(data).map(mapper).reduce(reducer).then(function (d) { | |
console.log(d); | |
}); | |
}); | |
// Open connection and find peers | |
s.open().requirePeers(data.length); |
OlderNewer