style: enable HideUtilityClassConstructor in checkstyle (#5147)

This commit is contained in:
Piotr Idzik
2024-05-08 08:58:29 +02:00
committed by GitHub
parent 030bb91d05
commit d3bb691f59
285 changed files with 895 additions and 339 deletions

View File

@ -1,6 +1,8 @@
package com.thealgorithms.maths;
public class AbsoluteMax {
public final class AbsoluteMax {
private AbsoluteMax() {
}
/**
* Finds the absolute maximum value among the given numbers.

View File

@ -2,7 +2,9 @@ package com.thealgorithms.maths;
import java.util.Arrays;
public class AbsoluteMin {
public final class AbsoluteMin {
private AbsoluteMin() {
}
/**
* Compares the numbers given as arguments to get the absolute min value.

View File

@ -1,6 +1,8 @@
package com.thealgorithms.maths;
public class AbsoluteValue {
public final class AbsoluteValue {
private AbsoluteValue() {
}
/**
* Returns the absolute value of a number.

View File

@ -9,7 +9,9 @@ import java.util.stream.IntStream;
* are not equal to 15) are 1, 3 and 5, so the aliquot sum of 15 is 9 i.e. (1 +
* 3 + 5). Wikipedia: https://en.wikipedia.org/wiki/Aliquot_sum
*/
public class AliquotSum {
public final class AliquotSum {
private AliquotSum() {
}
/**
* Finds the aliquot sum of an integer number.

View File

@ -19,7 +19,9 @@ import org.apache.commons.lang3.tuple.Pair;
* 220 is divisible by {1,2,4,5,10,11,20,22,44,55,110} <-SUM = 284
* 284 is divisible by {1,2,4,71,142} <-SUM = 220.
*/
public class AmicableNumber {
public final class AmicableNumber {
private AmicableNumber() {
}
/**
* Finds all the amicable numbers in a given range.
*

View File

@ -3,7 +3,9 @@ package com.thealgorithms.maths;
/**
* Find the area of various geometric shapes
*/
public class Area {
public final class Area {
private Area() {
}
/**
* String of IllegalArgumentException for radius

View File

@ -7,7 +7,9 @@ package com.thealgorithms.maths;
* @version 2.0
*/
public class AutoCorrelation {
public final class AutoCorrelation {
private AutoCorrelation() {
}
/**
* Discrete linear auto-correlation function.

View File

@ -10,7 +10,9 @@ package com.thealgorithms.maths;
import java.math.BigInteger;
public class AutomorphicNumber {
public final class AutomorphicNumber {
private AutomorphicNumber() {
}
/**
* A function to check if a number is Automorphic number or not

View File

@ -3,7 +3,9 @@ package com.thealgorithms.maths;
/**
* Calculate average of a list of numbers
*/
public class Average {
public final class Average {
private Average() {
}
/**
* Calculate average of a list of numbers

View File

@ -1,6 +1,8 @@
package com.thealgorithms.maths;
public class BinaryPow {
public final class BinaryPow {
private BinaryPow() {
}
/**
* Calculate a^p using binary exponentiation

View File

@ -10,7 +10,9 @@ package com.thealgorithms.maths;
*
* */
public class BinomialCoefficient {
public final class BinomialCoefficient {
private BinomialCoefficient() {
}
/**
* This method returns the number of ways in which k objects can be chosen from n objects

View File

@ -1,6 +1,8 @@
package com.thealgorithms.maths;
public class Ceil {
public final class Ceil {
private Ceil() {
}
/**
* Returns the smallest (closest to negative infinity)

View File

@ -9,7 +9,9 @@ import java.util.ArrayList;
* @author Ioannis Karavitsis
* @version 1.0
*/
public class CircularConvolutionFFT {
public final class CircularConvolutionFFT {
private CircularConvolutionFFT() {
}
/**
* This method pads the signal with zeros until it reaches the new size.

View File

@ -3,7 +3,9 @@ package com.thealgorithms.maths;
/**
* @see <a href="https://en.wikipedia.org/wiki/Combination">Combination</a>
*/
public class Combinations {
public final class Combinations {
private Combinations() {
}
/**
* Calculate of factorial

View File

@ -6,7 +6,9 @@ package com.thealgorithms.maths;
* @author Ioannis Karavitsis
* @version 1.0
*/
public class Convolution {
public final class Convolution {
private Convolution() {
}
/**
* Discrete linear convolution function. Both input signals and the output

View File

@ -9,7 +9,9 @@ import java.util.ArrayList;
* @author Ioannis Karavitsis
* @version 1.0
*/
public class ConvolutionFFT {
public final class ConvolutionFFT {
private ConvolutionFFT() {
}
/**
* This method pads the signal with zeros until it reaches the new size.

View File

@ -7,7 +7,9 @@ package com.thealgorithms.maths;
* @version 1.0
*/
public class CrossCorrelation {
public final class CrossCorrelation {
private CrossCorrelation() {
}
/**
* Discrete linear cross-correlation function.

View File

@ -6,7 +6,9 @@ import java.util.Scanner;
* @author Ojasva Jain
* Determinant of a Matrix Wikipedia link: https://en.wikipedia.org/wiki/Determinant
*/
public class DeterminantOfMatrix {
public final class DeterminantOfMatrix {
private DeterminantOfMatrix() {
}
// Determinant calculator
//@return determinant of the input matrix

View File

@ -40,7 +40,9 @@
*/
package com.thealgorithms.maths;
class DigitalRoot {
final class DigitalRoot {
private DigitalRoot() {
}
public static int digitalRoot(int n) {
if (single(n) <= 9) { // If n is already single digit than simply call single method and

View File

@ -1,6 +1,8 @@
package com.thealgorithms.maths;
public class DistanceFormula {
public final class DistanceFormula {
private DistanceFormula() {
}
public static double euclideanDistance(double x1, double y1, double x2, double y2) {
double dX = Math.pow(x2 - x1, 2);

View File

@ -6,7 +6,9 @@
*/
package com.thealgorithms.maths;
public class DudeneyNumber {
public final class DudeneyNumber {
private DudeneyNumber() {
}
// returns True if the number is a Dudeney number and False if it is not a Dudeney number.
public static boolean isDudeney(int n) {

View File

@ -15,7 +15,9 @@ import java.util.function.BiFunction;
* https://en.wikipedia.org/wiki/Euler_method ) (see also:
* https://www.geeksforgeeks.org/euler-method-solving-differential-equation/ )
*/
public class EulerMethod {
public final class EulerMethod {
private EulerMethod() {
}
/**
* Illustrates how the algorithm is used in 3 examples and prints the

View File

@ -10,7 +10,9 @@ import java.util.Collections;
* @author Ioannis Karavitsis
* @version 1.0
*/
public class FFT {
public final class FFT {
private FFT() {
}
/**
* This class represents a complex number and has methods for basic

View File

@ -9,7 +9,9 @@ import java.util.ArrayList;
* @author Ioannis Karavitsis
* @version 1.0
*/
public class FFTBluestein {
public final class FFTBluestein {
private FFTBluestein() {
}
/**
* Bluestein's FFT Algorithm.

View File

@ -9,7 +9,9 @@
package com.thealgorithms.maths;
public class FastInverseSqrt {
public final class FastInverseSqrt {
private FastInverseSqrt() {
}
public static boolean inverseSqrt(float number) {
float x = number;

View File

@ -9,7 +9,9 @@ import java.util.stream.Stream;
* @author: caos321
* @date: 14 October 2021 (Thursday)
*/
public class FibonacciJavaStreams {
public final class FibonacciJavaStreams {
private FibonacciJavaStreams() {
}
public static Optional<BigDecimal> calculate(final BigDecimal index) {
if (index == null || index.compareTo(BigDecimal.ZERO) < 0) {

View File

@ -5,7 +5,9 @@ package com.thealgorithms.maths;
* This code checks Fibonacci Numbers up to 45th number.
* Other checks fail because of 'long'-type overflow.
*/
public class FibonacciNumberCheck {
public final class FibonacciNumberCheck {
private FibonacciNumberCheck() {
}
/**
* Check if a number is perfect square number
*

View File

@ -6,7 +6,9 @@ import java.util.Random;
/**
* use quick sort algorithm to get kth largest or kth smallest element in given array
*/
public class FindKthNumber {
public final class FindKthNumber {
private FindKthNumber() {
}
private static final Random RANDOM = new Random();

View File

@ -7,7 +7,9 @@
package com.thealgorithms.maths;
public class FrizzyNumber {
public final class FrizzyNumber {
private FrizzyNumber() {
}
/**
* Returns the n-th number that is a sum of powers

View File

@ -6,7 +6,9 @@ package com.thealgorithms.maths;
*
* @author Oskar Enmalm 3/10/17
*/
public class GCD {
public final class GCD {
private GCD() {
}
/**
* get the greatest common divisor

View File

@ -3,7 +3,9 @@ package com.thealgorithms.maths;
/**
* @author https://github.com/shellhub/
*/
public class GCDRecursion {
public final class GCDRecursion {
private GCDRecursion() {
}
public static void main(String[] args) {
System.out.println(gcd(20, 15));

View File

@ -2,7 +2,9 @@ package com.thealgorithms.maths;
import java.util.ArrayList;
public class Gaussian {
public final class Gaussian {
private Gaussian() {
}
public static ArrayList<Double> gaussian(int mat_size, ArrayList<Double> matrix) {
ArrayList<Double> answerArray = new ArrayList<Double>();

View File

@ -2,7 +2,9 @@ package com.thealgorithms.maths;
// Wikipedia for Harshad Number : https://en.wikipedia.org/wiki/Harshad_number
public class HarshadNumber {
public final class HarshadNumber {
private HarshadNumber() {
}
/**
* A function to check if a number is Harshad number or not

View File

@ -20,7 +20,9 @@ package com.thealgorithms.maths;
@author Kunal
*/
public class JosephusProblem {
public final class JosephusProblem {
private JosephusProblem() {
}
/**
* Find the Winner of the Circular Game.

View File

@ -11,7 +11,9 @@ import java.util.List;
*
* */
public class JugglerSequence {
public final class JugglerSequence {
private JugglerSequence() {
}
/**
* This method prints juggler sequence starting with the number in the parameter

View File

@ -4,7 +4,9 @@ import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;
public class KaprekarNumbers {
public final class KaprekarNumbers {
private KaprekarNumbers() {
}
/* This program demonstrates if a given number is Kaprekar Number or not.
Kaprekar Number: A Kaprekar number is an n-digit number which its square can be split into

View File

@ -4,7 +4,9 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
class KeithNumber {
final class KeithNumber {
private KeithNumber() {
}
// user-defined function that checks if the given number is Keith or not
static boolean isKeith(int x) {

View File

@ -9,7 +9,9 @@ import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class KrishnamurthyNumber {
public final class KrishnamurthyNumber {
private KrishnamurthyNumber() {
}
// returns True if the number is a Krishnamurthy number and False if it is not.

View File

@ -9,7 +9,9 @@ import java.util.Scanner;
* @author LauKinHoong
*/
public class LeastCommonMultiple {
public final class LeastCommonMultiple {
private LeastCommonMultiple() {
}
/**
* Driver Code

View File

@ -3,7 +3,9 @@ package com.thealgorithms.maths;
/**
* https://en.wikipedia.org/wiki/Leonardo_number
*/
public class LeonardoNumber {
public final class LeonardoNumber {
private LeonardoNumber() {
}
/**
* Calculate nth Leonardo Number (1, 1, 3, 5, 9, 15, 25, 41, 67, 109, 177, ...)

View File

@ -3,6 +3,8 @@ package com.thealgorithms.maths;
import java.util.Objects;
public final class LinearDiophantineEquationsSolver {
private LinearDiophantineEquationsSolver() {
}
public static void main(String[] args) {
// 3x + 4y = 7

View File

@ -12,7 +12,9 @@ package com.thealgorithms.maths;
*
* */
public class LiouvilleLambdaFunction {
public final class LiouvilleLambdaFunction {
private LiouvilleLambdaFunction() {
}
/**
* This method returns λ(n) of given number n

View File

@ -8,7 +8,9 @@
package com.thealgorithms.maths;
public class LongDivision {
public final class LongDivision {
private LongDivision() {
}
public static int divide(int dividend, int divisor) {
long new_dividend_1 = dividend;
long new_divisor_1 = divisor;

View File

@ -3,7 +3,9 @@ package com.thealgorithms.maths;
/**
* https://en.wikipedia.org/wiki/Lucas_number
*/
public class LucasSeries {
public final class LucasSeries {
private LucasSeries() {
}
/**
* Calculate nth number of Lucas Series(2, 1, 3, 4, 7, 11, 18, 29, 47, 76,

View File

@ -5,7 +5,9 @@ import java.util.Scanner;
/*A magic square of order n is an arrangement of distinct n^2 integers,in a square, such that the n
numbers in all rows, all columns, and both diagonals sum to the same constant. A magic square
contains the integers from 1 to n^2.*/
public class MagicSquare {
public final class MagicSquare {
private MagicSquare() {
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);

View File

@ -11,7 +11,9 @@ import java.util.stream.IntStream;
* @author: caos321
* @date: 31 October 2021 (Sunday)
*/
public class MatrixUtil {
public final class MatrixUtil {
private MatrixUtil() {
}
public static boolean isValid(final BigDecimal[][] matrix) {
return matrix != null && matrix.length > 0 && matrix[0].length > 0;

View File

@ -5,7 +5,9 @@ import java.util.Arrays;
/**
* Wikipedia: https://en.wikipedia.org/wiki/Median
*/
public class Median {
public final class Median {
private Median() {
}
/**
* Calculate average median

View File

@ -2,7 +2,9 @@ package com.thealgorithms.maths;
import java.util.Random;
public class MillerRabinPrimalityCheck {
public final class MillerRabinPrimalityCheck {
private MillerRabinPrimalityCheck() {
}
/**
* Check whether the given number is prime or not

View File

@ -12,7 +12,9 @@ package com.thealgorithms.maths;
* Author: Akshay Dubey (https://github.com/itsAkshayDubey)
*
* */
public class MobiusFunction {
public final class MobiusFunction {
private MobiusFunction() {
}
/**
* This method returns μ(n) of given number n

View File

@ -7,7 +7,9 @@ import java.util.Scanner;
* Reason to use bitwise operator: It makes our program faster as we are operating on bits and not
* on actual numbers.
*/
public class NonRepeatingElement {
public final class NonRepeatingElement {
private NonRepeatingElement() {
}
public static void main(String[] args) {
try (Scanner sc = new Scanner(System.in)) {

View File

@ -1,6 +1,8 @@
package com.thealgorithms.maths;
public class PalindromeNumber {
public final class PalindromeNumber {
private PalindromeNumber() {
}
/**
* Check if {@code n} is palindrome number or not
*

View File

@ -1,6 +1,8 @@
package com.thealgorithms.maths;
public class PascalTriangle {
public final class PascalTriangle {
private PascalTriangle() {
}
/**
*In mathematics, Pascal's triangle is a triangular array of the binomial coefficients that

View File

@ -3,7 +3,9 @@ package com.thealgorithms.maths;
/**
* https://en.wikipedia.org/wiki/Cube_(algebra)
*/
public class PerfectCube {
public final class PerfectCube {
private PerfectCube() {
}
/**
* Check if a number is perfect cube or not

View File

@ -8,7 +8,9 @@ package com.thealgorithms.maths;
*
* link:https://en.wikipedia.org/wiki/Perfect_number
*/
public class PerfectNumber {
public final class PerfectNumber {
private PerfectNumber() {
}
/**
* Check if {@code number} is perfect number or not

View File

@ -1,7 +1,9 @@
package com.thealgorithms.maths;
// Perimeter of different 2D geometrical shapes
public class Perimeter {
public final class Perimeter {
private Perimeter() {
}
/**
* Calculate the Perimeter of regular polygon (equals sides)

View File

@ -1,6 +1,8 @@
package com.thealgorithms.maths;
public class PiNilakantha {
public final class PiNilakantha {
private PiNilakantha() {
}
// Calculates Pi using Nilakantha's infinite series
// Method 2 in the following link explains the algorithm

View File

@ -35,7 +35,9 @@ package com.thealgorithms.maths;
* Author: Akshay Dubey (https://github.com/itsAkshayDubey)
*
* */
public class PollardRho {
public final class PollardRho {
private PollardRho() {
}
/**
* This method returns a polynomial in x computed modulo n

View File

@ -1,7 +1,9 @@
package com.thealgorithms.maths;
// POWER (exponentials) Examples (a^b)
public class Pow {
public final class Pow {
private Pow() {
}
public static void main(String[] args) {
assert pow(2, 0) == Math.pow(2, 0); // == 1

View File

@ -5,7 +5,9 @@ package com.thealgorithms.maths;
* @author Bama Charan Chhandogi (https://github.com/BamaCharanChhandogi)
*/
public class PowerUsingRecursion {
public final class PowerUsingRecursion {
private PowerUsingRecursion() {
}
public static double power(double base, int exponent) {
// Base case: anything raised to the power of 0 is 1

View File

@ -2,7 +2,9 @@ package com.thealgorithms.maths;
import java.util.Scanner;
public class PrimeCheck {
public final class PrimeCheck {
private PrimeCheck() {
}
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);

View File

@ -9,7 +9,9 @@ package com.thealgorithms.maths;
import java.util.ArrayList;
import java.util.List;
public class PrimeFactorization {
public final class PrimeFactorization {
private PrimeFactorization() {
}
public static List<Integer> pfactors(int n) {
List<Integer> primeFactors = new ArrayList<>();

View File

@ -10,7 +10,9 @@ package com.thealgorithms.maths;
*
* */
public class PronicNumber {
public final class PronicNumber {
private PronicNumber() {
}
/**
* This method checks if the given number is pronic number or non-pronic number

View File

@ -3,7 +3,9 @@ package com.thealgorithms.maths;
/**
* https://en.wikipedia.org/wiki/Pythagorean_triple
*/
public class PythagoreanTriple {
public final class PythagoreanTriple {
private PythagoreanTriple() {
}
public static void main(String[] args) {
assert isPythagTriple(3, 4, 5);

View File

@ -8,7 +8,9 @@ package com.thealgorithms.maths;
* @author Sokratis Fotkatzikis
* @version 1.0
*/
public class RomanNumeralUtil {
public final class RomanNumeralUtil {
private RomanNumeralUtil() {
}
private static final int MIN_VALUE = 1;
private static final int MAX_VALUE = 5999;

View File

@ -14,7 +14,9 @@ package com.thealgorithms.maths;
import java.util.HashSet;
import java.util.List;
public class SquareFreeInteger {
public final class SquareFreeInteger {
private SquareFreeInteger() {
}
/**
* This method returns whether an integer is square free
*

View File

@ -1,6 +1,8 @@
package com.thealgorithms.maths;
public class SquareRootWithBabylonianMethod {
public final class SquareRootWithBabylonianMethod {
private SquareRootWithBabylonianMethod() {
}
/**
* get the value, return the square root

View File

@ -14,7 +14,9 @@ package com.thealgorithms.maths;
* be changed according to the user preference.
*/
public class SquareRootWithNewtonRaphsonMethod {
public final class SquareRootWithNewtonRaphsonMethod {
private SquareRootWithNewtonRaphsonMethod() {
}
public static double squareRoot(int n) {
double x = n; // initially taking a guess that x = n.

View File

@ -1,6 +1,8 @@
package com.thealgorithms.maths;
public class StandardDeviation {
public final class StandardDeviation {
private StandardDeviation() {
}
public static double stdDev(double[] data) {
double var = 0;

View File

@ -1,6 +1,8 @@
package com.thealgorithms.maths;
public class StandardScore {
public final class StandardScore {
private StandardScore() {
}
public static double zScore(double num, double mean, double stdDev) {
return (num - mean) / stdDev;

View File

@ -7,7 +7,9 @@ package com.thealgorithms.maths;
*
* Example Input: n = 4 Output 1 1 1 1 1 2 3 2 1 1 3 6 7 6 3 1
*/
public class TrinomialTriangle {
public final class TrinomialTriangle {
private TrinomialTriangle() {
}
public static int TrinomialValue(int n, int k) {
if (n == 0 && k == 0) {

View File

@ -9,7 +9,9 @@ package com.thealgorithms.maths;
*
* */
public class TwinPrime {
public final class TwinPrime {
private TwinPrime() {
}
/**
* This method returns twin prime of the integer value passed as argument

View File

@ -16,7 +16,9 @@ import java.util.Collections;
*
* <p>
*/
public class VampireNumber {
public final class VampireNumber {
private VampireNumber() {
}
public static void main(String[] args) {
test(10, 1000);

View File

@ -1,7 +1,9 @@
package com.thealgorithms.maths;
/* Calculate the volume of various shapes.*/
public class Volume {
public final class Volume {
private Volume() {
}
/**
* Calculate the volume of a cube.