Skip to content

Instantly share code, notes, and snippets.

@mpadmore
mpadmore / ExampleQuery.cfm
Last active June 3, 2018 16:24
Example of queryExecute
<cfscript>
people = queryNew(
"id, firstName, lastName, email, country, ip_address",
"integer, varchar, varchar, varchar, varchar, varchar",
[{
"id": 1,
"firstName": "Christopher",
"lastName": "Burton",
"email": "[email protected]",
"country": "Poland",
@mpadmore
mpadmore / froghops.cfm
Created February 28, 2018 21:11
How many frog hops from x to y
<cfscript>
// A small frog wants to get to the other side of the road.
// The frog is currently located at position X and wants to get to a position greater than or equal to Y.
// The small frog always jumps a fixed distance, D.
// Count the minimal number of jumps that the small frog must perform to reach its target.
// Write a function that, given three integers X, Y and D, returns the minimal number of jumps from position X to a position equal to or greater than Y.
// For example, given:
// X = 10
// Y = 85
// D = 30 the function should return 3
@mpadmore
mpadmore / fibonacci.cfm
Created February 28, 2018 21:01
Fibonacci example function
<cfscript>
function fibonacci(nth) {
fibString = "1";
if (nth GT 1) {
prev2 = 0;
prev1 = 1;
for (i=2; i LTE nth; i=i+1) {
thisItem = prev2 + prev1;
fibString = fibstring & " " & thisItem;