Git Product home page Git Product logo

aoc2023's Introduction

Build Status

Advent of Code 2023: https://adventofcode.com/2023

How to contribute

  • upload input and solutions in the same PR. Name and clean up them properly
  • when adding a new programming language, remember to update runtests.jl to "teach" it how to compile & run the <lang>

When testing locally, you can choose languages you want. For example, to avoid building C++ with bezel: to run - julia runtests.jl python cpp

> julia runtests.jl python cpp
Test Summary:                              | Pass  Total  Time
Day 00                                     |    4      4  0.3s
  python  00.py                00_test.txt |    2      2  0.0s
  cpp     00.cpp               00_test.txt |    2      2  0.3s

Repo structure

AoC2023/
├── runtests.jl
├── inputs
│   ├── 00_test.txt
│   ├── 01_bauerc.txt
│   └── 01_moelf.txt
├── solutions
│   ├── 00_test.txt
│   ├── 01_bauerc.txt
│   └── 01_moelf.txt
└── src
    ├── cpp
    │   ├── 00.cpp
    │   └── 01.cpp
    └── julia
        ├── 00_test.jl
        └── 01_bauerc_moelf.jl
  • the input files should be named as <day>_<name>.txt, the content should be the input of the day without any dangling empty lines at the end
  • the solutions files should be named exactly as corresponding input file, the content should be exactly one or two lines (depending on if you solved both parts)
  • the src/<lang>/<day>_<optional name>.<ext> should matched the double-digit day number convention. The <lang> should match what appears in runtests.jl

Note for Julia

Each <day>_julia.jl script should use a main() and @__FILE__ pattern similar to:

function main(path)
    println("hello world")
    println("solution 2")
end

(abspath(PROGRAM_FILE) == @__FILE__) && main(ARGS[1])

this way we can put each script int a DayN module and compile only once per day.

aoc2023's People

Contributors

carstenbauer avatar cryptum169 avatar moelf avatar rongkunwang avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

aoc2023's Issues

Local run test bazel build error

