All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.bogdanovmn.projecteuler.framework.ProblemParameters Maven / Gradle / Ivy

Go to download

This is a lite framework for solving of math problems of "Project Euler" (https://projecteuler.net)

There is a newer version: 0.5.2
Show newest version
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);
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy