Skip to content

Instantly share code, notes, and snippets.

View aaronjeline's full-sized avatar

Aaron Eline aaronjeline

  • AWS
  • Baltimore
View GitHub Profile
#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)))
@aaronjeline
aaronjeline / percept.rkt
Created September 18, 2023 23:02
Perceptrons and Rosette
#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)))
#lang racket
(require threading racket/trace)
(define FILE "/tmp/input")
(define lines
(with-input-from-file
FILE
(λ ()
(port->lines (current-input-port)))))
#lang racket
(require threading)
(define FILE "/tmp/input")
(struct grid (data length width) #:transparent)
(define/contract (point? x)
(-> any/c boolean?)
(match x
#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 " ")))
#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))))
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);
#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))]))
#lang racket
(require threading)
(require "parser.rkt")
(module+ test (require rackunit))
(define winnings '())
(define src
(syntax->datum
(with-input-from-file "/tmp/input"
#lang racket
(require threading)
(require data/bit-vector)
(define src
(~>
(with-input-from-file
"/tmp/input"
(λ () (port->lines (current-input-port))))
(map string->list _)))