Skip to content

Instantly share code, notes, and snippets.

View svantelidman's full-sized avatar

Svante Lidman svantelidman

  • Stockholm, Sweden
View GitHub Profile
@svantelidman
svantelidman / Book.md
Created March 19, 2021 22:49
Architecture Book

Chapters:

  • agile architecture

  • transparency humility involvement

  • forceful decisionmaking egen necessären

  • recruitment

  • what is architecture

  • processes

  • role of lead developers

  • principles, practices and guidelines

/*
Part 1 was solved by first exploring the internals of Santa's ship manually then
creating a command file / parsing to collect all items and move to the security
checkpoint. Then a random number of items between 3 and 6 are picked up and
tried if they are the right combination until we find the right one. Seemed simpler
solution which would be quick enough given the relatively few number of items compared to
doing a more proper search. It will typically take 5-20 seconds to find the right combination.
Part 2 will have to wait until days 16, 18, and 22 are completed, if ever.
/*
Well, well took longer than anticipated due to mixing up index-variables (unsurprisingly).
*/
use std::io::{BufReader, BufRead};
use std::fs::File;
type Level = Vec<Vec<char>>;
/*
This was swiftly accomplished but part_2 will be quite different...
*/
use std::io::{BufReader, BufRead};
use std::fs::File;
use std::collections::HashSet;
type Habitat = Vec<Vec<char>>;
fn main() {
/*
Probably one of the quicker days to solve both parts. Strayed a bit on the network-idle detection
but all else was quite straight forward. Solution could be cleaner with respect to the NAT-handling
though.
*/
use std::io::{BufReader, BufRead};
use std::fs::File;
use std::collections::HashMap;
/*
Part 1 was easy enough by simply appplying the different shuffles.
However, for part 2 the solution in the function part_2 will probably
take a number of years to complete. I was hoping that there would be a
loop somewhere so that you could determine the answer based on position
in the loop. But there does not seem to be a loop at least not one that
is reached in a reasonable time.
I need more mathematical puzzle practice, I guess, to handle these kind of
questions. I might get back and do a solution based on the function
/*
To run, put the IntCode-program in a file named prog and the spring droid program
in a file named droid_prog.
It was fairly easy to come up with a spring droid program for part 1 manually:
NOT C J
NOT A T
OR T J
AND D J
WALK
/*
Brute force solution in Rust. No attempt is made to predict the shape of the
tractor beam. Instead the beam is scanned for a sufficient distance (1200 steps).
and then the 100x100 box (supposedly Santa's ship) is fitted into the scan at
the optimal posistion
It take about 30 minutes to run this when compiled in release mode.
*/
use std::io::{BufReader, BufRead};
/*
Kotlin:
Messy - the mistake I made was not to go for memoization from the beginning which led to a lot
of churn which is obvious from the currrent look of the code.
Run like so:
val maze = Maze.loadFrom("prod")
maze.scan()
val preparedSegments = maze.prepareSegments()
val nodes = maze.createNodeMesh(preparedSegments)
/*
Day 20 of Adventofcode 2019 in Kotlin
Run like this:
val maze = Maze.loadFrom("prod") // prod is a file with the puzzle input
maze.scan()
maze.prepareSegments()
maze.createNodeMesh()
maze.createPortalConnections()
maze.shortestPathLength(maze.findPortal("AA"), maze.findPortal("ZZ"))