GithubHelp home page GithubHelp logo

arxcis / adventofcode2020 Goto Github PK

View Code? Open in Web Editor NEW
6.0 3.0 8.0 1.81 MB

Community-project solving https://adventofcode.com/ - problems, with Github CI, Docker and support for many languages.

Dockerfile 0.53% Makefile 0.16% Shell 8.95% Go 5.26% JavaScript 1.73% Python 30.50% Rust 13.46% C 4.12% C++ 0.85% Standard ML 13.08% Ruby 0.50% Zig 11.21% TypeScript 9.65%

adventofcode2020's Introduction

adventofcode2020 🕯️ 🎄 ⛄

Welcome to this community project, where we collaboratively solve https://adventofcode.com/.

CI test status

examples 2021 2020

Github CI runs the <year>/<day>/test.sh for each day. Example: 2020/day01/test.sh

Solved days by language

Language Total 2020 2021
python3 28 25 3
sml 19 19
deno.ts 15 15
rust 14 1 13
zig 11 9 2
golang 8 8
c 6 6
node.js 4 4
c++ 2 2
ruby 2 2

Last updated: 2021-12-18

See all languages we support in our Dockerfile.

Run make versions to see installed language versions in the docker-container.

Fork today! Anyone is encouraged to contribute, and as a contributor you may do whatever you want with this code. Treat it as your own 👍

Contributors

A special thanks to the developers over at Maritime Optima 🚢 - https://github.com/orgs/MaritimeOptima/people - volunteering to support this project 🙏

Also a big thanks to the rest of our contributors 🎉

Leaderboard

Contributors are welcomed to join our private leaderboard 😎 Use the join code 376961-8a514359 at https://adventofcode.com/2020/leaderboard/private

Sharing

If you enjoy working on this project, consider sharing it with your friends. The more the merrier 🎅

Getting started

Test solutions on your system

$ ./lang/rust.sh "2020/day01/solutions/day01.rs" "2020/day01/io/*"
cat INPUT | rustc    day01.rs                662ms      ✅

Test inside docker container

# Test everything:
make

# Test year:
make name=2021

# Test day:
make name=2021/day01

adventofcode2020's People

Contributors

arxcis avatar avokadoen avatar celebrian avatar hypirion avatar jorgenhanssen avatar klyve avatar preng69 avatar stektpotet avatar tholok97 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

adventofcode2020's Issues

Support prolog

Prolog could be an interesting language to add to the stack of supported languages.
During the day07 puzzle I again remembered the hell it was to was to write,
but also the power of it once you finally managed to wrap your head around how the facts, predicates and queries interact with each other.

I started looking into it over on my own fork
I still haven't managed to get it up and running due to not having touched apt-get in ages and ages, but I don't think I'm far of with it.


Likely one of the biggest difficulties of using prolog is going to be processing the various input for the puzzles, but from the little research I did before adding this issue, it's possible to read stdin and write to stdout fairly easily through the builtin "commands"

Which license should we have?

I have no idea. Github is suggesting to add a license everywhere. I am thinking the samller the better. MIT license perhaps. Does anyone have any feelings about this?

2020 solutions in Zig fails to compile with 2021 docker image

TBD

Is this an easy / quick fix?

$ make name=2020
docker run -ti -v /home/jonas/git/github.com/Arxcis/adventofcode2020:/aoc "jonasjso/adventofcode2020:2021-12-08-kill-java-and-kotlin" /bin/bash -c "cd /aoc && ./2020/test.sh && exit"

------------------------ 2020 ------------------------
--- Day 1: Report Repair ---
         go       day01.stektpotet.go      ⏱️  5ms        ✅
         go       day01.tholok97.go        ⏱️  5ms        ✅
         gcc      day01.c                  ⏱️  8ms        ✅
         zig      day01.zig                ⏱️  ./zig_solution.zig:27:33: error: no member named 'inStream' in struct 'std.fs.file.File'
    const in = std.io.getStdIn().inStream();
                                ^
