Move inputs to new folder
This commit is contained in:
parent
ec6efad8f7
commit
5556817cf9
|
@ -1,3 +1,3 @@
|
|||
(def sorted-totals (sort (map #(reduce + %) (map #(map read-string %) (map clojure.string/split-lines (clojure.string/split (slurp "day1-input") #"\n\n"))))))
|
||||
(def sorted-totals (sort (map #(reduce + %) (map #(map read-string %) (map clojure.string/split-lines (clojure.string/split (slurp "input/1") #"\n\n"))))))
|
||||
(println (last sorted-totals)) ; Part 1
|
||||
(println (reduce + (take-last 3 sorted-totals))) ; Part 2
|
|
@ -2,7 +2,7 @@ import scala.collection.mutable.ArrayBuffer
|
|||
import scala.io.Source
|
||||
|
||||
@main def main() =
|
||||
val elfRations = Source.fromFile("day1-input").mkString.split("\n\n").map(_.split("\n").map(_.toInt))
|
||||
val elfRations = Source.fromFile("input/1").mkString.split("\n\n").map(_.split("\n").map(_.toInt))
|
||||
val sortedElfCalories = elfRations.map(_.sum).sorted
|
||||
|
||||
// Part 1 solution: Total calories held by elf with the most total calories
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
(require '[clojure.string :as str])
|
||||
(def filename "day1-input")
|
||||
(def filename "input/1")
|
||||
(def elves-rations (map #(map read-string %) (map str/split-lines (str/split (slurp filename) #"\n\n"))))
|
||||
(def elves-totals (map #(reduce + %) elves-rations))
|
||||
(def sorted-totals (sort elves-totals))
|
||||
|
|
|
@ -3,7 +3,7 @@ import strutils
|
|||
import sugar
|
||||
from algorithm import sorted
|
||||
|
||||
let inputString = strip readFile "day1-input"
|
||||
let inputString = strip readFile "input/1"
|
||||
let elfStrings = split(inputString, "\n\n")
|
||||
let elfRations = collect newSeq:
|
||||
for elf in elfStrings: collect newSeq:
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import scala.collection.mutable.ArrayBuffer
|
||||
import scala.io.Source
|
||||
|
||||
val filename = "day1-input"
|
||||
val filename = "input/1"
|
||||
|
||||
|
||||
class Elf:
|
||||
|
@ -23,9 +23,6 @@ class Elf:
|
|||
elves.last.foodCalories = line.toInt :: elves.last.foodCalories
|
||||
elves.last.calculateTotalCalories()
|
||||
|
||||
// for (elf <- elves)
|
||||
// println(s"${elf.totalCalories}: ${elf.foodCalories}")
|
||||
|
||||
// Part 1 solution: Total calories held by elf with the most total calories
|
||||
println(s"${elves.map(elf => elf.totalCalories).max}")
|
||||
// Part 2 solution: Total calories held by the top 3 elves
|
||||
|
|
|
@ -20,7 +20,7 @@ enum RPS(val score: Int):
|
|||
val moveMap = Map("A"->RPS.Rock, "B"->RPS.Paper, "C"->RPS.Scissors, "X"->RPS.Rock, "Y"->RPS.Paper, "Z"->RPS.Scissors)
|
||||
|
||||
@main def main() =
|
||||
val strategyGuide = Source.fromFile("day2-input").getLines.map(_.split(" ")).toArray // Can't leave it lazy as Part 1 will consume it
|
||||
val strategyGuide = Source.fromFile("input/2").getLines.map(_.split(" ")).toArray // Can't leave it lazy as Part 1 will consume it
|
||||
// val strategyGuide = Source.fromString("A Y\nB X\nC Z\n").getLines.map(_.split(" ")).toArray
|
||||
|
||||
// Part 1 - evaluate all moves in the guide using moveMap and tally score
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
(require '[clojure.string :as str])
|
||||
(def filename "day2-input")
|
||||
(def filename "input/2")
|
||||
(def move-pairs (map #(str/split % #" ") (str/split-lines (slurp filename))))
|
||||
(def move-map {"A" 1 "B" 2 "C" 3 "X" 1 "Y" 2 "Z" 3})
|
||||
(defn draw-win-lose-score [our-move their-move]
|
||||
|
|
|
@ -7,7 +7,7 @@ import tables
|
|||
proc `%%` (a: int, b: int): int = floor_mod a, b
|
||||
|
||||
let move_map = to_table {'A': 1, 'B': 2, 'C': 3, 'X': 1, 'Y': 2, 'Z': 3}
|
||||
let rounds = split_lines strip read_file "day2-input"
|
||||
let rounds = split_lines strip read_file "input/2"
|
||||
|
||||
proc round_score(us: int, them: int): int = us + [3, 6, 0][(us-them) %% 3]
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ def resultScore(a: RPS, b: RPS) = a <=> b match
|
|||
val moveMap = Map("A"->RPS.Rock, "B"->RPS.Paper, "C"->RPS.Scissors, "X"->RPS.Rock, "Y"->RPS.Paper, "Z"->RPS.Scissors)
|
||||
|
||||
@main def main() =
|
||||
val strategyGuide = Source.fromFile("day2-input").getLines.map(_.split(" ")).toArray // Can't leave it lazy as Part 1 will consume it
|
||||
val strategyGuide = Source.fromFile("input/2").getLines.map(_.split(" ")).toArray // Can't leave it lazy as Part 1 will consume it
|
||||
// val strategyGuide = Source.fromString("A Y\nB X\nC Z\n").getLines.map(_.split(" ")).toArray
|
||||
|
||||
// Part 1 - evaluate all moves in the guide using moveMap and tally score
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
with open('day3-input', 'r') as file:
|
||||
with open('input/3', 'r') as file:
|
||||
input = file.read().strip().split('\n')
|
||||
|
||||
def prio(character):
|
||||
|
|
|
@ -9,7 +9,7 @@ def priorityScore(c: Char): Int = c match
|
|||
|
||||
|
||||
@main def main() =
|
||||
val inputLines = Source.fromFile("day3-input").getLines.toArray // Can't leave it lazy as Part 1 will consume it
|
||||
val inputLines = Source.fromFile("input/3").getLines.toArray // Can't leave it lazy as Part 1 will consume it
|
||||
|
||||
// Part 1 - find items common between first half and second half of each line
|
||||
println(inputLines.map(line =>
|
||||
|
|
Loading…
Reference in New Issue