Skip to content

Instantly share code, notes, and snippets.

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
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")
@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"
)

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 / comb.js
Last active November 1, 2015 03:55
var numbers = ["13", "01", "02", "24", "14", "12", "25"].map(x=>[].slice.call(x)).map(x=>x.concat(x.slice().reverse())).map(x=>x.join("")).map(x=>[x.substr(0,2),x.substr(-2)]);
var perm = function(arr){
if (arr.length===1){
return [arr];
}
var results = [];
@slofurno
slofurno / utc.cs
Last active October 12, 2015 19:26
get ms since utc epoch, compatible with js Date
var GetUtcMs = ((Func<Func<DateTime, long>>)(() =>
{
var _utczero = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
return x => (long)((x.ToUniversalTime() - _utczero).TotalMilliseconds);
}))();
@slofurno
slofurno / sl.c
Created September 24, 2015 02:05
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
unsigned char rndtable[256] = {
0, 8, 109, 220, 222, 241, 149, 107, 75, 248, 254, 140, 16, 66 ,
74, 21, 211, 47, 80, 242, 154, 27, 205, 128, 161, 89, 77, 36 ,
95, 110, 85, 48, 212, 140, 211, 249, 22, 79, 200, 50, 28, 188 ,
52, 140, 202, 120, 68, 145, 62, 70, 184, 190, 91, 197, 152, 224 ,
149, 104, 25, 178, 252, 182, 202, 182, 141, 197, 4, 81, 181, 242 ,
@slofurno
slofurno / json.cs
Created May 6, 2015 20:53
append json
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using Jil;
namespace ConsoleApplication8
{
# Blender v2.64 (sub 0) OBJ File: ''
# www.blender.org
o Mesh63_Component_17_8_Model
v -43.885899 11.667700 2.246782
v -43.930401 11.667700 2.118952
v -44.101398 11.667700 1.628182
v -44.158001 11.667700 1.465672
v -44.851002 11.667700 1.707122
v -44.578899 11.667700 2.488232
v -43.930401 12.161100 2.118952
@slofurno
slofurno / ziparchive.cs
Last active August 29, 2015 14:19
ziparchive
using System;
using System.Collections.Generic;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication5
{