Skip to content

Commit fdd02e6

Browse files
Run pre-commit hooks on existing files
1 parent 01b7ac9 commit fdd02e6

File tree

272 files changed

+700
-704
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

272 files changed

+700
-704
lines changed

.gitattributes

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@
77
# These are Windows script files and should use crlf
88
*.bat text eol=crlf
99

10-
* text=auto
10+
* text=auto

2015/.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ bin/
22
obj/
33
out/
44

5-
*.DotSettings*
5+
*.DotSettings*

2015/fsharp/Day01/Program.fs

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ let partOne =
99
>> Seq.sum
1010

1111
let partTwo input =
12-
let (pos, _) =
12+
let (pos, _) =
1313
input
1414
|> Seq.map parse
1515
|> Seq.indexed
@@ -19,7 +19,7 @@ let partTwo input =
1919
[<EntryPoint>]
2020
let main argv =
2121
let input = File.ReadAllText("Input.txt")
22-
22+
2323
partOne input |> printfn "Part one: %d"
2424
partTwo input |> printfn "Part two: %d"
2525
0

2015/fsharp/Day02/Program.fs

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ let calcSurfaceArea (l, w, h) =
1010
let sides = [l*w; w*h; h*l]
1111
List.sumBy (fun side -> side * 2) sides + List.min sides
1212

13-
let calcRibbonLength (l, w, h) =
13+
let calcRibbonLength (l, w, h) =
1414
let sides = [l; w; h]
1515
let ribbon = List.sort sides |> List.take 2 |> List.sumBy (fun side -> side * 2)
1616
let bow = List.fold (*) 1 sides
@@ -21,11 +21,11 @@ let partTwo = List.sumBy calcRibbonLength
2121

2222
[<EntryPoint>]
2323
let main argv =
24-
let input =
24+
let input =
2525
File.ReadLines("Input.txt")
2626
|> Seq.map parse
2727
|> Seq.toList
28-
28+
2929
partOne input |> printfn "Part one: %d"
3030
partTwo input |> printfn "Part two: %d"
3131
0

2015/fsharp/Day03/Program.fs

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@ open System.IO
55
type Direction = North | East | South | West
66

77
let parse c =
8-
match c with
8+
match c with
99
| '^' -> North
1010
| '>' -> East
1111
| 'v' -> South
1212
| '<' -> West
1313

1414
let nextPosition direction (x, y) =
15-
match direction with
15+
match direction with
1616
| North -> (x, y + 1)
1717
| East -> (x + 1, y)
1818
| South -> (x, y - 1)
@@ -41,7 +41,7 @@ let partTwo directions =
4141
[<EntryPoint>]
4242
let main argv =
4343
let input = File.ReadAllText("Input.txt") |> Seq.map parse |> Seq.toList
44-
44+
4545
partOne input |> printfn "Part one: %d"
4646
partTwo input |> printfn "Part two: %d"
4747
0

2015/fsharp/Day04/Program.fs

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ let hash (input: string): string =
1313

1414
let findHashMatching (pred: string -> bool) (input: string) =
1515
let toHash num = hash (input + num.ToString())
16-
16+
1717
Seq.initInfinite id
1818
|> Seq.find (fun num -> pred (toHash num))
1919

@@ -23,7 +23,7 @@ let partTwo = findHashMatching (fun h -> h.StartsWith("000000"))
2323
[<EntryPoint>]
2424
let main argv =
2525
let input = "bgvyzdsv"
26-
26+
2727
partOne input |> printfn "Part one: %d"
2828
partTwo input |> printfn "Part two: %d"
2929
0

2015/fsharp/Day05/Program.fs

+10-10
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ open System.IO
55

