Skip to content

Instantly share code, notes, and snippets.

View monkeygroover's full-sized avatar

Richard Bowker monkeygroover

View GitHub Profile
@monkeygroover
monkeygroover / happy_git_on_osx.md
Created July 26, 2016 23:38 — forked from trey/happy_git_on_osx.md
Creating a Happy Git Environment on OS X

Creating a Happy Git Environment on OS X

Step 1: Install Git

brew install git bash-completion

Configure things:

git config --global user.name "Your Name"

git config --global user.email "you@example.com"

-module(euler27).
%% API exports
-export([run/0]).
%%====================================================================
%% API functions
%%====================================================================
run() -> lists:foldl(
set -g default-terminal "screen-256color"
set-option -g mouse on
# smart pane switching with awareness of vim splits
bind -n C-h run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-h) || tmux select-pane -L"
bind -n C-j run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-j) || tmux select-pane -D"
bind -n C-k run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-k) || tmux select-pane -U"
bind -n C-l run "(tmux display-message -p '#{pane_current_command}' | grep -iq vim && tmux send-keys C-l) || tmux select-pane -R"
execute pathogen#infect()
execute pathogen#helptags()
set number
syntax enable
set background=dark
let g:solarized_termcolors=256
colorscheme solarized
let fibSeq = Seq.unfold (fun s -> Some(fst s, (snd s, fst s + snd s))) (1I,1I)
let result = fibSeq
|> Seq.takeWhile(fun x -> x < pown 10I 999)
|> Seq.length
|> (+) 1
printfn "%A" result
type DivisorType = Deficient | Perfect | Abundant
let divisors number = {1 .. number/2} |> Seq.filter(fun n -> number % n = 0)
let sumDivisors = divisors >> Seq.sum
let divisorSumType number = match (number - sumDivisors number) with
| 0 -> Perfect
| d when d > 0 -> Deficient
| d -> Abundant
@monkeygroover
monkeygroover / euler22.fsx
Last active March 30, 2016 20:59
euler22
open System.IO
let wordValue (word: string) = Seq.map(fun c -> (int c) - (int 'A') + 1) word
|> Seq.sum
let result = File.ReadLines("p022_names.txt")
|> Seq.collect(fun line -> line.Split ',')
|> Seq.map(fun quotedWord -> quotedWord.Trim [|'"'|] )
|> Seq.sort
|> Seq.mapi(fun i word -> (i + 1) * wordValue word)
let factors number = seq {
for divisor in 1 .. (float >> sqrt >> int) number do
if number % divisor = 0 then
yield divisor
if number <> 1 then yield number / divisor //special case condition: when number=1 then divisor=(number/divisor), so don't repeat it
}
let d n = Seq.sum(factors n) - n
let all = {1..9999} |> Seq.map(fun a -> (a, d(a))) |> Map.ofSeq
let units bi = (bi % 10I, bi/10I)
let rec sum bi = match units(bi) with
| (u, r) when r = 0I -> u
| (u, r) -> u + sum(r)
let rec fac(n:int): bigint = match n with
| 1 -> bigint(1)
| n -> bigint(n) * fac(n - 1)
@monkeygroover
monkeygroover / euler16.fsx
Last active March 30, 2016 20:59
euler16
let units bi = (bi % 10I, bi/10I)
let rec sum bi = match units(bi) with
| (u, r) when r = 0I -> u
| (u, r) -> u + sum(r)
let result = sum(pown 2I 1000)
printfn "%A" result