Skip to content

Instantly share code, notes, and snippets.

View monkeygroover's full-sized avatar

Richard Bowker monkeygroover

View GitHub Profile
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
@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)
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
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
execute pathogen#infect()
execute pathogen#helptags()
set number
syntax enable
set background=dark
let g:solarized_termcolors=256
colorscheme solarized
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"
-module(euler27).
%% API exports
-export([run/0]).
%%====================================================================
%% API functions
%%====================================================================
run() -> lists:foldl(
@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 "[email protected]"

/**
* Copyright 2011-2017 GatlingCorp (http://gatling.io)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
defmodule TableRenderer do
def render_html(service_data) do
markup = """
table
tr
th Service
th SHA(s)
th Nodes
= Enum.map service_data, fn({service, data}) ->