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
type Peg = String | |
type Move = (Peg, Peg) | |
hanoi :: Integer -> Peg -> Peg -> Peg -> [Move] | |
hanoi 0 _ _ _ = [] | |
hanoi n a b c = hanoi (n - 1) a c b ++ [(a, c)] ++ hanoi (n - 1) b a c | |
main = do | |
print $ hanoi 1 "a" "b" "c" | |
print $ hanoi 2 "a" "b" "c" |
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
-- Lucas Carmichael Numbers | |
-- | |
-- inspired by the Youtube channel Numberphile | |
-- episode https://www.youtube.com/watch?v=yfr3BIk6KFc | |
-- "Something special about 399 (and 2015)" | |
-- | |
-- by calle@upset.se, jan 2015 | |
import Data.Numbers.Primes |
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
-- cans.hs | |
-- Calculate number of cans in one pyramid | |
cansInPyramid :: Int -> Int | |
cansInPyramid 1 = 1 | |
cansInPyramid n = n + cansInPyramid (n - 1) | |
-- Smaller solution | |
cansInPyramid' n = sum [1..n] |
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
<!DOCTYPE html> | |
<!-- by calle@stenhall.com --> | |
<html> | |
<head> | |
<title>TITLE</title> | |
<style> | |
@import url("reset.css"); | |
@import url("style.css"); | |
</style> | |
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script> |
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
// Filter File | |
// a simple script for extracting parts in a textfile between two lines. | |
// by Calle Robertsson, calle@upset.se, 2013. | |
var fs = require('fs'); | |
var filename = process.argv[2]; | |
if (!filename) { | |
throw new Error('Missing command line argument for file name.'); |
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
// The javascript compare objects function | |
function compareObjects(o1, o2, ignoreFields){ | |
ignoreFields = ignoreFields || []; | |
//console.log('Ignore: ' + JSON.stringify(ignoreFields)); | |
for(var p in o1) { | |
if (ignoreFields.indexOf(p) < 0) { | |
if(o1[p] !== o2[p]){ | |
return false; | |
} | |
} |
NewerOlder