Given a directed graph with weighted nodes, find the a set of cycles that don't share any nodes, maximizing the total sum of the node weights. Ties can be broken arbitrarily.
All nodes have weight 1
(define with-dynamic-var (sym val f)
(define rec (f)
(match (reset (cons 'dyn sym) f)
({#finished, value} value)
({#shifted, {#lookup, cont}} (rec (thunk (continue cont val))))
({#shifted, {#mut, value, cont}} (with-dynamic-var sym value (thunk (continue cont))))
(rec f))
(define lookup (sym)
| extern crate serde; | |
| use serde::{Serialize, Deserialize}; | |
| struct PathInfo; | |
| struct QueryInfo; | |
| trait ApiFunction<I: Deserialize<'static>, R: Serialize> { | |
| fn build(self) -> Box<Fn(PathInfo, QueryInfo, I) -> R>; | |
| } |
| open System.Collections.Generic; | |
| let memoize f = | |
| let table = new Dictionary<_, _>() | |
| fun k -> | |
| if lock table (fun () -> table.ContainsKey(k)) | |
| then | |
| lock table (fun () -> table.[k]) | |
| else | |
| let res = f k |
| find . | grep "Cargo.toml$" | # Find all cargo.toml files \ | |
| sed 's#/[^/]*$##' | # Remove the filename leaving us with the directories containing cargo.toml files \ | |
| xargs -L1 printf "cd \"%s\"; cargo clean; cd -\n" | # Print "cd path/to/crate; cargo clean; cd -" \ | |
| bash # Execute |
| export PATH="$PATH:$HOME/.cargo/bin" | |
| export LIBRARY_PATH="$LIBRARY_PATH:/usr/local/lib" | |
| set_fg() | |
| { | |
| printf "\001\e[38;5;${1}m\002" | |
| } | |
| set_bg() | |
| { |
| cpp -undef -o foo.txt -nostdinc -E -P |
| # Make it use C-a, similar to screen.. | |
| unbind C-b | |
| unbind l | |
| set -g prefix C-a | |
| bind-key C-a last-window | |
| # Reload key | |
| bind r source-file ~/.tmux.conf | |
| set -g default-terminal "screen-256color" |