mirror of
https://github.com/Threnklyn/advent-of-code-go.git
synced 2026-05-19 03:23:27 +02:00
added day18 part1- OOF djikstras search -> weighted graph generation & traversal w/ locked edges...
This commit is contained in:
@@ -0,0 +1 @@
|
|||||||
|
.vscode/*
|
||||||
@@ -24,4 +24,4 @@ Day | Name | Type of Algo & Notes
|
|||||||
15 | Oxygen System | YAY INTCODE 🙄 <br> - Combination of __2D grid searching algo__, __backtracking algo__ and the the Intcode... <br> - I've realized that I really need to stop using x and y for 2D grids and start using row and col because mathematically x is horizontal and y is vertical... My brain is all jumbled up <br> - Created a Robot struct/class that has a computer inside of it. It goes and searches around, collecting data on the floor types at various coordinates. That data is transformed into a 2D grid/array, and then finally fed into a backtracking, searching algorithm to determine the shortest path (turns out there's only one path to the O2 tank...) <br> - part2 is fairly straight forward 2D grid traversing and tagging a spread of oxygen to valid tiles/hallway spaces
|
15 | Oxygen System | YAY INTCODE 🙄 <br> - Combination of __2D grid searching algo__, __backtracking algo__ and the the Intcode... <br> - I've realized that I really need to stop using x and y for 2D grids and start using row and col because mathematically x is horizontal and y is vertical... My brain is all jumbled up <br> - Created a Robot struct/class that has a computer inside of it. It goes and searches around, collecting data on the floor types at various coordinates. That data is transformed into a 2D grid/array, and then finally fed into a backtracking, searching algorithm to determine the shortest path (turns out there's only one path to the O2 tank...) <br> - part2 is fairly straight forward 2D grid traversing and tagging a spread of oxygen to valid tiles/hallway spaces
|
||||||
16 | Flawed Frequency Transmission | - Some really weird, contrived (as if this whole thing isn't) phase calculator?.. <br> - part2 broke my brain. Optimally calculate subsets by __precalculating running sums__ (linear), then getting subsets by subtracting two of the precalculated running sums. i.e. sub[2:4] = sub[0:4] - sub[0:2] <br> - And also switching pattern recognition to make calculating a particular output O(nlogn)...
|
16 | Flawed Frequency Transmission | - Some really weird, contrived (as if this whole thing isn't) phase calculator?.. <br> - part2 broke my brain. Optimally calculate subsets by __precalculating running sums__ (linear), then getting subsets by subtracting two of the precalculated running sums. i.e. sub[2:4] = sub[0:4] - sub[0:2] <br> - And also switching pattern recognition to make calculating a particular output O(nlogn)...
|
||||||
17 | Set and Forget | More Intcode... <br> Robot walking around a scaffolding... Fairly similar to previous algos, and a 2D grid traversal again <br> - I feel like I cheated part2 by finding the pattern by eye after printing what the 2D grid looks like. Then it was a matter of giving the intcode computer the corresponding inputs (in a weird format). <br> - Good example of __iterative approaches being better than recursive approaches__ because the recursive approach in "continuous video mode" causes a stack overflow very quickly
|
17 | Set and Forget | More Intcode... <br> Robot walking around a scaffolding... Fairly similar to previous algos, and a 2D grid traversal again <br> - I feel like I cheated part2 by finding the pattern by eye after printing what the 2D grid looks like. Then it was a matter of giving the intcode computer the corresponding inputs (in a weird format). <br> - Good example of __iterative approaches being better than recursive approaches__ because the recursive approach in "continuous video mode" causes a stack overflow very quickly
|
||||||
|
18 | Many-Worlds Interpretation | - Oof, this is the hardest algo so far I think... Combination of __Best Pathfinding Algo__ (going to use a BFS/Dijkstra's) and __Graph Traversal__ <br> - I toyed with the idea of using some kind of bitmap to track keys that were found, but ditched it so I wouldn't have to write my own wrapper around bitwise logic... Time complexity comparisons are roughly similar for comparing two maps as comparing two sets of bits, the space complexity is probably much better for 27-bits (@ and a-z) compared to a hashmap, but OH WELL. <br>
|
||||||
|
|||||||
@@ -0,0 +1,292 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"adventofcode/util"
|
||||||
|
"fmt"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
input := util.ReadFile("../input.txt")
|
||||||
|
|
||||||
|
// ! Tests that overwrite the actual input
|
||||||
|
// ! Expect 8
|
||||||
|
// input = "#########\n#b.A.@.a#\n#########"
|
||||||
|
// ! test: expect 86
|
||||||
|
// input = "########################\n#f.D.E.e.C.b.A.@.a.B.c.#\n######################.#\n#d.....................#\n########################"
|
||||||
|
|
||||||
|
linesSli := strings.Split(input, "\n")
|
||||||
|
|
||||||
|
grid := make([][]string, len(linesSli)) // string might be excessive, but it will be easier to look at
|
||||||
|
for i, line := range linesSli {
|
||||||
|
grid[i] = strings.Split(line, "")
|
||||||
|
}
|
||||||
|
|
||||||
|
// get all the coordinates of keys. will be used as starting points for dijkstra's searches
|
||||||
|
keyToCoordinates := getCoordinatesOfKeys(grid)
|
||||||
|
|
||||||
|
// initialize Graph
|
||||||
|
graph := MakeGraph()
|
||||||
|
|
||||||
|
// for every key, generate a new dijkstra grid where all distances are set to MAX SAFE INT, and the key's distance is set to 0
|
||||||
|
for key, coordinates := range keyToCoordinates {
|
||||||
|
// initialize a dijkstra grid for each key
|
||||||
|
dijkstraGrid := MakeDijkstraGrid(grid, coordinates)
|
||||||
|
|
||||||
|
// step through grid until complete, handleFrontOfQueue returns true when the queue is empty...
|
||||||
|
for !dijkstraGrid.handleFrontOfQueue() {
|
||||||
|
}
|
||||||
|
// small space optimization, overwrite the dijkstra queue b/c the underlying array is alive
|
||||||
|
dijkstraGrid.queue = nil
|
||||||
|
|
||||||
|
// update graph for all edges from `key` to all other keys
|
||||||
|
for otherKey, coordinates := range keyToCoordinates {
|
||||||
|
if key != otherKey && otherKey != "@" {
|
||||||
|
row, col := coordinates[0], coordinates[1]
|
||||||
|
// pass the key being pathed FROM and the dijkstraNode (found on the grid) of the key found
|
||||||
|
graph.AddEdges(key, dijkstraGrid.grid[row][col])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dfsStartTimestamp := time.Now()
|
||||||
|
// first off (recursive, memoized) dfs method on graph that finds minimum distance
|
||||||
|
fmt.Printf("DFS result: %v\n\nFinished in %v\n\n", graph.dfsMinmumDistance(), time.Since(dfsStartTimestamp))
|
||||||
|
}
|
||||||
|
|
||||||
|
// get a map of the coordinates of points of interests
|
||||||
|
func getCoordinatesOfKeys(grid [][]string) map[string][2]int {
|
||||||
|
pointsOfInterest := make(map[string][2]int)
|
||||||
|
for row, rowSli := range grid {
|
||||||
|
for col, cell := range rowSli {
|
||||||
|
switch {
|
||||||
|
case cell == "@":
|
||||||
|
pointsOfInterest["@"] = [2]int{row, col}
|
||||||
|
// typecase cell to its ASCII value
|
||||||
|
case int(cell[0]) >= 'a' && int(cell[0]) <= 'z':
|
||||||
|
pointsOfInterest[cell] = [2]int{row, col}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return pointsOfInterest
|
||||||
|
}
|
||||||
|
|
||||||
|
/********************************************************************************************
|
||||||
|
DIJKSTRA GRID Code
|
||||||
|
*********************************************************************************************/
|
||||||
|
|
||||||
|
// DijkstraGrid stores the grid itself and also the needed queue to traverse through the grid
|
||||||
|
type DijkstraGrid struct {
|
||||||
|
grid [][]*dijkstraNode
|
||||||
|
queue [][2]int // coordinates to be traversed next
|
||||||
|
}
|
||||||
|
|
||||||
|
// dijkstraNode is each cell within a DijkstraGrid.grid
|
||||||
|
type dijkstraNode struct {
|
||||||
|
value string // string of the floor type (key, door, floor?, wall)
|
||||||
|
distance int // distance from the source
|
||||||
|
keysFound map[string]bool // keys that have been run into
|
||||||
|
keysNeeded map[string]bool // keys needed to get to this node, i.e. all doors passed thorugh
|
||||||
|
seen bool
|
||||||
|
}
|
||||||
|
|
||||||
|
// MakeDijkstraGrid initializes a 2D grid of dijkstraNodes with distances initialized to the max safe integer
|
||||||
|
func MakeDijkstraGrid(grid [][]string, startCoords [2]int) *DijkstraGrid {
|
||||||
|
finalGrid := make([][]*dijkstraNode, len(grid))
|
||||||
|
startKey := grid[startCoords[0]][startCoords[1]]
|
||||||
|
for row, rowSli := range grid {
|
||||||
|
// initialize the row's slice in the finalGrid
|
||||||
|
finalGrid[row] = make([]*dijkstraNode, len(grid[0]))
|
||||||
|
for col, cellString := range rowSli {
|
||||||
|
finalGrid[row][col] = &dijkstraNode{
|
||||||
|
value: cellString,
|
||||||
|
distance: 1<<31 - 1, // maximum safe integer, effectively 2^31 - 1
|
||||||
|
keysFound: map[string]bool{startKey: true}, // initialize with the starting key
|
||||||
|
keysNeeded: make(map[string]bool), // empty map for now
|
||||||
|
seen: false, // initialize as false
|
||||||
|
}
|
||||||
|
// remove the "@" key because it's not a key... it's just the starting point
|
||||||
|
delete(finalGrid[row][col].keysFound, "@")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// set properties of starting coordinate
|
||||||
|
// distance = 0
|
||||||
|
finalGrid[startCoords[0]][startCoords[1]].distance = 0
|
||||||
|
finalGrid[startCoords[0]][startCoords[1]].seen = true
|
||||||
|
queue := [][2]int{
|
||||||
|
[2]int{startCoords[0], startCoords[1]},
|
||||||
|
}
|
||||||
|
return &DijkstraGrid{finalGrid, queue}
|
||||||
|
}
|
||||||
|
|
||||||
|
var dRow [4]int = [4]int{0, 0, -1, 1}
|
||||||
|
var dCol [4]int = [4]int{-1, 1, 0, 0}
|
||||||
|
|
||||||
|
// handleFrontOfQueue does just that, returns a true if queue is empty upon completion
|
||||||
|
func (dijk *DijkstraGrid) handleFrontOfQueue() (queueIsEmpty bool) {
|
||||||
|
row, col := dijk.queue[0][0], dijk.queue[0][1]
|
||||||
|
cell := dijk.grid[row][col]
|
||||||
|
|
||||||
|
// mark as seen
|
||||||
|
cell.seen = true
|
||||||
|
|
||||||
|
// if key is found, add to cell details
|
||||||
|
if ascii := int(cell.value[0]) - 'a'; ascii >= 0 && ascii < 26 {
|
||||||
|
cell.keysFound[cell.value] = true
|
||||||
|
}
|
||||||
|
|
||||||
|
// if door is found, add to keysNeeded as a lowercase (easier comparison later)
|
||||||
|
if ascii := int(cell.value[0]) - 'A'; ascii >= 0 && ascii < 26 {
|
||||||
|
cell.keysNeeded[string('a'+ascii)] = true
|
||||||
|
}
|
||||||
|
|
||||||
|
// push neighbors into queue IF not already seen and not walls
|
||||||
|
for i := 0; i < 4; i++ {
|
||||||
|
neighborRow, neighborCol := row+dRow[i], col+dCol[i]
|
||||||
|
neighborCell := dijk.grid[neighborRow][neighborCol]
|
||||||
|
if !neighborCell.seen && neighborCell.value != "#" {
|
||||||
|
// add to queue
|
||||||
|
dijk.queue = append(dijk.queue, [2]int{neighborRow, neighborCol})
|
||||||
|
|
||||||
|
// increment its distance by 1
|
||||||
|
neighborCell.distance = cell.distance + 1
|
||||||
|
|
||||||
|
// NOTE manually copying these, otherwise they'll be pointing to the same underlying map pointer
|
||||||
|
// copy keysFound (still carrying the same keys)
|
||||||
|
for key := range cell.keysFound {
|
||||||
|
neighborCell.keysFound[key] = true
|
||||||
|
}
|
||||||
|
|
||||||
|
// copy keysNeeded as well
|
||||||
|
for key := range cell.keysNeeded {
|
||||||
|
neighborCell.keysNeeded[key] = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// dequeue by rescoping the slice
|
||||||
|
dijk.queue = dijk.queue[1:]
|
||||||
|
|
||||||
|
// if queue is empty, there are no more paths to generate, return a true
|
||||||
|
if len(dijk.queue) == 0 {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
/********************************************************************************************
|
||||||
|
GRAPH Code
|
||||||
|
*********************************************************************************************/
|
||||||
|
|
||||||
|
// Graph stores the edges between keys by storing all paths from a particular key to all other keys
|
||||||
|
// all cells in this 2D MAP will be a dijkstraNode because those contain all the needed data
|
||||||
|
// such as distance from last key, the keysNeeded to take this path
|
||||||
|
type Graph struct {
|
||||||
|
keysToKeys map[string]map[string]*dijkstraNode
|
||||||
|
}
|
||||||
|
|
||||||
|
// MakeGraph initializes a Graph instance and returns a pointer to it
|
||||||
|
func MakeGraph() *Graph {
|
||||||
|
return &Graph{
|
||||||
|
keysToKeys: make(map[string]map[string]*dijkstraNode),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddEdges takes in the key being pathed FROM, and the dijkstraNode of a key pathed TO
|
||||||
|
// and adds that edge to the graph
|
||||||
|
func (graph *Graph) AddEdges(startKey string, destinationNode *dijkstraNode) {
|
||||||
|
// initialize this "row" of the map if it does not exist yet
|
||||||
|
if graph.keysToKeys[startKey] == nil {
|
||||||
|
graph.keysToKeys[startKey] = make(map[string]*dijkstraNode)
|
||||||
|
}
|
||||||
|
// add the destination node to the graph
|
||||||
|
keyFound := destinationNode.value
|
||||||
|
graph.keysToKeys[startKey][keyFound] = destinationNode
|
||||||
|
}
|
||||||
|
|
||||||
|
func (graph *Graph) dfsMinmumDistance() int {
|
||||||
|
// recursive function that dives through graph
|
||||||
|
var traverse func(string, map[string]bool) int
|
||||||
|
|
||||||
|
// Implement cache for traverse function
|
||||||
|
// caches the "<entry key>:<ordered keys found>" to resulting distance
|
||||||
|
cache := map[string]int{}
|
||||||
|
|
||||||
|
// NOTE helper function that leverages the above cache
|
||||||
|
// Traverse should return the minimum distance to a completion for these inputs
|
||||||
|
// inputs are: 1. the entry point (the key to generate a path FROM)
|
||||||
|
// 2. the keys that have been found so far
|
||||||
|
traverse = func(entry string, keysFound map[string]bool) int {
|
||||||
|
shortestFromThisNode := 1<<31 - 1
|
||||||
|
|
||||||
|
cacheKey := makeCacheKey(entry, keysFound, len(graph.keysToKeys)-1)
|
||||||
|
|
||||||
|
// cache hit
|
||||||
|
if cacheVal, found := cache[cacheKey]; found {
|
||||||
|
return cacheVal
|
||||||
|
}
|
||||||
|
|
||||||
|
// base case: all keys found, no more distance to be traveled, i.e. zero
|
||||||
|
if len(keysFound) == len(graph.keysToKeys)-1 {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
// iterate over all possible destination nodes.
|
||||||
|
nextEdges := graph.keysToKeys[entry]
|
||||||
|
for nextKey, node := range nextEdges {
|
||||||
|
// only traverse if key has not been found yet AND all needed keys have been collected already
|
||||||
|
if !keysFound[nextKey] && haveNeededKeys(keysFound, node.keysNeeded) {
|
||||||
|
// add the nextKey
|
||||||
|
keysFound[nextKey] = true
|
||||||
|
|
||||||
|
// update the shortestFromThisNode if applicable
|
||||||
|
distanceToEnd := node.distance + traverse(nextKey, keysFound)
|
||||||
|
if distanceToEnd < shortestFromThisNode {
|
||||||
|
shortestFromThisNode = distanceToEnd
|
||||||
|
}
|
||||||
|
|
||||||
|
// backtrack - remove the key
|
||||||
|
delete(keysFound, nextKey)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
cache[cacheKey] = shortestFromThisNode
|
||||||
|
return shortestFromThisNode
|
||||||
|
}
|
||||||
|
|
||||||
|
// fire off initially
|
||||||
|
return traverse("@", map[string]bool{})
|
||||||
|
}
|
||||||
|
|
||||||
|
// helper function to generate a cache string key
|
||||||
|
// cache string is of the form entryKey:allKeysToFind
|
||||||
|
func makeCacheKey(entry string, keysFound map[string]bool, totalKeys int) string {
|
||||||
|
// TODO: move this into the graph? to avoid making it 910238190382 times
|
||||||
|
allKeys := make([]string, totalKeys)
|
||||||
|
for i := 0; i < totalKeys; i++ {
|
||||||
|
allKeys[i] = string(int('a') + i)
|
||||||
|
}
|
||||||
|
|
||||||
|
cacheKey := entry + ":"
|
||||||
|
// generate
|
||||||
|
for i := 0; i < totalKeys; i++ {
|
||||||
|
char := string(int('a') + i)
|
||||||
|
if !keysFound[char] {
|
||||||
|
cacheKey += char
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return cacheKey
|
||||||
|
}
|
||||||
|
|
||||||
|
// simple helper function to make sure that all keysNeeded are in keysFound
|
||||||
|
func haveNeededKeys(keysFound, keysNeeded map[string]bool) bool {
|
||||||
|
for key := range keysNeeded {
|
||||||
|
if !keysFound[key] {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
@@ -90,4 +90,136 @@ Shortest paths are 81 steps; one is: a, c, f, i, d, g, b, e, h
|
|||||||
|
|
||||||
How many steps is the shortest path that collects all of the keys?
|
How many steps is the shortest path that collects all of the keys?
|
||||||
|
|
||||||
|
Your puzzle answer was 6286.
|
||||||
|
|
||||||
|
The first half of this puzzle is complete! It provides one gold star: *
|
||||||
|
|
||||||
|
--- Part Two ---
|
||||||
|
You arrive at the vault only to discover that there is not one vault, but four - each with its own entrance.
|
||||||
|
|
||||||
|
On your map, find the area in the middle that looks like this:
|
||||||
|
|
||||||
|
...
|
||||||
|
.@.
|
||||||
|
...
|
||||||
|
Update your map to instead use the correct data:
|
||||||
|
|
||||||
|
@#@
|
||||||
|
###
|
||||||
|
@#@
|
||||||
|
This change will split your map into four separate sections, each with its own entrance:
|
||||||
|
|
||||||
|
####### #######
|
||||||
|
#a.#Cd# #a.#Cd#
|
||||||
|
##...## ##@#@##
|
||||||
|
##.@.## --> #######
|
||||||
|
##...## ##@#@##
|
||||||
|
#cB#Ab# #cB#Ab#
|
||||||
|
####### #######
|
||||||
|
Because some of the keys are for doors in other vaults, it would take much too long to collect all of the keys by yourself. Instead, you deploy four remote-controlled robots. Each starts at one of the entrances (@).
|
||||||
|
|
||||||
|
Your goal is still to collect all of the keys in the fewest steps, but now, each robot has its own position and can move independently. You can only remotely control a single robot at a time. Collecting a key instantly unlocks any corresponding doors, regardless of the vault in which the key or door is found.
|
||||||
|
|
||||||
|
For example, in the map above, the top-left robot first collects key a, unlocking door A in the bottom-right vault:
|
||||||
|
|
||||||
|
#######
|
||||||
|
#@.#Cd#
|
||||||
|
##.#@##
|
||||||
|
#######
|
||||||
|
##@#@##
|
||||||
|
#cB#.b#
|
||||||
|
#######
|
||||||
|
Then, the bottom-right robot collects key b, unlocking door B in the bottom-left vault:
|
||||||
|
|
||||||
|
#######
|
||||||
|
#@.#Cd#
|
||||||
|
##.#@##
|
||||||
|
#######
|
||||||
|
##@#.##
|
||||||
|
#c.#.@#
|
||||||
|
#######
|
||||||
|
Then, the bottom-left robot collects key c:
|
||||||
|
|
||||||
|
#######
|
||||||
|
#@.#.d#
|
||||||
|
##.#@##
|
||||||
|
#######
|
||||||
|
##.#.##
|
||||||
|
#@.#.@#
|
||||||
|
#######
|
||||||
|
Finally, the top-right robot collects key d:
|
||||||
|
|
||||||
|
#######
|
||||||
|
#@.#.@#
|
||||||
|
##.#.##
|
||||||
|
#######
|
||||||
|
##.#.##
|
||||||
|
#@.#.@#
|
||||||
|
#######
|
||||||
|
In this example, it only took 8 steps to collect all of the keys.
|
||||||
|
|
||||||
|
Sometimes, multiple robots might have keys available, or a robot might have to wait for multiple keys to be collected:
|
||||||
|
|
||||||
|
###############
|
||||||
|
#d.ABC.#.....a#
|
||||||
|
######@#@######
|
||||||
|
###############
|
||||||
|
######@#@######
|
||||||
|
#b.....#.....c#
|
||||||
|
###############
|
||||||
|
First, the top-right, bottom-left, and bottom-right robots take turns collecting keys a, b, and c, a total of 6 + 6 + 6 = 18 steps. Then, the top-left robot can access key d, spending another 6 steps; collecting all of the keys here takes a minimum of 24 steps.
|
||||||
|
|
||||||
|
Here's a more complex example:
|
||||||
|
|
||||||
|
#############
|
||||||
|
#DcBa.#.GhKl#
|
||||||
|
#.###@#@#I###
|
||||||
|
#e#d#####j#k#
|
||||||
|
###C#@#@###J#
|
||||||
|
#fEbA.#.FgHi#
|
||||||
|
#############
|
||||||
|
Top-left robot collects key a.
|
||||||
|
Bottom-left robot collects key b.
|
||||||
|
Top-left robot collects key c.
|
||||||
|
Bottom-left robot collects key d.
|
||||||
|
Top-left robot collects key e.
|
||||||
|
Bottom-left robot collects key f.
|
||||||
|
Bottom-right robot collects key g.
|
||||||
|
Top-right robot collects key h.
|
||||||
|
Bottom-right robot collects key i.
|
||||||
|
Top-right robot collects key j.
|
||||||
|
Bottom-right robot collects key k.
|
||||||
|
Top-right robot collects key l.
|
||||||
|
In the above example, the fewest steps to collect all of the keys is 32.
|
||||||
|
|
||||||
|
Here's an example with more choices:
|
||||||
|
|
||||||
|
#############
|
||||||
|
#g#f.D#..h#l#
|
||||||
|
#F###e#E###.#
|
||||||
|
#dCba@#@BcIJ#
|
||||||
|
#############
|
||||||
|
#nK.L@#@G...#
|
||||||
|
#M###N#H###.#
|
||||||
|
#o#m..#i#jk.#
|
||||||
|
#############
|
||||||
|
One solution with the fewest steps is:
|
||||||
|
|
||||||
|
Top-left robot collects key e.
|
||||||
|
Top-right robot collects key h.
|
||||||
|
Bottom-right robot collects key i.
|
||||||
|
Top-left robot collects key a.
|
||||||
|
Top-left robot collects key b.
|
||||||
|
Top-right robot collects key c.
|
||||||
|
Top-left robot collects key d.
|
||||||
|
Top-left robot collects key f.
|
||||||
|
Top-left robot collects key g.
|
||||||
|
Bottom-right robot collects key k.
|
||||||
|
Bottom-right robot collects key j.
|
||||||
|
Top-right robot collects key l.
|
||||||
|
Bottom-left robot collects key n.
|
||||||
|
Bottom-left robot collects key m.
|
||||||
|
Bottom-left robot collects key o.
|
||||||
|
This example requires at least 72 steps to collect all keys.
|
||||||
|
|
||||||
|
After updating your map and using the remote-controlled robots, what is the fewest steps necessary to collect all of the keys?
|
||||||
|
|||||||
Reference in New Issue
Block a user