66
let isNice (input: string) =
77
// It contains at least three vowels (aeiou only), like aei, xazegov, or aeiouaeiouaeiou.
8-
let rule1 =
8+
let rule1 =
99
let vowels = ['a';'e';'i';'o';'u']
1010
Seq.filter (fun c -> List.contains c vowels) input |> Seq.length >= 3
11-
11+
1212
// It contains at least one letter that appears twice in a row, like xx, abcdde (dd), or aabbccdd (aa, bb, cc, or dd).
1313
let rule2 = input |> Seq.pairwise |> Seq.exists (fun (a, b) -> a = b)
14-
14+
1515
// It does not contain the strings ab, cd, pq, or xy, even if they are part of one of the other requirements.
1616
let rule3 =
1717
["ab";"cd";"pq";"xy"]
@@ -30,22 +30,22 @@ let isNice2 (input: string) =
3030
|> Seq.length > 0
3131

3232
// It contains at least one letter which repeats with exactly one letter between them, like xyx, abcdefeghi (efe), or even aaa.
33-
let rule2 =
34-
Seq.windowed 3 input
35-
|> Seq.map Seq.toArray
33+
let rule2 =
34+
Seq.windowed 3 input
35+
|> Seq.map Seq.toArray
3636
|> Seq.exists (fun chars -> chars.[0] = chars.[2])
37-
37+
3838
[rule1; rule2] |> List.forall id
3939

4040
let partOne = List.filter isNice >> List.length
4141
let partTwo = List.filter isNice2 >> List.length
4242

4343
[<EntryPoint>]
4444
let main argv =
45-
let input =
46-
File.ReadLines("Input.txt")
45+
let input =
46+
File.ReadLines("Input.txt")
4747
|> Seq.toList
48-
48+
4949
partOne input |> printfn "Part one: %d"
5050
partTwo input |> printfn "Part two: %d"
5151
0

2015/fsharp/Day06/Program.fs

+6-6
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ let (|Regex|_|) pattern input =
1717

1818
let parse line =
1919
match line with
20-
| Regex @"turn on (\d+),(\d+) through (\d+),(\d+)" [x1; y1; x2; y2] ->
20+
| Regex @"turn on (\d+),(\d+) through (\d+),(\d+)" [x1; y1; x2; y2] ->
2121
TurnOn ((int x1, int y1), (int x2, int y2))
22-
| Regex @"turn off (\d+),(\d+) through (\d+),(\d+)" [x1; y1; x2; y2] ->
22+
| Regex @"turn off (\d+),(\d+) through (\d+),(\d+)" [x1; y1; x2; y2] ->
2323
TurnOff ((int x1, int y1), (int x2, int y2))
24-
| Regex @"toggle (\d+),(\d+) through (\d+),(\d+)" [x1; y1; x2; y2] ->
24+
| Regex @"toggle (\d+),(\d+) through (\d+),(\d+)" [x1; y1; x2; y2] ->
2525
Toggle ((int x1, int y1), (int x2, int y2))
2626

2727
let solve input turnOn turnOff toggle =
@@ -57,11 +57,11 @@ let partTwo input =
5757

5858
[<EntryPoint>]
5959
let main argv =
60-
let input =
61-
File.ReadLines("Input.txt")
60+
let input =
61+
File.ReadLines("Input.txt")
6262
|> Seq.map parse
6363
|> Seq.toList
64-
64+
6565
partOne input |> printfn "Part one: %d"
6666
partTwo input |> printfn "Part two: %d"
6767
0

2015/fsharp/Day07/Program.fs

+6-6
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ let (|Regex|_|) pattern input =
2323

2424
let parse (line: string) =
2525
let parseGate gate =
26-
match gate with
26+
match gate with
2727
| Regex @"^([a-z]+)$" [a] -> Signal a
2828
| Regex @"^(\d+)$" [a] -> SignalValue (int16 a)
2929
| Regex @"^([a-z]+) OR ([a-z]+)$" [a; b] -> Or (a, b)
@@ -51,21 +51,21 @@ let rec resolve identifier gates (cache: byref<Map<string, int16>>) =
5151
| LeftShift (a, shift) -> (resolve a gates &cache) <<< shift
5252
| RightShift (a, shift) -> (resolve a gates &cache) >>> shift
5353
| Not a -> ~~~ (resolve a gates &cache)
54-
55-
cache <- cache.Add(identifier, value)
54+
55+
cache <- cache.Add(identifier, value)
5656
value
5757

