Giving of on Day 3 Part 2 (for now at least)
This commit is contained in:
parent
77d9537bdd
commit
1154c1489d
8 changed files with 594 additions and 0 deletions
140
day_3_part_2/test/day_3_part_2_test.gleam
Normal file
140
day_3_part_2/test/day_3_part_2_test.gleam
Normal file
|
|
@ -0,0 +1,140 @@
|
|||
import day_3_part_2.{Bank, Digit}
|
||||
import gleeunit
|
||||
|
||||
pub fn main() -> Nil {
|
||||
gleeunit.main()
|
||||
}
|
||||
|
||||
pub fn prepend_bank_base_test() {
|
||||
assert day_3_part_2.prepend_bank_with_max_joltage(
|
||||
Digit(1),
|
||||
#(Bank([]), []),
|
||||
2,
|
||||
)
|
||||
== #(Bank([Digit(1)]), [Digit(1)])
|
||||
}
|
||||
|
||||
pub fn ignored_prepend_test() {
|
||||
day_3_part_2.prepend_bank_with_max_joltage(
|
||||
Digit(1),
|
||||
#(day_3_part_2.int_list_to_bank([3, 4, 1, 1]), [
|
||||
Digit(3),
|
||||
Digit(4),
|
||||
Digit(1),
|
||||
]),
|
||||
3,
|
||||
)
|
||||
== #(day_3_part_2.int_list_to_bank([1, 3, 4, 1, 1]), [
|
||||
Digit(3),
|
||||
Digit(4),
|
||||
Digit(1),
|
||||
])
|
||||
}
|
||||
|
||||
pub fn prepend_anway_test() {
|
||||
assert day_3_part_2.prepend_bank_with_max_joltage(
|
||||
Digit(1),
|
||||
#(day_3_part_2.int_list_to_bank([3, 4, 1, 1]), [Digit(3), Digit(4)]),
|
||||
3,
|
||||
)
|
||||
== #(day_3_part_2.int_list_to_bank([1, 3, 4, 1, 1]), [
|
||||
Digit(1),
|
||||
Digit(3),
|
||||
Digit(4),
|
||||
])
|
||||
}
|
||||
|
||||
pub fn dont_prepend_simple_test() {
|
||||
assert day_3_part_2.prepend_bank_with_max_joltage(
|
||||
Digit(1),
|
||||
#(day_3_part_2.int_list_to_bank([3, 4, 1, 1]), [
|
||||
Digit(3),
|
||||
Digit(4),
|
||||
Digit(1),
|
||||
]),
|
||||
3,
|
||||
)
|
||||
== #(day_3_part_2.int_list_to_bank([1, 3, 4, 1, 1]), [
|
||||
Digit(3),
|
||||
Digit(4),
|
||||
Digit(1),
|
||||
])
|
||||
}
|
||||
|
||||
pub fn do_prepend_simple_test() {
|
||||
assert day_3_part_2.prepend_bank_with_max_joltage(
|
||||
Digit(5),
|
||||
#(
|
||||
day_3_part_2.int_list_to_bank([
|
||||
4,
|
||||
3,
|
||||
2,
|
||||
1,
|
||||
]),
|
||||
[Digit(4), Digit(3)],
|
||||
),
|
||||
2,
|
||||
)
|
||||
== #(
|
||||
day_3_part_2.int_list_to_bank([
|
||||
5,
|
||||
4,
|
||||
3,
|
||||
2,
|
||||
1,
|
||||
]),
|
||||
[Digit(5), Digit(4)],
|
||||
)
|
||||
}
|
||||
|
||||
pub fn calibration_line_1_test() {
|
||||
assert {
|
||||
day_3_part_2.int_list_to_bank([
|
||||
9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 1, 1, 1, 1, 1,
|
||||
])
|
||||
|> day_3_part_2.max_joltage_from_bank
|
||||
}
|
||||
== 987_654_321_111
|
||||
}
|
||||
|
||||
pub fn calibration_line_2_test() {
|
||||
assert {
|
||||
day_3_part_2.int_list_to_bank([
|
||||
8, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 9,
|
||||
])
|
||||
|> day_3_part_2.max_joltage_from_bank
|
||||
}
|
||||
== 811_111_111_119
|
||||
}
|
||||
|
||||
pub fn calibration_line_3_test() {
|
||||
assert {
|
||||
day_3_part_2.int_list_to_bank([
|
||||
2, 3, 4, 2, 3, 4, 2, 3, 4, 2, 3, 4, 2, 7, 8,
|
||||
])
|
||||
|> day_3_part_2.max_joltage_from_bank
|
||||
}
|
||||
== 434_234_234_278
|
||||
}
|
||||
|
||||
pub fn calibration_line_4_test() {
|
||||
assert {
|
||||
day_3_part_2.int_list_to_bank([
|
||||
8, 1, 8, 1, 8, 1, 9, 1, 1, 1, 1, 2, 1, 1, 1,
|
||||
])
|
||||
|> day_3_part_2.max_joltage_from_bank
|
||||
}
|
||||
== 888_911_112_111
|
||||
}
|
||||
|
||||
pub fn drop_at_front_test() {
|
||||
assert day_3_part_2.drop_first_min([1, 2, 3]) == [2, 3]
|
||||
}
|
||||
|
||||
pub fn drop_with_one_at_front_test() {
|
||||
assert day_3_part_2.drop_first_min([1, 2, 1, 3]) == [2, 1, 3]
|
||||
}
|
||||
|
||||
pub fn drop_at_end_test() {
|
||||
assert day_3_part_2.drop_first_min([3, 2, 1]) == [3, 2]
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue