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
// Write a program that creates a string that represents an 8×8 grid, | |
// using newline characters to separate lines.At each position of | |
// the grid there is either a space or a "#" character.The characters | |
// should form a chessboard. | |
// Passing this string to console.log should show something like this: | |
// # # # # | |
// # # # # | |
// # # # # |
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
// from https://eloquentjavascript.net/03_functions.html#i_3rsiDgC2do | |
/* | |
Write a function countBs that takes a string as its only argument | |
and returns a number that indicates how many uppercase “B” characters | |
there are in the string. | |
Next, write a function called countChar that behaves like countBs, | |
except it takes a second argument that indicates the character that | |
is to be counted (rather than counting only uppercase “B” characters). |
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 ZERO = () => 0 | |
const increment = (n) => n + 1 | |
// sanity check | |
const zero = ZERO() // 0 | |
const one = increment(zero) // 1 | |
const two = increment(increment(zero)) // 2 | |
const three = increment(increment(increment(zero))) // 3 | |
// this one gets a little hazy heh |
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
//from Michaelson (1989) | |
const identity = (x) => x; | |
const self_apply = (s) => s(s); | |
const apply = (func) => (arg) => func(arg); | |
const identity2 = (x) => (apply(identity))(x) | |
const self_apply2 = (s) => (apply(s))(s) |
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
set nocompatible " be iMproved, required | |
filetype off " required | |
set t_Co=256 | |
set number " Display line numbers beside buffer | |
set scrolloff=5 " Keep at least 5 lines below cursor | |
filetype plugin indent on | |
" show existing tab with 4 spaces width | |
set tabstop=4 |
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
# If you come from bash you might have to change your $PATH. | |
# export PATH=$HOME/bin:/usr/local/bin:$PATH | |
# Path to your oh-my-zsh installation. | |
export ZSH=/Users/kdubbels/.oh-my-zsh | |
# Set name of the theme to load. Optionally, if you set this to "random" | |
# it'll load a random theme each time that oh-my-zsh is loaded. | |
# See https://github.com/robbyrussell/oh-my-zsh/wiki/Themes | |
ZSH_THEME="robbyrussell" |
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
require 'sinatra' | |
get '/hi' do | |
"Hello World!" | |
end |
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
palindrome := method(a, a reverse == a) | |
palindrome("racecar") // ==> true | |
palindrome("foobar") // ==> false |
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 collatz = (n) => { | |
if (n == 1) { | |
console.log(n); | |
return 1; | |
} | |
if (n % 2 == 0) { // n is even | |
console.log(n); | |
return 1 + collatz(n/2) | |
} else { // n is odd |
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 ackermann = (m, n) => { | |
if (m === 0) { | |
return n+1 | |
} | |
if (n === 0) { | |
return ackermann((m - 1), 1); | |
} | |
if (m !== 0 && n !== 0) { |