58-
let solve input =
58+
let solve input =
5959
let mutable cache = Map.empty
6060
resolve "a" input &cache
6161

6262
[<EntryPoint>]
6363
let main argv =
64-
let input =
64+
let input =
6565
File.ReadLines("Input.txt")
6666
|> Seq.map parse
6767
|> Seq.toList
68-
68+
6969
let signalA = solve input
7070
signalA |> printfn "Part one: %d"
7171

2015/kotlin/src/main/kotlin/nl/sanderp/aoc/aoc2015/day11/Day11.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,4 @@ fun main() {
4040
val next = findNextPassword(input)
4141
println("Part one: $next")
4242
println("Part two: ${findNextPassword(next)}")
43-
}
43+
}

2015/kotlin/src/main/kotlin/nl/sanderp/aoc/aoc2015/day13/Day13.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,4 +92,4 @@ fun happiness(seating: List<String>) =
9292
fun main() {
9393
println("Part one: ${preferences.keys.toList().permutations().maxOf { happiness(it) }}")
9494
println("Part two: ${preferences.keys.toList().plus("Sander").permutations().maxOf { happiness(it) }}")
95-
}
95+
}

2015/kotlin/src/main/kotlin/nl/sanderp/aoc/aoc2015/day16/Day16.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,4 @@ fun main() {
4848
}
4949

5050
println("Part two: ${secondMatch.index + 1}")
51-
}
51+
}

2015/kotlin/src/main/kotlin/nl/sanderp/aoc/common/Digits.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ import kotlin.math.abs
44

55
fun Char.asDigit(): Int = code - '0'.code
66

7-
fun Int.toDigits() = abs(this).toString().map { it.asDigit() }
7+
fun Int.toDigits() = abs(this).toString().map { it.asDigit() }

2015/kotlin/src/main/kotlin/nl/sanderp/aoc/common/Duration.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,4 @@ fun Duration.prettyPrint(): String {
4141
)
4242

4343
return parts.filter { it.first > 0 }.joinToString(" ") { it.first.toString() + it.second }
44-
}
44+
}

2015/kotlin/src/main/kotlin/nl/sanderp/aoc/common/Navigation.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ fun Point2D.move(direction: Direction, steps: Int = 1) = when (direction) {
1919
Direction.East -> x + steps to y
2020
Direction.South -> x to y - steps
2121
Direction.West -> x - steps to y
22-
}
22+
}

2015/kotlin/src/main/kotlin/nl/sanderp/aoc/common/Resources.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ internal object Resources
1010
* @return the contents of the resource
1111
*/
1212
fun readResource(fileName: String) = Resources.javaClass.getResource("/$fileName")?.readText()?.trim()
13-
?: throw IOException("File does not exist: $fileName")
13+
?: throw IOException("File does not exist: $fileName")

2015/kotlin/src/test/kotlin/nl/sanderp/aoc/aoc2015/Day11Test.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@ class Day11Test {
2222
fun `increment password`() = mapOf("a" to "b", "aa" to "ab", "az" to "ba").map {
2323
DynamicTest.dynamicTest("${it.key} -> ${it.value}") { increment(it.key) `should be equal to` it.value }
2424
}
25-
}
25+
}

2015/kotlin/src/test/kotlin/nl/sanderp/aoc/common/DigitsTest.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ class DigitsTest {
2020
fun `Retrieving digits of a negative number`() {
2121
(-123).toDigits() `should be equal to` listOf(1, 2, 3)
2222
}
23-
}
23+
}

2015/kotlin/src/test/kotlin/nl/sanderp/aoc/common/DurationFormattingTest.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,4 @@ class DurationFormattingTest {
2929

3030
duration.prettyPrint() `should be equal to` "4m 2s"
3131
}
32-
}
32+
}

