Skip to content

Instantly share code, notes, and snippets.

View zoldar's full-sized avatar

Adrian Gruntkowski zoldar

View GitHub Profile
module top (
input CLK,
input BTN_N,
input BTN1,
output P1A1,
output P1A2,
output P1A3,
output P1A4,
output P1A7,
output P1A8,

EIO.inspect

Section

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
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$* $+"
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]
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)
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)
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)
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
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:
import std/sugar,
std/deques,
std/algorithm,
std/sequtils,
std/strformat,
std/strscans,
std/strutils,
std/tables,
std/enumerate