cpp     00.cpp               00_test.txt: Error During Test at /Users/rowang/Library/CloudStorage/[email protected]/My Drive/AdventOfCode/AoC2023/runtests.jl:56
  Got exception outside of a @test
  IOError: could not spawn `./bazel-bin/src/cpp/00 ./inputs/00_test.txt`: no such file or directory (ENOENT)
  Stacktrace:
    [1] _spawn_primitive(file::String, cmd::Cmd, stdio::Vector{Any})
      @ Base ./process.jl:99
    [2] #680
      @ ./process.jl:112 [inlined]
    [3] setup_stdios(f::Base.var"#680#681"{Cmd}, stdios::Vector{Any})
      @ Base ./process.jl:196
    [4] _spawn
      @ ./process.jl:111 [inlined]
    [5] eachline(cmd::Cmd; keep::Bool)
      @ Base ./process.jl:317
    [6] eachline
      @ ./process.jl:316 [inlined]
    [7] #readlines#368
      @ ./io.jl:553 [inlined]
    [8] readlines
      @ ./io.jl:553 [inlined]
    [9] run_solution(source_path::String, input_path::String, #unused#::Val{:cpp})
      @ Main ~/Library/CloudStorage/[email protected]/My Drive/AdventOfCode/AoC2023/runtests.jl:21
   [10] macro expansion
      @ ~/Library/CloudStorage/[email protected]/My Drive/AdventOfCode/AoC2023/runtests.jl:59 [inlined]
   [11] macro expansion
      @ /Users/sabae/src/julia/usr/share/julia/stdlib/v1.7/Test/src/Test.jl:1282 [inlined]
   [12] test_lang(day_num_str::String, input_path::String, reference_output::Vector{String}, lang::String)
      @ Main ~/Library/CloudStorage/[email protected]/My Drive/AdventOfCode/AoC2023/runtests.jl:57
   [13] macro expansion
      @ ~/Library/CloudStorage/[email protected]/My Drive/AdventOfCode/AoC2023/runtests.jl:73 [inlined]
   [14] macro expansion
      @ /Users/sabae/src/julia/usr/share/julia/stdlib/v1.7/Test/src/Test.jl:1282 [inlined]
   [15] top-level scope
      @ ~/Library/CloudStorage/[email protected]/My Drive/AdventOfCode/AoC2023/runtests.jl:72
   [16] include(mod::Module, _path::String)
      @ Base ./Base.jl:417
   [17] exec_options(opts::Base.JLOptions)
      @ Base ./client.jl:292
   [18] _start()
      @ Base ./client.jl:495
Test Summary:                              | Pass  Error  Total
Day 00                                     |    4      1      5
  cpp     00.cpp               00_test.txt |           1      1
  julia   00_test.jl           00_test.txt |    2             2
  python  00.py                00_test.txt |    2             2
ERROR: LoadError: Some tests did not pass: 4 passed, 0 failed, 1 errored, 0 broken.
in expression starting at /Users/rowang/Library/CloudStorage/[email protected]/My Drive/AdventOfCode/AoC2023/runtests.jl:67

Should we split `src` files by author too?

currently:

└── src
    ├── cpp
    │   └── 00.cpp
    └── julia
        └── 00.jl

@carstenbauer maybe we should split our source file so I don't change how you want to do things?

└── src
    ├── cpp
    │   └── 00.cpp
    └── julia
        └── 00_moelf.jl
        └── 00_bauerc.jl

Errors on `runtest.jl` on `feature/bazel` on local

Running julia runtest.jl gave the following output on local, any idea what to look for?

$ julia runtests.jl                                                                                                                                                                 ─╯
julia   00_test.jl           00_test.txt: Error During Test at /home/alex/GitHub_dev/AoC2023/runtests.jl:59
  Got exception outside of a @test
  IOError: could not spawn `julia /home/alex/GitHub_dev/AoC2023/src/julia/00_test.jl ./inputs/00_test.txt`: no such file or directory (ENOENT)
  Stacktrace:
    [1] _spawn_primitive(file::String, cmd::Cmd, stdio::Vector{Union{RawFD, IO}})
      @ Base ./process.jl:128
    [2] #760
      @ ./process.jl:139 [inlined]
    [3] setup_stdios(f::Base.var"#760#761"{Cmd}, stdios::Vector{Union{RawFD, IO}})
      @ Base ./process.jl:223
    [4] _spawn
      @ ./process.jl:138 [inlined]
    [5] #eachline#766
      @ ./process.jl:340 [inlined]
    [6] eachline
      @ ./process.jl:338 [inlined]
    [7] readlines(s::Cmd; kw::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
      @ Base ./io.jl:590
    [8] readlines
      @ ./io.jl:590 [inlined]
    [9] run_solution
      @ ~/GitHub_dev/AoC2023/runtests.jl:28 [inlined]
   [10] macro expansion
      @ ~/GitHub_dev/AoC2023/runtests.jl:62 [inlined]
   [11] macro expansion
      @ /usr/local/bin/julia-1.9.4/share/julia/stdlib/v1.9/Test/src/Test.jl:1498 [inlined]
   [12] test_lang(day_num_str::String, input_path::String, reference_output::Vector{String}, lang::String)
      @ Main ~/GitHub_dev/AoC2023/runtests.jl:60
   [13] macro expansion
      @ ~/GitHub_dev/AoC2023/runtests.jl:76 [inlined]
   [14] macro expansion
      @ /usr/local/bin/julia-1.9.4/share/julia/stdlib/v1.9/Test/src/Test.jl:1498 [inlined]
   [15] top-level scope
      @ ~/GitHub_dev/AoC2023/runtests.jl:75
   [16] include(mod::Module, _path::String)
      @ Base ./Base.jl:457
   [17] exec_options(opts::Base.JLOptions)
      @ Base ./client.jl:307
   [18] _start()
      @ Base ./client.jl:522
Test Summary:                              | Pass  Error  Total  Time
Day 00                                     |    4      1      5  0.6s
  cpp     00.cpp               00_test.txt |    2             2  0.0s
  julia   00_test.jl           00_test.txt |           1      1  0.6s
  python  00.py                00_test.txt |    2             2  0.0s
ERROR: LoadError: Some tests did not pass: 4 passed, 0 failed, 1 errored, 0 broken.
in expression starting at /home/alex/GitHub_dev/AoC2023/runtests.jl:70

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.