com.github.bogdanovmn.projecteuler.framework.ProblemParameters Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of project-euler-framework Show documentation
Show all versions of project-euler-framework Show documentation
This is a lite framework for solving of math problems of "Project Euler" (https://projecteuler.net)
package com.github.bogdanovmn.projecteuler.framework;
public class ProblemParameters {
private final String[] rawParameters;
public ProblemParameters(String[] rawParameters) {
this.rawParameters = rawParameters;
}
public long getLong(int index) {
if (rawParameters.length < index) {
throw new IllegalArgumentException(
String.format(
"Can't find any parameter with index %d. There are only %d parameters: [%s]",
index, rawParameters.length, toString()
)
);
}
return Long.parseLong(
rawParameters[index - 1].replaceAll("_", "")
);
}
@Override
public String toString() {
return String.join(",", rawParameters);
}
}