Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am slofurno on github.
  • I am slofurno (https://keybase.io/slofurno) on keybase.
  • I have a public key whose fingerprint is 250A 7A59 9DEF 57BE E405 F923 6520 052C EAED 3DD4

To claim this, I am signing this object:

@slofurno
slofurno / sql.go
Last active February 27, 2016 12:48
package main
import (
"database/sql"
"encoding/json"
"fmt"
_ "github.com/mattn/go-sqlite3"
"os"
)
defmodule S do
def test do
words = ["hot", "dot", "dog", "lot", "log", "cog"]
5 = shortest(words, "hit", "cog")
words = ["hot", "cog", "dog", "tot", "hog", "hop", "pot", "dot"]
3 = shortest(words, "hot", "dog")
words = ["talk", "tons", "fall", "tail", "gale", "hall", "negs"]
0 = shortest(words, "talk", "tail")
function wordLadder(beginWord, endWord, wordList) {
var words = {}
wordList.forEach(x => words[x] = true)
var queue = [[beginWord, 1]]
while(queue.length) {
var m = queue.shift()
var word = m[0]
var depth = m[1]
defmodule S do
def test do
a = [[1, 3], [2, 6], [8, 10], [7, 11]]
[[1,6], [7,11]] = interval(a)
a = [[5,12],[8,10]]
[[5,12]] = interval(a)
a = [[1,6], [6,10]]
^a = interval(a)
defmodule S do
def fizzbuzz(n), do: fb(3, 5, 1, n, [])
def fb(_fizz, _buzz, i, i, r), do: r |> Enum.reverse
def fb(i, i, i, j, r) do
fb(i+3, i+5, i+1, j, ["FizzBuzz"|r])
end
def fb(i, buzz, i, j, r) do
fb(i+3, buzz, i+1, j, ["Fizz"|r])
const elements = `1,H,Hydrogen,1.00794
2,He,Helium,4.002602
3,Li,Lithium,6.941
4,Be,Beryllium,9.012182
5,B,Boron,10.811
6,C,Carbon,12.0107
7,N,Nitrogen,14.0067
8,O,Oxygen,15.9994
9,F,Fluorine,18.9984032
10,Ne,Neon,20.1797
function kaprekar(n) {
const asc = [].slice.call('000' + n).slice(-4).sort((a,b) => a - b).join('')|0
const des = [].slice.call('000' + n).slice(-4).sort((a,b) => b - a).join('')|0
return des - asc
}
function iterations(n) {
let i = 0
defmodule BinaryTree do
defstruct [:left, :right, :value]
def invert(%__module__{left: left, right: right} = root) do
%{root| left: invert(right), right: invert(left)}
end
def invert(nil), do: nil
def test do
three = %BinaryTree{value: 3}
function invert(xs) {
let j = 1
while(j < xs.length) {
let start = j
let end = 2*j
while(end > start) {
swap(xs, start, end)
end--