A new tool to never again need to type the input data for Test Cases!

Hey all :slight_smile: I’ve just made a Quality of Life script that makes testing specific Test Cases for puzzles in your External Editor extremely easy, painless and most importantly: Automated!

It effectively works by overriding the default way of getting input from the user typing in the console (e.g. System.Console.ReadLine() in C#) and instead automatically grabs the input data for you from a dedicated file and uses this instead (line by line). This should save your sanity & fingers from repeatedly typing out the same test data each time you wan to debug the Test Case.

Pros

  • Removes the need for you to ever type the Input Data from test cases line by line in the console ever again!
  • It’s extremely simple to use (there’s a step-by-step guide on how to add it to your project)
  • Setup takes a matter of minutes: Copy the file, follow the 5 steps and you’re good to go!
  • It doesn’t intefere with your actual submission file on CodinGame in any way whatsoever
  • You can enable and disable the functionality by a single character change
  • Will work with any External Editor setup (although instructions are based on using Visual Studio)
  • Removes the risk of typos happening from repeatedly typing the same data each time
  • No need to temporarily change he code in order to hack in the input data for testing purposes
  • Memory friendly! Won’t affect your running of the solution locally in any visible way

How to use

  1. Ensure you’ve setup the External Editor plugin: Coding Games and Programming Challenges to Code Better
  2. Head to: CodinGame/Helpers/InputHelper at main · Chazzmundo/CodinGame · GitHub
  3. Find the InputHelper file corresponding to the language of your choice (more will be added over time) and copy to your project
  4. Follow the steps as listed at the InputHelper file
  5. Enjoy living in the fast lane!

Supported languages

For now, I’ve only added support for:

  • C#

However, the GitHub repository is open for contribution if anyone would like to help porting to other languages and I’ve added guidelines in the ReadMe file on how to ensure it’s ready to use by other people

Feedback

I hope it is helpful, please let me know if you encounter any bugs, or have suggestions/requests for future helpers!

Nice one, congrats.

With an interpreted language (php) I just run the interpreter from the command line, with the standard input redirected, and VS Code IDE intercepts the breakpoint automatically, so no additional setup is necessary. But I never managed to debug CG in C#.

PS: To help also in the “create the input file” part, here is my repo with 750+ test case input files for ~600 puzzles: https://github.com/tbali0524/cgtest/tree/main/.tests/input
Originally, this is part of my ‘batch test runner tool’ repo, but these files should work with your tool as well. File names include the puzzle’s name slug.

Thanks for sharing this!

Yeah some languages don’t really benefit from doing this as much, so it actually may be a pretty elegant solution to simply create empty comment files for such languages with instructions on how to do it out of box for each particular language as a way of highlighting it’s possible for those new enough to programming or the language itself to not be aware it’s possible (most advanced coders probably already created something similar to this solution for their own needs without thinking too much about it, but I suspect a lot of beginners are typing it out by hand each time!)

I originally wanted to do something more complex along the lines of a tool that would allow batch running against all test cases but I decided not to invest time in doing it given there’s already similar enough functionality for that in the webpage (and realistically there’s no reason to debug all of them in one go, you’d simply run on all test cases and debug the edge cases that fail as needed on a 1 by 1 basis IRL).

I decided it’s not really giving anything worthwhile for a lot more effort and points of failure so instead chose to go for a very straightforward little helper that can actively be beneficial for anyone actively using it.