├── .github └── workflows │ └── 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 ├── clojure │ ├── .codecrafters │ │ ├── compile.sh │ │ └── run.sh │ ├── .gitattributes │ ├── .gitignore │ ├── README.md │ ├── build.clj │ ├── codecrafters.yml │ ├── deps.edn │ ├── src │ │ └── redis │ │ │ └── core.clj │ └── your_program.sh ├── cpp │ ├── .codecrafters │ │ ├── compile.sh │ │ └── run.sh │ ├── .gitattributes │ ├── .gitignore │ ├── CMakeLists.txt │ ├── README.md │ ├── codecrafters.yml │ ├── src │ │ └── Server.cpp │ ├── vcpkg-configuration.json │ ├── vcpkg.json │ └── your_program.sh ├── crystal │ ├── .codecrafters │ │ ├── compile.sh │ │ └── run.sh │ ├── .gitattributes │ ├── README.md │ ├── app │ │ └── main.cr │ ├── codecrafters.yml │ └── your_program.sh ├── csharp │ ├── .codecrafters │ │ ├── compile.sh │ │ └── run.sh │ ├── .gitattributes │ ├── .gitignore │ ├── README.md │ ├── codecrafters-redis.csproj │ ├── codecrafters-redis.sln │ ├── codecrafters.yml │ ├── src │ │ └── Server.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 ├── haskell │ ├── .codecrafters │ │ ├── compile.sh │ │ └── run.sh │ ├── .gitattributes │ ├── .gitignore │ ├── README.md │ ├── app │ │ └── Main.hs │ ├── codecrafters.yml │ ├── package.yaml │ ├── stack.yaml │ ├── stack.yaml.lock │ └── 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_redis.opam │ ├── dune │ ├── dune-project │ ├── src │ │ └── main.ml │ └── 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 ├── ruby │ ├── .codecrafters │ │ ├── compile.sh │ │ └── run.sh │ ├── .gitattributes │ ├── Gemfile │ ├── Gemfile.lock │ ├── README.md │ ├── app │ │ └── server.rb │ ├── 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 ├── scala │ ├── .codecrafters │ │ ├── compile.sh │ │ └── run.sh │ ├── .gitattributes │ ├── .gitignore │ ├── README.md │ ├── build.sbt │ ├── codecrafters.yml │ ├── project │ │ ├── assembly.sbt │ │ └── build.properties │ ├── src │ │ └── main │ │ │ └── scala │ │ │ └── codecrafters_redis │ │ │ └── Server.scala │ └── your_program.sh ├── swift │ ├── .codecrafters │ │ ├── compile.sh │ │ └── run.sh │ ├── .gitattributes │ ├── .gitignore │ ├── Package.resolved │ ├── 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 │ ├── bun.lockb │ ├── 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 ├── c-9.2.Dockerfile ├── clojure-1.10.3.Dockerfile ├── clojure-1.11.3.Dockerfile ├── clojure-1.12.0.Dockerfile ├── cpp-20.Dockerfile ├── cpp-23.Dockerfile ├── crystal-1.1.Dockerfile ├── dotnet-6.0.Dockerfile ├── dotnet-8.0.Dockerfile ├── dotnet-9.0.Dockerfile ├── elixir-1.10.Dockerfile ├── elixir-1.16.Dockerfile ├── elixir-1.18.Dockerfile ├── gleam-1.0.Dockerfile ├── gleam-1.4.Dockerfile ├── gleam-1.6.Dockerfile ├── gleam-1.9.Dockerfile ├── go-1.13.Dockerfile ├── go-1.16.Dockerfile ├── go-1.19.Dockerfile ├── go-1.21.Dockerfile ├── go-1.22.Dockerfile ├── go-1.24.Dockerfile ├── haskell-9.4.Dockerfile ├── haskell-9.8.Dockerfile ├── java-1.8.Dockerfile ├── java-21.Dockerfile ├── java-23.Dockerfile ├── kotlin-2.0.Dockerfile ├── nodejs-14.Dockerfile ├── nodejs-16.Dockerfile ├── nodejs-18.Dockerfile ├── nodejs-21.Dockerfile ├── ocaml-5.2.0.Dockerfile ├── ocaml-5.3.Dockerfile ├── php-7.4.Dockerfile ├── php-8.3.Dockerfile ├── python-3.11.Dockerfile ├── python-3.12.Dockerfile ├── python-3.13.Dockerfile ├── python-3.7.Dockerfile ├── python-3.8.Dockerfile ├── ruby-2.7.Dockerfile ├── ruby-3.2.Dockerfile ├── ruby-3.3.Dockerfile ├── rust-1.43.Dockerfile ├── rust-1.54.Dockerfile ├── rust-1.62.Dockerfile ├── rust-1.68.Dockerfile ├── rust-1.70.Dockerfile ├── rust-1.76.Dockerfile ├── rust-1.77.Dockerfile ├── rust-1.82.Dockerfile ├── rust-1.85.Dockerfile ├── rust-1.86.Dockerfile ├── scala-2.12.Dockerfile ├── swift-6.0.Dockerfile ├── zig-0.12.Dockerfile ├── zig-0.13.Dockerfile └── zig-0.14.Dockerfile ├── solutions ├── c │ └── 01-jm1 │ │ ├── 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 ├── clojure │ └── 01-jm1 │ │ ├── code │ │ ├── .codecrafters │ │ │ ├── compile.sh │ │ │ └── run.sh │ │ ├── .gitattributes │ │ ├── .gitignore │ │ ├── README.md │ │ ├── build.clj │ │ ├── codecrafters.yml │ │ ├── deps.edn │ │ ├── src │ │ │ └── redis │ │ │ │ └── core.clj │ │ └── your_program.sh │ │ ├── diff │ │ └── src │ │ │ └── redis │ │ │ └── core.clj.diff │ │ └── explanation.md ├── cpp │ ├── 01-jm1 │ │ ├── code │ │ │ ├── .codecrafters │ │ │ │ ├── compile.sh │ │ │ │ └── run.sh │ │ │ ├── .gitattributes │ │ │ ├── .gitignore │ │ │ ├── CMakeLists.txt │ │ │ ├── README.md │ │ │ ├── codecrafters.yml │ │ │ ├── src │ │ │ │ └── Server.cpp │ │ │ ├── vcpkg-configuration.json │ │ │ ├── vcpkg.json │ │ │ └── your_program.sh │ │ ├── diff │ │ │ └── src │ │ │ │ └── Server.cpp.diff │ │ └── explanation.md │ └── 02-rg2 │ │ ├── code │ │ ├── .codecrafters │ │ │ ├── compile.sh │ │ │ └── run.sh │ │ ├── .gitattributes │ │ ├── .gitignore │ │ ├── CMakeLists.txt │ │ ├── README.md │ │ ├── codecrafters.yml │ │ ├── src │ │ │ └── Server.cpp │ │ ├── vcpkg-configuration.json │ │ ├── vcpkg.json │ │ └── your_program.sh │ │ └── diff │ │ └── src │ │ └── Server.cpp.diff ├── crystal │ └── 01-jm1 │ │ ├── code │ │ ├── .codecrafters │ │ │ ├── compile.sh │ │ │ └── run.sh │ │ ├── .gitattributes │ │ ├── README.md │ │ ├── app │ │ │ └── main.cr │ │ ├── codecrafters.yml │ │ └── your_program.sh │ │ ├── diff │ │ └── app │ │ │ └── main.cr.diff │ │ └── explanation.md ├── csharp │ └── 01-jm1 │ │ ├── code │ │ ├── .codecrafters │ │ │ ├── compile.sh │ │ │ └── run.sh │ │ ├── .gitattributes │ │ ├── .gitignore │ │ ├── README.md │ │ ├── codecrafters-redis.csproj │ │ ├── codecrafters-redis.sln │ │ ├── codecrafters.yml │ │ ├── src │ │ │ └── Server.cs │ │ └── your_program.sh │ │ ├── diff │ │ └── src │ │ │ └── Server.cs.diff │ │ └── explanation.md ├── elixir │ └── 01-jm1 │ │ ├── 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-jm1 │ │ ├── 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-jm1 │ │ ├── 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 │ └── 02-rg2 │ │ ├── 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 ├── haskell │ └── 01-jm1 │ │ ├── code │ │ ├── .codecrafters │ │ │ ├── compile.sh │ │ │ └── run.sh │ │ ├── .gitattributes │ │ ├── .gitignore │ │ ├── README.md │ │ ├── app │ │ │ └── Main.hs │ │ ├── codecrafters.yml │ │ ├── package.yaml │ │ ├── stack.yaml │ │ ├── stack.yaml.lock │ │ └── your_program.sh │ │ ├── diff │ │ └── app │ │ │ └── Main.hs.diff │ │ └── explanation.md ├── java │ ├── 01-jm1 │ │ ├── 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 │ └── 02-rg2 │ │ ├── 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 ├── javascript │ ├── 01-jm1 │ │ ├── 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 │ └── 02-rg2 │ │ ├── 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 ├── kotlin │ └── 01-jm1 │ │ ├── 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-jm1 │ │ ├── code │ │ ├── .codecrafters │ │ │ ├── compile.sh │ │ │ └── run.sh │ │ ├── .gitattributes │ │ ├── .gitignore │ │ ├── .ocamlformat │ │ ├── README.md │ │ ├── codecrafters.yml │ │ ├── codecrafters_redis.opam │ │ ├── dune │ │ ├── dune-project │ │ ├── src │ │ │ └── main.ml │ │ └── your_program.sh │ │ ├── diff │ │ └── src │ │ │ └── main.ml.diff │ │ └── explanation.md ├── php │ └── 01-jm1 │ │ ├── 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-jm1 │ │ ├── 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 │ └── 02-rg2 │ │ ├── code │ │ ├── .codecrafters │ │ │ ├── compile.sh │ │ │ └── run.sh │ │ ├── .gitattributes │ │ ├── .gitignore │ │ ├── Pipfile │ │ ├── Pipfile.lock │ │ ├── README.md │ │ ├── app │ │ │ └── main.py │ │ ├── codecrafters.yml │ │ └── your_program.sh │ │ └── diff │ │ ├── README.md.diff │ │ └── app │ │ └── main.py.diff ├── ruby │ └── 01-jm1 │ │ ├── code │ │ ├── .codecrafters │ │ │ ├── compile.sh │ │ │ └── run.sh │ │ ├── .gitattributes │ │ ├── Gemfile │ │ ├── Gemfile.lock │ │ ├── README.md │ │ ├── app │ │ │ └── server.rb │ │ ├── codecrafters.yml │ │ └── your_program.sh │ │ ├── diff │ │ └── app │ │ │ └── server.rb.diff │ │ └── explanation.md ├── rust │ ├── 01-jm1 │ │ ├── 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 │ └── 02-rg2 │ │ ├── code │ │ ├── .codecrafters │ │ │ ├── compile.sh │ │ │ └── run.sh │ │ ├── .gitattributes │ │ ├── .gitignore │ │ ├── Cargo.lock │ │ ├── Cargo.toml │ │ ├── README.md │ │ ├── codecrafters.yml │ │ ├── src │ │ │ └── main.rs │ │ └── your_program.sh │ │ └── diff │ │ ├── README.md.diff │ │ └── src │ │ └── main.rs.diff ├── scala │ └── 01-jm1 │ │ ├── code │ │ ├── .codecrafters │ │ │ ├── compile.sh │ │ │ └── run.sh │ │ ├── .gitattributes │ │ ├── .gitignore │ │ ├── README.md │ │ ├── build.sbt │ │ ├── codecrafters.yml │ │ ├── project │ │ │ ├── assembly.sbt │ │ │ └── build.properties │ │ ├── src │ │ │ └── main │ │ │ │ └── scala │ │ │ │ └── codecrafters_redis │ │ │ │ └── Server.scala │ │ └── your_program.sh │ │ ├── diff │ │ └── src │ │ │ └── main │ │ │ └── scala │ │ │ └── codecrafters_redis │ │ │ └── Server.scala.diff │ │ └── explanation.md ├── swift │ └── 01-jm1 │ │ ├── code │ │ ├── .codecrafters │ │ │ ├── compile.sh │ │ │ └── run.sh │ │ ├── .gitattributes │ │ ├── .gitignore │ │ ├── Package.resolved │ │ ├── Package.swift │ │ ├── README.md │ │ ├── Sources │ │ │ └── main.swift │ │ ├── codecrafters.yml │ │ └── your_program.sh │ │ ├── diff │ │ └── Sources │ │ │ └── main.swift.diff │ │ └── explanation.md ├── typescript │ ├── 01-jm1 │ │ ├── code │ │ │ ├── .codecrafters │ │ │ │ ├── compile.sh │ │ │ │ └── run.sh │ │ │ ├── .gitattributes │ │ │ ├── .gitignore │ │ │ ├── README.md │ │ │ ├── app │ │ │ │ └── main.ts │ │ │ ├── bun.lockb │ │ │ ├── codecrafters.yml │ │ │ ├── package.json │ │ │ ├── tsconfig.json │ │ │ └── your_program.sh │ │ ├── diff │ │ │ └── app │ │ │ │ └── main.ts.diff │ │ └── explanation.md │ └── 02-rg2 │ │ ├── code │ │ ├── .codecrafters │ │ │ ├── compile.sh │ │ │ └── run.sh │ │ ├── .gitattributes │ │ ├── .gitignore │ │ ├── README.md │ │ ├── app │ │ │ └── main.ts │ │ ├── bun.lockb │ │ ├── codecrafters.yml │ │ ├── package.json │ │ ├── tsconfig.json │ │ └── your_program.sh │ │ └── diff │ │ ├── README.md.diff │ │ └── app │ │ └── main.ts.diff └── zig │ └── 01-jm1 │ ├── 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 ├── clojure ├── code │ ├── .codecrafters │ │ ├── compile.sh │ │ └── run.sh │ ├── .gitignore │ ├── build.clj │ ├── deps.edn │ └── src │ │ └── redis │ │ └── core.clj └── config.yml ├── cpp ├── code │ ├── .codecrafters │ │ ├── compile.sh │ │ └── run.sh │ ├── .gitignore │ ├── CMakeLists.txt │ ├── src │ │ └── Server.cpp │ ├── vcpkg-configuration.json │ └── vcpkg.json └── config.yml ├── crystal ├── code │ ├── .codecrafters │ │ ├── compile.sh │ │ └── run.sh │ └── app │ │ └── main.cr └── config.yml ├── csharp ├── code │ ├── .codecrafters │ │ ├── compile.sh │ │ └── run.sh │ ├── .gitignore │ ├── codecrafters-redis.csproj │ ├── codecrafters-redis.sln │ └── src │ │ └── Server.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 ├── haskell ├── code │ ├── .codecrafters │ │ ├── compile.sh │ │ └── run.sh │ ├── .gitignore │ ├── app │ │ └── Main.hs │ ├── package.yaml │ ├── stack.yaml │ └── stack.yaml.lock └── 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_redis.opam │ ├── dune │ ├── dune-project │ └── src │ │ └── main.ml └── 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 ├── ruby ├── code │ ├── .codecrafters │ │ ├── compile.sh │ │ └── run.sh │ ├── Gemfile │ ├── Gemfile.lock │ └── app │ │ └── server.rb └── config.yml ├── rust ├── code │ ├── .codecrafters │ │ ├── compile.sh │ │ └── run.sh │ ├── .gitignore │ ├── Cargo.lock │ ├── Cargo.toml │ └── src │ │ └── main.rs └── config.yml ├── scala ├── code │ ├── .codecrafters │ │ ├── compile.sh │ │ └── run.sh │ ├── .gitignore │ ├── build.sbt │ ├── project │ │ ├── assembly.sbt │ │ └── build.properties │ └── src │ │ └── main │ │ └── scala │ │ └── codecrafters_redis │ │ └── Server.scala └── config.yml ├── swift ├── code │ ├── .codecrafters │ │ ├── compile.sh │ │ └── run.sh │ ├── .gitignore │ ├── Package.resolved │ ├── Package.swift │ └── Sources │ │ └── main.swift └── config.yml ├── typescript ├── code │ ├── .codecrafters │ │ ├── compile.sh │ │ └── run.sh │ ├── .gitignore │ ├── app │ │ └── main.ts │ ├── bun.lockb │ ├── 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/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 | with: 16 | sdkRef: main 17 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | course_definition_tester 2 | .history/ 3 | .idea/ 4 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # build-your-own-redis 2 | 3 | Content for the "Build your own Redis" challenge 4 | 5 | ### Setup 6 | 7 | This challenge is developed using https://github.com/codecrafters-io/course-sdk. Read the README there for information 8 | on how to contribute language support & submit solutions. -------------------------------------------------------------------------------- /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/redis "$@" 12 | -------------------------------------------------------------------------------- /compiled_starters/c/.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | -------------------------------------------------------------------------------- /compiled_starters/c/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.13) 2 | 3 | project(codecrafters-redis) 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(redis ${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 | } -------------------------------------------------------------------------------- /compiled_starters/clojure/.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 | clj -T:build 12 | -------------------------------------------------------------------------------- /compiled_starters/clojure/.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-redis-clojure/target.jar "$@" 12 | -------------------------------------------------------------------------------- /compiled_starters/clojure/.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | -------------------------------------------------------------------------------- /compiled_starters/clojure/.gitignore: -------------------------------------------------------------------------------- 1 | pom.xml 2 | pom.xml.asc 3 | *.jar 4 | *.class 5 | /lib/ 6 | /classes/ 7 | /target/ 8 | /checkouts/ 9 | .lein-deps-sum 10 | .lein-repl-history 11 | .lein-plugins/ 12 | .lein-failures 13 | .nrepl-port 14 | .cpcache/ 15 | deps/ -------------------------------------------------------------------------------- /compiled_starters/clojure/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 Clojure version used to run your code 8 | # on Codecrafters. 9 | # 10 | # Available versions: clojure-1.12.0 11 | language_pack: clojure-1.12.0 12 | -------------------------------------------------------------------------------- /compiled_starters/clojure/deps.edn: -------------------------------------------------------------------------------- 1 | { 2 | :paths ["src"] 3 | 4 | :deps { 5 | org.clojure/clojure {:mvn/version "1.12.0"} 6 | org.clojure/tools.cli {:mvn/version "1.1.230"} 7 | aleph/aleph {:mvn/version "0.8.3"} 8 | } 9 | 10 | :aliases { 11 | :build { 12 | :extra-deps {io.github.clojure/tools.build {:mvn/version "0.10.9"}} 13 | :exec-fn build/uber 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /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 ./build/server "$@" 12 | -------------------------------------------------------------------------------- /compiled_starters/cpp/.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | -------------------------------------------------------------------------------- /compiled_starters/cpp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.13) 2 | 3 | project(redis-starter-cpp) 4 | 5 | file(GLOB_RECURSE SOURCE_FILES src/*.cpp) 6 | 7 | set(CMAKE_CXX_STANDARD 23) # Enable the C++23 standard 8 | set(THREADS_PREFER_PTHREAD_FLAG ON) 9 | 10 | find_package(Threads REQUIRED) 11 | find_package(asio CONFIG REQUIRED) 12 | 13 | add_executable(server ${SOURCE_FILES}) 14 | 15 | target_link_libraries(server PRIVATE asio asio::asio) 16 | target_link_libraries(server PRIVATE Threads::Threads) -------------------------------------------------------------------------------- /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 | } 15 | -------------------------------------------------------------------------------- /compiled_starters/cpp/vcpkg.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": [ 3 | "asio", 4 | "pthreads" 5 | ] 6 | } 7 | -------------------------------------------------------------------------------- /compiled_starters/crystal/.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 | crystal build -o /tmp/codecrafters-build-redis-crystal app/main.cr 12 | -------------------------------------------------------------------------------- /compiled_starters/crystal/.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-redis-crystal "$@" 12 | -------------------------------------------------------------------------------- /compiled_starters/crystal/.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | -------------------------------------------------------------------------------- /compiled_starters/crystal/app/main.cr: -------------------------------------------------------------------------------- 1 | require "socket" 2 | 3 | # Ensure that the program terminates on SIGTERM, https://github.com/crystal-lang/crystal/issues/8687 4 | Signal::TERM.trap { exit } 5 | 6 | class YourRedisServer 7 | def start 8 | # You can use print statements as follows for debugging, they'll be visible when running tests. 9 | puts("Logs from your program will appear here!") 10 | 11 | # Uncomment this block to pass the first stage 12 | # server = TCPServer.new("0.0.0.0", 6379) 13 | # client = server.accept? 14 | end 15 | end 16 | 17 | YourRedisServer.new.start 18 | -------------------------------------------------------------------------------- /compiled_starters/crystal/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 Crystal version used to run your code 8 | # on Codecrafters. 9 | # 10 | # Available versions: crystal-1.1 11 | language_pack: crystal-1.1 12 | -------------------------------------------------------------------------------- /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-redis-csharp codecrafters-redis.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-redis-csharp/codecrafters-redis "$@" -------------------------------------------------------------------------------- /compiled_starters/csharp/.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | -------------------------------------------------------------------------------- /compiled_starters/csharp/codecrafters-redis.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net9.0 6 | codecrafters_redis 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/Server.cs: -------------------------------------------------------------------------------- 1 | using System.Net; 2 | using System.Net.Sockets; 3 | 4 | // You can use print statements as follows for debugging, they'll be visible when running tests. 5 | Console.WriteLine("Logs from your program will appear here!"); 6 | 7 | // Uncomment this block to pass the first stage 8 | // TcpListener server = new TcpListener(IPAddress.Any, 6379); 9 | // server.Start(); 10 | // server.AcceptSocket(); // wait for client 11 | -------------------------------------------------------------------------------- /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_redis /tmp/codecrafters-build-redis-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-redis-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/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/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_redis" 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 | gleam_erlang = "~> 0.25" 10 | gleam_otp = "~> 0.10" 11 | glisten = "~> 2.0" 12 | 13 | [dev-dependencies] 14 | gleeunit = "~> 1.0" 15 | -------------------------------------------------------------------------------- /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-redis-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-redis-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 | module github.com/codecrafters-io/redis-starter-go 2 | 3 | go 1.24.0 4 | -------------------------------------------------------------------------------- /compiled_starters/go/go.sum: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codecrafters-io/build-your-own-redis/3071246154c7de189b21bce634b01c471d0f0401/compiled_starters/go/go.sum -------------------------------------------------------------------------------- /compiled_starters/haskell/.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 compiles the program into $(stack path --local-install-root)/bin/codecrafters-redis-exe. 12 | stack build 13 | -------------------------------------------------------------------------------- /compiled_starters/haskell/.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 $(stack path --local-install-root)/bin/codecrafters-redis-exe "$@" -------------------------------------------------------------------------------- /compiled_starters/haskell/.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | -------------------------------------------------------------------------------- /compiled_starters/haskell/.gitignore: -------------------------------------------------------------------------------- 1 | codecrafters-redis.cabal 2 | *~ 3 | dist 4 | dist-* 5 | cabal-dev 6 | *.o 7 | *.hi 8 | *.hie 9 | *.chi 10 | *.chs.h 11 | *.dyn_o 12 | *.dyn_hi 13 | .hpc 14 | .hsenv 15 | .cabal-sandbox/ 16 | cabal.sandbox.config 17 | *.prof 18 | *.aux 19 | *.hp 20 | *.eventlog 21 | .stack/ 22 | .stack-work/ 23 | cabal.project.local 24 | cabal.project.local~ 25 | .HTF/ 26 | .ghc.environment.* -------------------------------------------------------------------------------- /compiled_starters/haskell/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 Haskell version used to run your code 8 | # on Codecrafters. 9 | # 10 | # Available versions: haskell-9.8 11 | language_pack: haskell-9.8 12 | -------------------------------------------------------------------------------- /compiled_starters/haskell/stack.yaml: -------------------------------------------------------------------------------- 1 | resolver: lts-23.18 2 | 3 | packages: 4 | - . 5 | -------------------------------------------------------------------------------- /compiled_starters/haskell/stack.yaml.lock: -------------------------------------------------------------------------------- 1 | # This file was autogenerated by Stack. 2 | # You should not edit this file by hand. 3 | # For more information, please see the documentation at: 4 | # https://docs.haskellstack.org/en/stable/lock_files 5 | 6 | packages: [] 7 | snapshots: 8 | - completed: 9 | sha256: d133abe75e408a407cce3f032c96ac1bbadf474a93b5156ebf4135b53382d56b 10 | size: 683827 11 | url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/23/18.yaml 12 | original: lts-23.18 13 | -------------------------------------------------------------------------------- /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-redis-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-redis-java/codecrafters-redis.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/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 | node_modules/ 2 | -------------------------------------------------------------------------------- /compiled_starters/javascript/app/main.js: -------------------------------------------------------------------------------- 1 | const net = require("net"); 2 | 3 | // You can use print statements as follows for debugging, they'll be visible when running tests. 4 | console.log("Logs from your program will appear here!"); 5 | 6 | // Uncomment this block to pass the first stage 7 | // const server = net.createServer((connection) => { 8 | // // Handle connection 9 | // }); 10 | // 11 | // server.listen(6379, "127.0.0.1"); 12 | -------------------------------------------------------------------------------- /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/redis", 3 | "version": "1.0.0", 4 | "lockfileVersion": 3, 5 | "requires": true, 6 | "packages": { 7 | "": { 8 | "name": "@codecrafters/redis", 9 | "version": "1.0.0" 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /compiled_starters/javascript/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@codecrafters/redis", 3 | "version": "1.0.0", 4 | "dependencies": {} 5 | } 6 | -------------------------------------------------------------------------------- /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-redis.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/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-redis-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-redis-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/dune: -------------------------------------------------------------------------------- 1 | (include_subdirs unqualified) 2 | 3 | (executable 4 | (name main) 5 | (libraries unix)) 6 | -------------------------------------------------------------------------------- /compiled_starters/ocaml/dune-project: -------------------------------------------------------------------------------- 1 | (lang dune 3.16) 2 | 3 | (name codecrafters_redis) 4 | 5 | (generate_opam_files true) 6 | 7 | (package 8 | (name codecrafters_redis) 9 | (maintainers "CodeCrafters ") 10 | (authors "CodeCrafters ") 11 | (synopsis "Starter code for the Build your own Redis challenge") 12 | (homepage "https://codecrafters.io") 13 | (bug_reports 14 | "https://github.com/codecrafters-io/build-your-own-redis/issues") 15 | (license "MIT") 16 | (allow_empty true) 17 | (version 0.1)) 18 | -------------------------------------------------------------------------------- /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) 12 | -------------------------------------------------------------------------------- /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/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.3 11 | language_pack: php-8.3 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 | set -e # Exit on failure 10 | 11 | # (This file is empty since Python programs don't use a compile step) 12 | -------------------------------------------------------------------------------- /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 | set -e # Exit on failure 10 | 11 | exec pipenv run python3 -m app.main "$@" -------------------------------------------------------------------------------- /compiled_starters/python/.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | -------------------------------------------------------------------------------- /compiled_starters/python/Pipfile: -------------------------------------------------------------------------------- 1 | [[source]] 2 | url = "https://pypi.org/simple" 3 | verify_ssl = true 4 | name = "pypi" 5 | 6 | [packages] 7 | 8 | [dev-packages] 9 | 10 | [requires] 11 | python_version = "3" 12 | -------------------------------------------------------------------------------- /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 socket # noqa: F401 2 | 3 | 4 | def main(): 5 | # You can use print statements as follows for debugging, they'll be visible when running tests. 6 | print("Logs from your program will appear here!") 7 | 8 | # Uncomment this to pass the first stage 9 | # 10 | # server_socket = socket.create_server(("localhost", 6379), reuse_port=True) 11 | # server_socket.accept() # wait for client 12 | 13 | 14 | if __name__ == "__main__": 15 | main() 16 | -------------------------------------------------------------------------------- /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/ruby/.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 Ruby programs don't use a compile step) 12 | -------------------------------------------------------------------------------- /compiled_starters/ruby/.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 bundle exec ruby app/server.rb "$@" 12 | -------------------------------------------------------------------------------- /compiled_starters/ruby/.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | -------------------------------------------------------------------------------- /compiled_starters/ruby/Gemfile: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | source "https://rubygems.org" 4 | 5 | # Add gems here if you need to use them. 6 | # Make sure to run `bundle install` before running tests or submitting your code. 7 | 8 | # Helps with declaratively parsing binary data. 9 | gem "bindata", "~> 2.4" 10 | -------------------------------------------------------------------------------- /compiled_starters/ruby/Gemfile.lock: -------------------------------------------------------------------------------- 1 | GEM 2 | remote: https://rubygems.org/ 3 | specs: 4 | bindata (2.4.15) 5 | 6 | PLATFORMS 7 | aarch64-linux-musl 8 | arm64-darwin-21 9 | x86_64-linux 10 | 11 | DEPENDENCIES 12 | bindata (~> 2.4) 13 | 14 | BUNDLED WITH 15 | 2.4.18 16 | -------------------------------------------------------------------------------- /compiled_starters/ruby/app/server.rb: -------------------------------------------------------------------------------- 1 | require "socket" 2 | 3 | class YourRedisServer 4 | def initialize(port) 5 | @port = port 6 | end 7 | 8 | def start 9 | # You can use print statements as follows for debugging, they'll be visible when running tests. 10 | puts("Logs from your program will appear here!") 11 | 12 | # Uncomment this block to pass the first stage 13 | # server = TCPServer.new(@port) 14 | # client = server.accept 15 | end 16 | end 17 | 18 | YourRedisServer.new(6379).start 19 | -------------------------------------------------------------------------------- /compiled_starters/ruby/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 Ruby version used to run your code 8 | # on Codecrafters. 9 | # 10 | # Available versions: ruby-3.3 11 | language_pack: ruby-3.3 12 | -------------------------------------------------------------------------------- /compiled_starters/ruby/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 bundle exec ruby app/server.rb "$@" 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-redis-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-redis-rust/release/codecrafters-redis "$@" 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-redis" 3 | version = "0.1.0" 4 | authors = ["Codecrafters "] 5 | edition = "2021" 6 | 7 | [dependencies] 8 | anyhow = "1.0.59" # error handling 9 | bytes = "1.3.0" # helps manage buffers 10 | thiserror = "1.0.32" # error handling 11 | tokio = { version = "1.23.0", features = ["full"] } # async networking 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/scala/.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 | sbt assembly 12 | -------------------------------------------------------------------------------- /compiled_starters/scala/.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 ./target/scala-2.13/redis.jar "$@" 12 | -------------------------------------------------------------------------------- /compiled_starters/scala/.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | -------------------------------------------------------------------------------- /compiled_starters/scala/.gitignore: -------------------------------------------------------------------------------- 1 | debug/ 2 | target/ 3 | -------------------------------------------------------------------------------- /compiled_starters/scala/build.sbt: -------------------------------------------------------------------------------- 1 | ThisBuild / scalaVersion := "2.13.12" 2 | ThisBuild / version := "0.1.0-SNAPSHOT" 3 | ThisBuild / organization := "com.CodeCrafters" 4 | ThisBuild / organizationName := "CodeCrafters" 5 | 6 | assembly / assemblyJarName := "redis.jar" 7 | 8 | lazy val root = (project in file(".")) 9 | .settings( 10 | name := "codecrafter-redis", 11 | // List your dependencies here 12 | libraryDependencies ++= Seq( 13 | ) 14 | ) 15 | -------------------------------------------------------------------------------- /compiled_starters/scala/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 Scala version used to run your code 8 | # on Codecrafters. 9 | # 10 | # Available versions: scala-2.12 11 | language_pack: scala-2.12 12 | -------------------------------------------------------------------------------- /compiled_starters/scala/project/assembly.sbt: -------------------------------------------------------------------------------- 1 | addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.10") 2 | -------------------------------------------------------------------------------- /compiled_starters/scala/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.9.9 2 | -------------------------------------------------------------------------------- /compiled_starters/scala/src/main/scala/codecrafters_redis/Server.scala: -------------------------------------------------------------------------------- 1 | package codecrafters_redis 2 | 3 | import java.net.{InetSocketAddress, ServerSocket} 4 | 5 | object Server { 6 | def main(args: Array[String]): Unit = { 7 | // You can use print statements as follows for debugging, they'll be visible when running tests. 8 | println("Logs from your program will appear here!") 9 | 10 | // Uncomment this to pass the first stage 11 | // 12 | // val serverSocket = new ServerSocket() 13 | // serverSocket.bind(new InetSocketAddress("localhost", 6379)) 14 | // val clientSocket = serverSocket.accept() // wait for client 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /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-redis-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-redis-swift build-your-own-redis "$@" 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/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/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 * as net from "net"; 2 | 3 | // You can use print statements as follows for debugging, they'll be visible when running tests. 4 | console.log("Logs from your program will appear here!"); 5 | 6 | // Uncomment this block to pass the first stage 7 | // const server: net.Server = net.createServer((connection: net.Socket) => { 8 | // // Handle connection 9 | // }); 10 | // 11 | // server.listen(6379, "127.0.0.1"); 12 | -------------------------------------------------------------------------------- /compiled_starters/typescript/bun.lockb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codecrafters-io/build-your-own-redis/3071246154c7de189b21bce634b01c471d0f0401/compiled_starters/typescript/bun.lockb -------------------------------------------------------------------------------- /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/redis", 3 | "description": "Build your own Redis 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/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 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 | -------------------------------------------------------------------------------- /dockerfiles/c-9.2.Dockerfile: -------------------------------------------------------------------------------- 1 | FROM n0madic/alpine-gcc:9.2.0 2 | -------------------------------------------------------------------------------- /dockerfiles/clojure-1.10.3.Dockerfile: -------------------------------------------------------------------------------- 1 | FROM clojure:openjdk-18-lein-alpine 2 | 3 | ENV CODECRAFTERS_DEPENDENCY_FILE_PATHS="project.clj" 4 | 5 | WORKDIR /app 6 | COPY project.clj ./ 7 | 8 | RUN lein deps 9 | 10 | RUN printf "cd \${CODECRAFTERS_REPOSITORY_DIR} && lein deps && lein uberjar && sed -i 's/^\(lein .*\)/#\1/' ./spawn_redis_server.sh\n" > /codecrafters-precompile.sh 11 | RUN chmod +x /codecrafters-precompile.sh 12 | -------------------------------------------------------------------------------- /dockerfiles/clojure-1.11.3.Dockerfile: -------------------------------------------------------------------------------- 1 | FROM clojure:openjdk-19-lein-alpine 2 | 3 | ENV CODECRAFTERS_DEPENDENCY_FILE_PATHS="project.clj" 4 | 5 | WORKDIR /app 6 | COPY project.clj ./ 7 | 8 | RUN lein deps 9 | 10 | RUN printf "cd \${CODECRAFTERS_REPOSITORY_DIR} && lein deps && lein uberjar && sed -i 's/^\(lein .*\)/#\1/' ./spawn_redis_server.sh\n" > /codecrafters-precompile.sh 11 | RUN chmod +x /codecrafters-precompile.sh 12 | -------------------------------------------------------------------------------- /dockerfiles/clojure-1.12.0.Dockerfile: -------------------------------------------------------------------------------- 1 | # syntax=docker/dockerfile:1.7-labs 2 | FROM clojure:tools-deps-bookworm 3 | 4 | # Ensures the container is re-built if dependency files change 5 | ENV CODECRAFTERS_DEPENDENCY_FILE_PATHS="deps.edn" 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/cpp-20.Dockerfile: -------------------------------------------------------------------------------- 1 | FROM gcc:12.2.0-bullseye 2 | 3 | RUN apt-get update && \ 4 | apt-get install --no-install-recommends -y cmake=3.18.* && \ 5 | apt-get clean && \ 6 | rm -rf /var/lib/apt/lists/* 7 | -------------------------------------------------------------------------------- /dockerfiles/crystal-1.1.Dockerfile: -------------------------------------------------------------------------------- 1 | FROM crystallang/crystal:1.1.0-alpine 2 | -------------------------------------------------------------------------------- /dockerfiles/elixir-1.10.Dockerfile: -------------------------------------------------------------------------------- 1 | FROM elixir:1.10-alpine 2 | -------------------------------------------------------------------------------- /dockerfiles/elixir-1.16.Dockerfile: -------------------------------------------------------------------------------- 1 | FROM elixir:1.16-alpine 2 | -------------------------------------------------------------------------------- /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.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.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.13.Dockerfile: -------------------------------------------------------------------------------- 1 | FROM golang:1.13-alpine 2 | -------------------------------------------------------------------------------- /dockerfiles/go-1.16.Dockerfile: -------------------------------------------------------------------------------- 1 | FROM golang:1.16-alpine 2 | -------------------------------------------------------------------------------- /dockerfiles/go-1.19.Dockerfile: -------------------------------------------------------------------------------- 1 | FROM golang:1.19-alpine 2 | 3 | ENV CODECRAFTERS_DEPENDENCY_FILE_PATHS="go.mod,go.sum" 4 | 5 | WORKDIR /app 6 | 7 | COPY go.mod go.sum ./ 8 | 9 | RUN go mod download 10 | -------------------------------------------------------------------------------- /dockerfiles/go-1.21.Dockerfile: -------------------------------------------------------------------------------- 1 | FROM golang:1.21-alpine 2 | 3 | ENV CODECRAFTERS_DEPENDENCY_FILE_PATHS="go.mod,go.sum" 4 | 5 | WORKDIR /app 6 | 7 | COPY go.mod go.sum ./ 8 | 9 | # Starting from Go 1.20, the go standard library is no loger compiled 10 | # setting the GODEBUG environment to "installgoroot=all" restores the old behavior 11 | RUN GODEBUG="installgoroot=all" go install std 12 | 13 | RUN go mod download 14 | -------------------------------------------------------------------------------- /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-1.8.Dockerfile: -------------------------------------------------------------------------------- 1 | FROM openjdk:8-jdk-alpine -------------------------------------------------------------------------------- /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-14.Dockerfile: -------------------------------------------------------------------------------- 1 | FROM mhart/alpine-node:14 2 | -------------------------------------------------------------------------------- /dockerfiles/nodejs-16.Dockerfile: -------------------------------------------------------------------------------- 1 | FROM node:16.14.0-alpine3.14 2 | -------------------------------------------------------------------------------- /dockerfiles/nodejs-18.Dockerfile: -------------------------------------------------------------------------------- 1 | FROM node:18.18.0-alpine3.17 -------------------------------------------------------------------------------- /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/php-7.4.Dockerfile: -------------------------------------------------------------------------------- 1 | FROM php:7.4-cli-alpine 2 | 3 | RUN docker-php-ext-install sockets 4 | -------------------------------------------------------------------------------- /dockerfiles/php-8.3.Dockerfile: -------------------------------------------------------------------------------- 1 | FROM php:8.3-cli-alpine3.19 2 | 3 | # For ext-sockets installation in php8.3 4 | RUN apk add --no-cache linux-headers=6.5-r0 5 | 6 | RUN docker-php-ext-install sockets 7 | -------------------------------------------------------------------------------- /dockerfiles/python-3.11.Dockerfile: -------------------------------------------------------------------------------- 1 | FROM python:3.11-alpine 2 | -------------------------------------------------------------------------------- /dockerfiles/python-3.12.Dockerfile: -------------------------------------------------------------------------------- 1 | FROM python:3.12-alpine 2 | -------------------------------------------------------------------------------- /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>=2025.0.2" 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" -------------------------------------------------------------------------------- /dockerfiles/python-3.7.Dockerfile: -------------------------------------------------------------------------------- 1 | FROM jfloff/alpine-python:3.7 2 | -------------------------------------------------------------------------------- /dockerfiles/python-3.8.Dockerfile: -------------------------------------------------------------------------------- 1 | FROM jfloff/alpine-python:3.8 2 | -------------------------------------------------------------------------------- /dockerfiles/ruby-2.7.Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ruby:2.7-alpine 2 | -------------------------------------------------------------------------------- /dockerfiles/ruby-3.2.Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ruby:3.2-alpine -------------------------------------------------------------------------------- /dockerfiles/ruby-3.3.Dockerfile: -------------------------------------------------------------------------------- 1 | # syntax=docker/dockerfile:1.7-labs 2 | FROM ruby:3.3-alpine 3 | 4 | # Required for installing the json/async gems 5 | RUN apk add --no-cache \ 6 | build-base~=0.5 \ 7 | libssl3~=3.5 \ 8 | readline-dev~=8.2 \ 9 | zlib-dev~=1.3 10 | 11 | # Re-build if Gemfile or Gemfile.lock changes 12 | ENV CODECRAFTERS_DEPENDENCY_FILE_PATHS="Gemfile,Gemfile.lock" 13 | 14 | WORKDIR /app 15 | 16 | # .git & README.md are unique per-repository. We ignore them on first copy to prevent cache misses 17 | COPY --exclude=.git --exclude=README.md . /app 18 | 19 | RUN bundle install --verbose 20 | -------------------------------------------------------------------------------- /dockerfiles/rust-1.77.Dockerfile: -------------------------------------------------------------------------------- 1 | # syntax=docker/dockerfile:1.7-labs 2 | FROM rust:1.77-buster 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 | RUN cargo build --release --target-dir=/tmp/codecrafters-redis-target 10 | 11 | RUN echo "cd \${CODECRAFTERS_REPOSITORY_DIR} && cargo build --release --target-dir=/tmp/codecrafters-redis-target --manifest-path Cargo.toml" > /codecrafters-precompile.sh 12 | RUN chmod +x /codecrafters-precompile.sh 13 | 14 | ENV CODECRAFTERS_DEPENDENCY_FILE_PATHS="Cargo.toml,Cargo.lock" 15 | -------------------------------------------------------------------------------- /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 -------------------------------------------------------------------------------- /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,Package.resolved" 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-redis-swift resolve -------------------------------------------------------------------------------- /solutions/c/01-jm1/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-jm1/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/redis "$@" 12 | -------------------------------------------------------------------------------- /solutions/c/01-jm1/code/.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | -------------------------------------------------------------------------------- /solutions/c/01-jm1/code/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.13) 2 | 3 | project(codecrafters-redis) 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(redis ${SOURCE_FILES}) 10 | -------------------------------------------------------------------------------- /solutions/c/01-jm1/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-jm1/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-jm1/code/vcpkg.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": [] 3 | } -------------------------------------------------------------------------------- /solutions/clojure/01-jm1/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 | clj -T:build 12 | -------------------------------------------------------------------------------- /solutions/clojure/01-jm1/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-redis-clojure/target.jar "$@" 12 | -------------------------------------------------------------------------------- /solutions/clojure/01-jm1/code/.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | -------------------------------------------------------------------------------- /solutions/clojure/01-jm1/code/.gitignore: -------------------------------------------------------------------------------- 1 | pom.xml 2 | pom.xml.asc 3 | *.jar 4 | *.class 5 | /lib/ 6 | /classes/ 7 | /target/ 8 | /checkouts/ 9 | .lein-deps-sum 10 | .lein-repl-history 11 | .lein-plugins/ 12 | .lein-failures 13 | .nrepl-port 14 | .cpcache/ 15 | deps/ -------------------------------------------------------------------------------- /solutions/clojure/01-jm1/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 Clojure version used to run your code 8 | # on Codecrafters. 9 | # 10 | # Available versions: clojure-1.12.0 11 | language_pack: clojure-1.12.0 12 | -------------------------------------------------------------------------------- /solutions/clojure/01-jm1/code/deps.edn: -------------------------------------------------------------------------------- 1 | { 2 | :paths ["src"] 3 | 4 | :deps { 5 | org.clojure/clojure {:mvn/version "1.12.0"} 6 | org.clojure/tools.cli {:mvn/version "1.1.230"} 7 | aleph/aleph {:mvn/version "0.8.3"} 8 | } 9 | 10 | :aliases { 11 | :build { 12 | :extra-deps {io.github.clojure/tools.build {:mvn/version "0.10.9"}} 13 | :exec-fn build/uber 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /solutions/clojure/01-jm1/explanation.md: -------------------------------------------------------------------------------- 1 | The entry point for your Redis implementation is in `src/redis/core.clj`. 2 | 3 | Study and uncomment the relevant code: 4 | 5 | ```clojure 6 | ;; Uncomment this block to pass the first stage 7 | (serve 6379 handler) 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/cpp/01-jm1/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-jm1/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 ./build/server "$@" 12 | -------------------------------------------------------------------------------- /solutions/cpp/01-jm1/code/.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | -------------------------------------------------------------------------------- /solutions/cpp/01-jm1/code/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.13) 2 | 3 | project(redis-starter-cpp) 4 | 5 | file(GLOB_RECURSE SOURCE_FILES src/*.cpp) 6 | 7 | set(CMAKE_CXX_STANDARD 23) # Enable the C++23 standard 8 | set(THREADS_PREFER_PTHREAD_FLAG ON) 9 | 10 | find_package(Threads REQUIRED) 11 | find_package(asio CONFIG REQUIRED) 12 | 13 | add_executable(server ${SOURCE_FILES}) 14 | 15 | target_link_libraries(server PRIVATE asio asio::asio) 16 | target_link_libraries(server PRIVATE Threads::Threads) -------------------------------------------------------------------------------- /solutions/cpp/01-jm1/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-jm1/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/cpp/01-jm1/code/vcpkg.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": [ 3 | "asio", 4 | "pthreads" 5 | ] 6 | } 7 | -------------------------------------------------------------------------------- /solutions/cpp/01-jm1/explanation.md: -------------------------------------------------------------------------------- 1 | The entry point for your Redis implementation is in `src/Server.cpp`. 2 | 3 | Study and uncomment the relevant code: 4 | 5 | ```cpp 6 | // Uncomment this block to pass the first stage 7 | 8 | accept(server_fd, (struct sockaddr *) &client_addr, (socklen_t *) &client_addr_len); 9 | std::cout << "Client connected\n"; 10 | 11 | close(server_fd); 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/02-rg2/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/02-rg2/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 ./build/server "$@" 12 | -------------------------------------------------------------------------------- /solutions/cpp/02-rg2/code/.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | -------------------------------------------------------------------------------- /solutions/cpp/02-rg2/code/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.13) 2 | 3 | project(redis-starter-cpp) 4 | 5 | file(GLOB_RECURSE SOURCE_FILES src/*.cpp) 6 | 7 | set(CMAKE_CXX_STANDARD 23) # Enable the C++23 standard 8 | set(THREADS_PREFER_PTHREAD_FLAG ON) 9 | 10 | find_package(Threads REQUIRED) 11 | find_package(asio CONFIG REQUIRED) 12 | 13 | add_executable(server ${SOURCE_FILES}) 14 | 15 | target_link_libraries(server PRIVATE asio asio::asio) 16 | target_link_libraries(server PRIVATE Threads::Threads) -------------------------------------------------------------------------------- /solutions/cpp/02-rg2/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/02-rg2/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/cpp/02-rg2/code/vcpkg.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": [ 3 | "asio", 4 | "pthreads" 5 | ] 6 | } 7 | -------------------------------------------------------------------------------- /solutions/crystal/01-jm1/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 | crystal build -o /tmp/codecrafters-build-redis-crystal app/main.cr 12 | -------------------------------------------------------------------------------- /solutions/crystal/01-jm1/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-redis-crystal "$@" 12 | -------------------------------------------------------------------------------- /solutions/crystal/01-jm1/code/.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | -------------------------------------------------------------------------------- /solutions/crystal/01-jm1/code/app/main.cr: -------------------------------------------------------------------------------- 1 | require "socket" 2 | 3 | # Ensure that the program terminates on SIGTERM, https://github.com/crystal-lang/crystal/issues/8687 4 | Signal::TERM.trap { exit } 5 | 6 | class YourRedisServer 7 | def start 8 | server = TCPServer.new("0.0.0.0", 6379) 9 | client = server.accept? 10 | end 11 | end 12 | 13 | YourRedisServer.new.start 14 | -------------------------------------------------------------------------------- /solutions/crystal/01-jm1/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 Crystal version used to run your code 8 | # on Codecrafters. 9 | # 10 | # Available versions: crystal-1.1 11 | language_pack: crystal-1.1 12 | -------------------------------------------------------------------------------- /solutions/crystal/01-jm1/explanation.md: -------------------------------------------------------------------------------- 1 | The entry point for your Redis implementation is in `app/main.cr`. 2 | 3 | Study and uncomment the relevant code: 4 | 5 | ```crystal 6 | # Uncomment this block to pass the first stage 7 | server = TCPServer.new("0.0.0.0", 6379) 8 | client = server.accept? 9 | ``` 10 | 11 | Push your changes to pass the first stage: 12 | 13 | ``` 14 | git add . 15 | git commit -m "pass 1st stage" # any msg 16 | git push origin master 17 | ``` 18 | -------------------------------------------------------------------------------- /solutions/csharp/01-jm1/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-redis-csharp codecrafters-redis.csproj 12 | -------------------------------------------------------------------------------- /solutions/csharp/01-jm1/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-redis-csharp/codecrafters-redis "$@" -------------------------------------------------------------------------------- /solutions/csharp/01-jm1/code/.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | -------------------------------------------------------------------------------- /solutions/csharp/01-jm1/code/codecrafters-redis.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net9.0 6 | codecrafters_redis 7 | enable 8 | enable 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /solutions/csharp/01-jm1/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-jm1/code/src/Server.cs: -------------------------------------------------------------------------------- 1 | using System.Net; 2 | using System.Net.Sockets; 3 | 4 | TcpListener server = new TcpListener(IPAddress.Any, 6379); 5 | server.Start(); 6 | server.AcceptSocket(); // wait for client 7 | -------------------------------------------------------------------------------- /solutions/csharp/01-jm1/diff/src/Server.cs.diff: -------------------------------------------------------------------------------- 1 | @@ -1,10 +1,6 @@ 2 | using System.Net; 3 | using System.Net.Sockets; 4 | 5 | -// You can use print statements as follows for debugging, they'll be visible when running tests. 6 | -Console.WriteLine("Logs from your program will appear here!"); 7 | - 8 | -// Uncomment this block to pass the first stage 9 | -// TcpListener server = new TcpListener(IPAddress.Any, 6379); 10 | -// server.Start(); 11 | -// server.AcceptSocket(); // wait for client 12 | +TcpListener server = new TcpListener(IPAddress.Any, 6379); 13 | +server.Start(); 14 | +server.AcceptSocket(); // wait for client 15 | -------------------------------------------------------------------------------- /solutions/csharp/01-jm1/explanation.md: -------------------------------------------------------------------------------- 1 | The entry point for your Redis implementation is in `src/Server.cs`. 2 | 3 | Study and uncomment the relevant code: 4 | 5 | ```csharp 6 | // Uncomment this block to pass the first stage 7 | TcpListener server = new TcpListener(IPAddress.Any, 6379); 8 | server.Start(); 9 | server.AcceptSocket(); // wait for client 10 | ``` 11 | 12 | Push your changes to pass the first stage: 13 | 14 | ``` 15 | git add . 16 | git commit -m "pass 1st stage" # any msg 17 | git push origin master 18 | ``` 19 | -------------------------------------------------------------------------------- /solutions/elixir/01-jm1/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_redis /tmp/codecrafters-build-redis-elixir 13 | -------------------------------------------------------------------------------- /solutions/elixir/01-jm1/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-redis-elixir "$@" 12 | -------------------------------------------------------------------------------- /solutions/elixir/01-jm1/code/.formatter.exs: -------------------------------------------------------------------------------- 1 | # Used by "mix format" 2 | [ 3 | inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"] 4 | ] 5 | -------------------------------------------------------------------------------- /solutions/elixir/01-jm1/code/.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | -------------------------------------------------------------------------------- /solutions/elixir/01-jm1/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-jm1/explanation.md: -------------------------------------------------------------------------------- 1 | The entry point for your Redis implementation is in `lib/main.ex`. 2 | 3 | Study and uncomment the relevant code: 4 | 5 | ```elixir 6 | # Uncomment this block to pass the first stage 7 | 8 | # Since the tester restarts your program quite often, setting SO_REUSEADDR 9 | # ensures that we don't run into 'Address already in use' errors 10 | {:ok, socket} = :gen_tcp.listen(6379, [:binary, active: false, reuseaddr: true]) 11 | {:ok, _client} = :gen_tcp.accept(socket) 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-jm1/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-jm1/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-jm1/code/.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | -------------------------------------------------------------------------------- /solutions/gleam/01-jm1/code/.gitignore: -------------------------------------------------------------------------------- 1 | *.beam 2 | *.ez 3 | /build 4 | erl_crash.dump 5 | -------------------------------------------------------------------------------- /solutions/gleam/01-jm1/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-jm1/code/gleam.toml: -------------------------------------------------------------------------------- 1 | name = "codecrafters_redis" 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 | gleam_erlang = "~> 0.25" 10 | gleam_otp = "~> 0.10" 11 | glisten = "~> 2.0" 12 | 13 | [dev-dependencies] 14 | gleeunit = "~> 1.0" 15 | -------------------------------------------------------------------------------- /solutions/gleam/01-jm1/explanation.md: -------------------------------------------------------------------------------- 1 | The entry point for your Redis implementation is in `src/main.gleam`. 2 | 3 | Study and uncomment the relevant code: 4 | 5 | ```gleam 6 | // Uncomment this block to pass the first stage 7 | 8 | let assert Ok(_) = 9 | glisten.handler(fn(_conn) { #(Nil, None) }, fn(_msg, state, _conn) { 10 | io.println("Received message!") 11 | actor.continue(state) 12 | }) 13 | |> glisten.serve(6379) 14 | 15 | process.sleep_forever() 16 | ``` 17 | 18 | Push your changes to pass the first stage: 19 | 20 | ``` 21 | git add . 22 | git commit -m "pass 1st stage" # any msg 23 | git push origin master 24 | ``` 25 | -------------------------------------------------------------------------------- /solutions/go/01-jm1/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-redis-go app/*.go 12 | -------------------------------------------------------------------------------- /solutions/go/01-jm1/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-redis-go "$@" 12 | -------------------------------------------------------------------------------- /solutions/go/01-jm1/code/.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | -------------------------------------------------------------------------------- /solutions/go/01-jm1/code/app/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "net" 6 | "os" 7 | ) 8 | 9 | // Ensures gofmt doesn't remove the "net" and "os" imports in stage 1 (feel free to remove this!) 10 | var _ = net.Listen 11 | var _ = os.Exit 12 | 13 | func main() { 14 | l, err := net.Listen("tcp", "0.0.0.0:6379") 15 | if err != nil { 16 | fmt.Println("Failed to bind to port 6379") 17 | os.Exit(1) 18 | } 19 | _, err = l.Accept() 20 | if err != nil { 21 | fmt.Println("Error accepting connection: ", err.Error()) 22 | os.Exit(1) 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /solutions/go/01-jm1/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-jm1/code/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/codecrafters-io/redis-starter-go 2 | 3 | go 1.24.0 4 | -------------------------------------------------------------------------------- /solutions/go/01-jm1/code/go.sum: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codecrafters-io/build-your-own-redis/3071246154c7de189b21bce634b01c471d0f0401/solutions/go/01-jm1/code/go.sum -------------------------------------------------------------------------------- /solutions/go/01-jm1/explanation.md: -------------------------------------------------------------------------------- 1 | The entry point for your Redis 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 | l, err := net.Listen("tcp", "0.0.0.0:6379") 9 | if err != nil { 10 | fmt.Println("Failed to bind to port 6379") 11 | os.Exit(1) 12 | } 13 | _, err = l.Accept() 14 | if err != nil { 15 | fmt.Println("Error accepting connection: ", err.Error()) 16 | os.Exit(1) 17 | } 18 | ``` 19 | 20 | Push your changes to pass the first stage: 21 | 22 | ``` 23 | git add . 24 | git commit -m "pass 1st stage" # any msg 25 | git push origin master 26 | ``` 27 | -------------------------------------------------------------------------------- /solutions/go/02-rg2/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-redis-go app/*.go 12 | -------------------------------------------------------------------------------- /solutions/go/02-rg2/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-redis-go "$@" 12 | -------------------------------------------------------------------------------- /solutions/go/02-rg2/code/.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | -------------------------------------------------------------------------------- /solutions/go/02-rg2/code/app/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "net" 6 | "os" 7 | ) 8 | 9 | // Ensures gofmt doesn't remove the "net" and "os" imports in stage 1 (feel free to remove this!) 10 | var _ = net.Listen 11 | var _ = os.Exit 12 | 13 | func main() { 14 | l, err := net.Listen("tcp", "0.0.0.0:6379") 15 | if err != nil { 16 | fmt.Println("Failed to bind to port 6379") 17 | os.Exit(1) 18 | } 19 | conn, err := l.Accept() 20 | if err != nil { 21 | fmt.Println("Error accepting connection: ", err.Error()) 22 | os.Exit(1) 23 | } 24 | conn.Write([]byte("+PONG\r\n")) 25 | } 26 | -------------------------------------------------------------------------------- /solutions/go/02-rg2/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/02-rg2/code/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/codecrafters-io/redis-starter-go 2 | 3 | go 1.24.0 4 | -------------------------------------------------------------------------------- /solutions/go/02-rg2/code/go.sum: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codecrafters-io/build-your-own-redis/3071246154c7de189b21bce634b01c471d0f0401/solutions/go/02-rg2/code/go.sum -------------------------------------------------------------------------------- /solutions/haskell/01-jm1/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 compiles the program into $(stack path --local-install-root)/bin/codecrafters-redis-exe. 12 | stack build 13 | -------------------------------------------------------------------------------- /solutions/haskell/01-jm1/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 $(stack path --local-install-root)/bin/codecrafters-redis-exe "$@" -------------------------------------------------------------------------------- /solutions/haskell/01-jm1/code/.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | -------------------------------------------------------------------------------- /solutions/haskell/01-jm1/code/.gitignore: -------------------------------------------------------------------------------- 1 | codecrafters-redis.cabal 2 | *~ 3 | dist 4 | dist-* 5 | cabal-dev 6 | *.o 7 | *.hi 8 | *.hie 9 | *.chi 10 | *.chs.h 11 | *.dyn_o 12 | *.dyn_hi 13 | .hpc 14 | .hsenv 15 | .cabal-sandbox/ 16 | cabal.sandbox.config 17 | *.prof 18 | *.aux 19 | *.hp 20 | *.eventlog 21 | .stack/ 22 | .stack-work/ 23 | cabal.project.local 24 | cabal.project.local~ 25 | .HTF/ 26 | .ghc.environment.* -------------------------------------------------------------------------------- /solutions/haskell/01-jm1/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 Haskell version used to run your code 8 | # on Codecrafters. 9 | # 10 | # Available versions: haskell-9.8 11 | language_pack: haskell-9.8 12 | -------------------------------------------------------------------------------- /solutions/haskell/01-jm1/code/stack.yaml: -------------------------------------------------------------------------------- 1 | resolver: lts-23.18 2 | 3 | packages: 4 | - . 5 | -------------------------------------------------------------------------------- /solutions/haskell/01-jm1/code/stack.yaml.lock: -------------------------------------------------------------------------------- 1 | # This file was autogenerated by Stack. 2 | # You should not edit this file by hand. 3 | # For more information, please see the documentation at: 4 | # https://docs.haskellstack.org/en/stable/lock_files 5 | 6 | packages: [] 7 | snapshots: 8 | - completed: 9 | sha256: d133abe75e408a407cce3f032c96ac1bbadf474a93b5156ebf4135b53382d56b 10 | size: 683827 11 | url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/23/18.yaml 12 | original: lts-23.18 13 | -------------------------------------------------------------------------------- /solutions/haskell/01-jm1/explanation.md: -------------------------------------------------------------------------------- 1 | The entry point for your Redis implementation is in `app/Main.hs`. 2 | 3 | Study and uncomment the relevant code: 4 | 5 | ```haskell 6 | -- Uncomment this block to pass stage 1 7 | let port = "6379" 8 | putStrLn $ "Redis server listening on port " ++ port 9 | serve HostAny port $ \(socket, address) -> do 10 | putStrLn $ "successfully connected client: " ++ show address 11 | closeSock socket 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/java/01-jm1/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-redis-java 12 | -------------------------------------------------------------------------------- /solutions/java/01-jm1/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-redis-java/codecrafters-redis.jar "$@" 12 | -------------------------------------------------------------------------------- /solutions/java/01-jm1/code/.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | -------------------------------------------------------------------------------- /solutions/java/01-jm1/code/.gitignore: -------------------------------------------------------------------------------- 1 | *.jar 2 | target/ 3 | .idea/ 4 | -------------------------------------------------------------------------------- /solutions/java/01-jm1/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/02-rg2/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-redis-java 12 | -------------------------------------------------------------------------------- /solutions/java/02-rg2/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-redis-java/codecrafters-redis.jar "$@" 12 | -------------------------------------------------------------------------------- /solutions/java/02-rg2/code/.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | -------------------------------------------------------------------------------- /solutions/java/02-rg2/code/.gitignore: -------------------------------------------------------------------------------- 1 | *.jar 2 | target/ 3 | .idea/ 4 | -------------------------------------------------------------------------------- /solutions/java/02-rg2/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/javascript/01-jm1/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-jm1/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-jm1/code/.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | -------------------------------------------------------------------------------- /solutions/javascript/01-jm1/code/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | -------------------------------------------------------------------------------- /solutions/javascript/01-jm1/code/app/main.js: -------------------------------------------------------------------------------- 1 | const net = require("net"); 2 | 3 | const server = net.createServer((connection) => { 4 | // Handle connection 5 | }); 6 | 7 | server.listen(6379, "127.0.0.1"); 8 | -------------------------------------------------------------------------------- /solutions/javascript/01-jm1/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-jm1/code/package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@codecrafters/redis", 3 | "version": "1.0.0", 4 | "lockfileVersion": 3, 5 | "requires": true, 6 | "packages": { 7 | "": { 8 | "name": "@codecrafters/redis", 9 | "version": "1.0.0" 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /solutions/javascript/01-jm1/code/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@codecrafters/redis", 3 | "version": "1.0.0", 4 | "dependencies": {} 5 | } 6 | -------------------------------------------------------------------------------- /solutions/javascript/01-jm1/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-jm1/diff/app/main.js.diff: -------------------------------------------------------------------------------- 1 | @@ -1,11 +1,7 @@ 2 | const net = require("net"); 3 | 4 | -// You can use print statements as follows for debugging, they'll be visible when running tests. 5 | -console.log("Logs from your program will appear here!"); 6 | +const server = net.createServer((connection) => { 7 | + // Handle connection 8 | +}); 9 | 10 | -// Uncomment this block to pass the first stage 11 | -// const server = net.createServer((connection) => { 12 | -// // Handle connection 13 | -// }); 14 | -// 15 | -// server.listen(6379, "127.0.0.1"); 16 | +server.listen(6379, "127.0.0.1"); 17 | -------------------------------------------------------------------------------- /solutions/javascript/01-jm1/explanation.md: -------------------------------------------------------------------------------- 1 | The entry point for your Redis 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 | const server = net.createServer((connection) => { 8 | // Handle connection 9 | }); 10 | 11 | server.listen(6379, "127.0.0.1"); 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/javascript/02-rg2/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/02-rg2/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/02-rg2/code/.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | -------------------------------------------------------------------------------- /solutions/javascript/02-rg2/code/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | -------------------------------------------------------------------------------- /solutions/javascript/02-rg2/code/app/main.js: -------------------------------------------------------------------------------- 1 | const net = require("net"); 2 | 3 | const server = net.createServer((connection) => { 4 | // Handle connection 5 | connection.write(`+PONG\r\n`); 6 | }); 7 | 8 | server.listen(6379, "127.0.0.1"); 9 | -------------------------------------------------------------------------------- /solutions/javascript/02-rg2/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/02-rg2/code/package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@codecrafters/redis", 3 | "version": "1.0.0", 4 | "lockfileVersion": 3, 5 | "requires": true, 6 | "packages": { 7 | "": { 8 | "name": "@codecrafters/redis", 9 | "version": "1.0.0" 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /solutions/javascript/02-rg2/code/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@codecrafters/redis", 3 | "version": "1.0.0", 4 | "dependencies": {} 5 | } 6 | -------------------------------------------------------------------------------- /solutions/javascript/02-rg2/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/02-rg2/diff/app/main.js.diff: -------------------------------------------------------------------------------- 1 | @@ -1,7 +1,8 @@ 2 | const net = require("net"); 3 | 4 | const server = net.createServer((connection) => { 5 | // Handle connection 6 | + connection.write(`+PONG\r\n`); 7 | }); 8 | 9 | server.listen(6379, "127.0.0.1"); 10 | -------------------------------------------------------------------------------- /solutions/kotlin/01-jm1/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-jm1/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-redis.jar "$@" 12 | -------------------------------------------------------------------------------- /solutions/kotlin/01-jm1/code/.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | -------------------------------------------------------------------------------- /solutions/kotlin/01-jm1/code/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | .idea/ -------------------------------------------------------------------------------- /solutions/kotlin/01-jm1/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-jm1/code/src/main/kotlin/Main.kt: -------------------------------------------------------------------------------- 1 | import java.net.ServerSocket 2 | 3 | fun main(args: Array) { 4 | var serverSocket = ServerSocket(6379) 5 | 6 | // Since the tester restarts your program quite often, setting SO_REUSEADDR 7 | // ensures that we don't run into 'Address already in use' errors 8 | serverSocket.reuseAddress = true 9 | 10 | serverSocket.accept() // Wait for connection from client. 11 | println("accepted new connection") 12 | } 13 | -------------------------------------------------------------------------------- /solutions/ocaml/01-jm1/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-redis-ocaml 12 | -------------------------------------------------------------------------------- /solutions/ocaml/01-jm1/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-redis-ocaml/default/main.exe "$@" 12 | -------------------------------------------------------------------------------- /solutions/ocaml/01-jm1/code/.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | -------------------------------------------------------------------------------- /solutions/ocaml/01-jm1/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-jm1/code/.ocamlformat: -------------------------------------------------------------------------------- 1 | profile = default -------------------------------------------------------------------------------- /solutions/ocaml/01-jm1/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-jm1/code/dune: -------------------------------------------------------------------------------- 1 | (include_subdirs unqualified) 2 | 3 | (executable 4 | (name main) 5 | (libraries unix)) 6 | -------------------------------------------------------------------------------- /solutions/ocaml/01-jm1/code/dune-project: -------------------------------------------------------------------------------- 1 | (lang dune 3.16) 2 | 3 | (name codecrafters_redis) 4 | 5 | (generate_opam_files true) 6 | 7 | (package 8 | (name codecrafters_redis) 9 | (maintainers "CodeCrafters ") 10 | (authors "CodeCrafters ") 11 | (synopsis "Starter code for the Build your own Redis challenge") 12 | (homepage "https://codecrafters.io") 13 | (bug_reports 14 | "https://github.com/codecrafters-io/build-your-own-redis/issues") 15 | (license "MIT") 16 | (allow_empty true) 17 | (version 0.1)) 18 | -------------------------------------------------------------------------------- /solutions/ocaml/01-jm1/code/src/main.ml: -------------------------------------------------------------------------------- 1 | open Unix 2 | 3 | let () = 4 | (* Create a TCP server socket *) 5 | let server_socket = socket PF_INET SOCK_STREAM 0 in 6 | setsockopt server_socket SO_REUSEADDR true; 7 | bind server_socket (ADDR_INET (inet_addr_of_string "127.0.0.1", 6379)); 8 | listen server_socket 1; 9 | 10 | let (client_socket, _) = accept server_socket in 11 | close client_socket; 12 | close server_socket 13 | -------------------------------------------------------------------------------- /solutions/ocaml/01-jm1/explanation.md: -------------------------------------------------------------------------------- 1 | The entry point for your Redis 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 | let (client_socket, _) = accept server_socket in 8 | close client_socket; 9 | close server_socket 10 | ``` 11 | 12 | Push your changes to pass the first stage: 13 | 14 | ``` 15 | git add . 16 | git commit -m "pass 1st stage" # any msg 17 | git push origin master 18 | ``` 19 | -------------------------------------------------------------------------------- /solutions/php/01-jm1/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) 12 | -------------------------------------------------------------------------------- /solutions/php/01-jm1/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-jm1/code/.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | -------------------------------------------------------------------------------- /solutions/php/01-jm1/code/app/main.php: -------------------------------------------------------------------------------- 1 | 2.4" 10 | -------------------------------------------------------------------------------- /solutions/ruby/01-jm1/code/Gemfile.lock: -------------------------------------------------------------------------------- 1 | GEM 2 | remote: https://rubygems.org/ 3 | specs: 4 | bindata (2.4.15) 5 | 6 | PLATFORMS 7 | aarch64-linux-musl 8 | arm64-darwin-21 9 | x86_64-linux 10 | 11 | DEPENDENCIES 12 | bindata (~> 2.4) 13 | 14 | BUNDLED WITH 15 | 2.4.18 16 | -------------------------------------------------------------------------------- /solutions/ruby/01-jm1/code/app/server.rb: -------------------------------------------------------------------------------- 1 | require "socket" 2 | 3 | class YourRedisServer 4 | def initialize(port) 5 | @port = port 6 | end 7 | 8 | def start 9 | server = TCPServer.new(@port) 10 | client = server.accept 11 | end 12 | end 13 | 14 | YourRedisServer.new(6379).start 15 | -------------------------------------------------------------------------------- /solutions/ruby/01-jm1/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 Ruby version used to run your code 8 | # on Codecrafters. 9 | # 10 | # Available versions: ruby-3.3 11 | language_pack: ruby-3.3 12 | -------------------------------------------------------------------------------- /solutions/ruby/01-jm1/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 bundle exec ruby app/server.rb "$@" 16 | -------------------------------------------------------------------------------- /solutions/ruby/01-jm1/diff/app/server.rb.diff: -------------------------------------------------------------------------------- 1 | @@ -1,18 +1,14 @@ 2 | require "socket" 3 | 4 | class YourRedisServer 5 | def initialize(port) 6 | @port = port 7 | end 8 | 9 | def start 10 | - # You can use print statements as follows for debugging, they'll be visible when running tests. 11 | - puts("Logs from your program will appear here!") 12 | - 13 | - # Uncomment this block to pass the first stage 14 | - # server = TCPServer.new(@port) 15 | - # client = server.accept 16 | + server = TCPServer.new(@port) 17 | + client = server.accept 18 | end 19 | end 20 | 21 | YourRedisServer.new(6379).start 22 | -------------------------------------------------------------------------------- /solutions/ruby/01-jm1/explanation.md: -------------------------------------------------------------------------------- 1 | The entry point for your Redis implementation is in `app/server.rb`. 2 | 3 | Study and uncomment the relevant code: 4 | 5 | ```ruby 6 | # Uncomment this block to pass the first stage 7 | server = TCPServer.new(@port) 8 | client = server.accept 9 | ``` 10 | 11 | Push your changes to pass the first stage: 12 | 13 | ``` 14 | git add . 15 | git commit -m "pass 1st stage" # any msg 16 | git push origin master 17 | ``` 18 | -------------------------------------------------------------------------------- /solutions/rust/01-jm1/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-redis-rust --manifest-path Cargo.toml 12 | -------------------------------------------------------------------------------- /solutions/rust/01-jm1/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-redis-rust/release/codecrafters-redis "$@" 12 | -------------------------------------------------------------------------------- /solutions/rust/01-jm1/code/.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | -------------------------------------------------------------------------------- /solutions/rust/01-jm1/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-jm1/code/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "codecrafters-redis" 3 | version = "0.1.0" 4 | authors = ["Codecrafters "] 5 | edition = "2021" 6 | 7 | [dependencies] 8 | anyhow = "1.0.59" # error handling 9 | bytes = "1.3.0" # helps manage buffers 10 | thiserror = "1.0.32" # error handling 11 | tokio = { version = "1.23.0", features = ["full"] } # async networking 12 | -------------------------------------------------------------------------------- /solutions/rust/01-jm1/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-jm1/code/src/main.rs: -------------------------------------------------------------------------------- 1 | #![allow(unused_imports)] 2 | use std::net::TcpListener; 3 | 4 | fn main() { 5 | let listener = TcpListener::bind("127.0.0.1:6379").unwrap(); 6 | 7 | for stream in listener.incoming() { 8 | match stream { 9 | Ok(_stream) => { 10 | println!("accepted new connection"); 11 | } 12 | Err(e) => { 13 | println!("error: {}", e); 14 | } 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /solutions/rust/02-rg2/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-redis-rust --manifest-path Cargo.toml 12 | -------------------------------------------------------------------------------- /solutions/rust/02-rg2/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-redis-rust/release/codecrafters-redis "$@" 12 | -------------------------------------------------------------------------------- /solutions/rust/02-rg2/code/.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | -------------------------------------------------------------------------------- /solutions/rust/02-rg2/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/02-rg2/code/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "codecrafters-redis" 3 | version = "0.1.0" 4 | authors = ["Codecrafters "] 5 | edition = "2021" 6 | 7 | [dependencies] 8 | anyhow = "1.0.59" # error handling 9 | bytes = "1.3.0" # helps manage buffers 10 | thiserror = "1.0.32" # error handling 11 | tokio = { version = "1.23.0", features = ["full"] } # async networking 12 | -------------------------------------------------------------------------------- /solutions/rust/02-rg2/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/02-rg2/code/src/main.rs: -------------------------------------------------------------------------------- 1 | #![allow(unused_imports)] 2 | use std::io::Write; 3 | use std::net::TcpListener; 4 | 5 | fn main() { 6 | let listener = TcpListener::bind("127.0.0.1:6379").unwrap(); 7 | 8 | for stream in listener.incoming() { 9 | match stream { 10 | Ok(mut stream) => { 11 | stream.write_all(b"+PONG\r\n").unwrap(); 12 | } 13 | Err(e) => { 14 | println!("error: {}", e); 15 | } 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /solutions/rust/02-rg2/diff/src/main.rs.diff: -------------------------------------------------------------------------------- 1 | @@ -1,17 +1,18 @@ 2 | #![allow(unused_imports)] 3 | +use std::io::Write; 4 | use std::net::TcpListener; 5 | 6 | fn main() { 7 | let listener = TcpListener::bind("127.0.0.1:6379").unwrap(); 8 | 9 | for stream in listener.incoming() { 10 | match stream { 11 | - Ok(_stream) => { 12 | - println!("accepted new connection"); 13 | + Ok(mut stream) => { 14 | + stream.write_all(b"+PONG\r\n").unwrap(); 15 | } 16 | Err(e) => { 17 | println!("error: {}", e); 18 | } 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /solutions/scala/01-jm1/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 | sbt assembly 12 | -------------------------------------------------------------------------------- /solutions/scala/01-jm1/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 ./target/scala-2.13/redis.jar "$@" 12 | -------------------------------------------------------------------------------- /solutions/scala/01-jm1/code/.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | -------------------------------------------------------------------------------- /solutions/scala/01-jm1/code/.gitignore: -------------------------------------------------------------------------------- 1 | debug/ 2 | target/ 3 | -------------------------------------------------------------------------------- /solutions/scala/01-jm1/code/build.sbt: -------------------------------------------------------------------------------- 1 | ThisBuild / scalaVersion := "2.13.12" 2 | ThisBuild / version := "0.1.0-SNAPSHOT" 3 | ThisBuild / organization := "com.CodeCrafters" 4 | ThisBuild / organizationName := "CodeCrafters" 5 | 6 | assembly / assemblyJarName := "redis.jar" 7 | 8 | lazy val root = (project in file(".")) 9 | .settings( 10 | name := "codecrafter-redis", 11 | // List your dependencies here 12 | libraryDependencies ++= Seq( 13 | ) 14 | ) 15 | -------------------------------------------------------------------------------- /solutions/scala/01-jm1/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 Scala version used to run your code 8 | # on Codecrafters. 9 | # 10 | # Available versions: scala-2.12 11 | language_pack: scala-2.12 12 | -------------------------------------------------------------------------------- /solutions/scala/01-jm1/code/project/assembly.sbt: -------------------------------------------------------------------------------- 1 | addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.10") 2 | -------------------------------------------------------------------------------- /solutions/scala/01-jm1/code/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.9.9 2 | -------------------------------------------------------------------------------- /solutions/scala/01-jm1/code/src/main/scala/codecrafters_redis/Server.scala: -------------------------------------------------------------------------------- 1 | package codecrafters_redis 2 | 3 | import java.net.{InetSocketAddress, ServerSocket} 4 | 5 | object Server { 6 | def main(args: Array[String]): Unit = { 7 | val serverSocket = new ServerSocket() 8 | serverSocket.bind(new InetSocketAddress("localhost", 6379)) 9 | val clientSocket = serverSocket.accept() // wait for client 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /solutions/scala/01-jm1/explanation.md: -------------------------------------------------------------------------------- 1 | The entry point for your Redis implementation is in `src/main/scala/codecrafters_redis/Server.scala`. 2 | 3 | Study and uncomment the relevant code: 4 | 5 | ```scala 6 | // Uncomment this to pass the first stage 7 | 8 | val serverSocket = new ServerSocket() 9 | serverSocket.bind(new InetSocketAddress("localhost", 6379)) 10 | val clientSocket = serverSocket.accept() // wait for client 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/swift/01-jm1/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-redis-swift 12 | -------------------------------------------------------------------------------- /solutions/swift/01-jm1/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-redis-swift build-your-own-redis "$@" 12 | -------------------------------------------------------------------------------- /solutions/swift/01-jm1/code/.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | -------------------------------------------------------------------------------- /solutions/swift/01-jm1/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-jm1/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/typescript/01-jm1/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-jm1/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-jm1/code/.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | -------------------------------------------------------------------------------- /solutions/typescript/01-jm1/code/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | -------------------------------------------------------------------------------- /solutions/typescript/01-jm1/code/app/main.ts: -------------------------------------------------------------------------------- 1 | import * as net from "net"; 2 | 3 | const server: net.Server = net.createServer((connection: net.Socket) => { 4 | // Handle connection 5 | }); 6 | 7 | server.listen(6379, "127.0.0.1"); 8 | -------------------------------------------------------------------------------- /solutions/typescript/01-jm1/code/bun.lockb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codecrafters-io/build-your-own-redis/3071246154c7de189b21bce634b01c471d0f0401/solutions/typescript/01-jm1/code/bun.lockb -------------------------------------------------------------------------------- /solutions/typescript/01-jm1/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-jm1/code/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@codecrafters/redis", 3 | "description": "Build your own Redis 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-jm1/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-jm1/diff/app/main.ts.diff: -------------------------------------------------------------------------------- 1 | @@ -1,11 +1,7 @@ 2 | import * as net from "net"; 3 | 4 | -// You can use print statements as follows for debugging, they'll be visible when running tests. 5 | -console.log("Logs from your program will appear here!"); 6 | +const server: net.Server = net.createServer((connection: net.Socket) => { 7 | + // Handle connection 8 | +}); 9 | 10 | -// Uncomment this block to pass the first stage 11 | -// const server: net.Server = net.createServer((connection: net.Socket) => { 12 | -// // Handle connection 13 | -// }); 14 | -// 15 | -// server.listen(6379, "127.0.0.1"); 16 | +server.listen(6379, "127.0.0.1"); 17 | -------------------------------------------------------------------------------- /solutions/typescript/01-jm1/explanation.md: -------------------------------------------------------------------------------- 1 | The entry point for your Redis 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 | const server: net.Server = net.createServer((connection: net.Socket) => { 8 | // Handle connection 9 | }); 10 | 11 | server.listen(6379, "127.0.0.1"); 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/typescript/02-rg2/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/02-rg2/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/02-rg2/code/.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | -------------------------------------------------------------------------------- /solutions/typescript/02-rg2/code/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | -------------------------------------------------------------------------------- /solutions/typescript/02-rg2/code/app/main.ts: -------------------------------------------------------------------------------- 1 | import * as net from "net"; 2 | 3 | const server: net.Server = net.createServer((connection: net.Socket) => { 4 | // Handle connection 5 | connection.write(`+PONG\r\n`); 6 | }); 7 | 8 | server.listen(6379, "127.0.0.1"); 9 | -------------------------------------------------------------------------------- /solutions/typescript/02-rg2/code/bun.lockb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codecrafters-io/build-your-own-redis/3071246154c7de189b21bce634b01c471d0f0401/solutions/typescript/02-rg2/code/bun.lockb -------------------------------------------------------------------------------- /solutions/typescript/02-rg2/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/02-rg2/code/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@codecrafters/redis", 3 | "description": "Build your own Redis 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/02-rg2/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/02-rg2/diff/app/main.ts.diff: -------------------------------------------------------------------------------- 1 | @@ -1,7 +1,8 @@ 2 | import * as net from "net"; 3 | 4 | const server: net.Server = net.createServer((connection: net.Socket) => { 5 | // Handle connection 6 | + connection.write(`+PONG\r\n`); 7 | }); 8 | 9 | server.listen(6379, "127.0.0.1"); 10 | -------------------------------------------------------------------------------- /solutions/zig/01-jm1/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-jm1/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 zig-out/bin/main "$@" 12 | -------------------------------------------------------------------------------- /solutions/zig/01-jm1/code/.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | -------------------------------------------------------------------------------- /solutions/zig/01-jm1/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-jm1/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-jm1/code/src/main.zig: -------------------------------------------------------------------------------- 1 | const std = @import("std"); 2 | const net = std.net; 3 | 4 | pub fn main() !void { 5 | const stdout = std.io.getStdOut().writer(); 6 | 7 | const address = try net.Address.resolveIp("127.0.0.1", 6379); 8 | 9 | var listener = try address.listen(.{ 10 | .reuse_address = true, 11 | }); 12 | defer listener.deinit(); 13 | 14 | while (true) { 15 | const connection = try listener.accept(); 16 | 17 | try stdout.print("accepted new connection", .{}); 18 | connection.stream.close(); 19 | } 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/redis "$@" 12 | -------------------------------------------------------------------------------- /starter_templates/c/code/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.13) 2 | 3 | project(codecrafters-redis) 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(redis ${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 | } -------------------------------------------------------------------------------- /starter_templates/c/config.yml: -------------------------------------------------------------------------------- 1 | attributes: 2 | required_executable: cmake 3 | user_editable_file: src/main.c 4 | -------------------------------------------------------------------------------- /starter_templates/clojure/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 | clj -T:build 12 | -------------------------------------------------------------------------------- /starter_templates/clojure/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-redis-clojure/target.jar "$@" 12 | -------------------------------------------------------------------------------- /starter_templates/clojure/code/.gitignore: -------------------------------------------------------------------------------- 1 | pom.xml 2 | pom.xml.asc 3 | *.jar 4 | *.class 5 | /lib/ 6 | /classes/ 7 | /target/ 8 | /checkouts/ 9 | .lein-deps-sum 10 | .lein-repl-history 11 | .lein-plugins/ 12 | .lein-failures 13 | .nrepl-port 14 | .cpcache/ 15 | deps/ -------------------------------------------------------------------------------- /starter_templates/clojure/code/deps.edn: -------------------------------------------------------------------------------- 1 | { 2 | :paths ["src"] 3 | 4 | :deps { 5 | org.clojure/clojure {:mvn/version "1.12.0"} 6 | org.clojure/tools.cli {:mvn/version "1.1.230"} 7 | aleph/aleph {:mvn/version "0.8.3"} 8 | } 9 | 10 | :aliases { 11 | :build { 12 | :extra-deps {io.github.clojure/tools.build {:mvn/version "0.10.9"}} 13 | :exec-fn build/uber 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /starter_templates/clojure/config.yml: -------------------------------------------------------------------------------- 1 | attributes: 2 | required_executable: clj 3 | user_editable_file: src/redis/core.clj 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 ./build/server "$@" 12 | -------------------------------------------------------------------------------- /starter_templates/cpp/code/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.13) 2 | 3 | project(redis-starter-cpp) 4 | 5 | file(GLOB_RECURSE SOURCE_FILES src/*.cpp) 6 | 7 | set(CMAKE_CXX_STANDARD 23) # Enable the C++23 standard 8 | set(THREADS_PREFER_PTHREAD_FLAG ON) 9 | 10 | find_package(Threads REQUIRED) 11 | find_package(asio CONFIG REQUIRED) 12 | 13 | add_executable(server ${SOURCE_FILES}) 14 | 15 | target_link_libraries(server PRIVATE asio asio::asio) 16 | target_link_libraries(server PRIVATE Threads::Threads) -------------------------------------------------------------------------------- /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 | } 15 | -------------------------------------------------------------------------------- /starter_templates/cpp/code/vcpkg.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": [ 3 | "asio", 4 | "pthreads" 5 | ] 6 | } 7 | -------------------------------------------------------------------------------- /starter_templates/cpp/config.yml: -------------------------------------------------------------------------------- 1 | attributes: 2 | required_executable: cmake 3 | user_editable_file: src/Server.cpp 4 | -------------------------------------------------------------------------------- /starter_templates/crystal/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 | crystal build -o /tmp/codecrafters-build-redis-crystal app/main.cr 12 | -------------------------------------------------------------------------------- /starter_templates/crystal/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-redis-crystal "$@" 12 | -------------------------------------------------------------------------------- /starter_templates/crystal/code/app/main.cr: -------------------------------------------------------------------------------- 1 | require "socket" 2 | 3 | # Ensure that the program terminates on SIGTERM, https://github.com/crystal-lang/crystal/issues/8687 4 | Signal::TERM.trap { exit } 5 | 6 | class YourRedisServer 7 | def start 8 | # You can use print statements as follows for debugging, they'll be visible when running tests. 9 | puts("Logs from your program will appear here!") 10 | 11 | # Uncomment this block to pass the first stage 12 | # server = TCPServer.new("0.0.0.0", 6379) 13 | # client = server.accept? 14 | end 15 | end 16 | 17 | YourRedisServer.new.start 18 | -------------------------------------------------------------------------------- /starter_templates/crystal/config.yml: -------------------------------------------------------------------------------- 1 | attributes: 2 | required_executable: crystal (1.1.0) 3 | user_editable_file: app/main.cr 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-redis-csharp codecrafters-redis.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-redis-csharp/codecrafters-redis "$@" -------------------------------------------------------------------------------- /starter_templates/csharp/code/codecrafters-redis.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net9.0 6 | codecrafters_redis 7 | enable 8 | enable 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /starter_templates/csharp/code/src/Server.cs: -------------------------------------------------------------------------------- 1 | using System.Net; 2 | using System.Net.Sockets; 3 | 4 | // You can use print statements as follows for debugging, they'll be visible when running tests. 5 | Console.WriteLine("Logs from your program will appear here!"); 6 | 7 | // Uncomment this block to pass the first stage 8 | // TcpListener server = new TcpListener(IPAddress.Any, 6379); 9 | // server.Start(); 10 | // server.AcceptSocket(); // wait for client 11 | -------------------------------------------------------------------------------- /starter_templates/csharp/config.yml: -------------------------------------------------------------------------------- 1 | attributes: 2 | required_executable: dotnet (8.0) 3 | user_editable_file: src/Server.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_redis /tmp/codecrafters-build-redis-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-redis-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/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_redis" 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 | gleam_erlang = "~> 0.25" 10 | gleam_otp = "~> 0.10" 11 | glisten = "~> 2.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-redis-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-redis-go "$@" 12 | -------------------------------------------------------------------------------- /starter_templates/go/code/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/codecrafters-io/redis-starter-go 2 | 3 | go 1.24.0 4 | -------------------------------------------------------------------------------- /starter_templates/go/code/go.sum: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codecrafters-io/build-your-own-redis/3071246154c7de189b21bce634b01c471d0f0401/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/haskell/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 compiles the program into $(stack path --local-install-root)/bin/codecrafters-redis-exe. 12 | stack build 13 | -------------------------------------------------------------------------------- /starter_templates/haskell/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 $(stack path --local-install-root)/bin/codecrafters-redis-exe "$@" -------------------------------------------------------------------------------- /starter_templates/haskell/code/.gitignore: -------------------------------------------------------------------------------- 1 | codecrafters-redis.cabal 2 | *~ 3 | dist 4 | dist-* 5 | cabal-dev 6 | *.o 7 | *.hi 8 | *.hie 9 | *.chi 10 | *.chs.h 11 | *.dyn_o 12 | *.dyn_hi 13 | .hpc 14 | .hsenv 15 | .cabal-sandbox/ 16 | cabal.sandbox.config 17 | *.prof 18 | *.aux 19 | *.hp 20 | *.eventlog 21 | .stack/ 22 | .stack-work/ 23 | cabal.project.local 24 | cabal.project.local~ 25 | .HTF/ 26 | .ghc.environment.* -------------------------------------------------------------------------------- /starter_templates/haskell/code/stack.yaml: -------------------------------------------------------------------------------- 1 | resolver: lts-23.18 2 | 3 | packages: 4 | - . 5 | -------------------------------------------------------------------------------- /starter_templates/haskell/code/stack.yaml.lock: -------------------------------------------------------------------------------- 1 | # This file was autogenerated by Stack. 2 | # You should not edit this file by hand. 3 | # For more information, please see the documentation at: 4 | # https://docs.haskellstack.org/en/stable/lock_files 5 | 6 | packages: [] 7 | snapshots: 8 | - completed: 9 | sha256: d133abe75e408a407cce3f032c96ac1bbadf474a93b5156ebf4135b53382d56b 10 | size: 683827 11 | url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/23/18.yaml 12 | original: lts-23.18 13 | -------------------------------------------------------------------------------- /starter_templates/haskell/config.yml: -------------------------------------------------------------------------------- 1 | attributes: 2 | required_executable: stack (23.18) 3 | user_editable_file: app/Main.hs 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-redis-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-redis-java/codecrafters-redis.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 | node_modules/ 2 | -------------------------------------------------------------------------------- /starter_templates/javascript/code/app/main.js: -------------------------------------------------------------------------------- 1 | const net = require("net"); 2 | 3 | // You can use print statements as follows for debugging, they'll be visible when running tests. 4 | console.log("Logs from your program will appear here!"); 5 | 6 | // Uncomment this block to pass the first stage 7 | // const server = net.createServer((connection) => { 8 | // // Handle connection 9 | // }); 10 | // 11 | // server.listen(6379, "127.0.0.1"); 12 | -------------------------------------------------------------------------------- /starter_templates/javascript/code/package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@codecrafters/redis", 3 | "version": "1.0.0", 4 | "lockfileVersion": 3, 5 | "requires": true, 6 | "packages": { 7 | "": { 8 | "name": "@codecrafters/redis", 9 | "version": "1.0.0" 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /starter_templates/javascript/code/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@codecrafters/redis", 3 | "version": "1.0.0", 4 | "dependencies": {} 5 | } 6 | -------------------------------------------------------------------------------- /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-redis.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-redis-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-redis-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/dune: -------------------------------------------------------------------------------- 1 | (include_subdirs unqualified) 2 | 3 | (executable 4 | (name main) 5 | (libraries unix)) 6 | -------------------------------------------------------------------------------- /starter_templates/ocaml/code/dune-project: -------------------------------------------------------------------------------- 1 | (lang dune 3.16) 2 | 3 | (name codecrafters_redis) 4 | 5 | (generate_opam_files true) 6 | 7 | (package 8 | (name codecrafters_redis) 9 | (maintainers "CodeCrafters ") 10 | (authors "CodeCrafters ") 11 | (synopsis "Starter code for the Build your own Redis challenge") 12 | (homepage "https://codecrafters.io") 13 | (bug_reports 14 | "https://github.com/codecrafters-io/build-your-own-redis/issues") 15 | (license "MIT") 16 | (allow_empty true) 17 | (version 0.1)) 18 | -------------------------------------------------------------------------------- /starter_templates/ocaml/config.yml: -------------------------------------------------------------------------------- 1 | attributes: 2 | required_executable: "dune" 3 | user_editable_file: "src/main.ml" 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) 12 | -------------------------------------------------------------------------------- /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/config.yml: -------------------------------------------------------------------------------- 1 | attributes: 2 | required_executable: php (7.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 | set -e # Exit on failure 10 | 11 | # (This file is empty since Python programs don't use a compile step) 12 | -------------------------------------------------------------------------------- /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 | set -e # Exit on failure 10 | 11 | exec pipenv run python3 -m app.main "$@" -------------------------------------------------------------------------------- /starter_templates/python/code/Pipfile: -------------------------------------------------------------------------------- 1 | [[source]] 2 | url = "https://pypi.org/simple" 3 | verify_ssl = true 4 | name = "pypi" 5 | 6 | [packages] 7 | 8 | [dev-packages] 9 | 10 | [requires] 11 | python_version = "3" 12 | -------------------------------------------------------------------------------- /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 socket # noqa: F401 2 | 3 | 4 | def main(): 5 | # You can use print statements as follows for debugging, they'll be visible when running tests. 6 | print("Logs from your program will appear here!") 7 | 8 | # Uncomment this to pass the first stage 9 | # 10 | # server_socket = socket.create_server(("localhost", 6379), reuse_port=True) 11 | # server_socket.accept() # wait for client 12 | 13 | 14 | if __name__ == "__main__": 15 | main() 16 | -------------------------------------------------------------------------------- /starter_templates/python/config.yml: -------------------------------------------------------------------------------- 1 | attributes: 2 | required_executable: "python (3.13)" 3 | user_editable_file: "app/main.py" 4 | -------------------------------------------------------------------------------- /starter_templates/ruby/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 Ruby programs don't use a compile step) 12 | -------------------------------------------------------------------------------- /starter_templates/ruby/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 bundle exec ruby app/server.rb "$@" 12 | -------------------------------------------------------------------------------- /starter_templates/ruby/code/Gemfile: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | source "https://rubygems.org" 4 | 5 | # Add gems here if you need to use them. 6 | # Make sure to run `bundle install` before running tests or submitting your code. 7 | 8 | # Helps with declaratively parsing binary data. 9 | gem "bindata", "~> 2.4" 10 | -------------------------------------------------------------------------------- /starter_templates/ruby/code/Gemfile.lock: -------------------------------------------------------------------------------- 1 | GEM 2 | remote: https://rubygems.org/ 3 | specs: 4 | bindata (2.4.15) 5 | 6 | PLATFORMS 7 | aarch64-linux-musl 8 | arm64-darwin-21 9 | x86_64-linux 10 | 11 | DEPENDENCIES 12 | bindata (~> 2.4) 13 | 14 | BUNDLED WITH 15 | 2.4.18 16 | -------------------------------------------------------------------------------- /starter_templates/ruby/code/app/server.rb: -------------------------------------------------------------------------------- 1 | require "socket" 2 | 3 | class YourRedisServer 4 | def initialize(port) 5 | @port = port 6 | end 7 | 8 | def start 9 | # You can use print statements as follows for debugging, they'll be visible when running tests. 10 | puts("Logs from your program will appear here!") 11 | 12 | # Uncomment this block to pass the first stage 13 | # server = TCPServer.new(@port) 14 | # client = server.accept 15 | end 16 | end 17 | 18 | YourRedisServer.new(6379).start 19 | -------------------------------------------------------------------------------- /starter_templates/ruby/config.yml: -------------------------------------------------------------------------------- 1 | attributes: 2 | required_executable: ruby (2.7) 3 | user_editable_file: app/server.rb 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-redis-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-redis-rust/release/codecrafters-redis "$@" 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-redis" 3 | version = "0.1.0" 4 | authors = ["Codecrafters "] 5 | edition = "2021" 6 | 7 | [dependencies] 8 | anyhow = "1.0.59" # error handling 9 | bytes = "1.3.0" # helps manage buffers 10 | thiserror = "1.0.32" # error handling 11 | tokio = { version = "1.23.0", features = ["full"] } # async networking 12 | -------------------------------------------------------------------------------- /starter_templates/rust/config.yml: -------------------------------------------------------------------------------- 1 | attributes: 2 | required_executable: cargo (1.86) 3 | user_editable_file: src/main.rs 4 | -------------------------------------------------------------------------------- /starter_templates/scala/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 | sbt assembly 12 | -------------------------------------------------------------------------------- /starter_templates/scala/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 ./target/scala-2.13/redis.jar "$@" 12 | -------------------------------------------------------------------------------- /starter_templates/scala/code/.gitignore: -------------------------------------------------------------------------------- 1 | debug/ 2 | target/ 3 | -------------------------------------------------------------------------------- /starter_templates/scala/code/build.sbt: -------------------------------------------------------------------------------- 1 | ThisBuild / scalaVersion := "2.13.12" 2 | ThisBuild / version := "0.1.0-SNAPSHOT" 3 | ThisBuild / organization := "com.CodeCrafters" 4 | ThisBuild / organizationName := "CodeCrafters" 5 | 6 | assembly / assemblyJarName := "redis.jar" 7 | 8 | lazy val root = (project in file(".")) 9 | .settings( 10 | name := "codecrafter-redis", 11 | // List your dependencies here 12 | libraryDependencies ++= Seq( 13 | ) 14 | ) 15 | -------------------------------------------------------------------------------- /starter_templates/scala/code/project/assembly.sbt: -------------------------------------------------------------------------------- 1 | addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.10") 2 | -------------------------------------------------------------------------------- /starter_templates/scala/code/project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=1.9.9 2 | -------------------------------------------------------------------------------- /starter_templates/scala/code/src/main/scala/codecrafters_redis/Server.scala: -------------------------------------------------------------------------------- 1 | package codecrafters_redis 2 | 3 | import java.net.{InetSocketAddress, ServerSocket} 4 | 5 | object Server { 6 | def main(args: Array[String]): Unit = { 7 | // You can use print statements as follows for debugging, they'll be visible when running tests. 8 | println("Logs from your program will appear here!") 9 | 10 | // Uncomment this to pass the first stage 11 | // 12 | // val serverSocket = new ServerSocket() 13 | // serverSocket.bind(new InetSocketAddress("localhost", 6379)) 14 | // val clientSocket = serverSocket.accept() // wait for client 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /starter_templates/scala/config.yml: -------------------------------------------------------------------------------- 1 | attributes: 2 | required_executable: sbt (1.9.9) 3 | user_editable_file: src/main/scala/codecrafters_redis/Server.scala 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-redis-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-redis-swift build-your-own-redis "$@" 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/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 * as net from "net"; 2 | 3 | // You can use print statements as follows for debugging, they'll be visible when running tests. 4 | console.log("Logs from your program will appear here!"); 5 | 6 | // Uncomment this block to pass the first stage 7 | // const server: net.Server = net.createServer((connection: net.Socket) => { 8 | // // Handle connection 9 | // }); 10 | // 11 | // server.listen(6379, "127.0.0.1"); 12 | -------------------------------------------------------------------------------- /starter_templates/typescript/code/bun.lockb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codecrafters-io/build-your-own-redis/3071246154c7de189b21bce634b01c471d0f0401/starter_templates/typescript/code/bun.lockb -------------------------------------------------------------------------------- /starter_templates/typescript/code/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@codecrafters/redis", 3 | "description": "Build your own Redis 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/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 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 | --------------------------------------------------------------------------------