Merge pull request #21 from barrett-ruth/feat/philosophy
docs and philosophy
This commit is contained in:
commit
7b09d402a0
2 changed files with 96 additions and 28 deletions
94
doc/cp.txt
94
doc/cp.txt
|
|
@ -25,15 +25,14 @@ COMMANDS *cp-commands*
|
||||||
:CP {contest} Set up contest environment for {contest}.
|
:CP {contest} Set up contest environment for {contest}.
|
||||||
Available contests: atcoder, codeforces, cses
|
Available contests: atcoder, codeforces, cses
|
||||||
|
|
||||||
:CP {contest} {problem} Set up problem from {contest}. Scrapes test
|
:CP {contest} {contest_id} {problem_letter?}
|
||||||
cases and creates source file.
|
Set up problem from {contest}. Extract contest_id
|
||||||
|
and problem_letter (optional) from the problem URL.
|
||||||
|
Scrapes test cases and creates source file.
|
||||||
|
|
||||||
:CP {contest} {problem} {letter}
|
:CP {contest_id} {problem_letter}
|
||||||
For AtCoder/Codeforces: set up problem with
|
Set up problem in current contest mode.
|
||||||
specific letter (e.g. a, b, c)
|
Requires contest to be set first with :CP {contest}
|
||||||
|
|
||||||
:CP {problem} Set up {problem} in current contest mode.
|
|
||||||
Requires contest to be set first.
|
|
||||||
|
|
||||||
:CP run Compile and run current problem with test input.
|
:CP run Compile and run current problem with test input.
|
||||||
Shows execution time and output comparison.
|
Shows execution time and output comparison.
|
||||||
|
|
@ -135,31 +134,70 @@ filename Custom function to generate filenames
|
||||||
|
|
||||||
WORKFLOW *cp-workflow*
|
WORKFLOW *cp-workflow*
|
||||||
|
|
||||||
1. Set up contest environment: >
|
For the sake of consistency and simplicity, cp.nvim extracts contest/problem identifiers from
|
||||||
:CP atcoder
|
URLs. This means that, for example, CodeForces/AtCoder contests are configured by
|
||||||
<
|
their round id rather than round number. See below.
|
||||||
2. Set up specific problem: >
|
|
||||||
:CP abc123 a
|
|
||||||
<
|
|
||||||
This creates abc123a.cc and scrapes test cases to io/abc123a.in and
|
|
||||||
io/abc123a.expected. Alternatively, run :CP atcoder abc123 a
|
|
||||||
|
|
||||||
3. Write, test, and view your solution output:
|
PLATFORM-SPECIFIC USAGE *cp-platforms*
|
||||||
|
|
||||||
|
AtCoder ~
|
||||||
|
*cp-atcoder*
|
||||||
|
URL format: https://atcoder.jp/contests/abc123/tasks/abc123_a
|
||||||
|
|
||||||
|
In terms of cp.nvim, this corresponds to:
|
||||||
|
|
||||||
|
- Contest ID: abc123
|
||||||
|
- Problem letter: a
|
||||||
|
|
||||||
|
Usage examples: >
|
||||||
|
:CP atcoder abc123 a " Set up problem A from contest ABC123
|
||||||
|
:CP atcoder " Set up AtCoder contest mode first
|
||||||
|
:CP abc123 a " Then set up problem (if contest mode is set)
|
||||||
|
<
|
||||||
|
Codeforces ~
|
||||||
|
*cp-codeforces*
|
||||||
|
URL format: https://codeforces.com/contest/1234/problem/A
|
||||||
|
|
||||||
|
In terms of cp.nvim, this corresponds to:
|
||||||
|
|
||||||
|
- Contest ID: 1234
|
||||||
|
- Problem letter: A
|
||||||
|
|
||||||
|
Usage examples: >
|
||||||
|
:CP codeforces 1234 a " Set up problem A from contest id 1234
|
||||||
|
:CP codeforces " Set up Codeforces contest mode first
|
||||||
|
:CP 1234 a " Then set up problem (if contest mode is set)
|
||||||
|
<
|
||||||
|
CSES ~
|
||||||
|
*cp-cses*
|
||||||
|
URL format: https://cses.fi/problemset/task/1068
|
||||||
|
|
||||||
|
In terms of cp.nvim, this corresponds to:
|
||||||
|
- Problem ID: 1068
|
||||||
|
|
||||||
|
Usage examples: >
|
||||||
|
:CP cses 1068 " Set up problem 1068
|
||||||
|
:CP cses " Set up CSES contest mode first
|
||||||
|
:CP 1068 " Then set up problem (if contest mode is set)
|
||||||
|
<
|
||||||
|
COMPLETE WORKFLOW EXAMPLE *cp-example*
|
||||||
|
|
||||||
|
Example: Setting up AtCoder problem ABC123-A
|
||||||
|
|
||||||
|
1. Browse to https://atcoder.jp/contests/abc123/tasks/abc123_a
|
||||||
|
2. Read the problem statement on the website
|
||||||
|
3. In Neovim, extract identifiers and set up
|
||||||
|
:CP atcoder abc123 a
|
||||||
|
<
|
||||||
|
This creates abc123a.cc (or however you've configured the filename in
|
||||||
|
*cp-setup*) and scrapes test cases
|
||||||
|
4. Code and test
|
||||||
:CP run
|
:CP run
|
||||||
<
|
5. Debug
|
||||||
Output appears in vertical split showing execution time, output, and
|
|
||||||
whether it matches expected output.
|
|
||||||
|
|
||||||
4. Debug if needed:
|
|
||||||
|
|
||||||
:CP debug
|
:CP debug
|
||||||
<
|
6. Test: >
|
||||||
5. Compare actual vs. expected output visually: >
|
|
||||||
|
|
||||||
:CP diff
|
:CP diff
|
||||||
<
|
7. Submit remote on AtCoder
|
||||||
Enters 3-way diff mode with actual, expected, and input files.
|
|
||||||
|
|
||||||
FILE STRUCTURE *cp-files*
|
FILE STRUCTURE *cp-files*
|
||||||
|
|
||||||
|
|
|
||||||
30
readme.md
30
readme.md
|
|
@ -26,6 +26,36 @@ https://private-user-images.githubusercontent.com/62671086/489116291-391976d1-c2
|
||||||
:help cp.nvim
|
:help cp.nvim
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Philosophy
|
||||||
|
|
||||||
|
This plugin is highly tuned to my workflow and may not fit for you. Personally,
|
||||||
|
I believe there are two aspects of a cp workflow:
|
||||||
|
|
||||||
|
- local work (i.e. coding, running test cases)
|
||||||
|
- site work (i.e. problem reading, submitting)
|
||||||
|
|
||||||
|
Namely, I do not like the idea of submitting problems locally - the experience
|
||||||
|
will never quite offer what the remote does. Therefore, cp.nvim works as
|
||||||
|
follows:
|
||||||
|
|
||||||
|
1. Find a problem
|
||||||
|
|
||||||
|
- Browse the remote and find it
|
||||||
|
- Read it on the remote
|
||||||
|
|
||||||
|
2. Set up your local environment with `:CP ...`
|
||||||
|
|
||||||
|
- test cases and expected output automatically scraped
|
||||||
|
- templates automatically configured
|
||||||
|
|
||||||
|
3. Solve the problem locally
|
||||||
|
|
||||||
|
- easy to run/debug
|
||||||
|
- easy to diff actual vs. expected output
|
||||||
|
|
||||||
|
4. Submit the problem (on the remote!)
|
||||||
|
|
||||||
|
|
||||||
## TODO
|
## TODO
|
||||||
|
|
||||||
- finer-tuned problem limits (i.e. per-problem codeforces time, memory)
|
- finer-tuned problem limits (i.e. per-problem codeforces time, memory)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue