-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Advent of Code 2021 - Day 03 - Part 2 - OK
- Loading branch information
1 parent
3852a4b
commit e061ff6
Showing
5 changed files
with
204 additions
and
23 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.vscode |
This file was deleted.
Oops, something went wrong.
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
package main | ||
|
||
import "testing" | ||
|
||
func TestPart2(t *testing.T) { | ||
// Given | ||
lines := []string{ | ||
"00100", | ||
"11110", | ||
"10110", | ||
"10111", | ||
"10101", | ||
"01111", | ||
"00111", | ||
"11100", | ||
"10000", | ||
"11001", | ||
"00010", | ||
"01010"} | ||
var expectedLifeSupportRating int64 = 230 | ||
|
||
// When | ||
var actualLifeSupportRating int64 = part2(lines) | ||
|
||
// Then | ||
if actualLifeSupportRating != expectedLifeSupportRating { | ||
t.Errorf("Life support rating was incorrect, actual: %d, expected: %d", | ||
actualLifeSupportRating, expectedLifeSupportRating) | ||
} | ||
} | ||
|
||
func TestGetOxygenGeneratorRating(t *testing.T) { | ||
// Given | ||
lines := []string{ | ||
"00100", | ||
"11110", | ||
"10110", | ||
"10111", | ||
"10101", | ||
"01111", | ||
"00111", | ||
"11100", | ||
"10000", | ||
"11001", | ||
"00010", | ||
"01010"} | ||
expectedOxygenGeneratorRating := "10111" | ||
|
||
// When | ||
actualOxygenGeneratorRating := getOxygenGeneratorRating(lines, 0) | ||
|
||
// Then | ||
if actualOxygenGeneratorRating != expectedOxygenGeneratorRating { | ||
t.Errorf("Oxygen generator rating was incorrect, actual: %s, expected: %s", | ||
actualOxygenGeneratorRating, expectedOxygenGeneratorRating) | ||
} | ||
} | ||
|
||
func TestGetCO2ScrubberRating(t *testing.T) { | ||
// Given | ||
lines := []string{ | ||
"00100", | ||
"11110", | ||
"10110", | ||
"10111", | ||
"10101", | ||
"01111", | ||
"00111", | ||
"11100", | ||
"10000", | ||
"11001", | ||
"00010", | ||
"01010"} | ||
expectedCO2ScrubberRating := "01010" | ||
|
||
// When | ||
actualCO2ScrubberRating := getCO2ScrubberRating(lines, 0) | ||
|
||
// Then | ||
if actualCO2ScrubberRating != expectedCO2ScrubberRating { | ||
t.Errorf("CO2 scrubber rating was incorrect, actual: %s, expected: %s", | ||
actualCO2ScrubberRating, expectedCO2ScrubberRating) | ||
} | ||
} |