This file contains hidden or 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
(defpackage #:my-hash-table | |
(:use #:cl #:arrows) | |
(:export #:new-hash #:put-hash #:get-hash #:hash-keys #:hash-values #:rem-hash)) | |
(in-package #:my-hash-table) | |
(defun ->hash-code (key) | |
(-<> (format nil "~A" key) | |
(coerce <> 'list) | |
(reduce (lambda (hash elem) (+ (* 31 hash) (char-code elem))) <> :initial-value 0))) |
This file contains hidden or 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
(defpackage :transposition | |
(:use :cl)) | |
(in-package :transposition) | |
(defparameter *text* "WEAREDISCOVEREDFLEEATONCE------") | |
(defun range (max &key (min 0) (step 1)) | |
(loop for n from min below max by step | |
collect n)) |
This file contains hidden or 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
(defpackage :matrices | |
(:use :cl :iterate) | |
(:export multiply)) | |
(in-package :matrices) | |
(defun multiply (m1 m2) | |
(flet ((multiply-row (row column size) | |
(iter | |
(for i :below size) |
This file contains hidden or 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
(defn queue [] | |
(java.util.PriorityQueue.)) | |
(defn peek [pqueue] | |
(.peek pqueue)) | |
(defn poll [pqueue] | |
(.poll pqueue) | |
pqueue) |
This file contains hidden or 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
#include <stdio.h> | |
#include <stdlib.h> | |
#include <stdint.h> | |
#ifdef _MSC_VER | |
#include <intrin.h> /* for rdtscp and clflush */ | |
#pragma optimize("gt",on) | |
#else | |
#include <x86intrin.h> /* for rdtscp and clflush */ | |
#endif |
This file contains hidden or 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
(ns prison.core | |
(:require [gniazdo.core :as ws] | |
[clojure.data.json :as json] | |
[clojure.string :as str])) | |
(defn parse [str] | |
(json/read-str str :key-fn keyword)) | |
(def score (atom {})) | |
(def last-round (atom nil)) |
This file contains hidden or 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
(ns prison.core | |
(:require [gniazdo.core :as ws] | |
[clojure.data.json :as json])) | |
(defn parse [str] | |
(json/read-str str :key-fn keyword)) | |
(def msg-atom (atom nil)) | |
(defn handle [msg] |
This file contains hidden or 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
defmodule Plumber do | |
def input(file) do | |
file | |
|> File.stream!() | |
|> Enum.map(&(Regex.split(~r/\D+/, String.trim(&1)))) | |
|> Enum.reduce(%{}, fn([first | rest],acc) -> Map.put(acc,first,rest) end ) | |
end | |
def count([], acc, input) do | |
case Map.keys(input) do |
This file contains hidden or 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
defmodule Plumber do | |
def input do | |
"/Users/maris/Projects/Advent_of_code_2017/plumber/test/input" |> | |
File.stream!() |> | |
Enum.map(&(Regex.split(~r/\D+/, String.trim(&1)))) |> | |
Enum.reduce(%{}, fn([first | rest],acc) -> Map.put(acc,first,rest) end ) | |
end | |
def count([], acc, input) do | |
case Map.keys(input) do |
This file contains hidden or 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
blur : Dict(Int,Int) Int -> ( Int, Int ) -> Int | |
blur cells ( x, y ) = | |
let | |
xs = | |
range (x - 1) (x + 1) | |
ys = | |
range (y - 1) (y + 1) | |
points = |
NewerOlder