2015/kotlin/src/test/kotlin/nl/sanderp/aoc/common/DurationMeasurementTest.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,4 @@ class DurationMeasurementTest {
2828

2929
duration.toMillis() `should be in range` 1000L..2000L
3030
}
31-
}
31+
}

2015/kotlin/src/test/kotlin/nl/sanderp/aoc/common/ListCombinationsTest.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,4 +76,4 @@ class ListCombinationsTest {
7676

7777
allTriples(ones, twos, threes) shouldContain randomCombination
7878
}
79-
}
79+
}

2015/kotlin/src/test/kotlin/nl/sanderp/aoc/common/ListPermutationsTest.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@ class ListPermutationsTest {
2626

2727
actual `should contain` items.shuffled()
2828
}
29-
}
29+
}

2015/kotlin/src/test/kotlin/nl/sanderp/aoc/common/NavigationTest.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ class NavigationTest {
1414

1515
finish `should be equal to` Point2D(2, 4)
1616
}
17-
}
17+
}

2015/kotlin/src/test/kotlin/nl/sanderp/aoc/common/Point2DTest.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,4 @@ class Point2DTest {
6262
fun `manhattan distance between points`() {
6363
Point2D(2, -3).manhattanTo(Point2D(-2, 8)) `should be equal to` 15
6464
}
65-
}
65+
}

2015/kotlin/src/test/kotlin/nl/sanderp/aoc/common/Point3DTest.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,4 @@ class Point3DTest {
6161
fun `manhattan distance between points`() {
6262
Point3D(1, 1, 1).manhattanTo(Point3D(-1, -1, -1)) `should be equal to` 6
6363
}
64-
}
64+
}

2015/kotlin/src/test/kotlin/nl/sanderp/aoc/common/ResourcesTest.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@ class ResourcesTest {
2525

2626
contents.lines() `should be equal to` listOf("apples", "bananas", "coconuts")
2727
}
28-
}
28+
}

2016/.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
bin/
22
obj/
33

4-
*.DotSettings*
4+
*.DotSettings*

2016/csharp/Day01/Solution.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,4 @@ private static (Rotation, int Steps) ParseInstruction(string instruction)
5858
return (rotation, steps);
5959
}
6060
}
61-
}
61+
}

2016/csharp/Day01/Tests.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ namespace AdventOfCode2016.Day01
66
public class Tests
77
{
88
private const string InputFile = @"Day01\Input.txt";
9-
9+
1010
[Theory]
1111
[InlineData("R2, L3", 5)]
1212
[InlineData("R2, R2, R2", 2)]
@@ -43,4 +43,4 @@ public void PartTwo()
4343
Assert.Equal(answer, solution.PartTwo());
4444
}
4545
}
46-
}
46+
}

2016/csharp/Day02/Solution.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ [new IntVector(-1, -1)] = '7',
1818
[new IntVector(0, -1)] = '8',
1919
[new IntVector(1, -1)] = '9',
2020
};
21-
21+
2222
private static readonly IDictionary<IntVector, char> Keypad2 = new Dictionary<IntVector, char>
2323
{
2424
[new IntVector(0, 2)] = '1',
@@ -35,7 +35,7 @@ [new IntVector(0, -1)] = 'B',
3535
[new IntVector(1, -1)] = 'C',
3636
[new IntVector(0, -2)] = 'D',
3737
};
38-
38+
3939
private readonly IReadOnlyCollection<IEnumerable<Direction>> _instructions;
4040

4141
public Solution(IEnumerable<string> input)
@@ -78,4 +78,4 @@ private static IEnumerable<Direction> ParseInstructions(string instructions) =>
7878
_ => throw new ArgumentException($"Unknown instruction {instruction}")
7979
});
8080
}
81-
}
81+
}

0 commit comments

Comments
 (0)