This file contains hidden or 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
# I have a biased coin that lands heads up with | |
# probability p and tails up with probability (1-p). I | |
# toss the coin n times. What is the probability that I | |
# will see at least k heads? | |
# | |
# https://www.quora.com/I-have-a-biased-coin-that-lands-heads-up-with-probability-p-and-tails-up-with-probability-1-p-I-toss-the-coin-n-times-What-is-the-probability-that-I-will-see-at-least-k-heads | |
def product(xs): | |
p = 1 | |
for i in xs: |
This file contains hidden or 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
-- https://stackoverflow.com/questions/30821491/haskell-take-and-drop-at-the-same-time | |
import Data.List (groupBy, unfoldr) | |
import Data.Function (on) | |
import Text.Printf (printf) | |
import Control.Monad (forM) | |
-- | | |
-- TODO | - Rename | |
-- - Deal with combining characters (eg. diacritics) (should probably use a Unicode-aware library) |
This file contains hidden or 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
Publishing selected text to a GitHub gist via Atom |
This file contains hidden or 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
-- | |
moses = require 'src.lib.moses.moses' | |
vec = require 'src.vec' | |
local Camera = class() | |
This file contains hidden or 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
-- | http://codegolf.stackexchange.com/questions/83377/write-a-program-to-elasticize-strings | |
elasticize :: [a] -> [a] | |
elasticize = concat . zipWith replicate [1..] |