├── .github └── workflows │ ├── post-diffs-in-pr.yml │ └── test.yml ├── .gitignore ├── LICENSE ├── README.md ├── compiled_starters ├── c │ ├── .codecrafters │ │ ├── compile.sh │ │ └── run.sh │ ├── .gitattributes │ ├── .gitignore │ ├── CMakeLists.txt │ ├── README.md │ ├── codecrafters.yml │ ├── src │ │ └── main.c │ ├── vcpkg-configuration.json │ ├── vcpkg.json │ └── your_program.sh ├── cpp │ ├── .codecrafters │ │ ├── compile.sh │ │ └── run.sh │ ├── .gitattributes │ ├── .gitignore │ ├── CMakeLists.txt │ ├── README.md │ ├── codecrafters.yml │ ├── src │ │ └── main.cpp │ ├── vcpkg-configuration.json │ ├── vcpkg.json │ └── your_program.sh ├── csharp │ ├── .codecrafters │ │ ├── compile.sh │ │ └── run.sh │ ├── .gitattributes │ ├── .gitignore │ ├── README.md │ ├── codecrafters-interpreter.csproj │ ├── codecrafters-interpreter.sln │ ├── codecrafters.yml │ ├── src │ │ └── main.cs │ └── your_program.sh ├── elixir │ ├── .codecrafters │ │ ├── compile.sh │ │ └── run.sh │ ├── .formatter.exs │ ├── .gitattributes │ ├── .gitignore │ ├── README.md │ ├── codecrafters.yml │ ├── lib │ │ └── main.ex │ ├── mix.exs │ └── your_program.sh ├── gleam │ ├── .codecrafters │ │ ├── compile.sh │ │ └── run.sh │ ├── .gitattributes │ ├── .gitignore │ ├── README.md │ ├── codecrafters.yml │ ├── gleam.toml │ ├── manifest.toml │ ├── src │ │ └── main.gleam │ └── your_program.sh ├── go │ ├── .codecrafters │ │ ├── compile.sh │ │ └── run.sh │ ├── .gitattributes │ ├── README.md │ ├── app │ │ └── main.go │ ├── codecrafters.yml │ ├── go.mod │ ├── go.sum │ └── your_program.sh ├── java │ ├── .codecrafters │ │ ├── compile.sh │ │ └── run.sh │ ├── .gitattributes │ ├── .gitignore │ ├── README.md │ ├── codecrafters.yml │ ├── pom.xml │ ├── src │ │ └── main │ │ │ └── java │ │ │ └── Main.java │ └── your_program.sh ├── javascript │ ├── .codecrafters │ │ ├── compile.sh │ │ └── run.sh │ ├── .gitattributes │ ├── .gitignore │ ├── README.md │ ├── app │ │ └── main.js │ ├── codecrafters.yml │ ├── package-lock.json │ ├── package.json │ └── your_program.sh ├── kotlin │ ├── .codecrafters │ │ ├── compile.sh │ │ └── run.sh │ ├── .gitattributes │ ├── .gitignore │ ├── README.md │ ├── codecrafters.yml │ ├── pom.xml │ ├── src │ │ └── main │ │ │ └── kotlin │ │ │ └── Main.kt │ └── your_program.sh ├── ocaml │ ├── .codecrafters │ │ ├── compile.sh │ │ └── run.sh │ ├── .gitattributes │ ├── .gitignore │ ├── .ocamlformat │ ├── README.md │ ├── codecrafters.yml │ ├── codecrafters_interpreter.opam │ ├── dune │ ├── dune-project │ ├── src │ │ └── main.ml │ └── your_program.sh ├── odin │ ├── .codecrafters │ │ ├── compile.sh │ │ └── run.sh │ ├── .gitattributes │ ├── .gitignore │ ├── README.md │ ├── codecrafters.yml │ ├── src │ │ └── main.odin │ └── your_program.sh ├── php │ ├── .codecrafters │ │ ├── compile.sh │ │ └── run.sh │ ├── .gitattributes │ ├── README.md │ ├── app │ │ └── main.php │ ├── codecrafters.yml │ └── your_program.sh ├── python │ ├── .codecrafters │ │ ├── compile.sh │ │ └── run.sh │ ├── .gitattributes │ ├── .gitignore │ ├── Pipfile │ ├── Pipfile.lock │ ├── README.md │ ├── app │ │ └── main.py │ ├── codecrafters.yml │ └── your_program.sh ├── rust │ ├── .codecrafters │ │ ├── compile.sh │ │ └── run.sh │ ├── .gitattributes │ ├── .gitignore │ ├── Cargo.lock │ ├── Cargo.toml │ ├── README.md │ ├── codecrafters.yml │ ├── src │ │ └── main.rs │ └── your_program.sh ├── swift │ ├── .codecrafters │ │ ├── compile.sh │ │ └── run.sh │ ├── .gitattributes │ ├── .gitignore │ ├── Package.swift │ ├── README.md │ ├── Sources │ │ └── main.swift │ ├── codecrafters.yml │ └── your_program.sh ├── typescript │ ├── .codecrafters │ │ ├── compile.sh │ │ └── run.sh │ ├── .gitattributes │ ├── .gitignore │ ├── README.md │ ├── app │ │ └── main.ts │ ├── codecrafters.yml │ ├── package.json │ ├── tsconfig.json │ └── your_program.sh └── zig │ ├── .codecrafters │ ├── compile.sh │ └── run.sh │ ├── .gitattributes │ ├── .gitignore │ ├── README.md │ ├── build.zig │ ├── build.zig.zon │ ├── codecrafters.yml │ ├── src │ └── main.zig │ └── your_program.sh ├── course-definition.yml ├── dockerfiles ├── bun-1.1.Dockerfile ├── bun-1.2.Dockerfile ├── c-23.Dockerfile ├── cpp-23.Dockerfile ├── dotnet-8.0.Dockerfile ├── dotnet-9.0.Dockerfile ├── elixir-1.17.Dockerfile ├── elixir-1.18.Dockerfile ├── gleam-1.4.Dockerfile ├── gleam-1.6.Dockerfile ├── gleam-1.9.Dockerfile ├── go-1.22.Dockerfile ├── go-1.24.Dockerfile ├── java-23.Dockerfile ├── kotlin-2.0.Dockerfile ├── nodejs-20.Dockerfile ├── nodejs-21.Dockerfile ├── ocaml-5.2.0.Dockerfile ├── ocaml-5.3.Dockerfile ├── odin-2025.4.Dockerfile ├── php-8.4.Dockerfile ├── python-3.12.Dockerfile ├── python-3.13.Dockerfile ├── rust-1.77.Dockerfile ├── rust-1.80.Dockerfile ├── rust-1.82.Dockerfile ├── rust-1.85.Dockerfile ├── rust-1.86.Dockerfile ├── swift-6.0.Dockerfile ├── zig-0.13.Dockerfile └── zig-0.14.Dockerfile ├── solutions ├── c │ └── 01-ry8 │ │ ├── code │ │ ├── .codecrafters │ │ │ ├── compile.sh │ │ │ └── run.sh │ │ ├── .gitattributes │ │ ├── .gitignore │ │ ├── CMakeLists.txt │ │ ├── README.md │ │ ├── codecrafters.yml │ │ ├── src │ │ │ └── main.c │ │ ├── vcpkg-configuration.json │ │ ├── vcpkg.json │ │ └── your_program.sh │ │ ├── diff │ │ └── src │ │ │ └── main.c.diff │ │ └── explanation.md ├── cpp │ └── 01-ry8 │ │ ├── code │ │ ├── .codecrafters │ │ │ ├── compile.sh │ │ │ └── run.sh │ │ ├── .gitattributes │ │ ├── .gitignore │ │ ├── CMakeLists.txt │ │ ├── README.md │ │ ├── codecrafters.yml │ │ ├── src │ │ │ └── main.cpp │ │ ├── vcpkg-configuration.json │ │ ├── vcpkg.json │ │ └── your_program.sh │ │ ├── diff │ │ └── src │ │ │ └── main.cpp.diff │ │ └── explanation.md ├── csharp │ └── 01-ry8 │ │ ├── code │ │ ├── .codecrafters │ │ │ ├── compile.sh │ │ │ └── run.sh │ │ ├── .gitattributes │ │ ├── .gitignore │ │ ├── README.md │ │ ├── codecrafters-interpreter.csproj │ │ ├── codecrafters-interpreter.sln │ │ ├── codecrafters.yml │ │ ├── src │ │ │ └── main.cs │ │ └── your_program.sh │ │ ├── diff │ │ └── src │ │ │ └── main.cs.diff │ │ └── explanation.md ├── elixir │ └── 01-ry8 │ │ ├── code │ │ ├── .codecrafters │ │ │ ├── compile.sh │ │ │ └── run.sh │ │ ├── .formatter.exs │ │ ├── .gitattributes │ │ ├── .gitignore │ │ ├── README.md │ │ ├── codecrafters.yml │ │ ├── lib │ │ │ └── main.ex │ │ ├── mix.exs │ │ └── your_program.sh │ │ ├── diff │ │ └── lib │ │ │ └── main.ex.diff │ │ └── explanation.md ├── gleam │ └── 01-ry8 │ │ ├── code │ │ ├── .codecrafters │ │ │ ├── compile.sh │ │ │ └── run.sh │ │ ├── .gitattributes │ │ ├── .gitignore │ │ ├── README.md │ │ ├── codecrafters.yml │ │ ├── gleam.toml │ │ ├── manifest.toml │ │ ├── src │ │ │ └── main.gleam │ │ └── your_program.sh │ │ ├── diff │ │ └── src │ │ │ └── main.gleam.diff │ │ └── explanation.md ├── go │ └── 01-ry8 │ │ ├── code │ │ ├── .codecrafters │ │ │ ├── compile.sh │ │ │ └── run.sh │ │ ├── .gitattributes │ │ ├── README.md │ │ ├── app │ │ │ └── main.go │ │ ├── codecrafters.yml │ │ ├── go.mod │ │ ├── go.sum │ │ └── your_program.sh │ │ ├── diff │ │ └── app │ │ │ └── main.go.diff │ │ └── explanation.md ├── java │ └── 01-ry8 │ │ ├── code │ │ ├── .codecrafters │ │ │ ├── compile.sh │ │ │ └── run.sh │ │ ├── .gitattributes │ │ ├── .gitignore │ │ ├── README.md │ │ ├── codecrafters.yml │ │ ├── pom.xml │ │ ├── src │ │ │ └── main │ │ │ │ └── java │ │ │ │ └── Main.java │ │ └── your_program.sh │ │ ├── diff │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── Main.java.diff │ │ └── explanation.md ├── javascript │ └── 01-ry8 │ │ ├── code │ │ ├── .codecrafters │ │ │ ├── compile.sh │ │ │ └── run.sh │ │ ├── .gitattributes │ │ ├── .gitignore │ │ ├── README.md │ │ ├── app │ │ │ └── main.js │ │ ├── codecrafters.yml │ │ ├── package-lock.json │ │ ├── package.json │ │ └── your_program.sh │ │ ├── diff │ │ └── app │ │ │ └── main.js.diff │ │ └── explanation.md ├── kotlin │ └── 01-ry8 │ │ ├── code │ │ ├── .codecrafters │ │ │ ├── compile.sh │ │ │ └── run.sh │ │ ├── .gitattributes │ │ ├── .gitignore │ │ ├── README.md │ │ ├── codecrafters.yml │ │ ├── pom.xml │ │ ├── src │ │ │ └── main │ │ │ │ └── kotlin │ │ │ │ └── Main.kt │ │ └── your_program.sh │ │ ├── diff │ │ └── src │ │ │ └── main │ │ │ └── kotlin │ │ │ └── Main.kt.diff │ │ └── explanation.md ├── ocaml │ └── 01-ry8 │ │ ├── code │ │ ├── .codecrafters │ │ │ ├── compile.sh │ │ │ └── run.sh │ │ ├── .gitattributes │ │ ├── .gitignore │ │ ├── .ocamlformat │ │ ├── README.md │ │ ├── codecrafters.yml │ │ ├── codecrafters_interpreter.opam │ │ ├── dune │ │ ├── dune-project │ │ ├── src │ │ │ └── main.ml │ │ └── your_program.sh │ │ ├── diff │ │ └── src │ │ │ └── main.ml.diff │ │ └── explanation.md ├── odin │ └── 01-ry8 │ │ ├── code │ │ ├── .codecrafters │ │ │ ├── compile.sh │ │ │ └── run.sh │ │ ├── .gitattributes │ │ ├── .gitignore │ │ ├── README.md │ │ ├── codecrafters.yml │ │ ├── src │ │ │ └── main.odin │ │ └── your_program.sh │ │ ├── diff │ │ └── src │ │ │ └── main.odin.diff │ │ └── explanation.md ├── php │ └── 01-ry8 │ │ ├── code │ │ ├── .codecrafters │ │ │ ├── compile.sh │ │ │ └── run.sh │ │ ├── .gitattributes │ │ ├── README.md │ │ ├── app │ │ │ └── main.php │ │ ├── codecrafters.yml │ │ └── your_program.sh │ │ ├── diff │ │ └── app │ │ │ └── main.php.diff │ │ └── explanation.md ├── python │ └── 01-ry8 │ │ ├── code │ │ ├── .codecrafters │ │ │ ├── compile.sh │ │ │ └── run.sh │ │ ├── .gitattributes │ │ ├── .gitignore │ │ ├── Pipfile │ │ ├── Pipfile.lock │ │ ├── README.md │ │ ├── app │ │ │ └── main.py │ │ ├── codecrafters.yml │ │ └── your_program.sh │ │ ├── diff │ │ └── app │ │ │ └── main.py.diff │ │ └── explanation.md ├── rust │ └── 01-ry8 │ │ ├── code │ │ ├── .codecrafters │ │ │ ├── compile.sh │ │ │ └── run.sh │ │ ├── .gitattributes │ │ ├── .gitignore │ │ ├── Cargo.lock │ │ ├── Cargo.toml │ │ ├── README.md │ │ ├── codecrafters.yml │ │ ├── src │ │ │ └── main.rs │ │ └── your_program.sh │ │ ├── diff │ │ └── src │ │ │ └── main.rs.diff │ │ └── explanation.md ├── swift │ └── 01-ry8 │ │ ├── code │ │ ├── .codecrafters │ │ │ ├── compile.sh │ │ │ └── run.sh │ │ ├── .gitattributes │ │ ├── .gitignore │ │ ├── Package.swift │ │ ├── README.md │ │ ├── Sources │ │ │ └── main.swift │ │ ├── codecrafters.yml │ │ └── your_program.sh │ │ ├── diff │ │ └── Sources │ │ │ └── main.swift.diff │ │ └── explanation.md ├── typescript │ └── 01-ry8 │ │ ├── code │ │ ├── .codecrafters │ │ │ ├── compile.sh │ │ │ └── run.sh │ │ ├── .gitattributes │ │ ├── .gitignore │ │ ├── README.md │ │ ├── app │ │ │ └── main.ts │ │ ├── codecrafters.yml │ │ ├── package.json │ │ ├── tsconfig.json │ │ └── your_program.sh │ │ ├── diff │ │ └── app │ │ │ └── main.ts.diff │ │ └── explanation.md └── zig │ └── 01-ry8 │ ├── code │ ├── .codecrafters │ │ ├── compile.sh │ │ └── run.sh │ ├── .gitattributes │ ├── .gitignore │ ├── README.md │ ├── build.zig │ ├── build.zig.zon │ ├── codecrafters.yml │ ├── src │ │ └── main.zig │ └── your_program.sh │ ├── diff │ └── src │ │ └── main.zig.diff │ └── explanation.md └── starter_templates ├── all └── code │ ├── .gitattributes │ ├── README.md │ └── codecrafters.yml ├── c ├── code │ ├── .codecrafters │ │ ├── compile.sh │ │ └── run.sh │ ├── .gitignore │ ├── CMakeLists.txt │ ├── src │ │ └── main.c │ ├── vcpkg-configuration.json │ └── vcpkg.json └── config.yml ├── cpp ├── code │ ├── .codecrafters │ │ ├── compile.sh │ │ └── run.sh │ ├── .gitignore │ ├── CMakeLists.txt │ ├── src │ │ └── main.cpp │ ├── vcpkg-configuration.json │ └── vcpkg.json └── config.yml ├── csharp ├── code │ ├── .codecrafters │ │ ├── compile.sh │ │ └── run.sh │ ├── .gitignore │ ├── codecrafters-interpreter.csproj │ ├── codecrafters-interpreter.sln │ └── src │ │ └── main.cs └── config.yml ├── elixir ├── code │ ├── .codecrafters │ │ ├── compile.sh │ │ └── run.sh │ ├── .formatter.exs │ ├── .gitignore │ ├── lib │ │ └── main.ex │ └── mix.exs └── config.yml ├── gleam ├── code │ ├── .codecrafters │ │ ├── compile.sh │ │ └── run.sh │ ├── .gitignore │ ├── gleam.toml │ ├── manifest.toml │ └── src │ │ └── main.gleam └── config.yml ├── go ├── code │ ├── .codecrafters │ │ ├── compile.sh │ │ └── run.sh │ ├── app │ │ └── main.go │ ├── go.mod │ └── go.sum └── config.yml ├── java ├── code │ ├── .codecrafters │ │ ├── compile.sh │ │ └── run.sh │ ├── .gitignore │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── Main.java └── config.yml ├── javascript ├── code │ ├── .codecrafters │ │ ├── compile.sh │ │ └── run.sh │ ├── .gitignore │ ├── app │ │ └── main.js │ ├── package-lock.json │ └── package.json └── config.yml ├── kotlin ├── code │ ├── .codecrafters │ │ ├── compile.sh │ │ └── run.sh │ ├── .gitignore │ ├── pom.xml │ └── src │ │ └── main │ │ └── kotlin │ │ └── Main.kt └── config.yml ├── ocaml ├── code │ ├── .codecrafters │ │ ├── compile.sh │ │ └── run.sh │ ├── .gitignore │ ├── .ocamlformat │ ├── codecrafters_interpreter.opam │ ├── dune │ ├── dune-project │ └── src │ │ └── main.ml └── config.yml ├── odin ├── code │ ├── .codecrafters │ │ ├── compile.sh │ │ └── run.sh │ ├── .gitignore │ └── src │ │ └── main.odin └── config.yml ├── php ├── code │ ├── .codecrafters │ │ ├── compile.sh │ │ └── run.sh │ └── app │ │ └── main.php └── config.yml ├── python ├── code │ ├── .codecrafters │ │ ├── compile.sh │ │ └── run.sh │ ├── .gitignore │ ├── Pipfile │ ├── Pipfile.lock │ └── app │ │ └── main.py └── config.yml ├── rust ├── code │ ├── .codecrafters │ │ ├── compile.sh │ │ └── run.sh │ ├── .gitignore │ ├── Cargo.lock │ ├── Cargo.toml │ └── src │ │ └── main.rs └── config.yml ├── swift ├── code │ ├── .codecrafters │ │ ├── compile.sh │ │ └── run.sh │ ├── .gitignore │ ├── Package.swift │ └── Sources │ │ └── main.swift └── config.yml ├── typescript ├── code │ ├── .codecrafters │ │ ├── compile.sh │ │ └── run.sh │ ├── .gitignore │ ├── app │ │ └── main.ts │ ├── package.json │ └── tsconfig.json └── config.yml └── zig ├── code ├── .codecrafters │ ├── compile.sh │ └── run.sh ├── .gitignore ├── build.zig ├── build.zig.zon └── src │ └── main.zig └── config.yml /.github/workflows/post-diffs-in-pr.yml: -------------------------------------------------------------------------------- 1 | name: Post diffs 2 | 3 | on: 4 | pull_request: 5 | 6 | concurrency: 7 | group: ${{ github.workflow }}-${{ github.ref }} 8 | cancel-in-progress: true 9 | 10 | jobs: 11 | post_diffs: 12 | uses: codecrafters-io/course-sdk/.github/workflows/post-diffs-in-pr.yml@main 13 | with: 14 | sdkRef: main 15 | -------------------------------------------------------------------------------- /.github/workflows/test.yml: -------------------------------------------------------------------------------- 1 | name: Test 2 | 3 | on: 4 | pull_request: 5 | push: 6 | branches: [main] 7 | 8 | concurrency: 9 | group: ${{ github.workflow }}-${{ github.ref }} 10 | cancel-in-progress: true 11 | 12 | jobs: 13 | test_course_definition: 14 | uses: codecrafters-io/course-sdk/.github/workflows/test-course-definition.yml@main 15 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .vscode/ 2 | 3 | .history/ 4 | .idea/ 5 | 6 | starter_templates/ruby/* 7 | course-definition-tester/ 8 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # build-your-own-interpreter 2 | 3 | Content for the "Build your own Interpreter" challenge 4 | 5 | ## Setup 6 | 7 | This challenge is developed using https://github.com/codecrafters-io/course-sdk. 8 | Read the README there for information on how to contribute language support & 9 | submit solutions. 10 | -------------------------------------------------------------------------------- /compiled_starters/c/.codecrafters/compile.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # This script is used to compile your program on CodeCrafters 4 | # 5 | # This runs before .codecrafters/run.sh 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | set -e # Exit on failure 10 | 11 | cmake -B build -S . -DCMAKE_TOOLCHAIN_FILE=${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake 12 | cmake --build ./build 13 | -------------------------------------------------------------------------------- /compiled_starters/c/.codecrafters/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # This script is used to run your program on CodeCrafters 4 | # 5 | # This runs after .codecrafters/compile.sh 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | set -e # Exit on failure 10 | 11 | exec $(dirname $0)/build/interpreter "$@" 12 | -------------------------------------------------------------------------------- /compiled_starters/c/.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | -------------------------------------------------------------------------------- /compiled_starters/c/.gitignore: -------------------------------------------------------------------------------- 1 | # Prerequisites 2 | *.d 3 | 4 | # Object files 5 | *.o 6 | *.ko 7 | *.obj 8 | *.elf 9 | 10 | # Linker output 11 | *.ilk 12 | *.map 13 | *.exp 14 | 15 | # Precompiled Headers 16 | *.gch 17 | *.pch 18 | 19 | # Libraries 20 | *.lib 21 | *.a 22 | *.la 23 | *.lo 24 | 25 | # Shared objects (inc. Windows DLLs) 26 | *.dll 27 | *.so 28 | *.so.* 29 | *.dylib 30 | 31 | # Executables 32 | *.exe 33 | *.out 34 | *.app 35 | *.i*86 36 | *.x86_64 37 | *.hex 38 | 39 | # Debug files 40 | *.dSYM/ 41 | *.su 42 | *.idb 43 | *.pdb 44 | 45 | # Kernel Module Compile Results 46 | *.mod* 47 | *.cmd 48 | .tmp_versions/ 49 | modules.order 50 | Module.symvers 51 | Mkfile.old 52 | dkms.conf 53 | 54 | build 55 | vcpkg_installed -------------------------------------------------------------------------------- /compiled_starters/c/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.13) 2 | 3 | project(codecrafters-interpreter) 4 | 5 | file(GLOB_RECURSE SOURCE_FILES src/*.c src/*.h) 6 | 7 | set(CMAKE_C_STANDARD 23) # Enable the C23 standard 8 | 9 | add_executable(interpreter ${SOURCE_FILES}) 10 | -------------------------------------------------------------------------------- /compiled_starters/c/codecrafters.yml: -------------------------------------------------------------------------------- 1 | # Set this to true if you want debug logs. 2 | # 3 | # These can be VERY verbose, so we suggest turning them off 4 | # unless you really need them. 5 | debug: false 6 | 7 | # Use this to change the C version used to run your code 8 | # on Codecrafters. 9 | # 10 | # Available versions: c-23 11 | language_pack: c-23 12 | -------------------------------------------------------------------------------- /compiled_starters/c/vcpkg-configuration.json: -------------------------------------------------------------------------------- 1 | { 2 | "default-registry": { 3 | "kind": "git", 4 | "baseline": "c4af3593e1f1aa9e14a560a09e45ea2cb0dfd74d", 5 | "repository": "https://github.com/microsoft/vcpkg" 6 | }, 7 | "registries": [ 8 | { 9 | "kind": "artifact", 10 | "location": "https://github.com/microsoft/vcpkg-ce-catalog/archive/refs/heads/main.zip", 11 | "name": "microsoft" 12 | } 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /compiled_starters/c/vcpkg.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": [] 3 | } 4 | -------------------------------------------------------------------------------- /compiled_starters/c/your_program.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Use this script to run your program LOCALLY. 4 | # 5 | # Note: Changing this script WILL NOT affect how CodeCrafters runs your program. 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | set -e # Exit early if any commands fail 10 | 11 | # Copied from .codecrafters/compile.sh 12 | # 13 | # - Edit this to change how your program compiles locally 14 | # - Edit .codecrafters/compile.sh to change how your program compiles remotely 15 | ( 16 | cd "$(dirname "$0")" # Ensure compile steps are run within the repository directory 17 | cmake -B build -S . -DCMAKE_TOOLCHAIN_FILE=${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake 18 | cmake --build ./build 19 | ) 20 | 21 | # Copied from .codecrafters/run.sh 22 | # 23 | # - Edit this to change how your program runs locally 24 | # - Edit .codecrafters/run.sh to change how your program runs remotely 25 | exec $(dirname $0)/build/interpreter "$@" 26 | -------------------------------------------------------------------------------- /compiled_starters/cpp/.codecrafters/compile.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # This script is used to compile your program on CodeCrafters 4 | # 5 | # This runs before .codecrafters/run.sh 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | set -e # Exit on failure 10 | 11 | cmake -B build -S . -DCMAKE_TOOLCHAIN_FILE=${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake 12 | cmake --build ./build 13 | -------------------------------------------------------------------------------- /compiled_starters/cpp/.codecrafters/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # This script is used to run your program on CodeCrafters 4 | # 5 | # This runs after .codecrafters/compile.sh 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | set -e # Exit on failure 10 | 11 | exec $(dirname $0)/build/interpreter "$@" 12 | -------------------------------------------------------------------------------- /compiled_starters/cpp/.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | -------------------------------------------------------------------------------- /compiled_starters/cpp/.gitignore: -------------------------------------------------------------------------------- 1 | # Prerequisites 2 | *.d 3 | 4 | # Object files 5 | *.o 6 | *.ko 7 | *.obj 8 | *.elf 9 | 10 | # Linker output 11 | *.ilk 12 | *.map 13 | *.exp 14 | 15 | # Precompiled Headers 16 | *.gch 17 | *.pch 18 | 19 | # Libraries 20 | *.lib 21 | *.a 22 | *.la 23 | *.lo 24 | 25 | # Shared objects (inc. Windows DLLs) 26 | *.dll 27 | *.so 28 | *.so.* 29 | *.dylib 30 | 31 | # Executables 32 | *.exe 33 | *.out 34 | *.app 35 | *.i*86 36 | *.x86_64 37 | *.hex 38 | 39 | # Debug files 40 | *.dSYM/ 41 | *.su 42 | *.idb 43 | *.pdb 44 | 45 | # Kernel Module Compile Results 46 | *.mod* 47 | *.cmd 48 | .tmp_versions/ 49 | modules.order 50 | Module.symvers 51 | Mkfile.old 52 | dkms.conf 53 | 54 | build 55 | vcpkg_installed -------------------------------------------------------------------------------- /compiled_starters/cpp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.13) 2 | 3 | project(codecrafters-interpreter) 4 | 5 | set(CMAKE_CXX_STANDARD 23) # Enable the C++23 standard 6 | 7 | file(GLOB_RECURSE SOURCE_FILES src/*.cpp src/*.hpp) 8 | 9 | add_executable(interpreter ${SOURCE_FILES}) -------------------------------------------------------------------------------- /compiled_starters/cpp/codecrafters.yml: -------------------------------------------------------------------------------- 1 | # Set this to true if you want debug logs. 2 | # 3 | # These can be VERY verbose, so we suggest turning them off 4 | # unless you really need them. 5 | debug: false 6 | 7 | # Use this to change the C++ version used to run your code 8 | # on Codecrafters. 9 | # 10 | # Available versions: cpp-23 11 | language_pack: cpp-23 12 | -------------------------------------------------------------------------------- /compiled_starters/cpp/vcpkg-configuration.json: -------------------------------------------------------------------------------- 1 | { 2 | "default-registry": { 3 | "kind": "git", 4 | "baseline": "c4af3593e1f1aa9e14a560a09e45ea2cb0dfd74d", 5 | "repository": "https://github.com/microsoft/vcpkg" 6 | }, 7 | "registries": [ 8 | { 9 | "kind": "artifact", 10 | "location": "https://github.com/microsoft/vcpkg-ce-catalog/archive/refs/heads/main.zip", 11 | "name": "microsoft" 12 | } 13 | ] 14 | } -------------------------------------------------------------------------------- /compiled_starters/cpp/vcpkg.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": [] 3 | } -------------------------------------------------------------------------------- /compiled_starters/cpp/your_program.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Use this script to run your program LOCALLY. 4 | # 5 | # Note: Changing this script WILL NOT affect how CodeCrafters runs your program. 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | set -e # Exit early if any commands fail 10 | 11 | # Copied from .codecrafters/compile.sh 12 | # 13 | # - Edit this to change how your program compiles locally 14 | # - Edit .codecrafters/compile.sh to change how your program compiles remotely 15 | ( 16 | cd "$(dirname "$0")" # Ensure compile steps are run within the repository directory 17 | cmake -B build -S . -DCMAKE_TOOLCHAIN_FILE=${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake 18 | cmake --build ./build 19 | ) 20 | 21 | # Copied from .codecrafters/run.sh 22 | # 23 | # - Edit this to change how your program runs locally 24 | # - Edit .codecrafters/run.sh to change how your program runs remotely 25 | exec $(dirname $0)/build/interpreter "$@" 26 | -------------------------------------------------------------------------------- /compiled_starters/csharp/.codecrafters/compile.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # This script is used to compile your program on CodeCrafters 4 | # 5 | # This runs before .codecrafters/run.sh 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | set -e # Exit on failure 10 | 11 | dotnet build --configuration Release --output /tmp/codecrafters-build-csharp codecrafters-interpreter.csproj 12 | -------------------------------------------------------------------------------- /compiled_starters/csharp/.codecrafters/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # This script is used to run your program on CodeCrafters 4 | # 5 | # This runs after .codecrafters/compile.sh 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | set -e # Exit on failure 10 | 11 | exec /tmp/codecrafters-build-csharp/codecrafters-interpreter "$@" 12 | -------------------------------------------------------------------------------- /compiled_starters/csharp/.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | -------------------------------------------------------------------------------- /compiled_starters/csharp/codecrafters-interpreter.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net9.0 6 | codecrafters-interpreter 7 | enable 8 | enable 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /compiled_starters/csharp/codecrafters.yml: -------------------------------------------------------------------------------- 1 | # Set this to true if you want debug logs. 2 | # 3 | # These can be VERY verbose, so we suggest turning them off 4 | # unless you really need them. 5 | debug: false 6 | 7 | # Use this to change the C# version used to run your code 8 | # on Codecrafters. 9 | # 10 | # Available versions: dotnet-9.0 11 | language_pack: dotnet-9.0 12 | -------------------------------------------------------------------------------- /compiled_starters/csharp/src/main.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | 4 | if (args.Length < 2) 5 | { 6 | Console.Error.WriteLine("Usage: ./your_program.sh tokenize "); 7 | Environment.Exit(1); 8 | } 9 | 10 | string command = args[0]; 11 | string filename = args[1]; 12 | 13 | if (command != "tokenize") 14 | { 15 | Console.Error.WriteLine($"Unknown command: {command}"); 16 | Environment.Exit(1); 17 | } 18 | 19 | string fileContents = File.ReadAllText(filename); 20 | 21 | // You can use print statements as follows for debugging, they'll be visible when running tests. 22 | Console.Error.WriteLine("Logs from your program will appear here!"); 23 | 24 | // Uncomment this block to pass the first stage 25 | // if (!string.IsNullOrEmpty(fileContents)) 26 | // { 27 | // throw new NotImplementedException("Scanner not implemented"); 28 | // } 29 | // else 30 | // { 31 | // Console.WriteLine("EOF null"); // Placeholder, replace this line when implementing the scanner 32 | // } 33 | -------------------------------------------------------------------------------- /compiled_starters/csharp/your_program.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Use this script to run your program LOCALLY. 4 | # 5 | # Note: Changing this script WILL NOT affect how CodeCrafters runs your program. 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | set -e # Exit early if any commands fail 10 | 11 | # Copied from .codecrafters/compile.sh 12 | # 13 | # - Edit this to change how your program compiles locally 14 | # - Edit .codecrafters/compile.sh to change how your program compiles remotely 15 | ( 16 | cd "$(dirname "$0")" # Ensure compile steps are run within the repository directory 17 | dotnet build --configuration Release --output /tmp/codecrafters-build-csharp codecrafters-interpreter.csproj 18 | ) 19 | 20 | # Copied from .codecrafters/run.sh 21 | # 22 | # - Edit this to change how your program runs locally 23 | # - Edit .codecrafters/run.sh to change how your program runs remotely 24 | exec /tmp/codecrafters-build-csharp/codecrafters-interpreter "$@" 25 | -------------------------------------------------------------------------------- /compiled_starters/elixir/.codecrafters/compile.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # This script is used to compile your program on CodeCrafters 4 | # 5 | # This runs before .codecrafters/run.sh 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | set -e # Exit on failure 10 | 11 | mix escript.build 12 | mv codecrafters_interpreter /tmp/codecrafters-build-interpreter-elixir 13 | -------------------------------------------------------------------------------- /compiled_starters/elixir/.codecrafters/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # This script is used to run your program on CodeCrafters 4 | # 5 | # This runs after .codecrafters/compile.sh 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | set -e # Exit on failure 10 | 11 | exec /tmp/codecrafters-build-interpreter-elixir "$@" 12 | -------------------------------------------------------------------------------- /compiled_starters/elixir/.formatter.exs: -------------------------------------------------------------------------------- 1 | # Used by "mix format" 2 | [ 3 | inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"] 4 | ] 5 | -------------------------------------------------------------------------------- /compiled_starters/elixir/.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | -------------------------------------------------------------------------------- /compiled_starters/elixir/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore the compiled binary 2 | /codecrafters_interpreter 3 | 4 | # The directory Mix will write compiled artifacts to. 5 | /_build/ 6 | 7 | # If you run "mix test --cover", coverage assets end up here. 8 | /cover/ 9 | 10 | # The directory Mix downloads your dependencies sources to. 11 | /deps/ 12 | 13 | # Where third-party dependencies like ExDoc output generated docs. 14 | /doc/ 15 | 16 | # Ignore .fetch files in case you like to edit your project deps locally. 17 | /.fetch 18 | 19 | # If the VM crashes, it generates a dump, let's ignore it too. 20 | erl_crash.dump 21 | 22 | # Also ignore archive artifacts (built via "mix archive.build"). 23 | *.ez 24 | 25 | # Ignore package tarball (built via "mix hex.build"). 26 | app-*.tar 27 | 28 | -------------------------------------------------------------------------------- /compiled_starters/elixir/codecrafters.yml: -------------------------------------------------------------------------------- 1 | # Set this to true if you want debug logs. 2 | # 3 | # These can be VERY verbose, so we suggest turning them off 4 | # unless you really need them. 5 | debug: false 6 | 7 | # Use this to change the Elixir version used to run your code 8 | # on Codecrafters. 9 | # 10 | # Available versions: elixir-1.18 11 | language_pack: elixir-1.18 12 | -------------------------------------------------------------------------------- /compiled_starters/elixir/mix.exs: -------------------------------------------------------------------------------- 1 | defmodule App.MixProject do 2 | # NOTE: You do not need to change anything in this file. 3 | use Mix.Project 4 | 5 | def project do 6 | [ 7 | app: :codecrafters_interpreter, 8 | version: "1.0.0", 9 | elixir: "~> 1.18", 10 | start_permanent: Mix.env() == :prod, 11 | deps: deps(), 12 | escript: [main_module: CLI] 13 | ] 14 | end 15 | 16 | # Run "mix help compile.app" to learn about applications. 17 | def application do 18 | [ 19 | extra_applications: [:logger] 20 | ] 21 | end 22 | 23 | # Run "mix help deps" to learn about dependencies. 24 | defp deps do 25 | [ 26 | # {:dep_from_hexpm, "~> 0.3.0"}, 27 | # {:dep_from_git, git: "https://github.com/elixir-lang/my_dep.git", tag: "0.1.0"} 28 | ] 29 | end 30 | end 31 | -------------------------------------------------------------------------------- /compiled_starters/elixir/your_program.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Use this script to run your program LOCALLY. 4 | # 5 | # Note: Changing this script WILL NOT affect how CodeCrafters runs your program. 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | set -e # Exit early if any commands fail 10 | 11 | # Copied from .codecrafters/compile.sh 12 | # 13 | # - Edit this to change how your program compiles locally 14 | # - Edit .codecrafters/compile.sh to change how your program compiles remotely 15 | ( 16 | cd "$(dirname "$0")" # Ensure compile steps are run within the repository directory 17 | mix escript.build 18 | mv codecrafters_interpreter /tmp/codecrafters-build-interpreter-elixir 19 | ) 20 | 21 | # Copied from .codecrafters/run.sh 22 | # 23 | # - Edit this to change how your program runs locally 24 | # - Edit .codecrafters/run.sh to change how your program runs remotely 25 | exec /tmp/codecrafters-build-interpreter-elixir "$@" 26 | -------------------------------------------------------------------------------- /compiled_starters/gleam/.codecrafters/compile.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # This script is used to compile your program on CodeCrafters 4 | # 5 | # This runs before .codecrafters/run.sh 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | set -e # Exit on failure 10 | 11 | gleam build 12 | -------------------------------------------------------------------------------- /compiled_starters/gleam/.codecrafters/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # This script is used to run your program on CodeCrafters 4 | # 5 | # This runs after .codecrafters/compile.sh 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | set -e # Exit on failure 10 | 11 | exec gleam run --module main -- "$@" 12 | -------------------------------------------------------------------------------- /compiled_starters/gleam/.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | -------------------------------------------------------------------------------- /compiled_starters/gleam/.gitignore: -------------------------------------------------------------------------------- 1 | *.beam 2 | *.ez 3 | /build 4 | erl_crash.dump 5 | -------------------------------------------------------------------------------- /compiled_starters/gleam/codecrafters.yml: -------------------------------------------------------------------------------- 1 | # Set this to true if you want debug logs. 2 | # 3 | # These can be VERY verbose, so we suggest turning them off 4 | # unless you really need them. 5 | debug: false 6 | 7 | # Use this to change the Gleam version used to run your code 8 | # on Codecrafters. 9 | # 10 | # Available versions: gleam-1.9 11 | language_pack: gleam-1.9 12 | -------------------------------------------------------------------------------- /compiled_starters/gleam/gleam.toml: -------------------------------------------------------------------------------- 1 | name = "codecrafters_interpreter" 2 | version = "1.0.0" 3 | 4 | # For a full reference of all the available options, you can have a look at 5 | # https://gleam.run/writing-gleam/gleam-toml/. 6 | 7 | [dependencies] 8 | gleam_stdlib = "~> 0.34 or ~> 1.0" 9 | simplifile = ">= 2.0.1 and < 3.0.0" 10 | gleam_erlang = ">= 0.25.0 and < 1.0.0" 11 | argv = ">= 1.0.2 and < 2.0.0" 12 | 13 | [dev-dependencies] 14 | gleeunit = "~> 1.0" 15 | -------------------------------------------------------------------------------- /compiled_starters/gleam/your_program.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Use this script to run your program LOCALLY. 4 | # 5 | # Note: Changing this script WILL NOT affect how CodeCrafters runs your program. 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | set -e # Exit early if any commands fail 10 | 11 | # Copied from .codecrafters/compile.sh 12 | # 13 | # - Edit this to change how your program compiles locally 14 | # - Edit .codecrafters/compile.sh to change how your program compiles remotely 15 | ( 16 | cd "$(dirname "$0")" # Ensure compile steps are run within the repository directory 17 | gleam build 18 | ) 19 | 20 | # Copied from .codecrafters/run.sh 21 | # 22 | # - Edit this to change how your program runs locally 23 | # - Edit .codecrafters/run.sh to change how your program runs remotely 24 | exec gleam run --module main -- "$@" 25 | -------------------------------------------------------------------------------- /compiled_starters/go/.codecrafters/compile.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # This script is used to compile your program on CodeCrafters 4 | # 5 | # This runs before .codecrafters/run.sh 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | set -e # Exit on failure 10 | 11 | go build -o /tmp/codecrafters-build-interpreter-go app/*.go 12 | -------------------------------------------------------------------------------- /compiled_starters/go/.codecrafters/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # This script is used to run your program on CodeCrafters 4 | # 5 | # This runs after .codecrafters/compile.sh 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | set -e # Exit on failure 10 | 11 | exec /tmp/codecrafters-build-interpreter-go "$@" 12 | -------------------------------------------------------------------------------- /compiled_starters/go/.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | -------------------------------------------------------------------------------- /compiled_starters/go/codecrafters.yml: -------------------------------------------------------------------------------- 1 | # Set this to true if you want debug logs. 2 | # 3 | # These can be VERY verbose, so we suggest turning them off 4 | # unless you really need them. 5 | debug: false 6 | 7 | # Use this to change the Go version used to run your code 8 | # on Codecrafters. 9 | # 10 | # Available versions: go-1.24 11 | language_pack: go-1.24 12 | -------------------------------------------------------------------------------- /compiled_starters/go/go.mod: -------------------------------------------------------------------------------- 1 | 2 | module github.com/codecrafters-io/interpreter-starter-go 3 | 4 | go 1.24.0 5 | -------------------------------------------------------------------------------- /compiled_starters/go/go.sum: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codecrafters-io/build-your-own-interpreter/10de14d10190fdb9daa22963094d47e606ad5e66/compiled_starters/go/go.sum -------------------------------------------------------------------------------- /compiled_starters/go/your_program.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Use this script to run your program LOCALLY. 4 | # 5 | # Note: Changing this script WILL NOT affect how CodeCrafters runs your program. 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | set -e # Exit early if any commands fail 10 | 11 | # Copied from .codecrafters/compile.sh 12 | # 13 | # - Edit this to change how your program compiles locally 14 | # - Edit .codecrafters/compile.sh to change how your program compiles remotely 15 | ( 16 | cd "$(dirname "$0")" # Ensure compile steps are run within the repository directory 17 | go build -o /tmp/codecrafters-build-interpreter-go app/*.go 18 | ) 19 | 20 | # Copied from .codecrafters/run.sh 21 | # 22 | # - Edit this to change how your program runs locally 23 | # - Edit .codecrafters/run.sh to change how your program runs remotely 24 | exec /tmp/codecrafters-build-interpreter-go "$@" 25 | -------------------------------------------------------------------------------- /compiled_starters/java/.codecrafters/compile.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # This script is used to compile your program on CodeCrafters 4 | # 5 | # This runs before .codecrafters/run.sh 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | set -e # Exit on failure 10 | 11 | mvn -B package -Ddir=/tmp/codecrafters-build-interpreter-java 12 | -------------------------------------------------------------------------------- /compiled_starters/java/.codecrafters/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # This script is used to run your program on CodeCrafters 4 | # 5 | # This runs after .codecrafters/compile.sh 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | set -e # Exit on failure 10 | 11 | exec java -jar /tmp/codecrafters-build-interpreter-java/codecrafters-interpreter.jar "$@" 12 | -------------------------------------------------------------------------------- /compiled_starters/java/.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | -------------------------------------------------------------------------------- /compiled_starters/java/.gitignore: -------------------------------------------------------------------------------- 1 | *.jar 2 | target/ 3 | .idea/ 4 | -------------------------------------------------------------------------------- /compiled_starters/java/codecrafters.yml: -------------------------------------------------------------------------------- 1 | # Set this to true if you want debug logs. 2 | # 3 | # These can be VERY verbose, so we suggest turning them off 4 | # unless you really need them. 5 | debug: false 6 | 7 | # Use this to change the Java version used to run your code 8 | # on Codecrafters. 9 | # 10 | # Available versions: java-23 11 | language_pack: java-23 12 | -------------------------------------------------------------------------------- /compiled_starters/java/your_program.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Use this script to run your program LOCALLY. 4 | # 5 | # Note: Changing this script WILL NOT affect how CodeCrafters runs your program. 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | set -e # Exit early if any commands fail 10 | 11 | # Copied from .codecrafters/compile.sh 12 | # 13 | # - Edit this to change how your program compiles locally 14 | # - Edit .codecrafters/compile.sh to change how your program compiles remotely 15 | ( 16 | cd "$(dirname "$0")" # Ensure compile steps are run within the repository directory 17 | mvn -B package -Ddir=/tmp/codecrafters-build-interpreter-java 18 | ) 19 | 20 | # Copied from .codecrafters/run.sh 21 | # 22 | # - Edit this to change how your program runs locally 23 | # - Edit .codecrafters/run.sh to change how your program runs remotely 24 | exec java -jar /tmp/codecrafters-build-interpreter-java/codecrafters-interpreter.jar "$@" 25 | -------------------------------------------------------------------------------- /compiled_starters/javascript/.codecrafters/compile.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # This script is used to compile your program on CodeCrafters 4 | # 5 | # This runs before .codecrafters/run.sh 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | set -e # Exit on failure 10 | 11 | # (This file is empty since JavaScript programs don't use a compile step) 12 | -------------------------------------------------------------------------------- /compiled_starters/javascript/.codecrafters/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # This script is used to run your program on CodeCrafters 4 | # 5 | # This runs after .codecrafters/compile.sh 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | set -e # Exit on failure 10 | 11 | exec node app/main.js "$@" 12 | -------------------------------------------------------------------------------- /compiled_starters/javascript/.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | -------------------------------------------------------------------------------- /compiled_starters/javascript/.gitignore: -------------------------------------------------------------------------------- 1 | # Dependency directories 2 | node_modules/ -------------------------------------------------------------------------------- /compiled_starters/javascript/app/main.js: -------------------------------------------------------------------------------- 1 | import fs from "fs"; 2 | 3 | const args = process.argv.slice(2); // Skip the first two arguments (node path and script path) 4 | 5 | if (args.length < 2) { 6 | console.error("Usage: ./your_program.sh tokenize "); 7 | process.exit(1); 8 | } 9 | 10 | const command = args[0]; 11 | 12 | if (command !== "tokenize") { 13 | console.error(`Usage: Unknown command: ${command}`); 14 | process.exit(1); 15 | } 16 | 17 | // You can use print statements as follows for debugging, they'll be visible when running tests. 18 | console.error("Logs from your program will appear here!"); 19 | 20 | const filename = args[1]; 21 | 22 | // Uncomment this block to pass the first stage 23 | // 24 | // const fileContent = fs.readFileSync(filename, "utf8"); 25 | // 26 | // if (fileContent.length !== 0) { 27 | // throw new Error("Scanner not implemented"); 28 | // } else { 29 | // console.log("EOF null"); 30 | // } 31 | -------------------------------------------------------------------------------- /compiled_starters/javascript/codecrafters.yml: -------------------------------------------------------------------------------- 1 | # Set this to true if you want debug logs. 2 | # 3 | # These can be VERY verbose, so we suggest turning them off 4 | # unless you really need them. 5 | debug: false 6 | 7 | # Use this to change the JavaScript version used to run your code 8 | # on Codecrafters. 9 | # 10 | # Available versions: nodejs-21 11 | language_pack: nodejs-21 12 | -------------------------------------------------------------------------------- /compiled_starters/javascript/package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@codecrafters/interpreter", 3 | "version": "1.0.0", 4 | "lockfileVersion": 3, 5 | "requires": true, 6 | "packages": { 7 | "": { 8 | "name": "@codecrafters/interpreter", 9 | "version": "1.0.0" 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /compiled_starters/javascript/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@codecrafters/interpreter", 3 | "version": "1.0.0", 4 | "type": "module", 5 | "dependencies": {} 6 | } 7 | -------------------------------------------------------------------------------- /compiled_starters/javascript/your_program.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Use this script to run your program LOCALLY. 4 | # 5 | # Note: Changing this script WILL NOT affect how CodeCrafters runs your program. 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | set -e # Exit early if any commands fail 10 | 11 | # Copied from .codecrafters/run.sh 12 | # 13 | # - Edit this to change how your program runs locally 14 | # - Edit .codecrafters/run.sh to change how your program runs remotely 15 | exec node app/main.js "$@" 16 | -------------------------------------------------------------------------------- /compiled_starters/kotlin/.codecrafters/compile.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # This script is used to compile your program on CodeCrafters 4 | # 5 | # This runs before .codecrafters/run.sh 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | set -e # Exit on failure 10 | 11 | mvn -B package -Ddir=/tmp/codecrafters-build-dir 12 | -------------------------------------------------------------------------------- /compiled_starters/kotlin/.codecrafters/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # This script is used to run your program on CodeCrafters 4 | # 5 | # This runs after .codecrafters/compile.sh 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | set -e # Exit on failure 10 | 11 | exec java -jar /tmp/codecrafters-build-dir/build-your-own-interpreter.jar "$@" 12 | -------------------------------------------------------------------------------- /compiled_starters/kotlin/.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | -------------------------------------------------------------------------------- /compiled_starters/kotlin/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | .idea/ -------------------------------------------------------------------------------- /compiled_starters/kotlin/codecrafters.yml: -------------------------------------------------------------------------------- 1 | # Set this to true if you want debug logs. 2 | # 3 | # These can be VERY verbose, so we suggest turning them off 4 | # unless you really need them. 5 | debug: false 6 | 7 | # Use this to change the Kotlin version used to run your code 8 | # on Codecrafters. 9 | # 10 | # Available versions: kotlin-2.0 11 | language_pack: kotlin-2.0 12 | -------------------------------------------------------------------------------- /compiled_starters/kotlin/your_program.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Use this script to run your program LOCALLY. 4 | # 5 | # Note: Changing this script WILL NOT affect how CodeCrafters runs your program. 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | set -e # Exit early if any commands fail 10 | 11 | # Copied from .codecrafters/compile.sh 12 | # 13 | # - Edit this to change how your program compiles locally 14 | # - Edit .codecrafters/compile.sh to change how your program compiles remotely 15 | ( 16 | cd "$(dirname "$0")" # Ensure compile steps are run within the repository directory 17 | mvn -B package -Ddir=/tmp/codecrafters-build-dir 18 | ) 19 | 20 | # Copied from .codecrafters/run.sh 21 | # 22 | # - Edit this to change how your program runs locally 23 | # - Edit .codecrafters/run.sh to change how your program runs remotely 24 | exec java -jar /tmp/codecrafters-build-dir/build-your-own-interpreter.jar "$@" 25 | -------------------------------------------------------------------------------- /compiled_starters/ocaml/.codecrafters/compile.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # This script is used to compile your program on CodeCrafters 4 | # 5 | # This runs before .codecrafters/run.sh 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | set -e # Exit on failure 10 | 11 | dune build --build-dir /tmp/codecrafters-build-interpreter-ocaml 12 | -------------------------------------------------------------------------------- /compiled_starters/ocaml/.codecrafters/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # This script is used to run your program on CodeCrafters 4 | # 5 | # This runs after .codecrafters/compile.sh 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | set -e # Exit on failure 10 | 11 | exec /tmp/codecrafters-build-interpreter-ocaml/default/main.exe "$@" 12 | -------------------------------------------------------------------------------- /compiled_starters/ocaml/.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | -------------------------------------------------------------------------------- /compiled_starters/ocaml/.gitignore: -------------------------------------------------------------------------------- 1 | *.annot 2 | *.cmo 3 | *.cma 4 | *.cmi 5 | *.a 6 | *.o 7 | *.cmx 8 | *.cmxs 9 | *.cmxa 10 | 11 | # ocamlbuild working directory 12 | _build/ 13 | 14 | # ocamlbuild targets 15 | *.byte 16 | *.native 17 | 18 | # oasis generated files 19 | setup.data 20 | setup.log 21 | 22 | # Merlin configuring file for Vim and Emacs 23 | .merlin 24 | 25 | # Dune generated files 26 | *.install 27 | 28 | # Local OPAM switch 29 | _opam/ -------------------------------------------------------------------------------- /compiled_starters/ocaml/.ocamlformat: -------------------------------------------------------------------------------- 1 | profile = default -------------------------------------------------------------------------------- /compiled_starters/ocaml/codecrafters.yml: -------------------------------------------------------------------------------- 1 | # Set this to true if you want debug logs. 2 | # 3 | # These can be VERY verbose, so we suggest turning them off 4 | # unless you really need them. 5 | debug: false 6 | 7 | # Use this to change the OCaml version used to run your code 8 | # on Codecrafters. 9 | # 10 | # Available versions: ocaml-5.3 11 | language_pack: ocaml-5.3 12 | -------------------------------------------------------------------------------- /compiled_starters/ocaml/codecrafters_interpreter.opam: -------------------------------------------------------------------------------- 1 | # This file is generated by dune, edit dune-project instead 2 | opam-version: "2.0" 3 | version: "0.1" 4 | synopsis: "Starter code for the Build your own Interpreter challenge" 5 | maintainer: ["CodeCrafters "] 6 | authors: ["CodeCrafters "] 7 | license: "MIT" 8 | homepage: "https://codecrafters.io" 9 | bug-reports: 10 | "https://github.com/codecrafters-io/build-your-own-interpreter/issues" 11 | depends: [ 12 | "dune" {>= "3.16"} 13 | "lwt" 14 | "odoc" {with-doc} 15 | ] 16 | build: [ 17 | ["dune" "subst"] {dev} 18 | [ 19 | "dune" 20 | "build" 21 | "-p" 22 | name 23 | "-j" 24 | jobs 25 | "@install" 26 | "@runtest" {with-test} 27 | "@doc" {with-doc} 28 | ] 29 | ] 30 | -------------------------------------------------------------------------------- /compiled_starters/ocaml/dune: -------------------------------------------------------------------------------- 1 | (include_subdirs unqualified) 2 | 3 | (executable 4 | (name main) 5 | (libraries lwt)) 6 | -------------------------------------------------------------------------------- /compiled_starters/ocaml/dune-project: -------------------------------------------------------------------------------- 1 | (lang dune 3.16) 2 | 3 | (name codecrafters_interpreter) 4 | 5 | (generate_opam_files true) 6 | 7 | (package 8 | (name codecrafters_interpreter) 9 | (maintainers "CodeCrafters ") 10 | (authors "CodeCrafters ") 11 | (synopsis "Starter code for the Build your own Interpreter challenge") 12 | (homepage "https://codecrafters.io") 13 | (bug_reports 14 | "https://github.com/codecrafters-io/build-your-own-interpreter/issues") 15 | (license "MIT") 16 | (allow_empty true) 17 | (version 0.1) 18 | (depends lwt)) 19 | -------------------------------------------------------------------------------- /compiled_starters/ocaml/src/main.ml: -------------------------------------------------------------------------------- 1 | let () = 2 | if Array.length Sys.argv < 3 then ( 3 | Printf.eprintf "Usage: ./your_program.sh tokenize \n"; 4 | exit 1); 5 | 6 | let command = Sys.argv.(1) in 7 | let filename = Sys.argv.(2) in 8 | 9 | if command <> "tokenize" then ( 10 | Printf.eprintf "Unknown command: %s\n" command; 11 | exit 1); 12 | 13 | let file_contents = In_channel.with_open_text filename In_channel.input_all in 14 | 15 | (* You can use print statements as follows for debugging, they'll be visible when running tests. *) 16 | Printf.eprintf "Logs from your program will appear here!\n"; 17 | 18 | if String.length file_contents > 0 then 19 | (* Implement & use your scanner here *) 20 | failwith "Scanner not implemented" 21 | else 22 | (* Uncomment this block to pass the first stage *) 23 | (* print_endline "EOF null"; (* Placeholder, replace this line when implementing the scanner *) *) 24 | () 25 | -------------------------------------------------------------------------------- /compiled_starters/ocaml/your_program.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Use this script to run your program LOCALLY. 4 | # 5 | # Note: Changing this script WILL NOT affect how CodeCrafters runs your program. 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | set -e # Exit early if any commands fail 10 | 11 | # Copied from .codecrafters/compile.sh 12 | # 13 | # - Edit this to change how your program compiles locally 14 | # - Edit .codecrafters/compile.sh to change how your program compiles remotely 15 | ( 16 | cd "$(dirname "$0")" # Ensure compile steps are run within the repository directory 17 | dune build --build-dir /tmp/codecrafters-build-interpreter-ocaml 18 | ) 19 | 20 | # Copied from .codecrafters/run.sh 21 | # 22 | # - Edit this to change how your program runs locally 23 | # - Edit .codecrafters/run.sh to change how your program runs remotely 24 | exec /tmp/codecrafters-build-interpreter-ocaml/default/main.exe "$@" 25 | -------------------------------------------------------------------------------- /compiled_starters/odin/.codecrafters/compile.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # This script is used to compile your program on CodeCrafters 4 | # 5 | # This runs before .codecrafters/run.sh 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | set -e # Exit on failure 10 | 11 | mkdir -p /tmp/codecrafters-build-interpreter-odin 12 | odin build src -out:/tmp/codecrafters-build-interpreter-odin/main -------------------------------------------------------------------------------- /compiled_starters/odin/.codecrafters/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # This script is used to run your program on CodeCrafters 4 | # 5 | # This runs after .codecrafters/compile.sh 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | set -e # Exit on failure 10 | 11 | exec /tmp/codecrafters-build-interpreter-odin/main "$@" 12 | -------------------------------------------------------------------------------- /compiled_starters/odin/.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | -------------------------------------------------------------------------------- /compiled_starters/odin/codecrafters.yml: -------------------------------------------------------------------------------- 1 | # Set this to true if you want debug logs. 2 | # 3 | # These can be VERY verbose, so we suggest turning them off 4 | # unless you really need them. 5 | debug: false 6 | 7 | # Use this to change the Odin version used to run your code 8 | # on Codecrafters. 9 | # 10 | # Available versions: odin-2025.4 11 | language_pack: odin-2025.4 12 | -------------------------------------------------------------------------------- /compiled_starters/odin/your_program.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Use this script to run your program LOCALLY. 4 | # 5 | # Note: Changing this script WILL NOT affect how CodeCrafters runs your program. 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | set -e # Exit early if any commands fail 10 | 11 | # Copied from .codecrafters/compile.sh 12 | # 13 | # - Edit this to change how your program compiles locally 14 | # - Edit .codecrafters/compile.sh to change how your program compiles remotely 15 | ( 16 | cd "$(dirname "$0")" # Ensure compile steps are run within the repository directory 17 | mkdir -p /tmp/codecrafters-build-interpreter-odin 18 | odin build src -out:/tmp/codecrafters-build-interpreter-odin/main 19 | ) 20 | 21 | # Copied from .codecrafters/run.sh 22 | # 23 | # - Edit this to change how your program runs locally 24 | # - Edit .codecrafters/run.sh to change how your program runs remotely 25 | exec /tmp/codecrafters-build-interpreter-odin/main "$@" 26 | -------------------------------------------------------------------------------- /compiled_starters/php/.codecrafters/compile.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # This script is used to compile your program on CodeCrafters 4 | # 5 | # This runs before .codecrafters/run.sh 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | set -e # Exit on failure 10 | 11 | # (This file is empty since PHP programs don't use a compile step) -------------------------------------------------------------------------------- /compiled_starters/php/.codecrafters/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # This script is used to run your program on CodeCrafters 4 | # 5 | # This runs after .codecrafters/compile.sh 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | set -e # Exit on failure 10 | 11 | exec php app/main.php "$@" 12 | -------------------------------------------------------------------------------- /compiled_starters/php/.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | -------------------------------------------------------------------------------- /compiled_starters/php/app/main.php: -------------------------------------------------------------------------------- 1 | \n"); 6 | exit(1); 7 | } 8 | 9 | $command = $argv[1]; 10 | $filename = $argv[2]; 11 | 12 | if ($command !== "tokenize") { 13 | fwrite(STDERR, "Unknown command: {$command}\n"); 14 | exit(1); 15 | } 16 | 17 | $file_contents = file_get_contents($filename); 18 | 19 | // You can use print statements as follows for debugging, they'll be visible when running tests. 20 | fwrite(STDERR, "Logs from your program will appear here!\n"); 21 | 22 | // Uncomment this block to pass the first stage 23 | // if ($file_contents) { 24 | // throw new Exception("Scanner not implemented"); 25 | // } else { 26 | // echo "EOF null\n"; // Placeholder, replace this line when implementing the scanner 27 | // } 28 | -------------------------------------------------------------------------------- /compiled_starters/php/codecrafters.yml: -------------------------------------------------------------------------------- 1 | # Set this to true if you want debug logs. 2 | # 3 | # These can be VERY verbose, so we suggest turning them off 4 | # unless you really need them. 5 | debug: false 6 | 7 | # Use this to change the PHP version used to run your code 8 | # on Codecrafters. 9 | # 10 | # Available versions: php-8.4 11 | language_pack: php-8.4 12 | -------------------------------------------------------------------------------- /compiled_starters/php/your_program.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Use this script to run your program LOCALLY. 4 | # 5 | # Note: Changing this script WILL NOT affect how CodeCrafters runs your program. 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | set -e # Exit early if any commands fail 10 | 11 | # Copied from .codecrafters/run.sh 12 | # 13 | # - Edit this to change how your program runs locally 14 | # - Edit .codecrafters/run.sh to change how your program runs remotely 15 | exec php app/main.php "$@" 16 | -------------------------------------------------------------------------------- /compiled_starters/python/.codecrafters/compile.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # This script is used to compile your program on CodeCrafters 4 | # 5 | # This runs before .codecrafters/run.sh 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | # (This file is empty since Python programs don't use a compile step) 10 | -------------------------------------------------------------------------------- /compiled_starters/python/.codecrafters/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # This script is used to run your program on CodeCrafters 4 | # 5 | # This runs after .codecrafters/compile.sh 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | exec pipenv run python3 -m app.main "$@" 10 | -------------------------------------------------------------------------------- /compiled_starters/python/.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | -------------------------------------------------------------------------------- /compiled_starters/python/Pipfile: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | 4 | [[source]] 5 | url = "https://pypi.org/simple" 6 | verify_ssl = true 7 | name = "pypi" 8 | 9 | [packages] 10 | 11 | [dev-packages] 12 | 13 | [requires] 14 | python_version = "3" 15 | -------------------------------------------------------------------------------- /compiled_starters/python/Pipfile.lock: -------------------------------------------------------------------------------- 1 | { 2 | "_meta": { 3 | "hash": { 4 | "sha256": "4e61a4ba9e6f02f50f68627253af5ababd9b1b4c1e10294e48158e1f42c0c5a6" 5 | }, 6 | "pipfile-spec": 6, 7 | "requires": { 8 | "python_version": "3" 9 | }, 10 | "sources": [ 11 | { 12 | "name": "pypi", 13 | "url": "https://pypi.org/simple", 14 | "verify_ssl": true 15 | } 16 | ] 17 | }, 18 | "default": {}, 19 | "develop": {} 20 | } 21 | -------------------------------------------------------------------------------- /compiled_starters/python/app/main.py: -------------------------------------------------------------------------------- 1 | import sys 2 | 3 | 4 | def main(): 5 | if len(sys.argv) < 3: 6 | print("Usage: ./your_program.sh tokenize ", file=sys.stderr) 7 | exit(1) 8 | 9 | command = sys.argv[1] 10 | filename = sys.argv[2] 11 | 12 | if command != "tokenize": 13 | print(f"Unknown command: {command}", file=sys.stderr) 14 | exit(1) 15 | 16 | with open(filename) as file: 17 | file_contents = file.read() 18 | 19 | # You can use print statements as follows for debugging, they'll be visible when running tests. 20 | print("Logs from your program will appear here!", file=sys.stderr) 21 | 22 | # Uncomment this block to pass the first stage 23 | # if file_contents: 24 | # raise NotImplementedError("Scanner not implemented") 25 | # else: 26 | # print("EOF null") # Placeholder, replace this line when implementing the scanner 27 | 28 | 29 | if __name__ == "__main__": 30 | main() 31 | -------------------------------------------------------------------------------- /compiled_starters/python/codecrafters.yml: -------------------------------------------------------------------------------- 1 | # Set this to true if you want debug logs. 2 | # 3 | # These can be VERY verbose, so we suggest turning them off 4 | # unless you really need them. 5 | debug: false 6 | 7 | # Use this to change the Python version used to run your code 8 | # on Codecrafters. 9 | # 10 | # Available versions: python-3.13 11 | language_pack: python-3.13 12 | -------------------------------------------------------------------------------- /compiled_starters/python/your_program.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Use this script to run your program LOCALLY. 4 | # 5 | # Note: Changing this script WILL NOT affect how CodeCrafters runs your program. 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | set -e # Exit early if any commands fail 10 | 11 | # Copied from .codecrafters/run.sh 12 | # 13 | # - Edit this to change how your program runs locally 14 | # - Edit .codecrafters/run.sh to change how your program runs remotely 15 | exec pipenv run python3 -m app.main "$@" 16 | -------------------------------------------------------------------------------- /compiled_starters/rust/.codecrafters/compile.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # This script is used to compile your program on CodeCrafters 4 | # 5 | # This runs before .codecrafters/run.sh 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | set -e # Exit on failure 10 | 11 | cargo build --release --target-dir=/tmp/codecrafters-build-interpreter-rust --manifest-path Cargo.toml 12 | -------------------------------------------------------------------------------- /compiled_starters/rust/.codecrafters/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # This script is used to run your program on CodeCrafters 4 | # 5 | # This runs after .codecrafters/compile.sh 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | set -e # Exit on failure 10 | 11 | exec /tmp/codecrafters-build-interpreter-rust/release/codecrafters-interpreter "$@" 12 | -------------------------------------------------------------------------------- /compiled_starters/rust/.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | -------------------------------------------------------------------------------- /compiled_starters/rust/.gitignore: -------------------------------------------------------------------------------- 1 | # Generated by Cargo 2 | # will have compiled files and executables 3 | debug/ 4 | target/ 5 | 6 | # These are backup files generated by rustfmt 7 | **/*.rs.bk 8 | 9 | # MSVC Windows builds of rustc generate these, which store debugging information 10 | *.pdb 11 | -------------------------------------------------------------------------------- /compiled_starters/rust/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "codecrafters-interpreter" 3 | version = "0.1.0" 4 | authors = ["Codecrafters "] 5 | edition = "2021" 6 | rust-version = "1.80" 7 | 8 | [dependencies] 9 | anyhow = "1.0.68" # error handling 10 | bytes = "1.3.0" # helps manage buffers 11 | thiserror = "1.0.38" # error handling 12 | -------------------------------------------------------------------------------- /compiled_starters/rust/codecrafters.yml: -------------------------------------------------------------------------------- 1 | # Set this to true if you want debug logs. 2 | # 3 | # These can be VERY verbose, so we suggest turning them off 4 | # unless you really need them. 5 | debug: false 6 | 7 | # Use this to change the Rust version used to run your code 8 | # on Codecrafters. 9 | # 10 | # Available versions: rust-1.86 11 | language_pack: rust-1.86 12 | -------------------------------------------------------------------------------- /compiled_starters/rust/your_program.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Use this script to run your program LOCALLY. 4 | # 5 | # Note: Changing this script WILL NOT affect how CodeCrafters runs your program. 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | set -e # Exit early if any commands fail 10 | 11 | # Copied from .codecrafters/compile.sh 12 | # 13 | # - Edit this to change how your program compiles locally 14 | # - Edit .codecrafters/compile.sh to change how your program compiles remotely 15 | ( 16 | cd "$(dirname "$0")" # Ensure compile steps are run within the repository directory 17 | cargo build --release --target-dir=/tmp/codecrafters-build-interpreter-rust --manifest-path Cargo.toml 18 | ) 19 | 20 | # Copied from .codecrafters/run.sh 21 | # 22 | # - Edit this to change how your program runs locally 23 | # - Edit .codecrafters/run.sh to change how your program runs remotely 24 | exec /tmp/codecrafters-build-interpreter-rust/release/codecrafters-interpreter "$@" 25 | -------------------------------------------------------------------------------- /compiled_starters/swift/.codecrafters/compile.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # This script is used to compile your program on CodeCrafters 4 | # 5 | # This runs before .codecrafters/run.sh 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | set -e # Exit on failure 10 | 11 | swift build -c release --build-path /tmp/codecrafters-build-interpreter-swift 12 | -------------------------------------------------------------------------------- /compiled_starters/swift/.codecrafters/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # This script is used to run your program on CodeCrafters 4 | # 5 | # This runs after .codecrafters/compile.sh 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | set -e # Exit on failure 10 | 11 | exec swift run -c release --skip-build --build-path /tmp/codecrafters-build-interpreter-swift build-your-own-interpreter "$@" 12 | -------------------------------------------------------------------------------- /compiled_starters/swift/.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | -------------------------------------------------------------------------------- /compiled_starters/swift/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .build 3 | Packages 4 | xcuserdata/ 5 | DerivedData/ 6 | .swiftpm/configuration/registries.json 7 | .swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata 8 | .netrc -------------------------------------------------------------------------------- /compiled_starters/swift/Package.swift: -------------------------------------------------------------------------------- 1 | // swift-tools-version: 6.0 2 | // The swift-tools-version declares the minimum version of Swift required to build this package. 3 | 4 | import PackageDescription 5 | 6 | let package = Package( 7 | name: "build-your-own-interpreter", 8 | targets: [ 9 | // Targets are the basic building blocks of a package, defining a module or a test suite. 10 | // Targets can depend on other targets in this package and products from dependencies. 11 | .executableTarget( 12 | name: "build-your-own-interpreter"), 13 | ] 14 | ) -------------------------------------------------------------------------------- /compiled_starters/swift/Sources/main.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | // You can use print statements as follows for debugging, they'll be visible when running tests. 4 | print("Logs from your program will appear here!") 5 | 6 | guard CommandLine.argc == 3 else { 7 | print("Usage: ./your_program.sh tokenize ") 8 | exit(1) 9 | } 10 | 11 | let command = CommandLine.arguments[1] 12 | let filename = CommandLine.arguments[2] 13 | 14 | guard command == "tokenize" else { 15 | print("Unknown command: \(command)") 16 | exit(1) 17 | } 18 | 19 | let fileContents: String 20 | do { 21 | fileContents = try String(contentsOfFile: filename, encoding: .utf8) 22 | } catch { 23 | print("Error reading file: \(filename) with error: \(error.localizedDescription)") 24 | exit(1) 25 | } 26 | 27 | // Uncomment this block to pass the first stage 28 | // if fileContents.isEmpty { 29 | // print("EOF null") 30 | // } else { 31 | // print("Scanner not implemented") 32 | // exit(1) 33 | // } 34 | -------------------------------------------------------------------------------- /compiled_starters/swift/codecrafters.yml: -------------------------------------------------------------------------------- 1 | # Set this to true if you want debug logs. 2 | # 3 | # These can be VERY verbose, so we suggest turning them off 4 | # unless you really need them. 5 | debug: false 6 | 7 | # Use this to change the Swift version used to run your code 8 | # on Codecrafters. 9 | # 10 | # Available versions: swift-6.0 11 | language_pack: swift-6.0 12 | -------------------------------------------------------------------------------- /compiled_starters/swift/your_program.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Use this script to run your program LOCALLY. 4 | # 5 | # Note: Changing this script WILL NOT affect how CodeCrafters runs your program. 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | set -e # Exit early if any commands fail 10 | 11 | # Copied from .codecrafters/compile.sh 12 | # 13 | # - Edit this to change how your program compiles locally 14 | # - Edit .codecrafters/compile.sh to change how your program compiles remotely 15 | ( 16 | cd "$(dirname "$0")" # Ensure compile steps are run within the repository directory 17 | swift build -c release --build-path /tmp/codecrafters-build-interpreter-swift 18 | ) 19 | 20 | # Copied from .codecrafters/run.sh 21 | # 22 | # - Edit this to change how your program runs locally 23 | # - Edit .codecrafters/run.sh to change how your program runs remotely 24 | exec swift run -c release --skip-build --build-path /tmp/codecrafters-build-interpreter-swift build-your-own-interpreter "$@" 25 | -------------------------------------------------------------------------------- /compiled_starters/typescript/.codecrafters/compile.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # This script is used to compile your program on CodeCrafters 4 | # 5 | # This runs before .codecrafters/run.sh 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | set -e # Exit on failure 10 | 11 | # (This file is empty since TypeScript programs don't use a compile step) 12 | -------------------------------------------------------------------------------- /compiled_starters/typescript/.codecrafters/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # This script is used to run your program on CodeCrafters 4 | # 5 | # This runs after .codecrafters/compile.sh 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | set -e # Exit on failure 10 | 11 | exec bun run "$(dirname "$0")/app/main.ts" "$@" 12 | -------------------------------------------------------------------------------- /compiled_starters/typescript/.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | -------------------------------------------------------------------------------- /compiled_starters/typescript/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | -------------------------------------------------------------------------------- /compiled_starters/typescript/app/main.ts: -------------------------------------------------------------------------------- 1 | import fs from "fs"; 2 | 3 | const args: string[] = process.argv.slice(2); // Skip the first two arguments (node path and script path) 4 | 5 | if (args.length < 2) { 6 | console.error("Usage: ./your_program.sh tokenize "); 7 | process.exit(1); 8 | } 9 | 10 | const command: string = args[0]; 11 | 12 | if (command !== "tokenize") { 13 | console.error(`Usage: Unknown command: ${command}`); 14 | process.exit(1); 15 | } 16 | 17 | // You can use print statements as follows for debugging, they'll be visible when running tests. 18 | console.error("Logs from your program will appear here!"); 19 | 20 | const filename: string = args[1]; 21 | 22 | // Uncomment this block to pass the first stage 23 | // 24 | // const fileContent: string = fs.readFileSync(filename, "utf8"); 25 | // 26 | // if (fileContent.length !== 0) { 27 | // throw new Error("Scanner not implemented"); 28 | // } else { 29 | // console.log("EOF null"); 30 | // } 31 | -------------------------------------------------------------------------------- /compiled_starters/typescript/codecrafters.yml: -------------------------------------------------------------------------------- 1 | # Set this to true if you want debug logs. 2 | # 3 | # These can be VERY verbose, so we suggest turning them off 4 | # unless you really need them. 5 | debug: false 6 | 7 | # Use this to change the TypeScript version used to run your code 8 | # on Codecrafters. 9 | # 10 | # Available versions: bun-1.2 11 | language_pack: bun-1.2 12 | -------------------------------------------------------------------------------- /compiled_starters/typescript/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@codecrafters/interpreter", 3 | "description": "Build your own Interpreter challenge, from CodeCrafters", 4 | "type": "module", 5 | "scripts": { 6 | "dev": "bun run app/main.ts" 7 | }, 8 | "devDependencies": { 9 | "@types/bun": "latest" 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /compiled_starters/typescript/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | // Enable latest features 4 | "lib": ["ESNext", "DOM"], 5 | "target": "ESNext", 6 | "module": "ESNext", 7 | "moduleDetection": "force", 8 | "jsx": "react-jsx", 9 | "allowJs": true, 10 | 11 | // Bundler mode 12 | "moduleResolution": "bundler", 13 | "allowImportingTsExtensions": true, 14 | "verbatimModuleSyntax": true, 15 | "noEmit": true, 16 | 17 | // Best practices 18 | "strict": true, 19 | "skipLibCheck": true, 20 | "noFallthroughCasesInSwitch": true, 21 | 22 | // Some stricter flags (disabled by default) 23 | "noUnusedLocals": false, 24 | "noUnusedParameters": false, 25 | "noPropertyAccessFromIndexSignature": false 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /compiled_starters/typescript/your_program.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Use this script to run your program LOCALLY. 4 | # 5 | # Note: Changing this script WILL NOT affect how CodeCrafters runs your program. 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | set -e # Exit early if any commands fail 10 | 11 | # Copied from .codecrafters/run.sh 12 | # 13 | # - Edit this to change how your program runs locally 14 | # - Edit .codecrafters/run.sh to change how your program runs remotely 15 | exec bun run "$(dirname "$0")/app/main.ts" "$@" 16 | -------------------------------------------------------------------------------- /compiled_starters/zig/.codecrafters/compile.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # This script is used to compile your program on CodeCrafters 4 | # 5 | # This runs before .codecrafters/run.sh 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | set -e # Exit on failure 10 | 11 | zig build 12 | -------------------------------------------------------------------------------- /compiled_starters/zig/.codecrafters/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # This script is used to run your program on CodeCrafters 4 | # 5 | # This runs after .codecrafters/compile.sh 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | set -e # Exit on failure 10 | 11 | exec $(dirname $0)/zig-out/bin/main "$@" 12 | -------------------------------------------------------------------------------- /compiled_starters/zig/.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | -------------------------------------------------------------------------------- /compiled_starters/zig/.gitignore: -------------------------------------------------------------------------------- 1 | # Zig build artifacts 2 | main 3 | zig-cache/ 4 | .zig-cache/ 5 | zig-out/ 6 | 7 | # Compiled binary output 8 | bin/ 9 | !bin/.gitkeep 10 | 11 | # Ignore any .o or .h files generated during build 12 | *.o 13 | *.h 14 | 15 | # Ignore OS and editor specific files 16 | **/.DS_Store 17 | *.swp 18 | *~ 19 | -------------------------------------------------------------------------------- /compiled_starters/zig/codecrafters.yml: -------------------------------------------------------------------------------- 1 | # Set this to true if you want debug logs. 2 | # 3 | # These can be VERY verbose, so we suggest turning them off 4 | # unless you really need them. 5 | debug: false 6 | 7 | # Use this to change the Zig version used to run your code 8 | # on Codecrafters. 9 | # 10 | # Available versions: zig-0.14 11 | language_pack: zig-0.14 12 | -------------------------------------------------------------------------------- /compiled_starters/zig/your_program.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Use this script to run your program LOCALLY. 4 | # 5 | # Note: Changing this script WILL NOT affect how CodeCrafters runs your program. 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | set -e # Exit early if any commands fail 10 | 11 | # Copied from .codecrafters/compile.sh 12 | # 13 | # - Edit this to change how your program compiles locally 14 | # - Edit .codecrafters/compile.sh to change how your program compiles remotely 15 | ( 16 | cd "$(dirname "$0")" # Ensure compile steps are run within the repository directory 17 | zig build 18 | ) 19 | 20 | # Copied from .codecrafters/run.sh 21 | # 22 | # - Edit this to change how your program runs locally 23 | # - Edit .codecrafters/run.sh to change how your program runs remotely 24 | exec $(dirname $0)/zig-out/bin/main "$@" 25 | -------------------------------------------------------------------------------- /dockerfiles/bun-1.1.Dockerfile: -------------------------------------------------------------------------------- 1 | # syntax=docker/dockerfile:1.7-labs 2 | FROM oven/bun:1.1-alpine 3 | 4 | ENV CODECRAFTERS_DEPENDENCY_FILE_PATHS="package.json,bun.lockb" 5 | 6 | WORKDIR /app 7 | 8 | # .git & README.md are unique per-repository. We ignore them on first copy to prevent cache misses 9 | COPY --exclude=.git --exclude=README.md . /app 10 | 11 | # For reproducible builds. 12 | # This will install the exact versions of each package specified in the lockfile. 13 | # If package.json disagrees with bun.lockb, Bun will exit with an error. The lockfile will not be updated. 14 | RUN bun install --frozen-lockfile 15 | 16 | # If the node_modules directory exists, move it to /app-cached 17 | RUN mkdir -p /app-cached 18 | RUN if [ -d "/app/node_modules" ]; then mv /app/node_modules /app-cached; fi 19 | -------------------------------------------------------------------------------- /dockerfiles/bun-1.2.Dockerfile: -------------------------------------------------------------------------------- 1 | # syntax=docker/dockerfile:1.7-labs 2 | FROM oven/bun:1.2-alpine 3 | 4 | ENV CODECRAFTERS_DEPENDENCY_FILE_PATHS="package.json,bun.lockb" 5 | 6 | WORKDIR /app 7 | 8 | # .git & README.md are unique per-repository. We ignore them on first copy to prevent cache misses 9 | COPY --exclude=.git --exclude=README.md . /app 10 | 11 | # For reproducible builds. 12 | # This will install the exact versions of each package specified in the lockfile. 13 | # If package.json disagrees with bun.lockb, Bun will exit with an error. The lockfile will not be updated. 14 | RUN bun install --frozen-lockfile 15 | 16 | # If the node_modules directory exists, move it to /app-cached 17 | RUN mkdir -p /app-cached 18 | RUN if [ -d "/app/node_modules" ]; then mv /app/node_modules /app-cached; fi 19 | -------------------------------------------------------------------------------- /dockerfiles/dotnet-8.0.Dockerfile: -------------------------------------------------------------------------------- 1 | # syntax=docker/dockerfile:1.7-labs 2 | FROM mcr.microsoft.com/dotnet/sdk:8.0-alpine 3 | 4 | WORKDIR /app 5 | 6 | # .git & README.md are unique per-repository. We ignore them on first copy to prevent cache misses 7 | COPY --exclude=.git --exclude=README.md . /app 8 | 9 | # This saves nuget packages to ~/.nuget 10 | RUN dotnet build --configuration Release . 11 | 12 | # This seems to cause a caching issue with the dotnet build command, where old contents are used 13 | # https://github.com/codecrafters-io/build-your-own-redis/pull/203 14 | # TODO: See if this needs to be brought back? 15 | # RUN rm -rf /app/obj 16 | # RUN rm -rf /app/bin 17 | 18 | RUN echo "cd \${CODECRAFTERS_REPOSITORY_DIR} && dotnet build --configuration Release ." > /codecrafters-precompile.sh 19 | RUN chmod +x /codecrafters-precompile.sh 20 | 21 | ENV CODECRAFTERS_DEPENDENCY_FILE_PATHS="codecrafters-interpreter.csproj,codecrafters-interpreter.sln" 22 | -------------------------------------------------------------------------------- /dockerfiles/dotnet-9.0.Dockerfile: -------------------------------------------------------------------------------- 1 | # syntax=docker/dockerfile:1.7-labs 2 | FROM mcr.microsoft.com/dotnet/sdk:9.0-alpine 3 | 4 | WORKDIR /app 5 | 6 | # .git & README.md are unique per-repository. We ignore them on first copy to prevent cache misses 7 | COPY --exclude=.git --exclude=README.md . /app 8 | 9 | # This saves nuget packages to ~/.nuget 10 | RUN dotnet build --configuration Release . 11 | 12 | # This seems to cause a caching issue with the dotnet build command, where old contents are used 13 | # https://github.com/codecrafters-io/build-your-own-redis/pull/203 14 | # TODO: See if this needs to be brought back? 15 | # RUN rm -rf /app/obj 16 | # RUN rm -rf /app/bin 17 | 18 | RUN echo "cd \${CODECRAFTERS_REPOSITORY_DIR} && dotnet build --configuration Release ." > /codecrafters-precompile.sh 19 | RUN chmod +x /codecrafters-precompile.sh 20 | 21 | ENV CODECRAFTERS_DEPENDENCY_FILE_PATHS="codecrafters-interpreter.csproj,codecrafters-interpreter.sln" 22 | -------------------------------------------------------------------------------- /dockerfiles/elixir-1.17.Dockerfile: -------------------------------------------------------------------------------- 1 | # syntax=docker/dockerfile:1.7-labs 2 | FROM elixir:1.17.2-alpine 3 | 4 | # Ensures the container is re-built if dependency files change 5 | ENV CODECRAFTERS_DEPENDENCY_FILE_PATHS="mix.exs" 6 | 7 | WORKDIR /app 8 | 9 | # .git & README.md are unique per-repository. We ignore them on first copy to prevent cache misses 10 | COPY --exclude=.git --exclude=README.md . /app 11 | 12 | # install hex + rebar 13 | RUN mix local.hex --force && \ 14 | mix local.rebar --force 15 | 16 | # install and compile mix dependencies 17 | RUN mix deps.get && \ 18 | mix deps.compile 19 | 20 | # Install & cache deps 21 | RUN .codecrafters/compile.sh 22 | 23 | RUN mkdir -p /app-cached 24 | RUN if [ -d "/app/_build" ]; then mv /app/_build /app-cached; fi 25 | RUN if [ -d "/app/deps" ]; then mv /app/deps /app-cached; fi 26 | -------------------------------------------------------------------------------- /dockerfiles/elixir-1.18.Dockerfile: -------------------------------------------------------------------------------- 1 | # syntax=docker/dockerfile:1.7-labs 2 | FROM elixir:1.18.3-alpine 3 | 4 | # Ensures the container is re-built if dependency files change 5 | ENV CODECRAFTERS_DEPENDENCY_FILE_PATHS="mix.exs" 6 | 7 | WORKDIR /app 8 | 9 | # .git & README.md are unique per-repository. We ignore them on first copy to prevent cache misses 10 | COPY --exclude=.git --exclude=README.md . /app 11 | 12 | # install hex + rebar 13 | RUN mix local.hex --force && \ 14 | mix local.rebar --force 15 | 16 | # install and compile mix dependencies 17 | RUN mix deps.get && \ 18 | mix deps.compile 19 | 20 | # Install & cache deps 21 | RUN .codecrafters/compile.sh 22 | 23 | RUN mkdir -p /app-cached 24 | RUN if [ -d "/app/_build" ]; then mv /app/_build /app-cached; fi 25 | RUN if [ -d "/app/deps" ]; then mv /app/deps /app-cached; fi 26 | -------------------------------------------------------------------------------- /dockerfiles/gleam-1.4.Dockerfile: -------------------------------------------------------------------------------- 1 | # syntax=docker/dockerfile:1.7-labs 2 | FROM ghcr.io/gleam-lang/gleam:v1.4.1-erlang-alpine 3 | 4 | # Rebuild if gleam.toml or manifest.toml change 5 | ENV CODECRAFTERS_DEPENDENCY_FILE_PATHS="gleam.toml,manifest.toml" 6 | 7 | WORKDIR /app 8 | 9 | # .git & README.md are unique per-repository. We ignore them on first copy to prevent cache misses 10 | COPY --exclude=.git --exclude=README.md . /app 11 | 12 | # Force deps to be downloaded 13 | RUN gleam build 14 | 15 | # Cache build directory 16 | RUN mkdir -p /app-cached 17 | RUN mv build /app-cached/build 18 | -------------------------------------------------------------------------------- /dockerfiles/gleam-1.6.Dockerfile: -------------------------------------------------------------------------------- 1 | # syntax=docker/dockerfile:1.7-labs 2 | FROM ghcr.io/gleam-lang/gleam:v1.6.3-erlang-alpine 3 | 4 | # Rebuild if gleam.toml or manifest.toml change 5 | ENV CODECRAFTERS_DEPENDENCY_FILE_PATHS="gleam.toml,manifest.toml" 6 | 7 | WORKDIR /app 8 | 9 | # .git & README.md are unique per-repository. We ignore them on first copy to prevent cache misses 10 | COPY --exclude=.git --exclude=README.md . /app 11 | 12 | # Force deps to be downloaded 13 | RUN gleam build 14 | 15 | # Cache build directory 16 | RUN mkdir -p /app-cached 17 | RUN mv build /app-cached/build 18 | -------------------------------------------------------------------------------- /dockerfiles/gleam-1.9.Dockerfile: -------------------------------------------------------------------------------- 1 | # syntax=docker/dockerfile:1.7-labs 2 | FROM ghcr.io/gleam-lang/gleam:v1.9.1-erlang-alpine 3 | 4 | # Rebuild if gleam.toml or manifest.toml change 5 | ENV CODECRAFTERS_DEPENDENCY_FILE_PATHS="gleam.toml,manifest.toml" 6 | 7 | WORKDIR /app 8 | 9 | # .git & README.md are unique per-repository. We ignore them on first copy to prevent cache misses 10 | COPY --exclude=.git --exclude=README.md . /app 11 | 12 | # Force deps to be downloaded 13 | RUN gleam build 14 | 15 | # Cache build directory 16 | RUN mkdir -p /app-cached 17 | RUN mv build /app-cached/build 18 | -------------------------------------------------------------------------------- /dockerfiles/go-1.22.Dockerfile: -------------------------------------------------------------------------------- 1 | # syntax=docker/dockerfile:1.7-labs 2 | FROM golang:1.22-alpine 3 | 4 | # Ensures the container is re-built if go.mod or go.sum changes 5 | ENV CODECRAFTERS_DEPENDENCY_FILE_PATHS="go.mod,go.sum" 6 | 7 | WORKDIR /app 8 | 9 | # .git & README.md are unique per-repository. We ignore them on first copy to prevent cache misses 10 | COPY --exclude=.git --exclude=README.md . /app 11 | 12 | # Starting from Go 1.20, the go standard library is no loger compiled. 13 | # Setting GODEBUG to "installgoroot=all" restores the old behavior 14 | RUN GODEBUG="installgoroot=all" go install std 15 | 16 | RUN go mod download 17 | -------------------------------------------------------------------------------- /dockerfiles/go-1.24.Dockerfile: -------------------------------------------------------------------------------- 1 | # syntax=docker/dockerfile:1.7-labs 2 | FROM golang:1.24-alpine 3 | 4 | # Ensures the container is re-built if go.mod or go.sum changes 5 | ENV CODECRAFTERS_DEPENDENCY_FILE_PATHS="go.mod,go.sum" 6 | 7 | WORKDIR /app 8 | 9 | # .git & README.md are unique per-repository. We ignore them on first copy to prevent cache misses 10 | COPY --exclude=.git --exclude=README.md . /app 11 | 12 | # Starting from Go 1.20, the go standard library is no loger compiled. 13 | # Setting GODEBUG to "installgoroot=all" restores the old behavior 14 | RUN GODEBUG="installgoroot=all" go install std 15 | 16 | RUN go mod download 17 | -------------------------------------------------------------------------------- /dockerfiles/java-23.Dockerfile: -------------------------------------------------------------------------------- 1 | # syntax=docker/dockerfile:1.7-labs 2 | FROM maven:3.9.9-eclipse-temurin-23-alpine 3 | 4 | # Ensures the container is re-built if dependency files change 5 | ENV CODECRAFTERS_DEPENDENCY_FILE_PATHS="pom.xml" 6 | 7 | WORKDIR /app 8 | 9 | # .git & README.md are unique per-repository. We ignore them on first copy to prevent cache misses 10 | COPY --exclude=.git --exclude=README.md . /app 11 | 12 | # Install language-specific dependencies 13 | RUN .codecrafters/compile.sh 14 | -------------------------------------------------------------------------------- /dockerfiles/kotlin-2.0.Dockerfile: -------------------------------------------------------------------------------- 1 | # syntax=docker/dockerfile:1.7-labs 2 | FROM maven:3.9.8-eclipse-temurin-22-alpine 3 | 4 | # Ensures the container is re-built if pom.xml changes 5 | ENV CODECRAFTERS_DEPENDENCY_FILE_PATHS="pom.xml" 6 | 7 | WORKDIR /app 8 | 9 | # .git & README.md are unique per-repository. We ignore them on first copy to prevent cache misses 10 | COPY --exclude=.git --exclude=README.md . /app 11 | 12 | # Cache dependencies 13 | RUN mvn -B package -Ddir=/tmp/codecrafters-build-dir 14 | -------------------------------------------------------------------------------- /dockerfiles/nodejs-20.Dockerfile: -------------------------------------------------------------------------------- 1 | # syntax=docker/dockerfile:1.7-labs 2 | FROM node:20-alpine 3 | 4 | # Ensures the container is re-built if package.json changes 5 | ENV CODECRAFTERS_DEPENDENCY_FILE_PATHS="package.json,package-lock.json" 6 | 7 | WORKDIR /app 8 | 9 | # .git & README.md are unique per-repository. We ignore them on first copy to prevent cache misses 10 | COPY --exclude=.git --exclude=README.md . /app 11 | 12 | # Cache dependencies 13 | RUN npm install 14 | 15 | # Once the heavy steps are done, we can copy all files back 16 | COPY . /app -------------------------------------------------------------------------------- /dockerfiles/nodejs-21.Dockerfile: -------------------------------------------------------------------------------- 1 | # syntax=docker/dockerfile:1.7-labs 2 | FROM node:21.7-alpine3.19 3 | 4 | # Ensures the container is re-built if dependency files change 5 | ENV CODECRAFTERS_DEPENDENCY_FILE_PATHS="package.json,package-lock.json" 6 | 7 | WORKDIR /app 8 | 9 | # .git & README.md are unique per-repository. We ignore them on first copy to prevent cache misses 10 | COPY --exclude=.git --exclude=README.md . /app 11 | 12 | # Install deps 13 | RUN npm ci 14 | 15 | # If the node_modules directory exists, move it to /app-cached 16 | RUN mkdir -p /app-cached 17 | RUN if [ -d "/app/node_modules" ]; then mv /app/node_modules /app-cached; fi -------------------------------------------------------------------------------- /dockerfiles/ocaml-5.2.0.Dockerfile: -------------------------------------------------------------------------------- 1 | # syntax=docker/dockerfile:1.7-labs 2 | FROM ocaml/opam:alpine-3.20-ocaml-5.2 3 | 4 | # The image uses opam as the user, so let's set OPAMROOT to re-use whatever is already built 5 | ENV OPAMROOT /home/opam/.opam 6 | 7 | # Ensures the container is re-built if dune/dune-project changes 8 | ENV CODECRAFTERS_DEPENDENCY_FILE_PATHS="dune,dune-project" 9 | 10 | # Change to root user. All other images seem to use root, so let's do the same here 11 | # hadolint ignore=DL3002 12 | USER root 13 | 14 | # Install dune 15 | RUN opam update && opam install dune.3.16.0 --yes 16 | 17 | # Dune path is /home/opam/.opam/5.2/bin/dune 18 | ENV PATH="${OPAMROOT}/5.2/bin:${PATH}" 19 | 20 | WORKDIR /app 21 | 22 | # .git & README.md are unique per-repository. We ignore them on first copy to prevent cache misses 23 | COPY --exclude=.git --exclude=README.md . /app 24 | 25 | # Cache dependencies 26 | RUN opam install . --yes 27 | 28 | # This runs dune build 29 | RUN .codecrafters/compile.sh 30 | -------------------------------------------------------------------------------- /dockerfiles/ocaml-5.3.Dockerfile: -------------------------------------------------------------------------------- 1 | # syntax=docker/dockerfile:1.7-labs 2 | FROM ocaml/opam:alpine-3.21-ocaml-5.3 3 | 4 | # The image uses opam as the user, so let's set OPAMROOT to re-use whatever is already built 5 | ENV OPAMROOT /home/opam/.opam 6 | 7 | # Ensures the container is re-built if dune/dune-project changes 8 | ENV CODECRAFTERS_DEPENDENCY_FILE_PATHS="dune,dune-project" 9 | 10 | # Change to root user. All other images seem to use root, so let's do the same here 11 | # hadolint ignore=DL3002 12 | USER root 13 | 14 | # Install dune 15 | RUN opam install dune.3.19.0 --yes 16 | 17 | # Dune path is /home/opam/.opam/5.3/bin/dune 18 | ENV PATH="${OPAMROOT}/5.3/bin:${PATH}" 19 | 20 | WORKDIR /app 21 | 22 | # .git & README.md are unique per-repository. We ignore them on first copy to prevent cache misses 23 | COPY --exclude=.git --exclude=README.md . /app 24 | 25 | # Cache dependencies 26 | RUN opam install . --yes 27 | 28 | # This runs dune build 29 | RUN .codecrafters/compile.sh 30 | -------------------------------------------------------------------------------- /dockerfiles/odin-2025.4.Dockerfile: -------------------------------------------------------------------------------- 1 | # syntax=docker/dockerfile:1.7-labs 2 | FROM silkeh/clang:19-bookworm 3 | 4 | WORKDIR /Odin-install 5 | RUN git clone --depth 1 -b dev-2025-04 https://github.com/odin-lang/Odin.git /Odin-install \ 6 | && git checkout dev-2025-04 \ 7 | && make 8 | 9 | RUN mkdir /opt/Odin \ 10 | && cp -R ./base ./core ./shared ./vendor ./odin /opt/Odin/ 11 | 12 | WORKDIR / 13 | RUN rm -rf /Odin-install 14 | ENV PATH="/opt/Odin:${PATH}" 15 | 16 | WORKDIR /app 17 | 18 | # .git & README.md are unique per-repository. We ignore them on first copy to prevent cache misses 19 | COPY --exclude=.git --exclude=README.md . /app 20 | 21 | # Install language-specific dependencies 22 | RUN .codecrafters/compile.sh 23 | -------------------------------------------------------------------------------- /dockerfiles/php-8.4.Dockerfile: -------------------------------------------------------------------------------- 1 | # syntax=docker/dockerfile:1.7-labs 2 | FROM php:8.4.2RC1-cli-alpine3.20 3 | -------------------------------------------------------------------------------- /dockerfiles/python-3.12.Dockerfile: -------------------------------------------------------------------------------- 1 | # syntax=docker/dockerfile:1.7-labs 2 | FROM python:3.12-alpine 3 | 4 | ENV CODECRAFTERS_DEPENDENCY_FILE_PATHS="Pipfile,Pipfile.lock" 5 | 6 | # pipenv uses this to store virtualenvs 7 | ENV WORKON_HOME=/venvs 8 | 9 | RUN pip install --no-cache-dir "pipenv>=2023.12.1" 10 | 11 | WORKDIR /app 12 | 13 | # .git & README.md are unique per-repository. We ignore them on first copy to prevent cache misses 14 | COPY --exclude=.git --exclude=README.md . /app 15 | 16 | RUN pipenv install 17 | 18 | # Force environment creation 19 | RUN pipenv run python3 -c "1+1" 20 | -------------------------------------------------------------------------------- /dockerfiles/python-3.13.Dockerfile: -------------------------------------------------------------------------------- 1 | # syntax=docker/dockerfile:1.7-labs 2 | FROM python:3.13-alpine 3 | 4 | ENV CODECRAFTERS_DEPENDENCY_FILE_PATHS="Pipfile,Pipfile.lock" 5 | 6 | # pipenv uses this to store virtualenvs 7 | ENV WORKON_HOME=/venvs 8 | 9 | RUN pip install --no-cache-dir "pipenv>=2024.4.0" 10 | 11 | WORKDIR /app 12 | 13 | # .git & README.md are unique per-repository. We ignore them on first copy to prevent cache misses 14 | COPY --exclude=.git --exclude=README.md . /app 15 | 16 | RUN pipenv install 17 | 18 | # Force environment creation 19 | RUN pipenv run python3 -c "1+1" 20 | -------------------------------------------------------------------------------- /dockerfiles/rust-1.77.Dockerfile: -------------------------------------------------------------------------------- 1 | # syntax=docker/dockerfile:1.7-labs 2 | FROM rust:1.77-buster 3 | 4 | ENV CODECRAFTERS_DEPENDENCY_FILE_PATHS="Cargo.toml,Cargo.lock" 5 | 6 | WORKDIR /app 7 | 8 | # .git & README.md are unique per-repository. We ignore them on first copy to prevent cache misses 9 | COPY --exclude=.git --exclude=README.md . /app 10 | 11 | RUN cargo build --release --target-dir=/tmp/codecrafters-interpreter-target 12 | -------------------------------------------------------------------------------- /dockerfiles/rust-1.80.Dockerfile: -------------------------------------------------------------------------------- 1 | # syntax=docker/dockerfile:1.7-labs 2 | FROM rust:1.80-bookworm 3 | 4 | # Rebuild the container if these files change 5 | ENV CODECRAFTERS_DEPENDENCY_FILE_PATHS="Cargo.toml,Cargo.lock" 6 | 7 | WORKDIR /app 8 | 9 | # .git & README.md are unique per-repository. We ignore them on first copy to prevent cache misses 10 | COPY --exclude=.git --exclude=README.md . /app 11 | 12 | # This runs cargo build 13 | RUN .codecrafters/compile.sh 14 | -------------------------------------------------------------------------------- /dockerfiles/rust-1.82.Dockerfile: -------------------------------------------------------------------------------- 1 | # syntax=docker/dockerfile:1.7-labs 2 | FROM rust:1.82-bookworm 3 | 4 | # Rebuild the container if these files change 5 | ENV CODECRAFTERS_DEPENDENCY_FILE_PATHS="Cargo.toml,Cargo.lock" 6 | 7 | WORKDIR /app 8 | 9 | # .git & README.md are unique per-repository. We ignore them on first copy to prevent cache misses 10 | COPY --exclude=.git --exclude=README.md . /app 11 | 12 | # This runs cargo build 13 | RUN .codecrafters/compile.sh 14 | -------------------------------------------------------------------------------- /dockerfiles/rust-1.85.Dockerfile: -------------------------------------------------------------------------------- 1 | # syntax=docker/dockerfile:1.7-labs 2 | FROM rust:1.85-bookworm 3 | 4 | # Rebuild the container if these files change 5 | ENV CODECRAFTERS_DEPENDENCY_FILE_PATHS="Cargo.toml,Cargo.lock" 6 | 7 | WORKDIR /app 8 | 9 | # .git & README.md are unique per-repository. We ignore them on first copy to prevent cache misses 10 | COPY --exclude=.git --exclude=README.md . /app 11 | 12 | # This runs cargo build 13 | RUN .codecrafters/compile.sh 14 | -------------------------------------------------------------------------------- /dockerfiles/rust-1.86.Dockerfile: -------------------------------------------------------------------------------- 1 | # syntax=docker/dockerfile:1.7-labs 2 | FROM rust:1.86-bookworm 3 | 4 | # Rebuild the container if these files change 5 | ENV CODECRAFTERS_DEPENDENCY_FILE_PATHS="Cargo.toml,Cargo.lock" 6 | 7 | WORKDIR /app 8 | 9 | # .git & README.md are unique per-repository. We ignore them on first copy to prevent cache misses 10 | COPY --exclude=.git --exclude=README.md . /app 11 | 12 | # This runs cargo build 13 | RUN .codecrafters/compile.sh 14 | -------------------------------------------------------------------------------- /dockerfiles/swift-6.0.Dockerfile: -------------------------------------------------------------------------------- 1 | # syntax=docker/dockerfile:1.7-labs 2 | FROM swift:6.0-focal 3 | 4 | # Ensures the container is re-built if Package.swift changes 5 | ENV CODECRAFTERS_DEPENDENCY_FILE_PATHS="Package.swift" 6 | 7 | WORKDIR /app 8 | 9 | # .git & README.md are unique per-repository. We ignore them on first copy to prevent cache misses 10 | COPY --exclude=.git --exclude=README.md . /app 11 | 12 | RUN .codecrafters/compile.sh 13 | 14 | # Cache dependencies (TODO: Check if this is required, or whether build implicitly caches dependencies) 15 | RUN swift package --build-path /tmp/codecrafters-build-interpreter-swift resolve -------------------------------------------------------------------------------- /dockerfiles/zig-0.13.Dockerfile: -------------------------------------------------------------------------------- 1 | # syntax=docker/dockerfile:1.7-labs 2 | FROM alpine:3.20 3 | 4 | RUN apk add --no-cache 'xz>=5.6' 'curl>=8.9' 5 | 6 | # Download and install Zig 7 | RUN curl -O https://ziglang.org/download/0.13.0/zig-linux-x86_64-0.13.0.tar.xz \ 8 | && tar -xf zig-linux-x86_64-0.13.0.tar.xz \ 9 | && mv zig-linux-x86_64-0.13.0 /usr/local/zig \ 10 | && rm zig-linux-x86_64-0.13.0.tar.xz 11 | 12 | # Add Zig to PATH 13 | ENV PATH="/usr/local/zig:${PATH}" 14 | 15 | ENV CODECRAFTERS_DEPENDENCY_FILE_PATHS="build.zig,build.zig.zon" 16 | 17 | WORKDIR /app 18 | 19 | # .git & README.md are unique per-repository. We ignore them on first copy to prevent cache misses 20 | COPY --exclude=.git --exclude=README.md . /app 21 | 22 | # This runs zig build 23 | RUN .codecrafters/compile.sh 24 | 25 | # Cache build directory 26 | RUN mkdir -p /app-cached 27 | RUN mv /app/.zig-cache /app-cached/.zig-cache || true 28 | -------------------------------------------------------------------------------- /dockerfiles/zig-0.14.Dockerfile: -------------------------------------------------------------------------------- 1 | # syntax=docker/dockerfile:1.7-labs 2 | FROM alpine:3.20 3 | 4 | RUN apk add --no-cache 'xz>=5.6' 'curl>=8.9' 5 | 6 | # Download and install Zig 7 | RUN curl -O https://ziglang.org/download/0.14.0/zig-linux-x86_64-0.14.0.tar.xz \ 8 | && tar -xf zig-linux-x86_64-0.14.0.tar.xz \ 9 | && mv zig-linux-x86_64-0.14.0 /usr/local/zig \ 10 | && rm zig-linux-x86_64-0.14.0.tar.xz 11 | 12 | # Add Zig to PATH 13 | ENV PATH="/usr/local/zig:${PATH}" 14 | 15 | ENV CODECRAFTERS_DEPENDENCY_FILE_PATHS="build.zig,build.zig.zon" 16 | 17 | WORKDIR /app 18 | 19 | # .git & README.md are unique per-repository. We ignore them on first copy to prevent cache misses 20 | COPY --exclude=.git --exclude=README.md . /app 21 | 22 | # This runs zig build 23 | RUN .codecrafters/compile.sh 24 | 25 | # Cache build directory 26 | RUN mkdir -p /app-cached 27 | RUN mv /app/.zig-cache /app-cached/.zig-cache || true 28 | -------------------------------------------------------------------------------- /solutions/c/01-ry8/code/.codecrafters/compile.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # This script is used to compile your program on CodeCrafters 4 | # 5 | # This runs before .codecrafters/run.sh 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | set -e # Exit on failure 10 | 11 | cmake -B build -S . -DCMAKE_TOOLCHAIN_FILE=${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake 12 | cmake --build ./build 13 | -------------------------------------------------------------------------------- /solutions/c/01-ry8/code/.codecrafters/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # This script is used to run your program on CodeCrafters 4 | # 5 | # This runs after .codecrafters/compile.sh 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | set -e # Exit on failure 10 | 11 | exec $(dirname $0)/build/interpreter "$@" 12 | -------------------------------------------------------------------------------- /solutions/c/01-ry8/code/.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | -------------------------------------------------------------------------------- /solutions/c/01-ry8/code/.gitignore: -------------------------------------------------------------------------------- 1 | # Prerequisites 2 | *.d 3 | 4 | # Object files 5 | *.o 6 | *.ko 7 | *.obj 8 | *.elf 9 | 10 | # Linker output 11 | *.ilk 12 | *.map 13 | *.exp 14 | 15 | # Precompiled Headers 16 | *.gch 17 | *.pch 18 | 19 | # Libraries 20 | *.lib 21 | *.a 22 | *.la 23 | *.lo 24 | 25 | # Shared objects (inc. Windows DLLs) 26 | *.dll 27 | *.so 28 | *.so.* 29 | *.dylib 30 | 31 | # Executables 32 | *.exe 33 | *.out 34 | *.app 35 | *.i*86 36 | *.x86_64 37 | *.hex 38 | 39 | # Debug files 40 | *.dSYM/ 41 | *.su 42 | *.idb 43 | *.pdb 44 | 45 | # Kernel Module Compile Results 46 | *.mod* 47 | *.cmd 48 | .tmp_versions/ 49 | modules.order 50 | Module.symvers 51 | Mkfile.old 52 | dkms.conf 53 | 54 | build 55 | vcpkg_installed -------------------------------------------------------------------------------- /solutions/c/01-ry8/code/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.13) 2 | 3 | project(codecrafters-interpreter) 4 | 5 | file(GLOB_RECURSE SOURCE_FILES src/*.c src/*.h) 6 | 7 | set(CMAKE_C_STANDARD 23) # Enable the C23 standard 8 | 9 | add_executable(interpreter ${SOURCE_FILES}) 10 | -------------------------------------------------------------------------------- /solutions/c/01-ry8/code/codecrafters.yml: -------------------------------------------------------------------------------- 1 | # Set this to true if you want debug logs. 2 | # 3 | # These can be VERY verbose, so we suggest turning them off 4 | # unless you really need them. 5 | debug: false 6 | 7 | # Use this to change the C version used to run your code 8 | # on Codecrafters. 9 | # 10 | # Available versions: c-23 11 | language_pack: c-23 12 | -------------------------------------------------------------------------------- /solutions/c/01-ry8/code/vcpkg-configuration.json: -------------------------------------------------------------------------------- 1 | { 2 | "default-registry": { 3 | "kind": "git", 4 | "baseline": "c4af3593e1f1aa9e14a560a09e45ea2cb0dfd74d", 5 | "repository": "https://github.com/microsoft/vcpkg" 6 | }, 7 | "registries": [ 8 | { 9 | "kind": "artifact", 10 | "location": "https://github.com/microsoft/vcpkg-ce-catalog/archive/refs/heads/main.zip", 11 | "name": "microsoft" 12 | } 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /solutions/c/01-ry8/code/vcpkg.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": [] 3 | } 4 | -------------------------------------------------------------------------------- /solutions/c/01-ry8/code/your_program.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Use this script to run your program LOCALLY. 4 | # 5 | # Note: Changing this script WILL NOT affect how CodeCrafters runs your program. 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | set -e # Exit early if any commands fail 10 | 11 | # Copied from .codecrafters/compile.sh 12 | # 13 | # - Edit this to change how your program compiles locally 14 | # - Edit .codecrafters/compile.sh to change how your program compiles remotely 15 | ( 16 | cd "$(dirname "$0")" # Ensure compile steps are run within the repository directory 17 | cmake -B build -S . -DCMAKE_TOOLCHAIN_FILE=${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake 18 | cmake --build ./build 19 | ) 20 | 21 | # Copied from .codecrafters/run.sh 22 | # 23 | # - Edit this to change how your program runs locally 24 | # - Edit .codecrafters/run.sh to change how your program runs remotely 25 | exec $(dirname $0)/build/interpreter "$@" 26 | -------------------------------------------------------------------------------- /solutions/c/01-ry8/explanation.md: -------------------------------------------------------------------------------- 1 | The entry point for your Interpreter implementation is in `src/main.c`. 2 | 3 | Study and uncomment the relevant code: 4 | 5 | ```c 6 | // Uncomment this block to pass the first stage 7 | if (strlen(file_contents) > 0) { 8 | fprintf(stderr, "Scanner not implemented\n"); 9 | exit(1); 10 | } 11 | printf("EOF null\n"); // Placeholder, replace this line when implementing the scanner 12 | ``` 13 | 14 | Push your changes to pass the first stage: 15 | 16 | ``` 17 | git add . 18 | git commit -m "pass 1st stage" # any msg 19 | git push origin master 20 | ``` 21 | -------------------------------------------------------------------------------- /solutions/cpp/01-ry8/code/.codecrafters/compile.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # This script is used to compile your program on CodeCrafters 4 | # 5 | # This runs before .codecrafters/run.sh 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | set -e # Exit on failure 10 | 11 | cmake -B build -S . -DCMAKE_TOOLCHAIN_FILE=${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake 12 | cmake --build ./build 13 | -------------------------------------------------------------------------------- /solutions/cpp/01-ry8/code/.codecrafters/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # This script is used to run your program on CodeCrafters 4 | # 5 | # This runs after .codecrafters/compile.sh 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | set -e # Exit on failure 10 | 11 | exec $(dirname $0)/build/interpreter "$@" 12 | -------------------------------------------------------------------------------- /solutions/cpp/01-ry8/code/.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | -------------------------------------------------------------------------------- /solutions/cpp/01-ry8/code/.gitignore: -------------------------------------------------------------------------------- 1 | # Prerequisites 2 | *.d 3 | 4 | # Object files 5 | *.o 6 | *.ko 7 | *.obj 8 | *.elf 9 | 10 | # Linker output 11 | *.ilk 12 | *.map 13 | *.exp 14 | 15 | # Precompiled Headers 16 | *.gch 17 | *.pch 18 | 19 | # Libraries 20 | *.lib 21 | *.a 22 | *.la 23 | *.lo 24 | 25 | # Shared objects (inc. Windows DLLs) 26 | *.dll 27 | *.so 28 | *.so.* 29 | *.dylib 30 | 31 | # Executables 32 | *.exe 33 | *.out 34 | *.app 35 | *.i*86 36 | *.x86_64 37 | *.hex 38 | 39 | # Debug files 40 | *.dSYM/ 41 | *.su 42 | *.idb 43 | *.pdb 44 | 45 | # Kernel Module Compile Results 46 | *.mod* 47 | *.cmd 48 | .tmp_versions/ 49 | modules.order 50 | Module.symvers 51 | Mkfile.old 52 | dkms.conf 53 | 54 | build 55 | vcpkg_installed -------------------------------------------------------------------------------- /solutions/cpp/01-ry8/code/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.13) 2 | 3 | project(codecrafters-interpreter) 4 | 5 | set(CMAKE_CXX_STANDARD 23) # Enable the C++23 standard 6 | 7 | file(GLOB_RECURSE SOURCE_FILES src/*.cpp src/*.hpp) 8 | 9 | add_executable(interpreter ${SOURCE_FILES}) -------------------------------------------------------------------------------- /solutions/cpp/01-ry8/code/codecrafters.yml: -------------------------------------------------------------------------------- 1 | # Set this to true if you want debug logs. 2 | # 3 | # These can be VERY verbose, so we suggest turning them off 4 | # unless you really need them. 5 | debug: false 6 | 7 | # Use this to change the C++ version used to run your code 8 | # on Codecrafters. 9 | # 10 | # Available versions: cpp-23 11 | language_pack: cpp-23 12 | -------------------------------------------------------------------------------- /solutions/cpp/01-ry8/code/vcpkg-configuration.json: -------------------------------------------------------------------------------- 1 | { 2 | "default-registry": { 3 | "kind": "git", 4 | "baseline": "c4af3593e1f1aa9e14a560a09e45ea2cb0dfd74d", 5 | "repository": "https://github.com/microsoft/vcpkg" 6 | }, 7 | "registries": [ 8 | { 9 | "kind": "artifact", 10 | "location": "https://github.com/microsoft/vcpkg-ce-catalog/archive/refs/heads/main.zip", 11 | "name": "microsoft" 12 | } 13 | ] 14 | } -------------------------------------------------------------------------------- /solutions/cpp/01-ry8/code/vcpkg.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": [] 3 | } -------------------------------------------------------------------------------- /solutions/cpp/01-ry8/code/your_program.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Use this script to run your program LOCALLY. 4 | # 5 | # Note: Changing this script WILL NOT affect how CodeCrafters runs your program. 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | set -e # Exit early if any commands fail 10 | 11 | # Copied from .codecrafters/compile.sh 12 | # 13 | # - Edit this to change how your program compiles locally 14 | # - Edit .codecrafters/compile.sh to change how your program compiles remotely 15 | ( 16 | cd "$(dirname "$0")" # Ensure compile steps are run within the repository directory 17 | cmake -B build -S . -DCMAKE_TOOLCHAIN_FILE=${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake 18 | cmake --build ./build 19 | ) 20 | 21 | # Copied from .codecrafters/run.sh 22 | # 23 | # - Edit this to change how your program runs locally 24 | # - Edit .codecrafters/run.sh to change how your program runs remotely 25 | exec $(dirname $0)/build/interpreter "$@" 26 | -------------------------------------------------------------------------------- /solutions/cpp/01-ry8/explanation.md: -------------------------------------------------------------------------------- 1 | The entry point for your Interpreter implementation is in `src/main.cpp`. 2 | 3 | Study and uncomment the relevant code: 4 | 5 | ```cpp 6 | // Uncomment this block to pass the first stage 7 | 8 | if (!file_contents.empty()) { 9 | std::cerr << "Scanner not implemented" << std::endl; 10 | return 1; 11 | } 12 | std::cout << "EOF null" << std::endl; // Placeholder, replace this line when implementing the scanner 13 | ``` 14 | 15 | Push your changes to pass the first stage: 16 | 17 | ``` 18 | git add . 19 | git commit -m "pass 1st stage" # any msg 20 | git push origin master 21 | ``` 22 | -------------------------------------------------------------------------------- /solutions/csharp/01-ry8/code/.codecrafters/compile.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # This script is used to compile your program on CodeCrafters 4 | # 5 | # This runs before .codecrafters/run.sh 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | set -e # Exit on failure 10 | 11 | dotnet build --configuration Release --output /tmp/codecrafters-build-csharp codecrafters-interpreter.csproj 12 | -------------------------------------------------------------------------------- /solutions/csharp/01-ry8/code/.codecrafters/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # This script is used to run your program on CodeCrafters 4 | # 5 | # This runs after .codecrafters/compile.sh 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | set -e # Exit on failure 10 | 11 | exec /tmp/codecrafters-build-csharp/codecrafters-interpreter "$@" 12 | -------------------------------------------------------------------------------- /solutions/csharp/01-ry8/code/.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | -------------------------------------------------------------------------------- /solutions/csharp/01-ry8/code/codecrafters-interpreter.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net9.0 6 | codecrafters-interpreter 7 | enable 8 | enable 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /solutions/csharp/01-ry8/code/codecrafters.yml: -------------------------------------------------------------------------------- 1 | # Set this to true if you want debug logs. 2 | # 3 | # These can be VERY verbose, so we suggest turning them off 4 | # unless you really need them. 5 | debug: false 6 | 7 | # Use this to change the C# version used to run your code 8 | # on Codecrafters. 9 | # 10 | # Available versions: dotnet-9.0 11 | language_pack: dotnet-9.0 12 | -------------------------------------------------------------------------------- /solutions/csharp/01-ry8/code/src/main.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | 4 | if (args.Length < 2) 5 | { 6 | Console.Error.WriteLine("Usage: ./your_program.sh tokenize "); 7 | Environment.Exit(1); 8 | } 9 | 10 | string command = args[0]; 11 | string filename = args[1]; 12 | 13 | if (command != "tokenize") 14 | { 15 | Console.Error.WriteLine($"Unknown command: {command}"); 16 | Environment.Exit(1); 17 | } 18 | 19 | string fileContents = File.ReadAllText(filename); 20 | 21 | if (!string.IsNullOrEmpty(fileContents)) 22 | { 23 | throw new NotImplementedException("Scanner not implemented"); 24 | } 25 | else 26 | { 27 | Console.WriteLine("EOF null"); // Placeholder, replace this line when implementing the scanner 28 | } 29 | -------------------------------------------------------------------------------- /solutions/csharp/01-ry8/code/your_program.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Use this script to run your program LOCALLY. 4 | # 5 | # Note: Changing this script WILL NOT affect how CodeCrafters runs your program. 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | set -e # Exit early if any commands fail 10 | 11 | # Copied from .codecrafters/compile.sh 12 | # 13 | # - Edit this to change how your program compiles locally 14 | # - Edit .codecrafters/compile.sh to change how your program compiles remotely 15 | ( 16 | cd "$(dirname "$0")" # Ensure compile steps are run within the repository directory 17 | dotnet build --configuration Release --output /tmp/codecrafters-build-csharp codecrafters-interpreter.csproj 18 | ) 19 | 20 | # Copied from .codecrafters/run.sh 21 | # 22 | # - Edit this to change how your program runs locally 23 | # - Edit .codecrafters/run.sh to change how your program runs remotely 24 | exec /tmp/codecrafters-build-csharp/codecrafters-interpreter "$@" 25 | -------------------------------------------------------------------------------- /solutions/csharp/01-ry8/explanation.md: -------------------------------------------------------------------------------- 1 | The entry point for your Interpreter implementation is in `src/main.cs`. 2 | 3 | Study and uncomment the relevant code: 4 | 5 | ```csharp 6 | // Uncomment this block to pass the first stage 7 | if (!string.IsNullOrEmpty(fileContents)) 8 | { 9 | throw new NotImplementedException("Scanner not implemented"); 10 | } 11 | else 12 | { 13 | Console.WriteLine("EOF null"); // Placeholder, replace this line when implementing the scanner 14 | } 15 | ``` 16 | 17 | Push your changes to pass the first stage: 18 | 19 | ``` 20 | git add . 21 | git commit -m "pass 1st stage" # any msg 22 | git push origin master 23 | ``` 24 | -------------------------------------------------------------------------------- /solutions/elixir/01-ry8/code/.codecrafters/compile.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # This script is used to compile your program on CodeCrafters 4 | # 5 | # This runs before .codecrafters/run.sh 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | set -e # Exit on failure 10 | 11 | mix escript.build 12 | mv codecrafters_interpreter /tmp/codecrafters-build-interpreter-elixir 13 | -------------------------------------------------------------------------------- /solutions/elixir/01-ry8/code/.codecrafters/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # This script is used to run your program on CodeCrafters 4 | # 5 | # This runs after .codecrafters/compile.sh 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | set -e # Exit on failure 10 | 11 | exec /tmp/codecrafters-build-interpreter-elixir "$@" 12 | -------------------------------------------------------------------------------- /solutions/elixir/01-ry8/code/.formatter.exs: -------------------------------------------------------------------------------- 1 | # Used by "mix format" 2 | [ 3 | inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"] 4 | ] 5 | -------------------------------------------------------------------------------- /solutions/elixir/01-ry8/code/.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | -------------------------------------------------------------------------------- /solutions/elixir/01-ry8/code/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore the compiled binary 2 | /codecrafters_interpreter 3 | 4 | # The directory Mix will write compiled artifacts to. 5 | /_build/ 6 | 7 | # If you run "mix test --cover", coverage assets end up here. 8 | /cover/ 9 | 10 | # The directory Mix downloads your dependencies sources to. 11 | /deps/ 12 | 13 | # Where third-party dependencies like ExDoc output generated docs. 14 | /doc/ 15 | 16 | # Ignore .fetch files in case you like to edit your project deps locally. 17 | /.fetch 18 | 19 | # If the VM crashes, it generates a dump, let's ignore it too. 20 | erl_crash.dump 21 | 22 | # Also ignore archive artifacts (built via "mix archive.build"). 23 | *.ez 24 | 25 | # Ignore package tarball (built via "mix hex.build"). 26 | app-*.tar 27 | 28 | -------------------------------------------------------------------------------- /solutions/elixir/01-ry8/code/codecrafters.yml: -------------------------------------------------------------------------------- 1 | # Set this to true if you want debug logs. 2 | # 3 | # These can be VERY verbose, so we suggest turning them off 4 | # unless you really need them. 5 | debug: false 6 | 7 | # Use this to change the Elixir version used to run your code 8 | # on Codecrafters. 9 | # 10 | # Available versions: elixir-1.18 11 | language_pack: elixir-1.18 12 | -------------------------------------------------------------------------------- /solutions/elixir/01-ry8/code/mix.exs: -------------------------------------------------------------------------------- 1 | defmodule App.MixProject do 2 | # NOTE: You do not need to change anything in this file. 3 | use Mix.Project 4 | 5 | def project do 6 | [ 7 | app: :codecrafters_interpreter, 8 | version: "1.0.0", 9 | elixir: "~> 1.18", 10 | start_permanent: Mix.env() == :prod, 11 | deps: deps(), 12 | escript: [main_module: CLI] 13 | ] 14 | end 15 | 16 | # Run "mix help compile.app" to learn about applications. 17 | def application do 18 | [ 19 | extra_applications: [:logger] 20 | ] 21 | end 22 | 23 | # Run "mix help deps" to learn about dependencies. 24 | defp deps do 25 | [ 26 | # {:dep_from_hexpm, "~> 0.3.0"}, 27 | # {:dep_from_git, git: "https://github.com/elixir-lang/my_dep.git", tag: "0.1.0"} 28 | ] 29 | end 30 | end 31 | -------------------------------------------------------------------------------- /solutions/elixir/01-ry8/code/your_program.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Use this script to run your program LOCALLY. 4 | # 5 | # Note: Changing this script WILL NOT affect how CodeCrafters runs your program. 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | set -e # Exit early if any commands fail 10 | 11 | # Copied from .codecrafters/compile.sh 12 | # 13 | # - Edit this to change how your program compiles locally 14 | # - Edit .codecrafters/compile.sh to change how your program compiles remotely 15 | ( 16 | cd "$(dirname "$0")" # Ensure compile steps are run within the repository directory 17 | mix escript.build 18 | mv codecrafters_interpreter /tmp/codecrafters-build-interpreter-elixir 19 | ) 20 | 21 | # Copied from .codecrafters/run.sh 22 | # 23 | # - Edit this to change how your program runs locally 24 | # - Edit .codecrafters/run.sh to change how your program runs remotely 25 | exec /tmp/codecrafters-build-interpreter-elixir "$@" 26 | -------------------------------------------------------------------------------- /solutions/elixir/01-ry8/explanation.md: -------------------------------------------------------------------------------- 1 | The entry point for your Interpreter implementation is in `lib/main.ex`. 2 | 3 | Study and uncomment the relevant code: 4 | 5 | ```elixir 6 | # TODO: Uncomment this when implementing the scanner 7 | if file_contents != "" do 8 | raise "Scanner not implemented" 9 | else 10 | IO.puts("EOF null") # Placeholder, replace this line when implementing the scanner 11 | end 12 | ``` 13 | 14 | Push your changes to pass the first stage: 15 | 16 | ``` 17 | git add . 18 | git commit -m "pass 1st stage" # any msg 19 | git push origin master 20 | ``` 21 | -------------------------------------------------------------------------------- /solutions/gleam/01-ry8/code/.codecrafters/compile.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # This script is used to compile your program on CodeCrafters 4 | # 5 | # This runs before .codecrafters/run.sh 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | set -e # Exit on failure 10 | 11 | gleam build 12 | -------------------------------------------------------------------------------- /solutions/gleam/01-ry8/code/.codecrafters/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # This script is used to run your program on CodeCrafters 4 | # 5 | # This runs after .codecrafters/compile.sh 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | set -e # Exit on failure 10 | 11 | exec gleam run --module main -- "$@" 12 | -------------------------------------------------------------------------------- /solutions/gleam/01-ry8/code/.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | -------------------------------------------------------------------------------- /solutions/gleam/01-ry8/code/.gitignore: -------------------------------------------------------------------------------- 1 | *.beam 2 | *.ez 3 | /build 4 | erl_crash.dump 5 | -------------------------------------------------------------------------------- /solutions/gleam/01-ry8/code/codecrafters.yml: -------------------------------------------------------------------------------- 1 | # Set this to true if you want debug logs. 2 | # 3 | # These can be VERY verbose, so we suggest turning them off 4 | # unless you really need them. 5 | debug: false 6 | 7 | # Use this to change the Gleam version used to run your code 8 | # on Codecrafters. 9 | # 10 | # Available versions: gleam-1.9 11 | language_pack: gleam-1.9 12 | -------------------------------------------------------------------------------- /solutions/gleam/01-ry8/code/gleam.toml: -------------------------------------------------------------------------------- 1 | name = "codecrafters_interpreter" 2 | version = "1.0.0" 3 | 4 | # For a full reference of all the available options, you can have a look at 5 | # https://gleam.run/writing-gleam/gleam-toml/. 6 | 7 | [dependencies] 8 | gleam_stdlib = "~> 0.34 or ~> 1.0" 9 | simplifile = ">= 2.0.1 and < 3.0.0" 10 | gleam_erlang = ">= 0.25.0 and < 1.0.0" 11 | argv = ">= 1.0.2 and < 2.0.0" 12 | 13 | [dev-dependencies] 14 | gleeunit = "~> 1.0" 15 | -------------------------------------------------------------------------------- /solutions/gleam/01-ry8/code/src/main.gleam: -------------------------------------------------------------------------------- 1 | import gleam/io 2 | import gleam/string 3 | 4 | import argv 5 | import simplifile 6 | 7 | pub fn main() { 8 | let args = argv.load().arguments 9 | 10 | case args { 11 | ["tokenize", filename] -> { 12 | case simplifile.read(filename) { 13 | Ok(contents) -> { 14 | case string.length(contents) { 15 | 0 -> io.println("EOF null") 16 | _ -> io.println_error("TODO: Implement scanner!") 17 | } 18 | } 19 | Error(error) -> { 20 | io.println_error("Error: " <> simplifile.describe_error(error)) 21 | exit(1) 22 | } 23 | } 24 | } 25 | _ -> { 26 | io.println_error("Usage: ./your_program.sh tokenize ") 27 | exit(1) 28 | } 29 | } 30 | } 31 | 32 | @external(erlang, "erlang", "halt") 33 | pub fn exit(code: Int) -> Nil 34 | -------------------------------------------------------------------------------- /solutions/gleam/01-ry8/code/your_program.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Use this script to run your program LOCALLY. 4 | # 5 | # Note: Changing this script WILL NOT affect how CodeCrafters runs your program. 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | set -e # Exit early if any commands fail 10 | 11 | # Copied from .codecrafters/compile.sh 12 | # 13 | # - Edit this to change how your program compiles locally 14 | # - Edit .codecrafters/compile.sh to change how your program compiles remotely 15 | ( 16 | cd "$(dirname "$0")" # Ensure compile steps are run within the repository directory 17 | gleam build 18 | ) 19 | 20 | # Copied from .codecrafters/run.sh 21 | # 22 | # - Edit this to change how your program runs locally 23 | # - Edit .codecrafters/run.sh to change how your program runs remotely 24 | exec gleam run --module main -- "$@" 25 | -------------------------------------------------------------------------------- /solutions/gleam/01-ry8/explanation.md: -------------------------------------------------------------------------------- 1 | The entry point for your Interpreter implementation is in `src/main.gleam`. 2 | 3 | Study and uncomment the relevant code: 4 | 5 | ```gleam 6 | // Uncomment this line to pass the first stage 7 | 0 -> io.println("EOF null") 8 | ``` 9 | 10 | Push your changes to pass the first stage: 11 | 12 | ``` 13 | git add . 14 | git commit -m "pass 1st stage" # any msg 15 | git push origin master 16 | ``` 17 | -------------------------------------------------------------------------------- /solutions/go/01-ry8/code/.codecrafters/compile.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # This script is used to compile your program on CodeCrafters 4 | # 5 | # This runs before .codecrafters/run.sh 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | set -e # Exit on failure 10 | 11 | go build -o /tmp/codecrafters-build-interpreter-go app/*.go 12 | -------------------------------------------------------------------------------- /solutions/go/01-ry8/code/.codecrafters/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # This script is used to run your program on CodeCrafters 4 | # 5 | # This runs after .codecrafters/compile.sh 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | set -e # Exit on failure 10 | 11 | exec /tmp/codecrafters-build-interpreter-go "$@" 12 | -------------------------------------------------------------------------------- /solutions/go/01-ry8/code/.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | -------------------------------------------------------------------------------- /solutions/go/01-ry8/code/app/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | ) 7 | 8 | func main() { 9 | if len(os.Args) < 3 { 10 | fmt.Fprintln(os.Stderr, "Usage: ./your_program.sh tokenize ") 11 | os.Exit(1) 12 | } 13 | 14 | command := os.Args[1] 15 | 16 | if command != "tokenize" { 17 | fmt.Fprintf(os.Stderr, "Unknown command: %s\n", command) 18 | os.Exit(1) 19 | } 20 | 21 | filename := os.Args[2] 22 | fileContents, err := os.ReadFile(filename) 23 | if err != nil { 24 | fmt.Fprintf(os.Stderr, "Error reading file: %v\n", err) 25 | os.Exit(1) 26 | } 27 | 28 | if len(fileContents) > 0 { 29 | panic("Scanner not implemented") 30 | } else { 31 | fmt.Println("EOF null") // Placeholder, replace this line when implementing the scanner 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /solutions/go/01-ry8/code/codecrafters.yml: -------------------------------------------------------------------------------- 1 | # Set this to true if you want debug logs. 2 | # 3 | # These can be VERY verbose, so we suggest turning them off 4 | # unless you really need them. 5 | debug: false 6 | 7 | # Use this to change the Go version used to run your code 8 | # on Codecrafters. 9 | # 10 | # Available versions: go-1.24 11 | language_pack: go-1.24 12 | -------------------------------------------------------------------------------- /solutions/go/01-ry8/code/go.mod: -------------------------------------------------------------------------------- 1 | 2 | module github.com/codecrafters-io/interpreter-starter-go 3 | 4 | go 1.24.0 5 | -------------------------------------------------------------------------------- /solutions/go/01-ry8/code/go.sum: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codecrafters-io/build-your-own-interpreter/10de14d10190fdb9daa22963094d47e606ad5e66/solutions/go/01-ry8/code/go.sum -------------------------------------------------------------------------------- /solutions/go/01-ry8/code/your_program.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Use this script to run your program LOCALLY. 4 | # 5 | # Note: Changing this script WILL NOT affect how CodeCrafters runs your program. 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | set -e # Exit early if any commands fail 10 | 11 | # Copied from .codecrafters/compile.sh 12 | # 13 | # - Edit this to change how your program compiles locally 14 | # - Edit .codecrafters/compile.sh to change how your program compiles remotely 15 | ( 16 | cd "$(dirname "$0")" # Ensure compile steps are run within the repository directory 17 | go build -o /tmp/codecrafters-build-interpreter-go app/*.go 18 | ) 19 | 20 | # Copied from .codecrafters/run.sh 21 | # 22 | # - Edit this to change how your program runs locally 23 | # - Edit .codecrafters/run.sh to change how your program runs remotely 24 | exec /tmp/codecrafters-build-interpreter-go "$@" 25 | -------------------------------------------------------------------------------- /solutions/go/01-ry8/explanation.md: -------------------------------------------------------------------------------- 1 | The entry point for your Interpreter implementation is in `app/main.go`. 2 | 3 | Study and uncomment the relevant code: 4 | 5 | ```go 6 | // Uncomment this block to pass the first stage 7 | 8 | filename := os.Args[2] 9 | fileContents, err := os.ReadFile(filename) 10 | if err != nil { 11 | fmt.Fprintf(os.Stderr, "Error reading file: %v\n", err) 12 | os.Exit(1) 13 | } 14 | 15 | if len(fileContents) > 0 { 16 | panic("Scanner not implemented") 17 | } else { 18 | fmt.Println("EOF null") // Placeholder, replace this line when implementing the scanner 19 | } 20 | ``` 21 | 22 | Push your changes to pass the first stage: 23 | 24 | ``` 25 | git add . 26 | git commit -m "pass 1st stage" # any msg 27 | git push origin master 28 | ``` 29 | -------------------------------------------------------------------------------- /solutions/java/01-ry8/code/.codecrafters/compile.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # This script is used to compile your program on CodeCrafters 4 | # 5 | # This runs before .codecrafters/run.sh 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | set -e # Exit on failure 10 | 11 | mvn -B package -Ddir=/tmp/codecrafters-build-interpreter-java 12 | -------------------------------------------------------------------------------- /solutions/java/01-ry8/code/.codecrafters/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # This script is used to run your program on CodeCrafters 4 | # 5 | # This runs after .codecrafters/compile.sh 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | set -e # Exit on failure 10 | 11 | exec java -jar /tmp/codecrafters-build-interpreter-java/codecrafters-interpreter.jar "$@" 12 | -------------------------------------------------------------------------------- /solutions/java/01-ry8/code/.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | -------------------------------------------------------------------------------- /solutions/java/01-ry8/code/.gitignore: -------------------------------------------------------------------------------- 1 | *.jar 2 | target/ 3 | .idea/ 4 | -------------------------------------------------------------------------------- /solutions/java/01-ry8/code/codecrafters.yml: -------------------------------------------------------------------------------- 1 | # Set this to true if you want debug logs. 2 | # 3 | # These can be VERY verbose, so we suggest turning them off 4 | # unless you really need them. 5 | debug: false 6 | 7 | # Use this to change the Java version used to run your code 8 | # on Codecrafters. 9 | # 10 | # Available versions: java-23 11 | language_pack: java-23 12 | -------------------------------------------------------------------------------- /solutions/java/01-ry8/code/your_program.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Use this script to run your program LOCALLY. 4 | # 5 | # Note: Changing this script WILL NOT affect how CodeCrafters runs your program. 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | set -e # Exit early if any commands fail 10 | 11 | # Copied from .codecrafters/compile.sh 12 | # 13 | # - Edit this to change how your program compiles locally 14 | # - Edit .codecrafters/compile.sh to change how your program compiles remotely 15 | ( 16 | cd "$(dirname "$0")" # Ensure compile steps are run within the repository directory 17 | mvn -B package -Ddir=/tmp/codecrafters-build-interpreter-java 18 | ) 19 | 20 | # Copied from .codecrafters/run.sh 21 | # 22 | # - Edit this to change how your program runs locally 23 | # - Edit .codecrafters/run.sh to change how your program runs remotely 24 | exec java -jar /tmp/codecrafters-build-interpreter-java/codecrafters-interpreter.jar "$@" 25 | -------------------------------------------------------------------------------- /solutions/java/01-ry8/explanation.md: -------------------------------------------------------------------------------- 1 | The entry point for your Interpreter implementation is in `src/main/java/Main.java`. 2 | 3 | Study and uncomment the relevant code: 4 | 5 | ```java 6 | // Uncomment this block to pass the first stage 7 | 8 | if (fileContents.length() > 0) { 9 | throw new RuntimeException("Scanner not implemented"); 10 | } else { 11 | System.out.println("EOF null"); // Placeholder, replace this line when implementing the scanner 12 | } 13 | ``` 14 | 15 | Push your changes to pass the first stage: 16 | 17 | ``` 18 | git add . 19 | git commit -m "pass 1st stage" # any msg 20 | git push origin master 21 | ``` 22 | -------------------------------------------------------------------------------- /solutions/javascript/01-ry8/code/.codecrafters/compile.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # This script is used to compile your program on CodeCrafters 4 | # 5 | # This runs before .codecrafters/run.sh 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | set -e # Exit on failure 10 | 11 | # (This file is empty since JavaScript programs don't use a compile step) 12 | -------------------------------------------------------------------------------- /solutions/javascript/01-ry8/code/.codecrafters/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # This script is used to run your program on CodeCrafters 4 | # 5 | # This runs after .codecrafters/compile.sh 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | set -e # Exit on failure 10 | 11 | exec node app/main.js "$@" 12 | -------------------------------------------------------------------------------- /solutions/javascript/01-ry8/code/.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | -------------------------------------------------------------------------------- /solutions/javascript/01-ry8/code/.gitignore: -------------------------------------------------------------------------------- 1 | # Dependency directories 2 | node_modules/ -------------------------------------------------------------------------------- /solutions/javascript/01-ry8/code/app/main.js: -------------------------------------------------------------------------------- 1 | import fs from "fs"; 2 | 3 | const args = process.argv.slice(2); // Skip the first two arguments (node path and script path) 4 | 5 | if (args.length < 2) { 6 | console.error("Usage: ./your_program.sh tokenize "); 7 | process.exit(1); 8 | } 9 | 10 | const command = args[0]; 11 | 12 | if (command !== "tokenize") { 13 | console.error(`Usage: Unknown command: ${command}`); 14 | process.exit(1); 15 | } 16 | 17 | const filename = args[1]; 18 | 19 | const fileContent = fs.readFileSync(filename, "utf8"); 20 | 21 | if (fileContent.length !== 0) { 22 | throw new Error("Scanner not implemented"); 23 | } else { 24 | console.log("EOF null"); 25 | } 26 | -------------------------------------------------------------------------------- /solutions/javascript/01-ry8/code/codecrafters.yml: -------------------------------------------------------------------------------- 1 | # Set this to true if you want debug logs. 2 | # 3 | # These can be VERY verbose, so we suggest turning them off 4 | # unless you really need them. 5 | debug: false 6 | 7 | # Use this to change the JavaScript version used to run your code 8 | # on Codecrafters. 9 | # 10 | # Available versions: nodejs-21 11 | language_pack: nodejs-21 12 | -------------------------------------------------------------------------------- /solutions/javascript/01-ry8/code/package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@codecrafters/interpreter", 3 | "version": "1.0.0", 4 | "lockfileVersion": 3, 5 | "requires": true, 6 | "packages": { 7 | "": { 8 | "name": "@codecrafters/interpreter", 9 | "version": "1.0.0" 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /solutions/javascript/01-ry8/code/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@codecrafters/interpreter", 3 | "version": "1.0.0", 4 | "type": "module", 5 | "dependencies": {} 6 | } 7 | -------------------------------------------------------------------------------- /solutions/javascript/01-ry8/code/your_program.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Use this script to run your program LOCALLY. 4 | # 5 | # Note: Changing this script WILL NOT affect how CodeCrafters runs your program. 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | set -e # Exit early if any commands fail 10 | 11 | # Copied from .codecrafters/run.sh 12 | # 13 | # - Edit this to change how your program runs locally 14 | # - Edit .codecrafters/run.sh to change how your program runs remotely 15 | exec node app/main.js "$@" 16 | -------------------------------------------------------------------------------- /solutions/javascript/01-ry8/explanation.md: -------------------------------------------------------------------------------- 1 | The entry point for your Interpreter implementation is in `app/main.js`. 2 | 3 | Study and uncomment the relevant code: 4 | 5 | ```javascript 6 | // Uncomment this block to pass the first stage 7 | 8 | const fileContent = fs.readFileSync(filename, "utf8"); 9 | 10 | if (fileContent.length !== 0) { 11 | throw new Error("Scanner not implemented"); 12 | } else { 13 | console.log("EOF null"); 14 | } 15 | ``` 16 | 17 | Push your changes to pass the first stage: 18 | 19 | ``` 20 | git add . 21 | git commit -m "pass 1st stage" # any msg 22 | git push origin master 23 | ``` 24 | -------------------------------------------------------------------------------- /solutions/kotlin/01-ry8/code/.codecrafters/compile.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # This script is used to compile your program on CodeCrafters 4 | # 5 | # This runs before .codecrafters/run.sh 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | set -e # Exit on failure 10 | 11 | mvn -B package -Ddir=/tmp/codecrafters-build-dir 12 | -------------------------------------------------------------------------------- /solutions/kotlin/01-ry8/code/.codecrafters/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # This script is used to run your program on CodeCrafters 4 | # 5 | # This runs after .codecrafters/compile.sh 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | set -e # Exit on failure 10 | 11 | exec java -jar /tmp/codecrafters-build-dir/build-your-own-interpreter.jar "$@" 12 | -------------------------------------------------------------------------------- /solutions/kotlin/01-ry8/code/.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | -------------------------------------------------------------------------------- /solutions/kotlin/01-ry8/code/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | .idea/ -------------------------------------------------------------------------------- /solutions/kotlin/01-ry8/code/codecrafters.yml: -------------------------------------------------------------------------------- 1 | # Set this to true if you want debug logs. 2 | # 3 | # These can be VERY verbose, so we suggest turning them off 4 | # unless you really need them. 5 | debug: false 6 | 7 | # Use this to change the Kotlin version used to run your code 8 | # on Codecrafters. 9 | # 10 | # Available versions: kotlin-2.0 11 | language_pack: kotlin-2.0 12 | -------------------------------------------------------------------------------- /solutions/kotlin/01-ry8/code/src/main/kotlin/Main.kt: -------------------------------------------------------------------------------- 1 | import java.io.File 2 | import kotlin.system.exitProcess 3 | 4 | fun main(args: Array) { 5 | if (args.size < 2) { 6 | System.err.println("Usage: ./your_program.sh tokenize ") 7 | exitProcess(1) 8 | } 9 | 10 | val command = args[0] 11 | val filename = args[1] 12 | 13 | if (command != "tokenize") { 14 | System.err.println("Unknown command: ${command}") 15 | exitProcess(1) 16 | } 17 | 18 | val fileContents = File(filename).readText() 19 | 20 | if (fileContents.isNotEmpty()) { 21 | throw NotImplementedError("Scanner not implemented") 22 | } else { 23 | println("EOF null") // Placeholder, replace this line when implementing the scanner 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /solutions/kotlin/01-ry8/code/your_program.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Use this script to run your program LOCALLY. 4 | # 5 | # Note: Changing this script WILL NOT affect how CodeCrafters runs your program. 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | set -e # Exit early if any commands fail 10 | 11 | # Copied from .codecrafters/compile.sh 12 | # 13 | # - Edit this to change how your program compiles locally 14 | # - Edit .codecrafters/compile.sh to change how your program compiles remotely 15 | ( 16 | cd "$(dirname "$0")" # Ensure compile steps are run within the repository directory 17 | mvn -B package -Ddir=/tmp/codecrafters-build-dir 18 | ) 19 | 20 | # Copied from .codecrafters/run.sh 21 | # 22 | # - Edit this to change how your program runs locally 23 | # - Edit .codecrafters/run.sh to change how your program runs remotely 24 | exec java -jar /tmp/codecrafters-build-dir/build-your-own-interpreter.jar "$@" 25 | -------------------------------------------------------------------------------- /solutions/kotlin/01-ry8/explanation.md: -------------------------------------------------------------------------------- 1 | The entry point for your Interpreter implementation is in `src/main/kotlin/Main.kt`. 2 | 3 | Study and uncomment the relevant code: 4 | 5 | ```kotlin 6 | // Uncomment this block to pass the first stage 7 | if (fileContents.isNotEmpty()) { 8 | throw NotImplementedError("Scanner not implemented") 9 | } else { 10 | println("EOF null") // Placeholder, replace this line when implementing the scanner 11 | } 12 | ``` 13 | 14 | Push your changes to pass the first stage: 15 | 16 | ``` 17 | git add . 18 | git commit -m "pass 1st stage" # any msg 19 | git push origin master 20 | ``` 21 | -------------------------------------------------------------------------------- /solutions/ocaml/01-ry8/code/.codecrafters/compile.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # This script is used to compile your program on CodeCrafters 4 | # 5 | # This runs before .codecrafters/run.sh 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | set -e # Exit on failure 10 | 11 | dune build --build-dir /tmp/codecrafters-build-interpreter-ocaml 12 | -------------------------------------------------------------------------------- /solutions/ocaml/01-ry8/code/.codecrafters/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # This script is used to run your program on CodeCrafters 4 | # 5 | # This runs after .codecrafters/compile.sh 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | set -e # Exit on failure 10 | 11 | exec /tmp/codecrafters-build-interpreter-ocaml/default/main.exe "$@" 12 | -------------------------------------------------------------------------------- /solutions/ocaml/01-ry8/code/.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | -------------------------------------------------------------------------------- /solutions/ocaml/01-ry8/code/.gitignore: -------------------------------------------------------------------------------- 1 | *.annot 2 | *.cmo 3 | *.cma 4 | *.cmi 5 | *.a 6 | *.o 7 | *.cmx 8 | *.cmxs 9 | *.cmxa 10 | 11 | # ocamlbuild working directory 12 | _build/ 13 | 14 | # ocamlbuild targets 15 | *.byte 16 | *.native 17 | 18 | # oasis generated files 19 | setup.data 20 | setup.log 21 | 22 | # Merlin configuring file for Vim and Emacs 23 | .merlin 24 | 25 | # Dune generated files 26 | *.install 27 | 28 | # Local OPAM switch 29 | _opam/ -------------------------------------------------------------------------------- /solutions/ocaml/01-ry8/code/.ocamlformat: -------------------------------------------------------------------------------- 1 | profile = default -------------------------------------------------------------------------------- /solutions/ocaml/01-ry8/code/codecrafters.yml: -------------------------------------------------------------------------------- 1 | # Set this to true if you want debug logs. 2 | # 3 | # These can be VERY verbose, so we suggest turning them off 4 | # unless you really need them. 5 | debug: false 6 | 7 | # Use this to change the OCaml version used to run your code 8 | # on Codecrafters. 9 | # 10 | # Available versions: ocaml-5.3 11 | language_pack: ocaml-5.3 12 | -------------------------------------------------------------------------------- /solutions/ocaml/01-ry8/code/codecrafters_interpreter.opam: -------------------------------------------------------------------------------- 1 | # This file is generated by dune, edit dune-project instead 2 | opam-version: "2.0" 3 | version: "0.1" 4 | synopsis: "Starter code for the Build your own Interpreter challenge" 5 | maintainer: ["CodeCrafters "] 6 | authors: ["CodeCrafters "] 7 | license: "MIT" 8 | homepage: "https://codecrafters.io" 9 | bug-reports: 10 | "https://github.com/codecrafters-io/build-your-own-interpreter/issues" 11 | depends: [ 12 | "dune" {>= "3.16"} 13 | "lwt" 14 | "odoc" {with-doc} 15 | ] 16 | build: [ 17 | ["dune" "subst"] {dev} 18 | [ 19 | "dune" 20 | "build" 21 | "-p" 22 | name 23 | "-j" 24 | jobs 25 | "@install" 26 | "@runtest" {with-test} 27 | "@doc" {with-doc} 28 | ] 29 | ] 30 | -------------------------------------------------------------------------------- /solutions/ocaml/01-ry8/code/dune: -------------------------------------------------------------------------------- 1 | (include_subdirs unqualified) 2 | 3 | (executable 4 | (name main) 5 | (libraries lwt)) 6 | -------------------------------------------------------------------------------- /solutions/ocaml/01-ry8/code/dune-project: -------------------------------------------------------------------------------- 1 | (lang dune 3.16) 2 | 3 | (name codecrafters_interpreter) 4 | 5 | (generate_opam_files true) 6 | 7 | (package 8 | (name codecrafters_interpreter) 9 | (maintainers "CodeCrafters ") 10 | (authors "CodeCrafters ") 11 | (synopsis "Starter code for the Build your own Interpreter challenge") 12 | (homepage "https://codecrafters.io") 13 | (bug_reports 14 | "https://github.com/codecrafters-io/build-your-own-interpreter/issues") 15 | (license "MIT") 16 | (allow_empty true) 17 | (version 0.1) 18 | (depends lwt)) 19 | -------------------------------------------------------------------------------- /solutions/ocaml/01-ry8/code/src/main.ml: -------------------------------------------------------------------------------- 1 | let () = 2 | if Array.length Sys.argv < 3 then ( 3 | Printf.eprintf "Usage: ./your_program.sh tokenize \n"; 4 | exit 1); 5 | 6 | let command = Sys.argv.(1) in 7 | let filename = Sys.argv.(2) in 8 | 9 | if command <> "tokenize" then ( 10 | Printf.eprintf "Unknown command: %s\n" command; 11 | exit 1); 12 | 13 | let file_contents = In_channel.with_open_text filename In_channel.input_all in 14 | 15 | if String.length file_contents > 0 then 16 | (* Implement & use your scanner here *) 17 | failwith "Scanner not implemented" 18 | else 19 | print_endline "EOF null"; (* Placeholder, replace this line when implementing the scanner *) 20 | () 21 | -------------------------------------------------------------------------------- /solutions/ocaml/01-ry8/code/your_program.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Use this script to run your program LOCALLY. 4 | # 5 | # Note: Changing this script WILL NOT affect how CodeCrafters runs your program. 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | set -e # Exit early if any commands fail 10 | 11 | # Copied from .codecrafters/compile.sh 12 | # 13 | # - Edit this to change how your program compiles locally 14 | # - Edit .codecrafters/compile.sh to change how your program compiles remotely 15 | ( 16 | cd "$(dirname "$0")" # Ensure compile steps are run within the repository directory 17 | dune build --build-dir /tmp/codecrafters-build-interpreter-ocaml 18 | ) 19 | 20 | # Copied from .codecrafters/run.sh 21 | # 22 | # - Edit this to change how your program runs locally 23 | # - Edit .codecrafters/run.sh to change how your program runs remotely 24 | exec /tmp/codecrafters-build-interpreter-ocaml/default/main.exe "$@" 25 | -------------------------------------------------------------------------------- /solutions/ocaml/01-ry8/explanation.md: -------------------------------------------------------------------------------- 1 | The entry point for your Interpreter implementation is in `src/main.ml`. 2 | 3 | Study and uncomment the relevant code: 4 | 5 | ```ocaml 6 | (* Uncomment this block to pass the first stage *) 7 | print_endline "EOF null"; (* Placeholder, replace this line when implementing the scanner *) 8 | ``` 9 | 10 | Push your changes to pass the first stage: 11 | 12 | ``` 13 | git add . 14 | git commit -m "pass 1st stage" # any msg 15 | git push origin master 16 | ``` 17 | -------------------------------------------------------------------------------- /solutions/odin/01-ry8/code/.codecrafters/compile.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # This script is used to compile your program on CodeCrafters 4 | # 5 | # This runs before .codecrafters/run.sh 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | set -e # Exit on failure 10 | 11 | mkdir -p /tmp/codecrafters-build-interpreter-odin 12 | odin build src -out:/tmp/codecrafters-build-interpreter-odin/main -------------------------------------------------------------------------------- /solutions/odin/01-ry8/code/.codecrafters/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # This script is used to run your program on CodeCrafters 4 | # 5 | # This runs after .codecrafters/compile.sh 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | set -e # Exit on failure 10 | 11 | exec /tmp/codecrafters-build-interpreter-odin/main "$@" 12 | -------------------------------------------------------------------------------- /solutions/odin/01-ry8/code/.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | -------------------------------------------------------------------------------- /solutions/odin/01-ry8/code/codecrafters.yml: -------------------------------------------------------------------------------- 1 | # Set this to true if you want debug logs. 2 | # 3 | # These can be VERY verbose, so we suggest turning them off 4 | # unless you really need them. 5 | debug: false 6 | 7 | # Use this to change the Odin version used to run your code 8 | # on Codecrafters. 9 | # 10 | # Available versions: odin-2025.4 11 | language_pack: odin-2025.4 12 | -------------------------------------------------------------------------------- /solutions/odin/01-ry8/code/src/main.odin: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "core:os" 4 | import "core:fmt" 5 | import "core:strings" 6 | 7 | main :: proc() { 8 | if len(os.args) < 3 { 9 | fmt.eprintln("Usage: ./your_program.sh tokenize ") 10 | os.exit(1) 11 | } 12 | 13 | command := os.args[1] 14 | filename := os.args[2] 15 | 16 | if command != "tokenize" { 17 | fmt.eprintf("Unknown command: %s\n", command) 18 | os.exit(1) 19 | } 20 | 21 | file_contents, ok := os.read_entire_file(filename) 22 | if !ok { 23 | fmt.eprintf("Failed to read file: %s\n", filename) 24 | os.exit(1) 25 | } 26 | 27 | if len(file_contents) > 0 { 28 | panic("Scanner not implemented") 29 | } else { 30 | fmt.println("EOF null") // Placeholder, replace this line when implementing the scanner 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /solutions/odin/01-ry8/code/your_program.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Use this script to run your program LOCALLY. 4 | # 5 | # Note: Changing this script WILL NOT affect how CodeCrafters runs your program. 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | set -e # Exit early if any commands fail 10 | 11 | # Copied from .codecrafters/compile.sh 12 | # 13 | # - Edit this to change how your program compiles locally 14 | # - Edit .codecrafters/compile.sh to change how your program compiles remotely 15 | ( 16 | cd "$(dirname "$0")" # Ensure compile steps are run within the repository directory 17 | mkdir -p /tmp/codecrafters-build-interpreter-odin 18 | odin build src -out:/tmp/codecrafters-build-interpreter-odin/main 19 | ) 20 | 21 | # Copied from .codecrafters/run.sh 22 | # 23 | # - Edit this to change how your program runs locally 24 | # - Edit .codecrafters/run.sh to change how your program runs remotely 25 | exec /tmp/codecrafters-build-interpreter-odin/main "$@" 26 | -------------------------------------------------------------------------------- /solutions/odin/01-ry8/explanation.md: -------------------------------------------------------------------------------- 1 | The entry point for your Interpreter implementation is in `src/main.odin`. 2 | 3 | Study and uncomment the relevant code: 4 | 5 | ```odin 6 | // Uncomment this block to pass the first stage 7 | if len(file_contents) > 0 { 8 | panic("Scanner not implemented") 9 | } else { 10 | fmt.println("EOF null") // Placeholder, replace this line when implementing the scanner 11 | } 12 | ``` 13 | 14 | Push your changes to pass the first stage: 15 | 16 | ``` 17 | git add . 18 | git commit -m "pass 1st stage" # any msg 19 | git push origin master 20 | ``` 21 | -------------------------------------------------------------------------------- /solutions/php/01-ry8/code/.codecrafters/compile.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # This script is used to compile your program on CodeCrafters 4 | # 5 | # This runs before .codecrafters/run.sh 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | set -e # Exit on failure 10 | 11 | # (This file is empty since PHP programs don't use a compile step) -------------------------------------------------------------------------------- /solutions/php/01-ry8/code/.codecrafters/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # This script is used to run your program on CodeCrafters 4 | # 5 | # This runs after .codecrafters/compile.sh 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | set -e # Exit on failure 10 | 11 | exec php app/main.php "$@" 12 | -------------------------------------------------------------------------------- /solutions/php/01-ry8/code/.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | -------------------------------------------------------------------------------- /solutions/php/01-ry8/code/app/main.php: -------------------------------------------------------------------------------- 1 | \n"); 6 | exit(1); 7 | } 8 | 9 | $command = $argv[1]; 10 | $filename = $argv[2]; 11 | 12 | if ($command !== "tokenize") { 13 | fwrite(STDERR, "Unknown command: {$command}\n"); 14 | exit(1); 15 | } 16 | 17 | $file_contents = file_get_contents($filename); 18 | 19 | if ($file_contents) { 20 | throw new Exception("Scanner not implemented"); 21 | } else { 22 | echo "EOF null\n"; // Placeholder, replace this line when implementing the scanner 23 | } 24 | -------------------------------------------------------------------------------- /solutions/php/01-ry8/code/codecrafters.yml: -------------------------------------------------------------------------------- 1 | # Set this to true if you want debug logs. 2 | # 3 | # These can be VERY verbose, so we suggest turning them off 4 | # unless you really need them. 5 | debug: false 6 | 7 | # Use this to change the PHP version used to run your code 8 | # on Codecrafters. 9 | # 10 | # Available versions: php-8.4 11 | language_pack: php-8.4 12 | -------------------------------------------------------------------------------- /solutions/php/01-ry8/code/your_program.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Use this script to run your program LOCALLY. 4 | # 5 | # Note: Changing this script WILL NOT affect how CodeCrafters runs your program. 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | set -e # Exit early if any commands fail 10 | 11 | # Copied from .codecrafters/run.sh 12 | # 13 | # - Edit this to change how your program runs locally 14 | # - Edit .codecrafters/run.sh to change how your program runs remotely 15 | exec php app/main.php "$@" 16 | -------------------------------------------------------------------------------- /solutions/php/01-ry8/explanation.md: -------------------------------------------------------------------------------- 1 | The entry point for your Interpreter implementation is in `app/main.php`. 2 | 3 | Study and uncomment the relevant code: 4 | 5 | ```php 6 | // Uncomment this block to pass the first stage 7 | if ($file_contents) { 8 | throw new Exception("Scanner not implemented"); 9 | } else { 10 | echo "EOF null\n"; // Placeholder, replace this line when implementing the scanner 11 | } 12 | ``` 13 | 14 | Push your changes to pass the first stage: 15 | 16 | ``` 17 | git add . 18 | git commit -m "pass 1st stage" # any msg 19 | git push origin master 20 | ``` 21 | -------------------------------------------------------------------------------- /solutions/python/01-ry8/code/.codecrafters/compile.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # This script is used to compile your program on CodeCrafters 4 | # 5 | # This runs before .codecrafters/run.sh 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | # (This file is empty since Python programs don't use a compile step) 10 | -------------------------------------------------------------------------------- /solutions/python/01-ry8/code/.codecrafters/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # This script is used to run your program on CodeCrafters 4 | # 5 | # This runs after .codecrafters/compile.sh 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | exec pipenv run python3 -m app.main "$@" 10 | -------------------------------------------------------------------------------- /solutions/python/01-ry8/code/.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | -------------------------------------------------------------------------------- /solutions/python/01-ry8/code/Pipfile: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | 4 | [[source]] 5 | url = "https://pypi.org/simple" 6 | verify_ssl = true 7 | name = "pypi" 8 | 9 | [packages] 10 | 11 | [dev-packages] 12 | 13 | [requires] 14 | python_version = "3" 15 | -------------------------------------------------------------------------------- /solutions/python/01-ry8/code/Pipfile.lock: -------------------------------------------------------------------------------- 1 | { 2 | "_meta": { 3 | "hash": { 4 | "sha256": "4e61a4ba9e6f02f50f68627253af5ababd9b1b4c1e10294e48158e1f42c0c5a6" 5 | }, 6 | "pipfile-spec": 6, 7 | "requires": { 8 | "python_version": "3" 9 | }, 10 | "sources": [ 11 | { 12 | "name": "pypi", 13 | "url": "https://pypi.org/simple", 14 | "verify_ssl": true 15 | } 16 | ] 17 | }, 18 | "default": {}, 19 | "develop": {} 20 | } 21 | -------------------------------------------------------------------------------- /solutions/python/01-ry8/code/app/main.py: -------------------------------------------------------------------------------- 1 | import sys 2 | 3 | 4 | def main(): 5 | if len(sys.argv) < 3: 6 | print("Usage: ./your_program.sh tokenize ", file=sys.stderr) 7 | exit(1) 8 | 9 | command = sys.argv[1] 10 | filename = sys.argv[2] 11 | 12 | if command != "tokenize": 13 | print(f"Unknown command: {command}", file=sys.stderr) 14 | exit(1) 15 | 16 | with open(filename) as file: 17 | file_contents = file.read() 18 | 19 | if file_contents: 20 | raise NotImplementedError("Scanner not implemented") 21 | else: 22 | print("EOF null") # Placeholder, replace this line when implementing the scanner 23 | 24 | 25 | if __name__ == "__main__": 26 | main() 27 | -------------------------------------------------------------------------------- /solutions/python/01-ry8/code/codecrafters.yml: -------------------------------------------------------------------------------- 1 | # Set this to true if you want debug logs. 2 | # 3 | # These can be VERY verbose, so we suggest turning them off 4 | # unless you really need them. 5 | debug: false 6 | 7 | # Use this to change the Python version used to run your code 8 | # on Codecrafters. 9 | # 10 | # Available versions: python-3.13 11 | language_pack: python-3.13 12 | -------------------------------------------------------------------------------- /solutions/python/01-ry8/code/your_program.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Use this script to run your program LOCALLY. 4 | # 5 | # Note: Changing this script WILL NOT affect how CodeCrafters runs your program. 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | set -e # Exit early if any commands fail 10 | 11 | # Copied from .codecrafters/run.sh 12 | # 13 | # - Edit this to change how your program runs locally 14 | # - Edit .codecrafters/run.sh to change how your program runs remotely 15 | exec pipenv run python3 -m app.main "$@" 16 | -------------------------------------------------------------------------------- /solutions/python/01-ry8/explanation.md: -------------------------------------------------------------------------------- 1 | The entry point for your Interpreter implementation is in `app/main.py`. 2 | 3 | Study and uncomment the relevant code: 4 | 5 | ```python 6 | # Uncomment this block to pass the first stage 7 | if file_contents: 8 | raise NotImplementedError("Scanner not implemented") 9 | else: 10 | print("EOF null") # Placeholder, replace this line when implementing the scanner 11 | ``` 12 | 13 | Push your changes to pass the first stage: 14 | 15 | ``` 16 | git add . 17 | git commit -m "pass 1st stage" # any msg 18 | git push origin master 19 | ``` 20 | -------------------------------------------------------------------------------- /solutions/rust/01-ry8/code/.codecrafters/compile.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # This script is used to compile your program on CodeCrafters 4 | # 5 | # This runs before .codecrafters/run.sh 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | set -e # Exit on failure 10 | 11 | cargo build --release --target-dir=/tmp/codecrafters-build-interpreter-rust --manifest-path Cargo.toml 12 | -------------------------------------------------------------------------------- /solutions/rust/01-ry8/code/.codecrafters/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # This script is used to run your program on CodeCrafters 4 | # 5 | # This runs after .codecrafters/compile.sh 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | set -e # Exit on failure 10 | 11 | exec /tmp/codecrafters-build-interpreter-rust/release/codecrafters-interpreter "$@" 12 | -------------------------------------------------------------------------------- /solutions/rust/01-ry8/code/.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | -------------------------------------------------------------------------------- /solutions/rust/01-ry8/code/.gitignore: -------------------------------------------------------------------------------- 1 | # Generated by Cargo 2 | # will have compiled files and executables 3 | debug/ 4 | target/ 5 | 6 | # These are backup files generated by rustfmt 7 | **/*.rs.bk 8 | 9 | # MSVC Windows builds of rustc generate these, which store debugging information 10 | *.pdb 11 | -------------------------------------------------------------------------------- /solutions/rust/01-ry8/code/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "codecrafters-interpreter" 3 | version = "0.1.0" 4 | authors = ["Codecrafters "] 5 | edition = "2021" 6 | rust-version = "1.80" 7 | 8 | [dependencies] 9 | anyhow = "1.0.68" # error handling 10 | bytes = "1.3.0" # helps manage buffers 11 | thiserror = "1.0.38" # error handling 12 | -------------------------------------------------------------------------------- /solutions/rust/01-ry8/code/codecrafters.yml: -------------------------------------------------------------------------------- 1 | # Set this to true if you want debug logs. 2 | # 3 | # These can be VERY verbose, so we suggest turning them off 4 | # unless you really need them. 5 | debug: false 6 | 7 | # Use this to change the Rust version used to run your code 8 | # on Codecrafters. 9 | # 10 | # Available versions: rust-1.86 11 | language_pack: rust-1.86 12 | -------------------------------------------------------------------------------- /solutions/rust/01-ry8/code/your_program.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Use this script to run your program LOCALLY. 4 | # 5 | # Note: Changing this script WILL NOT affect how CodeCrafters runs your program. 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | set -e # Exit early if any commands fail 10 | 11 | # Copied from .codecrafters/compile.sh 12 | # 13 | # - Edit this to change how your program compiles locally 14 | # - Edit .codecrafters/compile.sh to change how your program compiles remotely 15 | ( 16 | cd "$(dirname "$0")" # Ensure compile steps are run within the repository directory 17 | cargo build --release --target-dir=/tmp/codecrafters-build-interpreter-rust --manifest-path Cargo.toml 18 | ) 19 | 20 | # Copied from .codecrafters/run.sh 21 | # 22 | # - Edit this to change how your program runs locally 23 | # - Edit .codecrafters/run.sh to change how your program runs remotely 24 | exec /tmp/codecrafters-build-interpreter-rust/release/codecrafters-interpreter "$@" 25 | -------------------------------------------------------------------------------- /solutions/rust/01-ry8/explanation.md: -------------------------------------------------------------------------------- 1 | The entry point for your Interpreter implementation is in `src/main.rs`. 2 | 3 | Study and uncomment the relevant code: 4 | 5 | ```rust 6 | // Uncomment this block to pass the first stage 7 | if !file_contents.is_empty() { 8 | panic!("Scanner not implemented"); 9 | } else { 10 | println!("EOF null"); // Placeholder, replace this line when implementing the scanner 11 | } 12 | ``` 13 | 14 | Push your changes to pass the first stage: 15 | 16 | ``` 17 | git add . 18 | git commit -m "pass 1st stage" # any msg 19 | git push origin master 20 | ``` 21 | -------------------------------------------------------------------------------- /solutions/swift/01-ry8/code/.codecrafters/compile.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # This script is used to compile your program on CodeCrafters 4 | # 5 | # This runs before .codecrafters/run.sh 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | set -e # Exit on failure 10 | 11 | swift build -c release --build-path /tmp/codecrafters-build-interpreter-swift 12 | -------------------------------------------------------------------------------- /solutions/swift/01-ry8/code/.codecrafters/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # This script is used to run your program on CodeCrafters 4 | # 5 | # This runs after .codecrafters/compile.sh 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | set -e # Exit on failure 10 | 11 | exec swift run -c release --skip-build --build-path /tmp/codecrafters-build-interpreter-swift build-your-own-interpreter "$@" 12 | -------------------------------------------------------------------------------- /solutions/swift/01-ry8/code/.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | -------------------------------------------------------------------------------- /solutions/swift/01-ry8/code/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .build 3 | Packages 4 | xcuserdata/ 5 | DerivedData/ 6 | .swiftpm/configuration/registries.json 7 | .swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata 8 | .netrc -------------------------------------------------------------------------------- /solutions/swift/01-ry8/code/Package.swift: -------------------------------------------------------------------------------- 1 | // swift-tools-version: 6.0 2 | // The swift-tools-version declares the minimum version of Swift required to build this package. 3 | 4 | import PackageDescription 5 | 6 | let package = Package( 7 | name: "build-your-own-interpreter", 8 | targets: [ 9 | // Targets are the basic building blocks of a package, defining a module or a test suite. 10 | // Targets can depend on other targets in this package and products from dependencies. 11 | .executableTarget( 12 | name: "build-your-own-interpreter"), 13 | ] 14 | ) -------------------------------------------------------------------------------- /solutions/swift/01-ry8/code/Sources/main.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | guard CommandLine.argc == 3 else { 4 | print("Usage: ./your_program.sh tokenize ") 5 | exit(1) 6 | } 7 | 8 | let command = CommandLine.arguments[1] 9 | let filename = CommandLine.arguments[2] 10 | 11 | guard command == "tokenize" else { 12 | print("Unknown command: \(command)") 13 | exit(1) 14 | } 15 | 16 | let fileContents: String 17 | do { 18 | fileContents = try String(contentsOfFile: filename, encoding: .utf8) 19 | } catch { 20 | print("Error reading file: \(filename) with error: \(error.localizedDescription)") 21 | exit(1) 22 | } 23 | 24 | if fileContents.isEmpty { 25 | print("EOF null") 26 | } else { 27 | print("Scanner not implemented") 28 | exit(1) 29 | } 30 | -------------------------------------------------------------------------------- /solutions/swift/01-ry8/code/codecrafters.yml: -------------------------------------------------------------------------------- 1 | # Set this to true if you want debug logs. 2 | # 3 | # These can be VERY verbose, so we suggest turning them off 4 | # unless you really need them. 5 | debug: false 6 | 7 | # Use this to change the Swift version used to run your code 8 | # on Codecrafters. 9 | # 10 | # Available versions: swift-6.0 11 | language_pack: swift-6.0 12 | -------------------------------------------------------------------------------- /solutions/swift/01-ry8/code/your_program.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Use this script to run your program LOCALLY. 4 | # 5 | # Note: Changing this script WILL NOT affect how CodeCrafters runs your program. 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | set -e # Exit early if any commands fail 10 | 11 | # Copied from .codecrafters/compile.sh 12 | # 13 | # - Edit this to change how your program compiles locally 14 | # - Edit .codecrafters/compile.sh to change how your program compiles remotely 15 | ( 16 | cd "$(dirname "$0")" # Ensure compile steps are run within the repository directory 17 | swift build -c release --build-path /tmp/codecrafters-build-interpreter-swift 18 | ) 19 | 20 | # Copied from .codecrafters/run.sh 21 | # 22 | # - Edit this to change how your program runs locally 23 | # - Edit .codecrafters/run.sh to change how your program runs remotely 24 | exec swift run -c release --skip-build --build-path /tmp/codecrafters-build-interpreter-swift build-your-own-interpreter "$@" 25 | -------------------------------------------------------------------------------- /solutions/swift/01-ry8/explanation.md: -------------------------------------------------------------------------------- 1 | The entry point for your Interpreter implementation is in `Sources/main.swift`. 2 | 3 | Study and uncomment the relevant code: 4 | 5 | ```swift 6 | // Uncomment this block to pass the first stage 7 | if fileContents.isEmpty { 8 | print("EOF null") 9 | } else { 10 | print("Scanner not implemented") 11 | exit(1) 12 | } 13 | ``` 14 | 15 | Push your changes to pass the first stage: 16 | 17 | ``` 18 | git add . 19 | git commit -m "pass 1st stage" # any msg 20 | git push origin master 21 | ``` 22 | -------------------------------------------------------------------------------- /solutions/typescript/01-ry8/code/.codecrafters/compile.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # This script is used to compile your program on CodeCrafters 4 | # 5 | # This runs before .codecrafters/run.sh 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | set -e # Exit on failure 10 | 11 | # (This file is empty since TypeScript programs don't use a compile step) 12 | -------------------------------------------------------------------------------- /solutions/typescript/01-ry8/code/.codecrafters/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # This script is used to run your program on CodeCrafters 4 | # 5 | # This runs after .codecrafters/compile.sh 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | set -e # Exit on failure 10 | 11 | exec bun run "$(dirname "$0")/app/main.ts" "$@" 12 | -------------------------------------------------------------------------------- /solutions/typescript/01-ry8/code/.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | -------------------------------------------------------------------------------- /solutions/typescript/01-ry8/code/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | -------------------------------------------------------------------------------- /solutions/typescript/01-ry8/code/app/main.ts: -------------------------------------------------------------------------------- 1 | import fs from "fs"; 2 | 3 | const args: string[] = process.argv.slice(2); // Skip the first two arguments (node path and script path) 4 | 5 | if (args.length < 2) { 6 | console.error("Usage: ./your_program.sh tokenize "); 7 | process.exit(1); 8 | } 9 | 10 | const command: string = args[0]; 11 | 12 | if (command !== "tokenize") { 13 | console.error(`Usage: Unknown command: ${command}`); 14 | process.exit(1); 15 | } 16 | 17 | const filename: string = args[1]; 18 | 19 | const fileContent: string = fs.readFileSync(filename, "utf8"); 20 | 21 | if (fileContent.length !== 0) { 22 | throw new Error("Scanner not implemented"); 23 | } else { 24 | console.log("EOF null"); 25 | } 26 | -------------------------------------------------------------------------------- /solutions/typescript/01-ry8/code/codecrafters.yml: -------------------------------------------------------------------------------- 1 | # Set this to true if you want debug logs. 2 | # 3 | # These can be VERY verbose, so we suggest turning them off 4 | # unless you really need them. 5 | debug: false 6 | 7 | # Use this to change the TypeScript version used to run your code 8 | # on Codecrafters. 9 | # 10 | # Available versions: bun-1.2 11 | language_pack: bun-1.2 12 | -------------------------------------------------------------------------------- /solutions/typescript/01-ry8/code/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@codecrafters/interpreter", 3 | "description": "Build your own Interpreter challenge, from CodeCrafters", 4 | "type": "module", 5 | "scripts": { 6 | "dev": "bun run app/main.ts" 7 | }, 8 | "devDependencies": { 9 | "@types/bun": "latest" 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /solutions/typescript/01-ry8/code/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | // Enable latest features 4 | "lib": ["ESNext", "DOM"], 5 | "target": "ESNext", 6 | "module": "ESNext", 7 | "moduleDetection": "force", 8 | "jsx": "react-jsx", 9 | "allowJs": true, 10 | 11 | // Bundler mode 12 | "moduleResolution": "bundler", 13 | "allowImportingTsExtensions": true, 14 | "verbatimModuleSyntax": true, 15 | "noEmit": true, 16 | 17 | // Best practices 18 | "strict": true, 19 | "skipLibCheck": true, 20 | "noFallthroughCasesInSwitch": true, 21 | 22 | // Some stricter flags (disabled by default) 23 | "noUnusedLocals": false, 24 | "noUnusedParameters": false, 25 | "noPropertyAccessFromIndexSignature": false 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /solutions/typescript/01-ry8/code/your_program.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Use this script to run your program LOCALLY. 4 | # 5 | # Note: Changing this script WILL NOT affect how CodeCrafters runs your program. 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | set -e # Exit early if any commands fail 10 | 11 | # Copied from .codecrafters/run.sh 12 | # 13 | # - Edit this to change how your program runs locally 14 | # - Edit .codecrafters/run.sh to change how your program runs remotely 15 | exec bun run "$(dirname "$0")/app/main.ts" "$@" 16 | -------------------------------------------------------------------------------- /solutions/typescript/01-ry8/explanation.md: -------------------------------------------------------------------------------- 1 | The entry point for your Interpreter implementation is in `app/main.ts`. 2 | 3 | Study and uncomment the relevant code: 4 | 5 | ```typescript 6 | // Uncomment this block to pass the first stage 7 | 8 | const fileContent: string = fs.readFileSync(filename, "utf8"); 9 | 10 | if (fileContent.length !== 0) { 11 | throw new Error("Scanner not implemented"); 12 | } else { 13 | console.log("EOF null"); 14 | } 15 | ``` 16 | 17 | Push your changes to pass the first stage: 18 | 19 | ``` 20 | git add . 21 | git commit -m "pass 1st stage" # any msg 22 | git push origin master 23 | ``` 24 | -------------------------------------------------------------------------------- /solutions/zig/01-ry8/code/.codecrafters/compile.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # This script is used to compile your program on CodeCrafters 4 | # 5 | # This runs before .codecrafters/run.sh 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | set -e # Exit on failure 10 | 11 | zig build 12 | -------------------------------------------------------------------------------- /solutions/zig/01-ry8/code/.codecrafters/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # This script is used to run your program on CodeCrafters 4 | # 5 | # This runs after .codecrafters/compile.sh 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | set -e # Exit on failure 10 | 11 | exec $(dirname $0)/zig-out/bin/main "$@" 12 | -------------------------------------------------------------------------------- /solutions/zig/01-ry8/code/.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | -------------------------------------------------------------------------------- /solutions/zig/01-ry8/code/.gitignore: -------------------------------------------------------------------------------- 1 | # Zig build artifacts 2 | main 3 | zig-cache/ 4 | .zig-cache/ 5 | zig-out/ 6 | 7 | # Compiled binary output 8 | bin/ 9 | !bin/.gitkeep 10 | 11 | # Ignore any .o or .h files generated during build 12 | *.o 13 | *.h 14 | 15 | # Ignore OS and editor specific files 16 | **/.DS_Store 17 | *.swp 18 | *~ 19 | -------------------------------------------------------------------------------- /solutions/zig/01-ry8/code/codecrafters.yml: -------------------------------------------------------------------------------- 1 | # Set this to true if you want debug logs. 2 | # 3 | # These can be VERY verbose, so we suggest turning them off 4 | # unless you really need them. 5 | debug: false 6 | 7 | # Use this to change the Zig version used to run your code 8 | # on Codecrafters. 9 | # 10 | # Available versions: zig-0.14 11 | language_pack: zig-0.14 12 | -------------------------------------------------------------------------------- /solutions/zig/01-ry8/code/your_program.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Use this script to run your program LOCALLY. 4 | # 5 | # Note: Changing this script WILL NOT affect how CodeCrafters runs your program. 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | set -e # Exit early if any commands fail 10 | 11 | # Copied from .codecrafters/compile.sh 12 | # 13 | # - Edit this to change how your program compiles locally 14 | # - Edit .codecrafters/compile.sh to change how your program compiles remotely 15 | ( 16 | cd "$(dirname "$0")" # Ensure compile steps are run within the repository directory 17 | zig build 18 | ) 19 | 20 | # Copied from .codecrafters/run.sh 21 | # 22 | # - Edit this to change how your program runs locally 23 | # - Edit .codecrafters/run.sh to change how your program runs remotely 24 | exec $(dirname $0)/zig-out/bin/main "$@" 25 | -------------------------------------------------------------------------------- /solutions/zig/01-ry8/explanation.md: -------------------------------------------------------------------------------- 1 | The entry point for your Interpreter implementation is in `src/main.zig`. 2 | 3 | Study and uncomment the relevant code: 4 | 5 | ```zig 6 | // Uncomment this block to pass the first stage 7 | if (file_contents.len > 0) { 8 | @panic("Scanner not implemented"); 9 | } else { 10 | try std.io.getStdOut().writer().print("EOF null\n", .{}); // Placeholder, replace this line when implementing the scanner 11 | } 12 | ``` 13 | 14 | Push your changes to pass the first stage: 15 | 16 | ``` 17 | git add . 18 | git commit -m "pass 1st stage" # any msg 19 | git push origin master 20 | ``` 21 | -------------------------------------------------------------------------------- /starter_templates/all/code/.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | -------------------------------------------------------------------------------- /starter_templates/all/code/codecrafters.yml: -------------------------------------------------------------------------------- 1 | # Set this to true if you want debug logs. 2 | # 3 | # These can be VERY verbose, so we suggest turning them off 4 | # unless you really need them. 5 | debug: false 6 | 7 | # Use this to change the {{language_name}} version used to run your code 8 | # on Codecrafters. 9 | # 10 | # Available versions: {{language_pack_with_version}} 11 | language_pack: {{language_pack_with_version}} 12 | -------------------------------------------------------------------------------- /starter_templates/c/code/.codecrafters/compile.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # This script is used to compile your program on CodeCrafters 4 | # 5 | # This runs before .codecrafters/run.sh 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | set -e # Exit on failure 10 | 11 | cmake -B build -S . -DCMAKE_TOOLCHAIN_FILE=${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake 12 | cmake --build ./build 13 | -------------------------------------------------------------------------------- /starter_templates/c/code/.codecrafters/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # This script is used to run your program on CodeCrafters 4 | # 5 | # This runs after .codecrafters/compile.sh 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | set -e # Exit on failure 10 | 11 | exec $(dirname $0)/build/interpreter "$@" 12 | -------------------------------------------------------------------------------- /starter_templates/c/code/.gitignore: -------------------------------------------------------------------------------- 1 | # Prerequisites 2 | *.d 3 | 4 | # Object files 5 | *.o 6 | *.ko 7 | *.obj 8 | *.elf 9 | 10 | # Linker output 11 | *.ilk 12 | *.map 13 | *.exp 14 | 15 | # Precompiled Headers 16 | *.gch 17 | *.pch 18 | 19 | # Libraries 20 | *.lib 21 | *.a 22 | *.la 23 | *.lo 24 | 25 | # Shared objects (inc. Windows DLLs) 26 | *.dll 27 | *.so 28 | *.so.* 29 | *.dylib 30 | 31 | # Executables 32 | *.exe 33 | *.out 34 | *.app 35 | *.i*86 36 | *.x86_64 37 | *.hex 38 | 39 | # Debug files 40 | *.dSYM/ 41 | *.su 42 | *.idb 43 | *.pdb 44 | 45 | # Kernel Module Compile Results 46 | *.mod* 47 | *.cmd 48 | .tmp_versions/ 49 | modules.order 50 | Module.symvers 51 | Mkfile.old 52 | dkms.conf 53 | 54 | build 55 | vcpkg_installed -------------------------------------------------------------------------------- /starter_templates/c/code/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.13) 2 | 3 | project(codecrafters-interpreter) 4 | 5 | file(GLOB_RECURSE SOURCE_FILES src/*.c src/*.h) 6 | 7 | set(CMAKE_C_STANDARD 23) # Enable the C23 standard 8 | 9 | add_executable(interpreter ${SOURCE_FILES}) 10 | -------------------------------------------------------------------------------- /starter_templates/c/code/vcpkg-configuration.json: -------------------------------------------------------------------------------- 1 | { 2 | "default-registry": { 3 | "kind": "git", 4 | "baseline": "c4af3593e1f1aa9e14a560a09e45ea2cb0dfd74d", 5 | "repository": "https://github.com/microsoft/vcpkg" 6 | }, 7 | "registries": [ 8 | { 9 | "kind": "artifact", 10 | "location": "https://github.com/microsoft/vcpkg-ce-catalog/archive/refs/heads/main.zip", 11 | "name": "microsoft" 12 | } 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /starter_templates/c/code/vcpkg.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": [] 3 | } 4 | -------------------------------------------------------------------------------- /starter_templates/c/config.yml: -------------------------------------------------------------------------------- 1 | attributes: 2 | required_executable: "gcc" 3 | user_editable_file: "src/main.c" 4 | -------------------------------------------------------------------------------- /starter_templates/cpp/code/.codecrafters/compile.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # This script is used to compile your program on CodeCrafters 4 | # 5 | # This runs before .codecrafters/run.sh 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | set -e # Exit on failure 10 | 11 | cmake -B build -S . -DCMAKE_TOOLCHAIN_FILE=${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake 12 | cmake --build ./build 13 | -------------------------------------------------------------------------------- /starter_templates/cpp/code/.codecrafters/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # This script is used to run your program on CodeCrafters 4 | # 5 | # This runs after .codecrafters/compile.sh 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | set -e # Exit on failure 10 | 11 | exec $(dirname $0)/build/interpreter "$@" 12 | -------------------------------------------------------------------------------- /starter_templates/cpp/code/.gitignore: -------------------------------------------------------------------------------- 1 | # Prerequisites 2 | *.d 3 | 4 | # Object files 5 | *.o 6 | *.ko 7 | *.obj 8 | *.elf 9 | 10 | # Linker output 11 | *.ilk 12 | *.map 13 | *.exp 14 | 15 | # Precompiled Headers 16 | *.gch 17 | *.pch 18 | 19 | # Libraries 20 | *.lib 21 | *.a 22 | *.la 23 | *.lo 24 | 25 | # Shared objects (inc. Windows DLLs) 26 | *.dll 27 | *.so 28 | *.so.* 29 | *.dylib 30 | 31 | # Executables 32 | *.exe 33 | *.out 34 | *.app 35 | *.i*86 36 | *.x86_64 37 | *.hex 38 | 39 | # Debug files 40 | *.dSYM/ 41 | *.su 42 | *.idb 43 | *.pdb 44 | 45 | # Kernel Module Compile Results 46 | *.mod* 47 | *.cmd 48 | .tmp_versions/ 49 | modules.order 50 | Module.symvers 51 | Mkfile.old 52 | dkms.conf 53 | 54 | build 55 | vcpkg_installed -------------------------------------------------------------------------------- /starter_templates/cpp/code/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.13) 2 | 3 | project(codecrafters-interpreter) 4 | 5 | set(CMAKE_CXX_STANDARD 23) # Enable the C++23 standard 6 | 7 | file(GLOB_RECURSE SOURCE_FILES src/*.cpp src/*.hpp) 8 | 9 | add_executable(interpreter ${SOURCE_FILES}) -------------------------------------------------------------------------------- /starter_templates/cpp/code/vcpkg-configuration.json: -------------------------------------------------------------------------------- 1 | { 2 | "default-registry": { 3 | "kind": "git", 4 | "baseline": "c4af3593e1f1aa9e14a560a09e45ea2cb0dfd74d", 5 | "repository": "https://github.com/microsoft/vcpkg" 6 | }, 7 | "registries": [ 8 | { 9 | "kind": "artifact", 10 | "location": "https://github.com/microsoft/vcpkg-ce-catalog/archive/refs/heads/main.zip", 11 | "name": "microsoft" 12 | } 13 | ] 14 | } -------------------------------------------------------------------------------- /starter_templates/cpp/code/vcpkg.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": [] 3 | } -------------------------------------------------------------------------------- /starter_templates/cpp/config.yml: -------------------------------------------------------------------------------- 1 | attributes: 2 | required_executable: cmake 3 | user_editable_file: src/main.cpp 4 | -------------------------------------------------------------------------------- /starter_templates/csharp/code/.codecrafters/compile.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # This script is used to compile your program on CodeCrafters 4 | # 5 | # This runs before .codecrafters/run.sh 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | set -e # Exit on failure 10 | 11 | dotnet build --configuration Release --output /tmp/codecrafters-build-csharp codecrafters-interpreter.csproj 12 | -------------------------------------------------------------------------------- /starter_templates/csharp/code/.codecrafters/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # This script is used to run your program on CodeCrafters 4 | # 5 | # This runs after .codecrafters/compile.sh 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | set -e # Exit on failure 10 | 11 | exec /tmp/codecrafters-build-csharp/codecrafters-interpreter "$@" 12 | -------------------------------------------------------------------------------- /starter_templates/csharp/code/codecrafters-interpreter.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net9.0 6 | codecrafters-interpreter 7 | enable 8 | enable 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /starter_templates/csharp/code/src/main.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | 4 | if (args.Length < 2) 5 | { 6 | Console.Error.WriteLine("Usage: ./your_program.sh tokenize "); 7 | Environment.Exit(1); 8 | } 9 | 10 | string command = args[0]; 11 | string filename = args[1]; 12 | 13 | if (command != "tokenize") 14 | { 15 | Console.Error.WriteLine($"Unknown command: {command}"); 16 | Environment.Exit(1); 17 | } 18 | 19 | string fileContents = File.ReadAllText(filename); 20 | 21 | // You can use print statements as follows for debugging, they'll be visible when running tests. 22 | Console.Error.WriteLine("Logs from your program will appear here!"); 23 | 24 | // Uncomment this block to pass the first stage 25 | // if (!string.IsNullOrEmpty(fileContents)) 26 | // { 27 | // throw new NotImplementedException("Scanner not implemented"); 28 | // } 29 | // else 30 | // { 31 | // Console.WriteLine("EOF null"); // Placeholder, replace this line when implementing the scanner 32 | // } 33 | -------------------------------------------------------------------------------- /starter_templates/csharp/config.yml: -------------------------------------------------------------------------------- 1 | attributes: 2 | required_executable: dotnet (9.0) 3 | user_editable_file: src/main.cs 4 | -------------------------------------------------------------------------------- /starter_templates/elixir/code/.codecrafters/compile.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # This script is used to compile your program on CodeCrafters 4 | # 5 | # This runs before .codecrafters/run.sh 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | set -e # Exit on failure 10 | 11 | mix escript.build 12 | mv codecrafters_interpreter /tmp/codecrafters-build-interpreter-elixir 13 | -------------------------------------------------------------------------------- /starter_templates/elixir/code/.codecrafters/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # This script is used to run your program on CodeCrafters 4 | # 5 | # This runs after .codecrafters/compile.sh 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | set -e # Exit on failure 10 | 11 | exec /tmp/codecrafters-build-interpreter-elixir "$@" 12 | -------------------------------------------------------------------------------- /starter_templates/elixir/code/.formatter.exs: -------------------------------------------------------------------------------- 1 | # Used by "mix format" 2 | [ 3 | inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"] 4 | ] 5 | -------------------------------------------------------------------------------- /starter_templates/elixir/code/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore the compiled binary 2 | /codecrafters_interpreter 3 | 4 | # The directory Mix will write compiled artifacts to. 5 | /_build/ 6 | 7 | # If you run "mix test --cover", coverage assets end up here. 8 | /cover/ 9 | 10 | # The directory Mix downloads your dependencies sources to. 11 | /deps/ 12 | 13 | # Where third-party dependencies like ExDoc output generated docs. 14 | /doc/ 15 | 16 | # Ignore .fetch files in case you like to edit your project deps locally. 17 | /.fetch 18 | 19 | # If the VM crashes, it generates a dump, let's ignore it too. 20 | erl_crash.dump 21 | 22 | # Also ignore archive artifacts (built via "mix archive.build"). 23 | *.ez 24 | 25 | # Ignore package tarball (built via "mix hex.build"). 26 | app-*.tar 27 | 28 | -------------------------------------------------------------------------------- /starter_templates/elixir/code/mix.exs: -------------------------------------------------------------------------------- 1 | defmodule App.MixProject do 2 | # NOTE: You do not need to change anything in this file. 3 | use Mix.Project 4 | 5 | def project do 6 | [ 7 | app: :codecrafters_interpreter, 8 | version: "1.0.0", 9 | elixir: "~> 1.18", 10 | start_permanent: Mix.env() == :prod, 11 | deps: deps(), 12 | escript: [main_module: CLI] 13 | ] 14 | end 15 | 16 | # Run "mix help compile.app" to learn about applications. 17 | def application do 18 | [ 19 | extra_applications: [:logger] 20 | ] 21 | end 22 | 23 | # Run "mix help deps" to learn about dependencies. 24 | defp deps do 25 | [ 26 | # {:dep_from_hexpm, "~> 0.3.0"}, 27 | # {:dep_from_git, git: "https://github.com/elixir-lang/my_dep.git", tag: "0.1.0"} 28 | ] 29 | end 30 | end 31 | -------------------------------------------------------------------------------- /starter_templates/elixir/config.yml: -------------------------------------------------------------------------------- 1 | attributes: 2 | required_executable: "mix" 3 | user_editable_file: "lib/main.ex" 4 | -------------------------------------------------------------------------------- /starter_templates/gleam/code/.codecrafters/compile.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # This script is used to compile your program on CodeCrafters 4 | # 5 | # This runs before .codecrafters/run.sh 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | set -e # Exit on failure 10 | 11 | gleam build 12 | -------------------------------------------------------------------------------- /starter_templates/gleam/code/.codecrafters/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # This script is used to run your program on CodeCrafters 4 | # 5 | # This runs after .codecrafters/compile.sh 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | set -e # Exit on failure 10 | 11 | exec gleam run --module main -- "$@" 12 | -------------------------------------------------------------------------------- /starter_templates/gleam/code/.gitignore: -------------------------------------------------------------------------------- 1 | *.beam 2 | *.ez 3 | /build 4 | erl_crash.dump 5 | -------------------------------------------------------------------------------- /starter_templates/gleam/code/gleam.toml: -------------------------------------------------------------------------------- 1 | name = "codecrafters_interpreter" 2 | version = "1.0.0" 3 | 4 | # For a full reference of all the available options, you can have a look at 5 | # https://gleam.run/writing-gleam/gleam-toml/. 6 | 7 | [dependencies] 8 | gleam_stdlib = "~> 0.34 or ~> 1.0" 9 | simplifile = ">= 2.0.1 and < 3.0.0" 10 | gleam_erlang = ">= 0.25.0 and < 1.0.0" 11 | argv = ">= 1.0.2 and < 2.0.0" 12 | 13 | [dev-dependencies] 14 | gleeunit = "~> 1.0" 15 | -------------------------------------------------------------------------------- /starter_templates/gleam/config.yml: -------------------------------------------------------------------------------- 1 | attributes: 2 | required_executable: gleam (1.9.1) 3 | user_editable_file: src/main.gleam 4 | -------------------------------------------------------------------------------- /starter_templates/go/code/.codecrafters/compile.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # This script is used to compile your program on CodeCrafters 4 | # 5 | # This runs before .codecrafters/run.sh 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | set -e # Exit on failure 10 | 11 | go build -o /tmp/codecrafters-build-interpreter-go app/*.go 12 | -------------------------------------------------------------------------------- /starter_templates/go/code/.codecrafters/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # This script is used to run your program on CodeCrafters 4 | # 5 | # This runs after .codecrafters/compile.sh 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | set -e # Exit on failure 10 | 11 | exec /tmp/codecrafters-build-interpreter-go "$@" 12 | -------------------------------------------------------------------------------- /starter_templates/go/code/go.mod: -------------------------------------------------------------------------------- 1 | 2 | module github.com/codecrafters-io/interpreter-starter-go 3 | 4 | go 1.24.0 5 | -------------------------------------------------------------------------------- /starter_templates/go/code/go.sum: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codecrafters-io/build-your-own-interpreter/10de14d10190fdb9daa22963094d47e606ad5e66/starter_templates/go/code/go.sum -------------------------------------------------------------------------------- /starter_templates/go/config.yml: -------------------------------------------------------------------------------- 1 | attributes: 2 | required_executable: go (1.24) 3 | user_editable_file: app/main.go 4 | -------------------------------------------------------------------------------- /starter_templates/java/code/.codecrafters/compile.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # This script is used to compile your program on CodeCrafters 4 | # 5 | # This runs before .codecrafters/run.sh 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | set -e # Exit on failure 10 | 11 | mvn -B package -Ddir=/tmp/codecrafters-build-interpreter-java 12 | -------------------------------------------------------------------------------- /starter_templates/java/code/.codecrafters/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # This script is used to run your program on CodeCrafters 4 | # 5 | # This runs after .codecrafters/compile.sh 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | set -e # Exit on failure 10 | 11 | exec java -jar /tmp/codecrafters-build-interpreter-java/codecrafters-interpreter.jar "$@" 12 | -------------------------------------------------------------------------------- /starter_templates/java/code/.gitignore: -------------------------------------------------------------------------------- 1 | *.jar 2 | target/ 3 | .idea/ 4 | -------------------------------------------------------------------------------- /starter_templates/java/config.yml: -------------------------------------------------------------------------------- 1 | attributes: 2 | required_executable: mvn 3 | user_editable_file: src/main/java/Main.java 4 | -------------------------------------------------------------------------------- /starter_templates/javascript/code/.codecrafters/compile.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # This script is used to compile your program on CodeCrafters 4 | # 5 | # This runs before .codecrafters/run.sh 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | set -e # Exit on failure 10 | 11 | # (This file is empty since JavaScript programs don't use a compile step) 12 | -------------------------------------------------------------------------------- /starter_templates/javascript/code/.codecrafters/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # This script is used to run your program on CodeCrafters 4 | # 5 | # This runs after .codecrafters/compile.sh 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | set -e # Exit on failure 10 | 11 | exec node app/main.js "$@" 12 | -------------------------------------------------------------------------------- /starter_templates/javascript/code/.gitignore: -------------------------------------------------------------------------------- 1 | # Dependency directories 2 | node_modules/ -------------------------------------------------------------------------------- /starter_templates/javascript/code/app/main.js: -------------------------------------------------------------------------------- 1 | import fs from "fs"; 2 | 3 | const args = process.argv.slice(2); // Skip the first two arguments (node path and script path) 4 | 5 | if (args.length < 2) { 6 | console.error("Usage: ./your_program.sh tokenize "); 7 | process.exit(1); 8 | } 9 | 10 | const command = args[0]; 11 | 12 | if (command !== "tokenize") { 13 | console.error(`Usage: Unknown command: ${command}`); 14 | process.exit(1); 15 | } 16 | 17 | // You can use print statements as follows for debugging, they'll be visible when running tests. 18 | console.error("Logs from your program will appear here!"); 19 | 20 | const filename = args[1]; 21 | 22 | // Uncomment this block to pass the first stage 23 | // 24 | // const fileContent = fs.readFileSync(filename, "utf8"); 25 | // 26 | // if (fileContent.length !== 0) { 27 | // throw new Error("Scanner not implemented"); 28 | // } else { 29 | // console.log("EOF null"); 30 | // } 31 | -------------------------------------------------------------------------------- /starter_templates/javascript/code/package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@codecrafters/interpreter", 3 | "version": "1.0.0", 4 | "lockfileVersion": 3, 5 | "requires": true, 6 | "packages": { 7 | "": { 8 | "name": "@codecrafters/interpreter", 9 | "version": "1.0.0" 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /starter_templates/javascript/code/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@codecrafters/interpreter", 3 | "version": "1.0.0", 4 | "type": "module", 5 | "dependencies": {} 6 | } 7 | -------------------------------------------------------------------------------- /starter_templates/javascript/config.yml: -------------------------------------------------------------------------------- 1 | attributes: 2 | required_executable: node (21) 3 | user_editable_file: app/main.js 4 | -------------------------------------------------------------------------------- /starter_templates/kotlin/code/.codecrafters/compile.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # This script is used to compile your program on CodeCrafters 4 | # 5 | # This runs before .codecrafters/run.sh 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | set -e # Exit on failure 10 | 11 | mvn -B package -Ddir=/tmp/codecrafters-build-dir 12 | -------------------------------------------------------------------------------- /starter_templates/kotlin/code/.codecrafters/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # This script is used to run your program on CodeCrafters 4 | # 5 | # This runs after .codecrafters/compile.sh 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | set -e # Exit on failure 10 | 11 | exec java -jar /tmp/codecrafters-build-dir/build-your-own-interpreter.jar "$@" 12 | -------------------------------------------------------------------------------- /starter_templates/kotlin/code/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | .idea/ -------------------------------------------------------------------------------- /starter_templates/kotlin/config.yml: -------------------------------------------------------------------------------- 1 | attributes: 2 | required_executable: "kotlin (>=2.0)" 3 | user_editable_file: src/main/kotlin/Main.kt 4 | -------------------------------------------------------------------------------- /starter_templates/ocaml/code/.codecrafters/compile.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # This script is used to compile your program on CodeCrafters 4 | # 5 | # This runs before .codecrafters/run.sh 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | set -e # Exit on failure 10 | 11 | dune build --build-dir /tmp/codecrafters-build-interpreter-ocaml 12 | -------------------------------------------------------------------------------- /starter_templates/ocaml/code/.codecrafters/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # This script is used to run your program on CodeCrafters 4 | # 5 | # This runs after .codecrafters/compile.sh 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | set -e # Exit on failure 10 | 11 | exec /tmp/codecrafters-build-interpreter-ocaml/default/main.exe "$@" 12 | -------------------------------------------------------------------------------- /starter_templates/ocaml/code/.gitignore: -------------------------------------------------------------------------------- 1 | *.annot 2 | *.cmo 3 | *.cma 4 | *.cmi 5 | *.a 6 | *.o 7 | *.cmx 8 | *.cmxs 9 | *.cmxa 10 | 11 | # ocamlbuild working directory 12 | _build/ 13 | 14 | # ocamlbuild targets 15 | *.byte 16 | *.native 17 | 18 | # oasis generated files 19 | setup.data 20 | setup.log 21 | 22 | # Merlin configuring file for Vim and Emacs 23 | .merlin 24 | 25 | # Dune generated files 26 | *.install 27 | 28 | # Local OPAM switch 29 | _opam/ -------------------------------------------------------------------------------- /starter_templates/ocaml/code/.ocamlformat: -------------------------------------------------------------------------------- 1 | profile = default -------------------------------------------------------------------------------- /starter_templates/ocaml/code/codecrafters_interpreter.opam: -------------------------------------------------------------------------------- 1 | # This file is generated by dune, edit dune-project instead 2 | opam-version: "2.0" 3 | version: "0.1" 4 | synopsis: "Starter code for the Build your own Interpreter challenge" 5 | maintainer: ["CodeCrafters "] 6 | authors: ["CodeCrafters "] 7 | license: "MIT" 8 | homepage: "https://codecrafters.io" 9 | bug-reports: 10 | "https://github.com/codecrafters-io/build-your-own-interpreter/issues" 11 | depends: [ 12 | "dune" {>= "3.16"} 13 | "lwt" 14 | "odoc" {with-doc} 15 | ] 16 | build: [ 17 | ["dune" "subst"] {dev} 18 | [ 19 | "dune" 20 | "build" 21 | "-p" 22 | name 23 | "-j" 24 | jobs 25 | "@install" 26 | "@runtest" {with-test} 27 | "@doc" {with-doc} 28 | ] 29 | ] 30 | -------------------------------------------------------------------------------- /starter_templates/ocaml/code/dune: -------------------------------------------------------------------------------- 1 | (include_subdirs unqualified) 2 | 3 | (executable 4 | (name main) 5 | (libraries lwt)) 6 | -------------------------------------------------------------------------------- /starter_templates/ocaml/code/dune-project: -------------------------------------------------------------------------------- 1 | (lang dune 3.16) 2 | 3 | (name codecrafters_interpreter) 4 | 5 | (generate_opam_files true) 6 | 7 | (package 8 | (name codecrafters_interpreter) 9 | (maintainers "CodeCrafters ") 10 | (authors "CodeCrafters ") 11 | (synopsis "Starter code for the Build your own Interpreter challenge") 12 | (homepage "https://codecrafters.io") 13 | (bug_reports 14 | "https://github.com/codecrafters-io/build-your-own-interpreter/issues") 15 | (license "MIT") 16 | (allow_empty true) 17 | (version 0.1) 18 | (depends lwt)) 19 | -------------------------------------------------------------------------------- /starter_templates/ocaml/code/src/main.ml: -------------------------------------------------------------------------------- 1 | let () = 2 | if Array.length Sys.argv < 3 then ( 3 | Printf.eprintf "Usage: ./your_program.sh tokenize \n"; 4 | exit 1); 5 | 6 | let command = Sys.argv.(1) in 7 | let filename = Sys.argv.(2) in 8 | 9 | if command <> "tokenize" then ( 10 | Printf.eprintf "Unknown command: %s\n" command; 11 | exit 1); 12 | 13 | let file_contents = In_channel.with_open_text filename In_channel.input_all in 14 | 15 | (* You can use print statements as follows for debugging, they'll be visible when running tests. *) 16 | Printf.eprintf "Logs from your program will appear here!\n"; 17 | 18 | if String.length file_contents > 0 then 19 | (* Implement & use your scanner here *) 20 | failwith "Scanner not implemented" 21 | else 22 | (* Uncomment this block to pass the first stage *) 23 | (* print_endline "EOF null"; (* Placeholder, replace this line when implementing the scanner *) *) 24 | () 25 | -------------------------------------------------------------------------------- /starter_templates/ocaml/config.yml: -------------------------------------------------------------------------------- 1 | attributes: 2 | required_executable: "dune" 3 | user_editable_file: "src/main.ml" 4 | -------------------------------------------------------------------------------- /starter_templates/odin/code/.codecrafters/compile.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # This script is used to compile your program on CodeCrafters 4 | # 5 | # This runs before .codecrafters/run.sh 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | set -e # Exit on failure 10 | 11 | mkdir -p /tmp/codecrafters-build-interpreter-odin 12 | odin build src -out:/tmp/codecrafters-build-interpreter-odin/main -------------------------------------------------------------------------------- /starter_templates/odin/code/.codecrafters/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # This script is used to run your program on CodeCrafters 4 | # 5 | # This runs after .codecrafters/compile.sh 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | set -e # Exit on failure 10 | 11 | exec /tmp/codecrafters-build-interpreter-odin/main "$@" 12 | -------------------------------------------------------------------------------- /starter_templates/odin/config.yml: -------------------------------------------------------------------------------- 1 | attributes: 2 | required_executable: odin 3 | user_editable_file: src/main.odin 4 | -------------------------------------------------------------------------------- /starter_templates/php/code/.codecrafters/compile.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # This script is used to compile your program on CodeCrafters 4 | # 5 | # This runs before .codecrafters/run.sh 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | set -e # Exit on failure 10 | 11 | # (This file is empty since PHP programs don't use a compile step) -------------------------------------------------------------------------------- /starter_templates/php/code/.codecrafters/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # This script is used to run your program on CodeCrafters 4 | # 5 | # This runs after .codecrafters/compile.sh 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | set -e # Exit on failure 10 | 11 | exec php app/main.php "$@" 12 | -------------------------------------------------------------------------------- /starter_templates/php/code/app/main.php: -------------------------------------------------------------------------------- 1 | \n"); 6 | exit(1); 7 | } 8 | 9 | $command = $argv[1]; 10 | $filename = $argv[2]; 11 | 12 | if ($command !== "tokenize") { 13 | fwrite(STDERR, "Unknown command: {$command}\n"); 14 | exit(1); 15 | } 16 | 17 | $file_contents = file_get_contents($filename); 18 | 19 | // You can use print statements as follows for debugging, they'll be visible when running tests. 20 | fwrite(STDERR, "Logs from your program will appear here!\n"); 21 | 22 | // Uncomment this block to pass the first stage 23 | // if ($file_contents) { 24 | // throw new Exception("Scanner not implemented"); 25 | // } else { 26 | // echo "EOF null\n"; // Placeholder, replace this line when implementing the scanner 27 | // } 28 | -------------------------------------------------------------------------------- /starter_templates/php/config.yml: -------------------------------------------------------------------------------- 1 | attributes: 2 | required_executable: "php (8.4)" 3 | user_editable_file: "app/main.php" 4 | -------------------------------------------------------------------------------- /starter_templates/python/code/.codecrafters/compile.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # This script is used to compile your program on CodeCrafters 4 | # 5 | # This runs before .codecrafters/run.sh 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | # (This file is empty since Python programs don't use a compile step) 10 | -------------------------------------------------------------------------------- /starter_templates/python/code/.codecrafters/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # This script is used to run your program on CodeCrafters 4 | # 5 | # This runs after .codecrafters/compile.sh 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | exec pipenv run python3 -m app.main "$@" 10 | -------------------------------------------------------------------------------- /starter_templates/python/code/Pipfile: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | 4 | [[source]] 5 | url = "https://pypi.org/simple" 6 | verify_ssl = true 7 | name = "pypi" 8 | 9 | [packages] 10 | 11 | [dev-packages] 12 | 13 | [requires] 14 | python_version = "3" 15 | -------------------------------------------------------------------------------- /starter_templates/python/code/Pipfile.lock: -------------------------------------------------------------------------------- 1 | { 2 | "_meta": { 3 | "hash": { 4 | "sha256": "4e61a4ba9e6f02f50f68627253af5ababd9b1b4c1e10294e48158e1f42c0c5a6" 5 | }, 6 | "pipfile-spec": 6, 7 | "requires": { 8 | "python_version": "3" 9 | }, 10 | "sources": [ 11 | { 12 | "name": "pypi", 13 | "url": "https://pypi.org/simple", 14 | "verify_ssl": true 15 | } 16 | ] 17 | }, 18 | "default": {}, 19 | "develop": {} 20 | } 21 | -------------------------------------------------------------------------------- /starter_templates/python/code/app/main.py: -------------------------------------------------------------------------------- 1 | import sys 2 | 3 | 4 | def main(): 5 | if len(sys.argv) < 3: 6 | print("Usage: ./your_program.sh tokenize ", file=sys.stderr) 7 | exit(1) 8 | 9 | command = sys.argv[1] 10 | filename = sys.argv[2] 11 | 12 | if command != "tokenize": 13 | print(f"Unknown command: {command}", file=sys.stderr) 14 | exit(1) 15 | 16 | with open(filename) as file: 17 | file_contents = file.read() 18 | 19 | # You can use print statements as follows for debugging, they'll be visible when running tests. 20 | print("Logs from your program will appear here!", file=sys.stderr) 21 | 22 | # Uncomment this block to pass the first stage 23 | # if file_contents: 24 | # raise NotImplementedError("Scanner not implemented") 25 | # else: 26 | # print("EOF null") # Placeholder, replace this line when implementing the scanner 27 | 28 | 29 | if __name__ == "__main__": 30 | main() 31 | -------------------------------------------------------------------------------- /starter_templates/python/config.yml: -------------------------------------------------------------------------------- 1 | attributes: 2 | required_executable: python (3.13) 3 | user_editable_file: app/main.py 4 | -------------------------------------------------------------------------------- /starter_templates/rust/code/.codecrafters/compile.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # This script is used to compile your program on CodeCrafters 4 | # 5 | # This runs before .codecrafters/run.sh 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | set -e # Exit on failure 10 | 11 | cargo build --release --target-dir=/tmp/codecrafters-build-interpreter-rust --manifest-path Cargo.toml 12 | -------------------------------------------------------------------------------- /starter_templates/rust/code/.codecrafters/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # This script is used to run your program on CodeCrafters 4 | # 5 | # This runs after .codecrafters/compile.sh 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | set -e # Exit on failure 10 | 11 | exec /tmp/codecrafters-build-interpreter-rust/release/codecrafters-interpreter "$@" 12 | -------------------------------------------------------------------------------- /starter_templates/rust/code/.gitignore: -------------------------------------------------------------------------------- 1 | # Generated by Cargo 2 | # will have compiled files and executables 3 | debug/ 4 | target/ 5 | 6 | # These are backup files generated by rustfmt 7 | **/*.rs.bk 8 | 9 | # MSVC Windows builds of rustc generate these, which store debugging information 10 | *.pdb 11 | -------------------------------------------------------------------------------- /starter_templates/rust/code/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "codecrafters-interpreter" 3 | version = "0.1.0" 4 | authors = ["Codecrafters "] 5 | edition = "2021" 6 | rust-version = "1.80" 7 | 8 | [dependencies] 9 | anyhow = "1.0.68" # error handling 10 | bytes = "1.3.0" # helps manage buffers 11 | thiserror = "1.0.38" # error handling 12 | -------------------------------------------------------------------------------- /starter_templates/rust/config.yml: -------------------------------------------------------------------------------- 1 | attributes: 2 | required_executable: cargo (1.86) 3 | user_editable_file: src/main.rs 4 | -------------------------------------------------------------------------------- /starter_templates/swift/code/.codecrafters/compile.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # This script is used to compile your program on CodeCrafters 4 | # 5 | # This runs before .codecrafters/run.sh 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | set -e # Exit on failure 10 | 11 | swift build -c release --build-path /tmp/codecrafters-build-interpreter-swift 12 | -------------------------------------------------------------------------------- /starter_templates/swift/code/.codecrafters/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # This script is used to run your program on CodeCrafters 4 | # 5 | # This runs after .codecrafters/compile.sh 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | set -e # Exit on failure 10 | 11 | exec swift run -c release --skip-build --build-path /tmp/codecrafters-build-interpreter-swift build-your-own-interpreter "$@" 12 | -------------------------------------------------------------------------------- /starter_templates/swift/code/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .build 3 | Packages 4 | xcuserdata/ 5 | DerivedData/ 6 | .swiftpm/configuration/registries.json 7 | .swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata 8 | .netrc -------------------------------------------------------------------------------- /starter_templates/swift/code/Package.swift: -------------------------------------------------------------------------------- 1 | // swift-tools-version: 6.0 2 | // The swift-tools-version declares the minimum version of Swift required to build this package. 3 | 4 | import PackageDescription 5 | 6 | let package = Package( 7 | name: "build-your-own-interpreter", 8 | targets: [ 9 | // Targets are the basic building blocks of a package, defining a module or a test suite. 10 | // Targets can depend on other targets in this package and products from dependencies. 11 | .executableTarget( 12 | name: "build-your-own-interpreter"), 13 | ] 14 | ) -------------------------------------------------------------------------------- /starter_templates/swift/code/Sources/main.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | // You can use print statements as follows for debugging, they'll be visible when running tests. 4 | print("Logs from your program will appear here!") 5 | 6 | guard CommandLine.argc == 3 else { 7 | print("Usage: ./your_program.sh tokenize ") 8 | exit(1) 9 | } 10 | 11 | let command = CommandLine.arguments[1] 12 | let filename = CommandLine.arguments[2] 13 | 14 | guard command == "tokenize" else { 15 | print("Unknown command: \(command)") 16 | exit(1) 17 | } 18 | 19 | let fileContents: String 20 | do { 21 | fileContents = try String(contentsOfFile: filename, encoding: .utf8) 22 | } catch { 23 | print("Error reading file: \(filename) with error: \(error.localizedDescription)") 24 | exit(1) 25 | } 26 | 27 | // Uncomment this block to pass the first stage 28 | // if fileContents.isEmpty { 29 | // print("EOF null") 30 | // } else { 31 | // print("Scanner not implemented") 32 | // exit(1) 33 | // } 34 | -------------------------------------------------------------------------------- /starter_templates/swift/config.yml: -------------------------------------------------------------------------------- 1 | attributes: 2 | required_executable: "swift (>=6.0)" 3 | user_editable_file: Sources/main.swift 4 | -------------------------------------------------------------------------------- /starter_templates/typescript/code/.codecrafters/compile.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # This script is used to compile your program on CodeCrafters 4 | # 5 | # This runs before .codecrafters/run.sh 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | set -e # Exit on failure 10 | 11 | # (This file is empty since TypeScript programs don't use a compile step) 12 | -------------------------------------------------------------------------------- /starter_templates/typescript/code/.codecrafters/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # This script is used to run your program on CodeCrafters 4 | # 5 | # This runs after .codecrafters/compile.sh 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | set -e # Exit on failure 10 | 11 | exec bun run "$(dirname "$0")/app/main.ts" "$@" 12 | -------------------------------------------------------------------------------- /starter_templates/typescript/code/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | -------------------------------------------------------------------------------- /starter_templates/typescript/code/app/main.ts: -------------------------------------------------------------------------------- 1 | import fs from "fs"; 2 | 3 | const args: string[] = process.argv.slice(2); // Skip the first two arguments (node path and script path) 4 | 5 | if (args.length < 2) { 6 | console.error("Usage: ./your_program.sh tokenize "); 7 | process.exit(1); 8 | } 9 | 10 | const command: string = args[0]; 11 | 12 | if (command !== "tokenize") { 13 | console.error(`Usage: Unknown command: ${command}`); 14 | process.exit(1); 15 | } 16 | 17 | // You can use print statements as follows for debugging, they'll be visible when running tests. 18 | console.error("Logs from your program will appear here!"); 19 | 20 | const filename: string = args[1]; 21 | 22 | // Uncomment this block to pass the first stage 23 | // 24 | // const fileContent: string = fs.readFileSync(filename, "utf8"); 25 | // 26 | // if (fileContent.length !== 0) { 27 | // throw new Error("Scanner not implemented"); 28 | // } else { 29 | // console.log("EOF null"); 30 | // } 31 | -------------------------------------------------------------------------------- /starter_templates/typescript/code/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@codecrafters/interpreter", 3 | "description": "Build your own Interpreter challenge, from CodeCrafters", 4 | "type": "module", 5 | "scripts": { 6 | "dev": "bun run app/main.ts" 7 | }, 8 | "devDependencies": { 9 | "@types/bun": "latest" 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /starter_templates/typescript/code/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | // Enable latest features 4 | "lib": ["ESNext", "DOM"], 5 | "target": "ESNext", 6 | "module": "ESNext", 7 | "moduleDetection": "force", 8 | "jsx": "react-jsx", 9 | "allowJs": true, 10 | 11 | // Bundler mode 12 | "moduleResolution": "bundler", 13 | "allowImportingTsExtensions": true, 14 | "verbatimModuleSyntax": true, 15 | "noEmit": true, 16 | 17 | // Best practices 18 | "strict": true, 19 | "skipLibCheck": true, 20 | "noFallthroughCasesInSwitch": true, 21 | 22 | // Some stricter flags (disabled by default) 23 | "noUnusedLocals": false, 24 | "noUnusedParameters": false, 25 | "noPropertyAccessFromIndexSignature": false 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /starter_templates/typescript/config.yml: -------------------------------------------------------------------------------- 1 | attributes: 2 | required_executable: bun (1.2) 3 | user_editable_file: app/main.ts 4 | -------------------------------------------------------------------------------- /starter_templates/zig/code/.codecrafters/compile.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # This script is used to compile your program on CodeCrafters 4 | # 5 | # This runs before .codecrafters/run.sh 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | set -e # Exit on failure 10 | 11 | zig build 12 | -------------------------------------------------------------------------------- /starter_templates/zig/code/.codecrafters/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # This script is used to run your program on CodeCrafters 4 | # 5 | # This runs after .codecrafters/compile.sh 6 | # 7 | # Learn more: https://codecrafters.io/program-interface 8 | 9 | set -e # Exit on failure 10 | 11 | exec $(dirname $0)/zig-out/bin/main "$@" 12 | -------------------------------------------------------------------------------- /starter_templates/zig/code/.gitignore: -------------------------------------------------------------------------------- 1 | # Zig build artifacts 2 | main 3 | zig-cache/ 4 | .zig-cache/ 5 | zig-out/ 6 | 7 | # Compiled binary output 8 | bin/ 9 | !bin/.gitkeep 10 | 11 | # Ignore any .o or .h files generated during build 12 | *.o 13 | *.h 14 | 15 | # Ignore OS and editor specific files 16 | **/.DS_Store 17 | *.swp 18 | *~ 19 | -------------------------------------------------------------------------------- /starter_templates/zig/config.yml: -------------------------------------------------------------------------------- 1 | attributes: 2 | required_executable: zig (0.14) 3 | user_editable_file: src/main.zig 4 | --------------------------------------------------------------------------------