day_16
Types
pub type Direction {
North
East
South
West
None
}
Constructors
-
North
-
East
-
South
-
West
-
None
Functions
pub fn debug_result(
result_tuple: #(
List(#(Int, List(#(Int, Int)))),
Dict(#(Int, Int), List(#(Int, List(#(Int, Int))))),
),
) -> #(
List(#(Int, List(#(Int, Int)))),
Dict(#(Int, Int), List(#(Int, List(#(Int, Int))))),
)
pub fn get_end_position(
map: Dict(#(Int, Int), Tile),
) -> #(Int, Int)
Get end position of a given map.
pub fn get_paths(
map: Dict(#(Int, Int), Tile),
current_position: #(Int, Int),
current_direction: Direction,
current_path: List(#(Int, Int)),
current_score: Int,
paths: List(#(Int, List(#(Int, Int)))),
already_checked: Dict(#(Int, Int), Bool),
target_position: #(Int, Int),
) -> List(#(Int, List(#(Int, Int))))
pub fn get_possible_steps(
map: Dict(#(Int, Int), Tile),
position: #(Int, Int),
) -> List(#(#(Int, Int), Direction))
Given a position, get all possible next steps, (i.e not a wall, start, or out of bounds)
pub fn get_scores(
map: Dict(#(Int, Int), Tile),
current_position: #(Int, Int),
current_direction: Direction,
current_path: List(#(Int, Int)),
current_score: Int,
scores: List(Int),
already_checked: Dict(#(Int, Int), Bool),
target_position: #(Int, Int),
counter: Int,
) -> List(Int)
pub fn get_scores_memoized(
map: Dict(#(Int, Int), Tile),
current_position: #(Int, Int),
current_direction: Direction,
current_path: List(#(Int, Int)),
current_score: Int,
scores: List(Int),
already_checked: Dict(#(Int, Int), Bool),
target_position: #(Int, Int),
known_scores: Dict(#(Int, Int), List(Int)),
) -> #(List(Int), Dict(#(Int, Int), List(Int)))
pub fn get_start_position(
map: Dict(#(Int, Int), Tile),
) -> #(Int, Int)
Get start position of a given map.
pub fn get_step_cost(
current_direction: Direction,
next_direction: Direction,
) -> Int
pub fn get_surrounding_positions(
position: #(Int, Int),
) -> List(#(#(Int, Int), Direction))
Get all surrounding positions (in a cross pattern) of a given position.
pub fn get_tile_position(
map: Dict(#(Int, Int), Tile),
tile: Tile,
) -> #(Int, Int)
Find the first coordinates corresponding to a specific tile (only really useful for start and end, as they appear exactly once)
pub fn heuristic_score(
current_position: #(Int, Int),
target_position: #(Int, Int),
) -> Int
If we’re not on the same x or y line, assume we have to turn once (i.e. that there are no walls)
pub fn is_start(
map: Dict(#(Int, Int), Tile),
position: #(Int, Int),
) -> Bool
Given a position, check if it is the start
pub fn parse_tile(char: String) -> Tile
pub fn print_path(
path: List(#(Int, Int)),
map: Dict(#(Int, Int), Tile),
) -> List(#(Int, Int))
pub fn stringify_map(
map: Dict(#(Int, Int), Tile),
) -> Dict(#(Int, Int), String)
pub fn tile_to_string(tile: Tile) -> String