Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/theteachr/eleet_camel
Collection of solutions to LeetCode problems (in OCaml)
https://github.com/theteachr/eleet_camel
leetcode-solutions ocaml
Last synced: 4 days ago
JSON representation
Collection of solutions to LeetCode problems (in OCaml)
- Host: GitHub
- URL: https://github.com/theteachr/eleet_camel
- Owner: theteachr
- License: mit
- Created: 2023-06-04T12:12:33.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-12-19T10:48:08.000Z (11 months ago)
- Last Synced: 2023-12-19T12:39:09.296Z (11 months ago)
- Topics: leetcode-solutions, ocaml
- Language: OCaml
- Homepage:
- Size: 117 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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.
```bash
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 `("", module )`.### 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.