Skip to content

Instantly share code, notes, and snippets.

View fbrubacher's full-sized avatar

Federico Brubacher fbrubacher

  • Montevideo, Uruguay
View GitHub Profile
from functools import lru_cache
class Solution:
def getProbability(self, A):
def binom(n, k):
if not(0 <= k <= n):
return 0
ans = 1
for i in range(1, k + 1):
ans *= n - i + 1
@fbrubacher
fbrubacher / brew-up-system.sh
Created June 4, 2018 16:13 — forked from Tehnix/brew-up-system.sh
Set up OS X with brew
#!/bin/sh
binaries=(
trash
git
mosh
tmux
screen
zsh
mackup
pyenv
@fbrubacher
fbrubacher / freearchitecture.scala
Created September 29, 2016 16:04
Reading de goes article
// -- in my opinion the wonderful polymorphism of monad type classes in MTL
// -- is the best thing about MTL (rather than transformers themselves), and clearly
// -- superior to how early Free programs were built
//
// -- Nonetheless Free has en equivalent mechanism, which I'm dubbing Free Transformers
// -- FT which goes head-to-head with MTL and even allows developers to target both MTL
// -- and free portions of their code
//
// -- Free Transformesr
//
@fbrubacher
fbrubacher / XorT.scala
Created September 5, 2016 03:31
XorT and Future and Either
package cats
import cats.instances.all._
import cats.data.XorT
import scala.concurrent.{Future, ExecutionContext}
case class User(val id: Integer, val name: String)
class UserRepo {
@fbrubacher
fbrubacher / exampleWriterTraverse.scala
Created August 23, 2016 23:26 — forked from ailiev/exampleWriterTraverse.scala
Scalaz Writer and traverse / mapM example
import scalaz._
import Scalaz._
object ScalazPlay extends App
{
// having this one-param type is critical for the subsequent type inference!
type MyWriter[A] = Writer[List[String],A]
def f1(i:Int) : MyWriter[Int] = for {
import Control.Applicative
import Control.Monad
import Data.List
main = (enumFromTo 1 <$> readLn) >>= mapM_ (\caseno -> do
getLine
x <- map read . words <$> getLine
y <- map read . words <$> getLine
let answer = sum $ zipWith (*) (sort x) (reverse $ sort y)
putStrLn $ "Case #" ++ show caseno ++ ": " ++ show answer
@fbrubacher
fbrubacher / springer-free-maths-books.md
Created December 28, 2015 16:51 — forked from bishboria/springer-free-maths-books.md
Springer have made a bunch of maths books available for free, here are the direct links
object OpsMain {
def main(args : Array[String]) {
hadoop.util.ToolRunner.run(new hadoop.mapred.JobConf, new Tool[XXX]({args => new XXX(args)}), args)
}
}
2014-07-21 16:59:44
Full thread dump Java HotSpot(TM) 64-Bit Server VM (20.65-b04-462 mixed mode):
"Attach Listener" daemon prio=9 tid=7fdba29da800 nid=0x10f40b000 waiting on condition [00000000]
java.lang.Thread.State: RUNNABLE
"Low Memory Detector" daemon prio=5 tid=7fdba4001800 nid=0x10f91d000 runnable [00000000]
java.lang.Thread.State: RUNNABLE
"C2 CompilerThread1" daemon prio=9 tid=7fdba4000800 nid=0x10f81a000 waiting on condition [00000000]
LENGTH = inputParam - 1;
List<Set<Basin>> myBasinSets = new List<HashSet<Basin>>();
Basin[][] basins = new Basin[LENGHT][LENGHT]
for (int i = 0; i < LENGTH; i++) {
for (int j = 0; j < LENGTH; j++) {
Basin currentBasin = basins[i][j];
if(isSink(currentBasin)) {
HashSet currentBasinTree = new HashSet<Basin>();
currentBasinTree.add(currentBasin)