Package 

Class HCUtilsKt

    • Method Detail

      • solveHCProblemAndWriteFile

         final Unit solveHCProblemAndWriteFile(Path inputFilePath, Path outputFilePath, Function1<HCReader, Iterable<CharSequence>> readAndSolve)

        Reads the input file at inputFilePath by calling readAndSolve, and writes the returned lines to the file at outputFilePath.

        Parameters:
        inputFilePath - the path to the input file
        outputFilePath - the path to the output file (will be overwritten if it exists).
        readAndSolve - a function that reads the problem, solves it, and returns the output lines to write
      • computeHCOutputPath

         final Path computeHCOutputPath(Path inputPath)

        Computes the output file path based on the input file path. If there is a .in extension, it is changed to .out, otherwise .out is simply appended. If there is a parent folder called inputs, it is changed to outputs.

      • solveHCFilesInParallel

         final Unit solveHCFilesInParallel(String filenames, UncaughtExceptionsLogger exceptionsLogger, Boolean remindExceptionsAtTheEnd, SuspendFunction1<HCReader, Iterable<CharSequence>> readAndSolve)

        Solves the problems defined by each of the given input files, each in its own coroutine.

        Parameters:
        filenames - the paths to the input files to read
        exceptionsLogger - the way to log uncaught exceptions (defaults to standard error stream)
        remindExceptionsAtTheEnd - whether to remind all exceptions that occurred during the runs when all coroutines are done (true by default to ease debugging when the output is too big)
        readAndSolve - a function to read the input and solve the problem, returning the output lines to write