competitest.nvim icon indicating copy to clipboard operation
competitest.nvim copied to clipboard

Feature request: Split a test into smaller cases

Open TroySigX opened this issue 2 years ago • 5 comments

For a test with multiple test cases. e.g let there be 4 test cases, and each test takes a and b as inputs:

4
1 2
2 3
4 5
5 5

Conventionally, competitest would just store this test into a single file (input0.txt), but instead, I'd like it to be broken down into smaller cases (e.g storing the tests in files input0, input1, input2, and input3), with each file in the following format:

1
a b

This makes it easier to debug while in the contest

TroySigX avatar May 12 '23 22:05 TroySigX

Suggested solution: If the feature above cannot be achieved, there's another alternative: When editing a test with multiple test cases (example test), being able to choose a region (using visual mode) and create a new test case (using :CompetiTestAdd or something similar) based on that chosen area would be great.

TroySigX avatar May 13 '23 21:05 TroySigX

Suggested solution: If the feature above cannot be achieved, there's another alternative: When editing a test with multiple test cases (example test), being able to choose a region (using visual mode) and create a new test case (using :CompetiTestAdd or something similar) based on that chosen area would be great.

This feature cannot be achieved because every problem has a different input structure. But there are some workaround:

  1. As you suggested, visual select a region and create a testcase
  2. Put some dashes between lines to split them into single testcases:
4
----
1 2
----
2 3
----
4 5
----
5 5

xeluxee avatar May 14 '23 15:05 xeluxee

Thanks @xeluxee! But what about the output, how about putting some dashes (or tickback, the symbol to the left of number 1) to seperate the testcases' output

TroySigX avatar May 14 '23 18:05 TroySigX

Here's what I think, how about having a command :Splitcases x y, where x is the test number to be split, and y is the splitting character between the cases (in your example, y is the dashes ----).

To further enhance the experience, we should have the option to set the default splitting character y in the setup.

TroySigX avatar May 14 '23 18:05 TroySigX

Hi, any updates on this feature?

TroySigX avatar May 30 '23 00:05 TroySigX