ceedee666
: ceedee666
ceedee666 |
This solution is written in python.
The following libraries are used to implement the solution:
Typer (https://typer.tiangolo.com/) to generate a nice command line interface
The main idea of this solution is to group the data into a list of lists.
Once the data is grouped into a list of lists simple Python functions
like sum
and max
can be used to solve the exercise.
How to use .vimspector.json
files to manage debug configurations.
This solution is written in python.
Typer (https://typer.tiangolo.com/) to generate a nice command line interface
The main idea of this solution is to use dicts represent the games.
This solution is written in python.
Typer (https://typer.tiangolo.com/) to generate a nice command line interface
The main idea of this solution is to use sets and set intersection to find the common items
That list comprehension can be use to split list into sub lists.
This solution is written in python.
The following libraries are used to implement the solution:
Typer (https://typer.tiangolo.com/) to generate a nice command line interface
The main idea of this solution is to:
check the boundaries of the ranges
use the filter function
If you type lamdba istead of lambda it can take quite some time to find the error.
This solution is written in python.
The following libraries are used to implement the solution:
Typer (https://typer.tiangolo.com/) to generate a nice command line interface
The main idea of this solution is to use Python list as stacks. This can be done with the
pop()
and append()
functions.
Parsing text files results in ugly code.
This solution is written in python.
The following libraries are used to implement the solution:
Typer (https://typer.tiangolo.com/) to generate a nice command line interface
The main idea of this solution is to group the input string into substrings of a given length and use
a set
to check how many different characters are in the substring.
This solution is written in python.
The following libraries are used to implement the solution:
Typer (https://typer.tiangolo.com/) to generate a nice command line interface
The main idea of this solution is to build a tree from the commands. The tree is implemented using dataclasses. The dataclass contains recursive methods to collect all children and to calculate the total size.
I learned a lot about dataclasses, typing and type hints, and enums.
This solution is written in python.
The following libraries are used to implement the solution:
Typer (https://typer.tiangolo.com/) to generate a nice command line interface
I got a little stuck with the first part today by trying to solve this puzzle using just list comprehension. I worked on rows and cols separately and tried to combine the results by just summing the visible trees in both. However, this does not work as it would count some trees multiple times.
Finally, I changed my approach an iterated through the grid using `range`s.
If you want to use a range
to count down the indices of a list be sure
to use range(start, -1, -1)
. Otherwise some of the elements might be missing.
=== How to run
Run using:
$ python day_08.py --help
This solution is written in python.
The following libraries are used to implement the solution:
Typer (https://typer.tiangolo.com/) to generate a nice command line interface
The main idea is to use a list
of lists
to collect the positions of the knots. First the
position of the head is updated with each move. Next the positions of all
following knots is updated. Positions are simply added to the list
. After all moves where
executed the list
ist converted to a set
to get the number visited positions.
One shouldn’t try to be to clever. Instead of trying to use pattern matching to solve this I
should have gone for the easier if … else…
approach.
This solution is written in python.
The following libraries are used to implement the solution:
Typer (https://typer.tiangolo.com/) to generate a nice command line interface
Today was straight forward. Just use a list to keep track of the values of x.
This solution is written in python.
The following libraries are used to implement the solution:
Typer (https://typer.tiangolo.com/) to generate a nice command line interface
Part one was quite easy. The parsing of the input file was the most complicated part. I used
a dict
to represent the monkey data. Depending on the operation the mokey performs I
added operator.add
or operator.mul
to the dict. This allowed me to just invoke the correct
operation later.
I struggled a litte with the math for part two.
I should work on my basic math skills….
This solution is written in python.
The following libraries are used to implement the solution:
Typer (https://typer.tiangolo.com/) to generate a nice command line interface
The main idea is to implement breath first search to find the shortest path from the start to the highest point.
I struggled a little with finding possible neighbours. It took me some time to realize that I need to take the hight into account.
This solution is written in python.
The following libraries are used to implement the solution:
Typer (https://typer.tiangolo.com/) to generate a nice command line interface
The main idea is to implement a comparison function for the lists. This
function returns -1
, 0
or 1
if the first list is smaller, equal,
or larger as the second one. This only became obvious after reading the
second part. Luckily a small refactoring of the solution for part one was
enough to create the comparison function.
Using the comparison function the second part could be solved by simply
using sorted
together with the comparison function.
I learned about functools.cmp_to_key
today.
=== How to run
Run using:
$ python day_13.py --help
This solution is written in python.
The following libraries are used to implement the solution:
Typer (https://typer.tiangolo.com/) to generate a nice command line interface
The main idea ist to use a dict
to represent the cave. (x,y)
coordinates
are mapped to "R"
for rocks and "S"
for sand.
Using this represenatiton it is easy to check if a certain position (x,y)
is already
in occupied by either a rock or a sand.
Initially I missed the end condition that a grain of sand could fall into the void,
i.e. y
in creases beyond the maximum y
of any rock.
How to use comprehensions to create `dict`s.
This solution is written in python.
The following libraries are used to implement the solution:
Typer (https://typer.tiangolo.com/) to generate a nice command line interface
I did really struggle totday. I tried to create all positions and filter those for part one. This wouldn’t work for part two. So I had to change the approach to calculate which ranges of a row are covered by the sensors.
Regex can be really useful to parse files ;)
This solution is written in python.
The following libraries are used to implement the solution:
Typer (https://typer.tiangolo.com/) to generate a nice command line interface
I did really struggle totday. I tried to create all positions and filter those for part one. This wouldn’t work for part two. So I had to change the approach to calculate which ranges of a row are covered by the sensors.
Regex can be really useful to parse files ;)
This solution is written in python.
The following libraries are used to implement the solution:
Typer (https://typer.tiangolo.com/) to generate a nice command line interface
I did really struggle today. I tried to create all positions and filter those for part one. This wouldn’t work for part two. So I had to change the approach to calculate which ranges of a row are covered by the sensors.
Regex can be really useful to parse files ;)
This solution is written in python.
The following libraries are used to implement the solution:
Typer (https://typer.tiangolo.com/) to generate a nice command line interface
First I just counted cubes. For the second part I had to change my approach. I implemented a flooding algorithm to find the outside. After that I calculated all neighbours of the cubes and counted only the ones visible from the outside.
I extended my knowledge of list comprehension. Such a cool feature!
This solution is written in python.
The following libraries are used to implement the solution:
Typer (https://typer.tiangolo.com/) to generate a nice command line interface
I didn’t really have an idea for today. Brute force seemed to be to slow. With some inspiration from reddit I was able to finally solve today.
This solution is written in python.
The following libraries are used to implement the solution:
Typer (https://typer.tiangolo.com/) to generate a nice command line interface
Solved today using deque
from the collections
module. This was my first idea.
However, I then tried using indices and modulo arithmetic instead. Couldn’t get a nice
solution and finally got back to the deque
approach.
This solution is written in python.
The following libraries are used to implement the solution:
Typer (https://typer.tiangolo.com/) to generate a nice command line interface
Implemented something similar to a binary search. The main idea was to increase the steps in each iteration and change directions when the sign of the difference between the result and the expected value changes.
This solution is written in python.
The following libraries are used to implement the solution:
Typer (https://typer.tiangolo.com/) to generate a nice command line interface
Only solved part one today.
When zipping two lists make sure they are of equal lenght.
This solution is written in python.
The following libraries are used to implement the solution:
Typer (https://typer.tiangolo.com/) to generate a nice command line interface
Only solved part one today.
When zipping two lists make sure they are of equal lenght.
This solution is written in python.
The following libraries are used to implement the solution:
Typer (https://typer.tiangolo.com/) to generate a nice command line interface
Basically use sets to keep track of the state. I very useful ideas is to move all positions -1 in x and y direction. This enables much simpler calculations. The next positions of the blizzards can then, e.g. simply be calculated using a modulo operation.
It is not necessary to create a list
wen using max
. The following is possible as
well. This approach creates a generator. Have to read some more details on generators I guess.
max_x = max(x for x, _ in walls)
This solution is written in python.
The following libraries are used to implement the solution:
Typer (https://typer.tiangolo.com/) to generate a nice command line interface
Basically use sets to keep track of the state. I very useful ideas is to move all positions -1 in x and y direction. This enables much simpler calculations. The next positions of the blizzards can then, e.g. simply be calculated using a modulo operation.
It is not necessary to create a list
wen using max
. The following is possible as
well. This approach creates a generator. Have to read some more details on generators I guess.
max_x = max(x for x, _ in walls)
Run using:
$ python day_24.py --help