Skip to content

Instantly share code, notes, and snippets.

def balance_teams(players, n_players, balance_mode):
# Partition or all set of team combinations
possible_teams = sympy.utilities.iterables.multiset_partitions(players,2)
# Filter possible teams to
filtered_possible_teams = []
for p in possible_teams:
if(all([len(p_)==int(n_players/2) for p_ in p])):
filtered_possible_teams.append(p)
# status: (:error (error connection-failed failed with code 22
:host 127.0.0.1 :service 61649))
# point: 1

Better current

class  CommunicationOp << (I, #9922DD) abstract >>

CommunicationOp <|-- BaseSendOp
CommunicationOp <|-- BaseRecvOp

CommunicationOp : __init__([CommunicationOp] paired)

Better current

class  CommunicationOp << (I, #9922DD) abstract >>

CommunicationOp <|-- BaseSendOp
CommunicationOp <|-- BaseRecvOp

CommunicationOp : __init__([CommunicationOp] paired)
@drwebb
drwebb / Lib.hs
Created July 6, 2016 16:16
Functional Kats Robot simulator kata
module Lib where
import Control.Arrow (first, second)
data Dir = N | E | S | W deriving (Show, Enum, Bounded)
type Pos = (Int, Int)
data Robot = Robot Dir Pos deriving Show
@drwebb
drwebb / stack.yaml
Created September 17, 2015 20:22
threepenny-gui and gloss stack yaml
flags: {}
packages:
- '.'
- location:
git: https://github.com/HeinrichApfelmus/threepenny-gui.git
commit: cd9e931cbd5706e8a7fd860a52e5beb9c23cabda
extra-dep: true
- location:
git: https://github.com/benl23x5/gloss.git
commit: c7a88173a08692cc9b0834604fc7d76868289eaa
@drwebb
drwebb / HaskellR.hs
Created September 7, 2015 16:37
GGplot in Haskell
demographicsAnalysis :: (MonadIO m, H.MonadR m) => Frame User -> m ()
demographicsAnalysis fr = do
let demographics = fmap (rcast :: User -> Record '[HaskellExperience
,RecommendHaskell
,Occupation])
(nubbed, counts) = view (runGetter ((,) <$> Getter (_1) <*> Getter _2))
(unzip
(sortByLens (_1.recommendHaskell)
(sortByLens (_1.haskellExperience)
@drwebb
drwebb / .navigate.tmux.conf
Created August 2, 2015 03:57
Emacs and tmux window move integration
# Tmux bit
bind -n C-h run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)vim(diff)?$|emacs.*$' && tmux send-keys C-h) || tmux select-pane -L"
bind -n C-j run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)vim(diff)?$|emacs.*$' && tmux send-keys C-j) || tmux select-pane -D"
bind -n C-k run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)vim(diff)?$|emacs.*$' && tmux send-keys C-k) || tmux select-pane -U"
bind -n C-l run "(tmux display-message -p '#{pane_current_command}' | grep -iqE '(^|\/)vim(diff)?$|emacs.*$' && tmux send-keys C-l) || tmux select-pane -R"
@drwebb
drwebb / wtf.py
Created September 11, 2014 00:45
def appendWithDefault(val, lst = []):
lst.append(val)
return lst
val = 42
mylist = appendWithDefault(val)
print(mylist)
# Does this do what you expect?
mylist2 = appendWithDefault(101)