defmodule EIO do
def inspect(input, opts \\ []) do
{when_fn, opts} = Keyword.pop(opts, :when)
if when_fn && not is_function(when_fn, 1) 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
module top ( | |
input CLK, | |
input BTN_N, | |
input BTN1, | |
output P1A1, | |
output P1A2, | |
output P1A3, | |
output P1A4, | |
output P1A7, | |
output P1A8, |
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
import deques, sets, tables, strscans, strutils, sequtils, strformat, threadpool | |
{.experimental: "parallel".} | |
type | |
Valve = ref object | |
flowRate: int | |
next: seq[string] | |
paths: seq[tuple[node: string, length: int]] | |
const inputPattern = "Valve $w has flow rate=$i; tunnel$* lead$* to valve$* $+" |
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
import strscans, strformat, sequtils, strutils, algorithm, intsets | |
type | |
Point = tuple[x: int, y: int] | |
Sensor = object | |
position: Point | |
beacon: Point | |
maxRange: int | |
Bounds = tuple[lower: int, upper: int] |
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
import tables, strutils, sequtils, math, sugar, strformat | |
type | |
StopAction = enum Continue, Put, Discard | |
Point = tuple[x: int, y: int] | |
Cave = object | |
map: Table[Point, char] | |
bounds: tuple[min: Point, max: Point] | |
proc `-`(p1, p2: Point): Point = (p1.x - p2.x, p1.y - p2.y) |
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
import tables, strutils, sequtils, math, sugar, strformat | |
type | |
StopAction = enum Continue, Put, Discard | |
Point = tuple[x: int, y: int] | |
Cave = object | |
map: Table[Point, char] | |
bounds: tuple[min: Point, max: Point] | |
proc `-`(p1, p2: Point): Point = (p1.x - p2.x, p1.y - p2.y) |
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
import tables, strutils, sequtils, math, sugar, strformat | |
type | |
StopAction = enum Continue, Put, Discard | |
Point = tuple[x: int, y: int] | |
Cave = object | |
map: Table[Point, char] | |
bounds: tuple[min: Point, max: Point] | |
proc `-`(p1, p2: Point): Point = (p1.x - p2.x, p1.y - p2.y) |
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
import sequtils, strformat, strutils, algorithm | |
type | |
CheckResult = enum Valid, Equal, Invalid | |
PacketKind = enum Seq, Int | |
Packet = ref PacketObj | |
PacketObj = object | |
case kind: PacketKind | |
of Seq: seqVal: seq[Packet] | |
of Int: intVal: int |
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
import tables, sets, deques, strformat, sugar | |
type Point = tuple[x: int, y: int] | |
proc loadMap(filename: string): (Table[Point, int], Point, Point) = | |
var y: int | |
var map: Table[Point, int] | |
var source: Point | |
var destination: Point | |
for line in filename.lines: |
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
import std/sugar, | |
std/deques, | |
std/algorithm, | |
std/sequtils, | |
std/strformat, | |
std/strscans, | |
std/strutils, | |
std/tables, | |
std/enumerate |
NewerOlder