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
const processInput = str => { | |
return str | |
.trim() | |
.split("\t") | |
.map(Number); | |
}; | |
const spread = step => { | |
step = step.slice(0); | |
let max = step.reduce((a, b) => Math.max(a, b)); |
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
const processInput = str => { | |
return str | |
.trim() | |
.split("\t") | |
.map(Number); | |
}; | |
const spread = step => { | |
step = step.slice(0); | |
let max = step.reduce((a, b) => Math.max(a, b)); |
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
<cfscript> | |
var bodyDot = {}; | |
bodyDot.grant_type = "authorization_code"; | |
writeDump(bodyDot); | |
var bodyBracket = {}; | |
bodyBracket['grant_type'] = "authorization_code"; | |
writeDump(bodyBracket); | |
</cfscript> |
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
// object test for equality fails as object need to be pointing to same reference in memory | |
// primitives like strings and numbers are compared by their value | |
function greetFailing(person) { | |
if (person == { name: 'amy' }) { | |
return 'hey amy' | |
} else { | |
return 'hey arnold' | |
} | |
} |
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
<cfscript> | |
lines = [1,2,3,4]; | |
lines.map(function(line){ | |
var greeting = "you"; | |
if(line eq 3){ | |
greeting = "Roahl Dahl"; | |
} | |
writeOutput( "Happy Birthday to " & greeting & "<br>"); | |
}); |
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
<cfscript> | |
function f(bytes){ | |
var hash = []; | |
var unit = 0; | |
var magnitude = ''; | |
var sizes = [ | |
{'unit':'B', size:1}, | |
{'unit':'KB', size:1024}, | |
{'unit':'MB', size:1024*1024}, |
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
<cfscript> | |
function smallestWholeNumberGreaterThanZero(prev, item){ | |
if (prev eq 0){ | |
return item; | |
} | |
if (item eq 0){ | |
return prev; | |
} |
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
<cfscript> | |
tests = [ | |
// sorted | |
[true,[1,2,3,4,5]] | |
,[true,[2,4,6,8,10]] | |
// 1 swap | |
,[true,[1,2,3,5,4]] | |
,[true,[5,2,3,4,1]] | |
,[true,[1,2,3,5,3]] |
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
<cfscript> | |
tests = [ | |
// sorted | |
[true,[1,2,3,4,5]] | |
,[true,[2,4,6,8,10]] | |
// 1 swap | |
,[true,[1,2,3,5,4]] | |
,[true,[5,2,3,4,1]] | |
,[true,[1,2,3,5,3]] |
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
<cffunction | |
name="REMatchGroup" | |
access="public" | |
returntype="array" | |
output="false" | |
hint="Gets the given group of a captured expression."> | |
<!--- Define arguments. ---> | |
<cfargument | |
name="Pattern" |