Code Monkey home page Code Monkey logo

eleet_camel's Introduction

Eleet Camel

A collection of solutions to LeetCode challenges in OCaml.

Running

dune exec eleet_camel

runs all solutions against all test cases. In case of wrong solutions, you'll see a diff in the tests directory.

Adding Challenges

Setting Up Tests

  • Automate this

  • Create a .txt file inside tests named after the challenge number on LeetCode.

  • Separate each test case by \n---\n.

  • Add expected output for each test case, where the test and answer are separated by ===.

Example

Writing tests for challenge 1 on LeetCode.

Create the file.

touch tests/1.txt

Add test cases.

2 7 11 15
9
===
0 1

---

3 2 4
6
===
1 2

---

3 3
6
===
0 1

Writing a Solution

Registering an Implementation

  • Create a(n) .ml file inside lib.
  • Add it as a module in the solvers list defined in main.ml.
    • The list entry should be in the form ("<challenge number>", module <Name>).

Implementation

Make the .ml file created as part of registration satisfy the following contract.

  • type input: Specify the type of input to the main algorithm (solve).
  • type output: Specify the type of output returned by the main algorithm (solve).
  • val to_string : output -> string: Provide a function to convert the output to a string.
  • val parse : string -> input: Provide a function to convert the test (read as a string) into input.
  • val solve : intput -> output: Write the core algorithm.

eleet_camel's People

Contributors

theteachr avatar

Recommend Projects

  • React photo React

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

  • Vue.js photo Vue.js

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

  • Typescript photo Typescript

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

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

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

  • web

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

  • server

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

  • Machine learning

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

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

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

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.