--- Day 2: Password Philosophy ---
         go       day02.stektpotet.go      ⏱️  4ms        ✅
         gcc      day02.c                  ⏱️  4ms        ✅
         zig      day02.zig                ⏱️  /tmp/zig_solution.zig:29:17: error: unused capture
        } else |err| {
                ^
--- Day 3: Counting trees ---
         go       day03.stektpotet.go      ⏱️  5ms        ✅
         go       day03.tholok97.go        ⏱️  5ms        ✅
         gcc      day03.c                  ⏱️  4ms        ✅
         zig      day03.zig                ⏱️  4ms        ✅
         polyc    day03.sml                ⏱️  29ms       ✅
         python3  day03.klyve.py           ⏱️  28ms       ✅
         python3  day03.preng.py           ⏱️  20ms       ✅
         python3  one-liner.py             ⏱️  25ms       ✅
         deno     day03.ts                 ⏱️  40ms       ✅
--- Day 4: Passport Processing ---
         gcc      day04.c                  ⏱️  5ms        ✅
         zig      day04.zig                ⏱️  /tmp/zig_solution.zig:124:5: error: unused while loop label
    line_read: while (lines.next()) |line| {
    ^
--- Day 5: Boarding pass ---
         go       day05.stektpotet.go      ⏱️  5ms        ✅
         gcc      day05.c                  ⏱️  5ms        ✅
         zig      day05.zig                ⏱️  /tmp/zig_solution.zig:52:5: error: 'comptime const' is redundant; instead wrap the initialization expression with 'comptime'
    comptime const row_extractor = LineSegmentParser('F', 'B', 127);
    ^
--- Day 6: Custom customs ---
         go       day06.stektpotet.go      ⏱️  7ms        ✅
         go       tholok97.go              ⏱️  8ms        ✅
         gcc      day06.c                  ⏱️  4ms        ✅
         zig      day06.zig                ⏱️  ./zig_solution.zig:64:29: error: expected type 'type', found '[]u8'
    var it = mem.split(bytes[0..length], "\n\n");
                            ^
--- Day 7: Handy Haversacks ---
         zig      day07.zig                ⏱️  /tmp/zig_solution.zig:102:11: error: unused local constant
    const stderr = std.io.getStdErr().writer();
          ^
--- Day 8: Handheld Halting ---
         zig      day08.zig                ⏱️  /tmp/zig_solution.zig:123:21: error: unused capture
            } else |err| {
                    ^
--- Day 9: Encoding Error ---
         zig      day09.zig                ⏱️  /tmp/zig_solution.zig:32:13: error: unused local variable
        var weakness: usize = 0;

Day 17 - Convay cubes complications

Merry christmas 🎄 🎅

I just don't get this day https://adventofcode.com/2020/day/17

Rules
During a cycle, all cubes simultaneously change their state according to the following rules:

  • If a cube is active and exactly 2 or 3 of its neighbors are also active, the cube remains active. Otherwise, the cube becomes inactive.
  • If a cube is inactive but exactly 3 of its neighbors are active, the cube becomes active. Otherwise, the cube remains inactive.

Example

Before any cycles:

z=0
.#.
..#
###


After 1 cycle:

z=-1
#..
..#
.#.

z=0
#.#
.##
.#.

z=1
#..
..#
.#.

My attempt at making sense of it
Let's consider z=0 initial state:

z=0
.#.
..#
###

And here is me applying the rules for each cell from left to right, top to bottom:

  1. Is inactive and has 1 active neighbor to the right -> remains inactive
  2. Is active and has 1 active neighbor to the bottom right -> turns to inactive
  3. Is inactive and has 2 active neighbors -> remains inactive
  4. Is inactive and has 3 active neighbor -> turns to active
  5. Is inactive and has 4 active neighbors -> remains active
  6. Is active and has 3 active neighbors -> remains active
  7. Is active and has 1 active neighbor -> turns to inactive
  8. Is active and has 3 active neighbors -> remains active
  9. Is active and has 2 active neightbors -> remains active

What I expected z=0 to be after 1 cycle

z=0
...
#.#
.##

Example after 1 cycle

After 1 cycle:
z=0
#.#
.##
.#.

What Is going on here? I have been completely stuck on this task for several days because I don't get it.

Annoying warnings from polyc compiler when running tests

It does not look pretty.
TODO: Figure out how we could mitigate it.

-- Day 1: Report Repair ---
cat input.txt | python3  day01.py         533ms      ✅
cat input.txt | rustc    day01.rs         753ms      ✅
/usr/bin/ld: /tmp/polyobj.413.o: warning: relocation in read-only section `.text'
/usr/bin/ld: warning: creating DT_TEXTREL in a PIE
cat input.txt | polyc    day01.sml        419ms      ✅
cat input.txt | ruby     day01.rb         1231ms     ✅
cat input.txt | g++      day01.cpp        409ms      ✅
cat input.txt | python3  one-liner.py     280ms      ✅


--- Day 2: Password Philosophy ---
cat input.txt | gcc      day02.c          2ms        ✅
cat input.txt | g++      day02.cpp        3ms        ✅
/usr/bin/ld: /tmp/polyobj.532.o: warning: relocation in read-only section `.text'
/usr/bin/ld: warning: creating DT_TEXTREL in a PIE
cat input.txt | polyc    day02.sml        404ms      ✅
cat input.txt | python3  day02.py         10ms       ✅


--- Day 3: Counting trees ---
cat input.txt | python3  day03.py         9ms        ✅
/usr/bin/ld: /tmp/polyobj.597.o: warning: relocation in read-only section `.text'
/usr/bin/ld: warning: creating DT_TEXTREL in a PIE
cat input.txt | polyc    day03.sml        404ms      ✅
cat input.txt | python3  python_klyve.py  12ms       ✅
cat input.txt | gcc      day03.c          1ms        ✅

Docker image size is getting too big

Stats

After #125 - adding Kotlin support - the biggest layer is now 3.8GB!

[jonas@macbookpro adventofcode2020]$ make push
docker push "jonasjso/adventofcode2020:2021-12-04-with-kotlin-1.5.32"
The push refers to repository [docker.io/jonasjso/adventofcode2020]
23ad0c1ac26c: Pushing [==>                                                ]  213.3MB/3.8GB

But on Dockerhub it looks a bit smaller, still it is increasing in size

2020-12-18-with-zig-v0.7.1 2021-12-04-with-kotlin-1.5.32
image image

Ideas on how to reduce size

Some ideas off the top of my head:

  • Try to install more via apt if possible.
  • Use a different distro than Ubuntu, with more packages available out of the box - maybe use Arch with Pacman + AUR instead?
  • Install the things missing in apt from brew or snap instead - requires installing brew and snap. Not sure if this will reduce image size at all 🤔

Compile go and zig before running, instead of "go run" and "zig run"

Because they get unfair performance numbers, by compiling and running in a single command:
image

There is no way to time only the run-time, when we compile and run with the same command, so we should split it up, to be able to only measure run-time:

start=$(($(date +%s%N)/1000000))
cat $INPUT | zig run $SOLUTION -O ReleaseFast | diff - $OUTPUT
end=$(($(date +%s%N)/1000000))

Kill Java support?

  • No-one is writing in Java at the moment.
  • Java (openjdk-11) is a fat language-run-time which takes +200MB of the Docker image.
  • Those 200MB could be used to have a smaller image, OR be freed up for people to add multiple smaller languages, if requested.

We should kill Kotlin and Java :skull:

Issue #126 and issue #134 are all caused by issues with Kotlin, Java, JVM, JDK, JRE and so on....

  • The whole Java VM + Kotlin is just very bloated, which means docker image is very big #126
  • Kotlin Native in the command line has been a terrible development environment, which relates to why it is so hard to fix #134. No JRE libraries for reading input available like java.io.File as an example.
  • Installing Kotlin Native in Dockerfile was extremely not-plug-and-play.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.