Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/6cdh/op_setup.rkt
online/competitive programming setup for Racket
https://github.com/6cdh/op_setup.rkt
racket
Last synced: 18 days ago
JSON representation
online/competitive programming setup for Racket
- Host: GitHub
- URL: https://github.com/6cdh/op_setup.rkt
- Owner: 6cdh
- License: mit
- Created: 2023-05-23T12:12:52.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-10-27T15:45:18.000Z (3 months ago)
- Last Synced: 2024-11-16T04:10:54.962Z (3 months ago)
- Topics: racket
- Language: Racket
- Homepage:
- Size: 212 KB
- Stars: 5
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Here is a setup for competitive/online programming for Racket that I use mainly for Leetcode or CodeWars.
It aims to provide a workflow, not a lot of common used algorithms or data structures library though there are some common functions I prefer in `lib.rkt`.
## Workflow
1. You have your favorite library in `lib.rkt`.
2. In `run.rkt`, require `lib.rkt` first, then write code and test as usual.
3. Run `copy.sh`. It copies your code from `run.rkt` and only necessary code from `lib.rkt`, then writes to `output.rkt` and copy it to your clipboard.
4. Paste your code into the browser.
5. Remove any test code. Because the functions from `lib.rkt` are appended after the existing code in `run.rkt`, so the test code will run before the dependent functions are defined.In this way, you can write code without manually write or copy code from your library or share code with a lot of boilerplate code.
## Requirements
- Racket
- A tool for copying to the clipboard
- wl-clipboard on Wayland
- xclip on X11
- Windows WSL is supportedOther platforms are not supported because I don't use them and can't test it. Feel free to open a issue if you have suggestion for other platforms.
## Note
- Your code must be correct in order to be copied otherwise the script will complain when analyze the dependency of your code.
- By default, `#lang racket` is not copied. Use the `--langline` flag with `copier.rkt` to include it.
- the current copy time is ~2s.## Library
`lib.rkt` contains functions that some of them may attract you use Racket (or a lisp) on online programming platform:
- shorter and convenient multi-dimension vector utilities that are compatible with existing vector functions: `make-array`, `aset!`, `aref`, `aupd!`, ...
- debug macros that print expression and its value: `P`.
- debug macros that hijack a function then print input/output/recursive calls: `debugf!`.
- cache macros that defines a recursive function use hash table for cache, or a vector for premature optimization if you provide enough hints: `define/cache` and `define/cache-vec`.
- assert macro so you can place it somewhere to make sure your code are correct: `assert`.
- counter macro that hijack a function, and record the number of calls and return it when you need: `log-call-times!`.
- threading macro: `~>`.
- modulo macro that modulo nested expression: `lc-mod`.
- `C` macro that provide part of C like language experience, support nested infix expression, convenient bitwise operation operator, C style assignment.
- hijack macro that wraps a function, record the number of calls, max recursion depth, the number of distinct arguments, cpu time and gc time of this function: `statistic!`.