This file contains 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
#lang racket | |
(define N 1000) | |
(define (main) | |
(printf "N: ~a\n" N) | |
(define data (play-n-games N)) | |
(printf "Alice wins: ~a\n" (count alice? data)) | |
(printf "Bob wins: ~a\n" (count bob? data)) | |
(printf "Ties: ~a\n" (count tie? data))) |
This file contains 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
#lang rosette/safe | |
;; take weights and threshold | |
;; returns a function that implements a perceptron neuron | |
(define (neuron weights threshold) | |
(λ inputs | |
(if ((foldl + 0 (map * weights inputs)) . > . threshold) | |
1 | |
0))) |
This file contains 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
#lang racket | |
(require threading racket/trace) | |
(define FILE "/tmp/input") | |
(define lines | |
(with-input-from-file | |
FILE | |
(λ () | |
(port->lines (current-input-port))))) |
This file contains 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
#lang racket | |
(require threading) | |
(define FILE "/tmp/input") | |
(struct grid (data length width) #:transparent) | |
(define/contract (point? x) | |
(-> any/c boolean?) | |
(match x |
This file contains 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
#lang racket | |
(require threading) | |
(module+ rackunit) | |
(struct line (wires output) #:transparent) | |
(define (parse-list lst) | |
(map (compose list->set string->list string-trim) (string-split lst " "))) |
This file contains 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
#lang racket | |
(require threading) | |
(define sample-pos | |
(~> | |
"16,1,2,0,4,2,7,1,2,14" | |
#; | |
(with-input-from-file | |
"/tmp/input" | |
(λ () (port->string (current-input-port)))) |
This file contains 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
use std::fs::read_to_string; | |
const DAYS: usize = 256; | |
type Fish = Vec<u64>; | |
fn main() { | |
let mut fish = vec![0; 9]; | |
let mut scratch; | |
parse_input(&mut fish); |
This file contains 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
#lang racket | |
(require threading) | |
(module+ test (require rackunit)) | |
(struct line (from to) #:transparent) | |
(struct posn (x y) #:transparent) | |
(define (parse-line l) | |
(match (string-split l "->") | |
[(list to from) | |
(line (parse-cord to) (parse-cord from))])) |
This file contains 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
#lang racket | |
(require threading) | |
(require "parser.rkt") | |
(module+ test (require rackunit)) | |
(define winnings '()) | |
(define src | |
(syntax->datum | |
(with-input-from-file "/tmp/input" |
This file contains 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
#lang racket | |
(require threading) | |
(require data/bit-vector) | |
(define src | |
(~> | |
(with-input-from-file | |
"/tmp/input" | |
(λ () (port->lines (current-input-port)))) | |
(map string->list _))) |
NewerOlder