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
""" | |
pip install fastapi | |
pip install "uvicorn[standard]" | |
uvicorn main:app --host 0.0.0.0 --port 8000 | |
""" | |
import glob | |
import json | |
import time |
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
package aoc | |
object Problem04 extends App { | |
println( | |
Some(scala.io.Source.fromResource("inputs/4.txt").getLines.next.split("-").map(_.toInt)) | |
.map(a => | |
(a(0) to a(1)) | |
.map(_.toString.sliding(2).toList) | |
.filter(s => s.exists(p => p(0) == p(1)) && s.forall(p => p(0) <= p(1))) | |
.foldLeft(List(0, 0))((l, s) => |
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
package aoc | |
object Problem03 extends App { | |
println( | |
Some( | |
scala.io.Source.fromFile("inputs/3.txt") | |
.getLines | |
.take(2) | |
.map(l => l.split(",").map(w => w(0) -> w.substring(1).toInt).toList) | |
.map( |
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
package aoc | |
object ProblemTwo extends App { | |
println( | |
(Vector(Vector(12, 2)) ++ ((0 to 100) ++ (0 to 100)).combinations(2)).map(v => | |
( | |
v, | |
Stream.from(0, 4).scanLeft( | |
( | |
scala.io.Source.fromFile("inputs/2.txt") |
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
// https://adventofcode.com/2018/day/5 | |
object Problem5 extends Base("input5.txt") { | |
def reactPolymer(string: String): String = string.foldLeft[List[Char]](Nil) { | |
case (h :: t, char) if h != char && h.toUpper == char.toUpper => t | |
case (acc, char) => char :: acc | |
}.mkString | |
val input = lines.head |
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
def find_next(urinals): | |
occupied = [i for (i, x) in enumerate(urinals) if x] | |
if not occupied: | |
return 0 | |
cur = 0 | |
cur_max = (None, None) | |
for i, u in enumerate(urinals): | |
p, n = occupied[cur], occupied[cur + 1] if cur + 1 != len(occupied) else None | |
if i == n: |
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
import scala.io.Source | |
def findGroup(v: String, groups: Map[String, Set[String]]): Set[String] = { | |
def loop(toVisit: Set[String], visited: Set[String]): Set[String] = (toVisit -- visited) match { | |
case v if v.isEmpty => visited | |
case v => loop(v.flatMap(n => groups.get(n).getOrElse(Set.empty[String])), visited ++ v) | |
} | |
loop(Set(v), Set.empty[String]) | |
} |
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
test: | |
npm install -g jasmine | |
jasmine test1.js test2.js | |
FORCE: |
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
package main | |
import ( | |
"encoding/json" | |
"fmt" | |
"io/ioutil" | |
"os" | |
) | |
// RouteState represents the current state of a given route |
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
.DS_Store |
NewerOlder