GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - zor-cell/cc-input-reader: A template for coding contests that handles reading inputs, writing outputs and verifying solutions

BranchesTags
Open more actions menu

Latest commit

 

History

49 Commits
49 Commits

Folders and files

NameName
Last commit message
Last commit date
input
input
 
 
output
output
 
 
src/main
src/main
 
 
.gitattributes
.gitattributes
 
 
.gitignore
.gitignore
 
 
CLAUDE.md
CLAUDE.md
 
 
README.md
README.md
 
 
pom.xml
pom.xml
 
 

Repository files navigation

Java Input Reader

Description

This repository contains an input reader implemented in Java that can read from files or folders (ie all files inside a folder). The purpose of this project is to take over tedious input- and output management in coding competitions. This repository can be used as a template to build your solution on.
This template was created specifically for the CCC.

Made by Philippe Zorman, Lutu

Usage

The application provides an interface in Solver.java with two methods, which are both run for every file in the configured inputPath:

  • solve(): Computes the result of each testcase. A working program should contain the following aspects:

    • Read lines of an input file with a given Java Scanner (see Documentation)
    • Compute result for the input
    • Write the result to an output file with a given Java FileWriter

    Example:

    //Outputs the sum of the space-separated integers
    public static void solve(Scanner reader, FileWriter writer) throws IOException {
          int maxRuns = reader.nextInt();
          reader.nextLine();
      
          for(int run = 0;run < maxRuns;run++) {
              //compute sum of each line
              List<Integer> list = IOUtils.readList(reader, " ", Integer::parseInt);
              int sum = list.stream().mapToInt(Integer::intValue).sum();
      
              writer.write(sum + "\n");
          }
    }
  • verify(): Is run after solve() to verify the solution of your output specific to CCC. For this to work a file visualizer.html has to be present, which can verify results for given inputs. A working program should contain the following:

    • Read lines of the input file that are used for one testcase
    • Read lines of the output file that are used for one testcase
    • Check validity with the given verifier

    Example:

      //Verifies a testcase with one input line and one output line
     public static void verify(Scanner input, Scanner output, SolutionVerifier verifier) throws IOException {
          int maxRuns = input.nextInt();
          input.nextLine();
    
          for(int run = 0;run < maxRuns;run++) {
              String inputLine = input.nextLine();
              String outputLine = output.nextLine();
    
              verifier.checkValidity(run, inputLine, outputLine);
         }
    }

Configuration

The application can be configured by changing the resources/config.xml file accordingly. For configuration details, look inside the file.

Getting Started

Prerequisites

  • Java JDK 21 (or newer)
  • Maven

Run with IntelliJ (Recommended)

This project is optimized for IntelliJ IDEA.

  1. Open the project in IntelliJ.
  2. Navigate to src/main/java/solver/Solver.java.
  3. Click the green Run arrow (▶) next to the main method.

Run with Maven (CLI)

Alternatively, you can run the solution directly from your terminal:

mvn clean compile exec:java -Dexec.mainClass="solver.Solver"

About

A template for coding contests that handles reading inputs, writing outputs and verifying solutions

Topics

cloudflight-coding-contestinput-readerjavamaven

Resources

Readme
Activity

Stars

1 star

Watchers

1 watching

Forks

2 forks
Report repository

Contributors

Languages

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.