-
public final class HCUtilsKt
-
-
Method Summary
Modifier and Type Method Description final UnitsolveHCProblemAndWriteFile(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. final PathcomputeHCOutputPath(Path inputPath)Computes the output file path based on the input file path. final UnitsolveHCFilesInParallel(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. -
-
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 fileoutputFilePath- 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
.inextension, it is changed to.out, otherwise.outis simply appended. If there is a parent folder calledinputs, it is changed tooutputs.
-
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 readexceptionsLogger- 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
-
-
-
-