mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-07-24 04:54:21 +08:00
Add automatic linter (#4214)
This commit is contained in:
@ -25,8 +25,7 @@ public class BankersAlgorithm {
|
||||
/**
|
||||
* This method finds the need of each process
|
||||
*/
|
||||
static void calculateNeed(int[][] needArray, int[][] maxArray, int[][] allocationArray,
|
||||
int totalProcess, int totalResources) {
|
||||
static void calculateNeed(int[][] needArray, int[][] maxArray, int[][] allocationArray, int totalProcess, int totalResources) {
|
||||
for (int i = 0; i < totalProcess; i++) {
|
||||
for (int j = 0; j < totalResources; j++) {
|
||||
needArray[i][j] = maxArray[i][j] - allocationArray[i][j];
|
||||
@ -49,8 +48,7 @@ public class BankersAlgorithm {
|
||||
*
|
||||
* @return boolean if the system is in safe state or not
|
||||
*/
|
||||
static boolean checkSafeSystem(int[] processes, int[] availableArray, int[][] maxArray,
|
||||
int[][] allocationArray, int totalProcess, int totalResources) {
|
||||
static boolean checkSafeSystem(int[] processes, int[] availableArray, int[][] maxArray, int[][] allocationArray, int totalProcess, int totalResources) {
|
||||
int[][] needArray = new int[totalProcess][totalResources];
|
||||
|
||||
calculateNeed(needArray, maxArray, allocationArray, totalProcess, totalResources);
|
||||
@ -158,8 +156,7 @@ public class BankersAlgorithm {
|
||||
}
|
||||
}
|
||||
|
||||
checkSafeSystem(processes, availableArray, maxArray, allocationArray, numberOfProcesses,
|
||||
numberOfResources);
|
||||
checkSafeSystem(processes, availableArray, maxArray, allocationArray, numberOfProcesses, numberOfResources);
|
||||
|
||||
sc.close();
|
||||
}
|
||||
|
@ -98,8 +98,7 @@ public class Damm {
|
||||
|
||||
private static void generateAndPrint(String input) {
|
||||
String result = addDammChecksum(input);
|
||||
System.out.println(
|
||||
"Generate and add checksum to initial value '" + input + "'. Result: '" + result + "'");
|
||||
System.out.println("Generate and add checksum to initial value '" + input + "'. Result: '" + result + "'");
|
||||
}
|
||||
|
||||
private static void checkInput(String input) {
|
||||
|
@ -125,8 +125,7 @@ class Graph {
|
||||
if (previous != null ? !previous.equals(vertex.previous) : vertex.previous != null) {
|
||||
return false;
|
||||
}
|
||||
return neighbours != null ? neighbours.equals(vertex.neighbours)
|
||||
: vertex.neighbours == null;
|
||||
return neighbours != null ? neighbours.equals(vertex.neighbours) : vertex.neighbours == null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -7,8 +7,7 @@ import java.util.Set;
|
||||
|
||||
public class HappyNumbersSeq {
|
||||
|
||||
private static final Set<Integer> CYCLE_NUMS
|
||||
= new HashSet<>(Arrays.asList(4, 16, 20, 37, 58, 145));
|
||||
private static final Set<Integer> CYCLE_NUMS = new HashSet<>(Arrays.asList(4, 16, 20, 37, 58, 145));
|
||||
|
||||
public static void main(String[] args) {
|
||||
Scanner in = new Scanner(System.in);
|
||||
|
@ -100,8 +100,7 @@ public class KochSnowflake {
|
||||
double offsetX = imageWidth / 10.;
|
||||
double offsetY = imageWidth / 3.7;
|
||||
Vector2 vector1 = new Vector2(offsetX, offsetY);
|
||||
Vector2 vector2
|
||||
= new Vector2(imageWidth / 2, Math.sin(Math.PI / 3) * imageWidth * 0.8 + offsetY);
|
||||
Vector2 vector2 = new Vector2(imageWidth / 2, Math.sin(Math.PI / 3) * imageWidth * 0.8 + offsetY);
|
||||
Vector2 vector3 = new Vector2(imageWidth - offsetX, offsetY);
|
||||
ArrayList<Vector2> initialVectors = new ArrayList<Vector2>();
|
||||
initialVectors.add(vector1);
|
||||
@ -146,10 +145,8 @@ public class KochSnowflake {
|
||||
* @param imageHeight The height of the rendered image.
|
||||
* @return The image of the rendered edges.
|
||||
*/
|
||||
private static BufferedImage GetImage(
|
||||
ArrayList<Vector2> vectors, int imageWidth, int imageHeight) {
|
||||
BufferedImage image
|
||||
= new BufferedImage(imageWidth, imageHeight, BufferedImage.TYPE_INT_RGB);
|
||||
private static BufferedImage GetImage(ArrayList<Vector2> vectors, int imageWidth, int imageHeight) {
|
||||
BufferedImage image = new BufferedImage(imageWidth, imageHeight, BufferedImage.TYPE_INT_RGB);
|
||||
Graphics2D g2d = image.createGraphics();
|
||||
|
||||
// Set the background white
|
||||
|
@ -35,8 +35,7 @@ public class LinearCongruentialGenerator {
|
||||
* @param modulo The maximum number that can be generated (exclusive). A
|
||||
* common value is 2^32.
|
||||
*/
|
||||
public LinearCongruentialGenerator(
|
||||
double seed, double multiplier, double increment, double modulo) {
|
||||
public LinearCongruentialGenerator(double seed, double multiplier, double increment, double modulo) {
|
||||
this.previousValue = seed;
|
||||
this.a = multiplier;
|
||||
this.c = increment;
|
||||
@ -58,8 +57,7 @@ public class LinearCongruentialGenerator {
|
||||
// Show the LCG in action.
|
||||
// Decisive proof that the LCG works could be made by adding each number
|
||||
// generated to a Set while checking for duplicates.
|
||||
LinearCongruentialGenerator lcg
|
||||
= new LinearCongruentialGenerator(1664525, 1013904223, Math.pow(2.0, 32.0));
|
||||
LinearCongruentialGenerator lcg = new LinearCongruentialGenerator(1664525, 1013904223, Math.pow(2.0, 32.0));
|
||||
for (int i = 0; i < 512; i++) {
|
||||
System.out.println(lcg.nextNumber());
|
||||
}
|
||||
|
@ -115,8 +115,7 @@ public class Luhn {
|
||||
int[] cardNumbers = toIntArray(trimmedCardNumber);
|
||||
boolean isValid = luhnCheck(cardNumbers);
|
||||
if (!isValid) {
|
||||
throw new IllegalArgumentException(
|
||||
"Credit card number {" + cardNumber + "} - have a typo");
|
||||
throw new IllegalArgumentException("Credit card number {" + cardNumber + "} - have a typo");
|
||||
}
|
||||
|
||||
return new CreditCard(cardNumbers);
|
||||
@ -149,8 +148,7 @@ public class Luhn {
|
||||
|
||||
private static void businessExample(String cardNumber) {
|
||||
try {
|
||||
System.out.println(
|
||||
"Trying to create CreditCard object from valid card number: " + cardNumber);
|
||||
System.out.println("Trying to create CreditCard object from valid card number: " + cardNumber);
|
||||
CreditCard creditCard = CreditCard.fromString(cardNumber);
|
||||
System.out.println("And business object is successfully created: " + creditCard + "\n");
|
||||
} catch (IllegalArgumentException e) {
|
||||
|
@ -70,8 +70,7 @@ public class Mandelbrot {
|
||||
* @param useDistanceColorCoding Render in color or black and white.
|
||||
* @return The image of the rendered Mandelbrot set.
|
||||
*/
|
||||
public static BufferedImage getImage(int imageWidth, int imageHeight, double figureCenterX,
|
||||
double figureCenterY, double figureWidth, int maxStep, boolean useDistanceColorCoding) {
|
||||
public static BufferedImage getImage(int imageWidth, int imageHeight, double figureCenterX, double figureCenterY, double figureWidth, int maxStep, boolean useDistanceColorCoding) {
|
||||
if (imageWidth <= 0) {
|
||||
throw new IllegalArgumentException("imageWidth should be greater than zero");
|
||||
}
|
||||
@ -84,8 +83,7 @@ public class Mandelbrot {
|
||||
throw new IllegalArgumentException("maxStep should be greater than zero");
|
||||
}
|
||||
|
||||
BufferedImage image
|
||||
= new BufferedImage(imageWidth, imageHeight, BufferedImage.TYPE_INT_RGB);
|
||||
BufferedImage image = new BufferedImage(imageWidth, imageHeight, BufferedImage.TYPE_INT_RGB);
|
||||
double figureHeight = figureWidth / imageWidth * imageHeight;
|
||||
|
||||
// loop through the image-coordinates
|
||||
@ -93,15 +91,12 @@ public class Mandelbrot {
|
||||
for (int imageY = 0; imageY < imageHeight; imageY++) {
|
||||
// determine the figure-coordinates based on the image-coordinates
|
||||
double figureX = figureCenterX + ((double) imageX / imageWidth - 0.5) * figureWidth;
|
||||
double figureY
|
||||
= figureCenterY + ((double) imageY / imageHeight - 0.5) * figureHeight;
|
||||
double figureY = figureCenterY + ((double) imageY / imageHeight - 0.5) * figureHeight;
|
||||
|
||||
double distance = getDistance(figureX, figureY, maxStep);
|
||||
|
||||
// color the corresponding pixel based on the selected coloring-function
|
||||
image.setRGB(imageX, imageY,
|
||||
useDistanceColorCoding ? colorCodedColorMap(distance).getRGB()
|
||||
: blackAndWhiteColorMap(distance).getRGB());
|
||||
image.setRGB(imageX, imageY, useDistanceColorCoding ? colorCodedColorMap(distance).getRGB() : blackAndWhiteColorMap(distance).getRGB());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -75,8 +75,7 @@ class BestFitCPU extends MemoryManagementAlgorithms {
|
||||
int index = NO_ALLOCATION; // If there is no block that can fit the process, return
|
||||
// NO_ALLOCATION as the
|
||||
// result.
|
||||
for (int i = 0; i < blockSizes.length;
|
||||
i++) { // Find the most fitting memory block for the given process.
|
||||
for (int i = 0; i < blockSizes.length; i++) { // Find the most fitting memory block for the given process.
|
||||
if (blockSizes[i] - processSize < minDiff && blockSizes[i] - processSize >= 0) {
|
||||
minDiff = blockSizes[i] - processSize;
|
||||
index = i;
|
||||
@ -103,13 +102,10 @@ class BestFitCPU extends MemoryManagementAlgorithms {
|
||||
ArrayList<Integer> memAlloc = new ArrayList<>();
|
||||
// Do this for every process
|
||||
for (int processSize : sizeOfProcesses) {
|
||||
int chosenBlockIdx = findBestFit(
|
||||
sizeOfBlocks, processSize); // Find the index of the memory block going to be used
|
||||
int chosenBlockIdx = findBestFit(sizeOfBlocks, processSize); // Find the index of the memory block going to be used
|
||||
memAlloc.add(chosenBlockIdx); // Store the chosen block index in the memAlloc array list
|
||||
if (chosenBlockIdx
|
||||
!= NO_ALLOCATION) { // Only if a block was chosen to store the process in it,
|
||||
sizeOfBlocks[chosenBlockIdx]
|
||||
-= processSize; // resize the block based on the process size
|
||||
if (chosenBlockIdx != NO_ALLOCATION) { // Only if a block was chosen to store the process in it,
|
||||
sizeOfBlocks[chosenBlockIdx] -= processSize; // resize the block based on the process size
|
||||
}
|
||||
}
|
||||
return memAlloc;
|
||||
@ -133,8 +129,7 @@ class WorstFitCPU extends MemoryManagementAlgorithms {
|
||||
private static int findWorstFit(int[] blockSizes, int processSize) {
|
||||
int max = -1;
|
||||
int index = -1;
|
||||
for (int i = 0; i < blockSizes.length;
|
||||
i++) { // Find the index of the biggest memory block available.
|
||||
for (int i = 0; i < blockSizes.length; i++) { // Find the index of the biggest memory block available.
|
||||
if (blockSizes[i] > max) {
|
||||
max = blockSizes[i];
|
||||
index = i;
|
||||
@ -165,13 +160,10 @@ class WorstFitCPU extends MemoryManagementAlgorithms {
|
||||
ArrayList<Integer> memAlloc = new ArrayList<>();
|
||||
// Do this for every process
|
||||
for (int processSize : sizeOfProcesses) {
|
||||
int chosenBlockIdx = findWorstFit(
|
||||
sizeOfBlocks, processSize); // Find the index of the memory block going to be used
|
||||
int chosenBlockIdx = findWorstFit(sizeOfBlocks, processSize); // Find the index of the memory block going to be used
|
||||
memAlloc.add(chosenBlockIdx); // Store the chosen block index in the memAlloc array list
|
||||
if (chosenBlockIdx
|
||||
!= NO_ALLOCATION) { // Only if a block was chosen to store the process in it,
|
||||
sizeOfBlocks[chosenBlockIdx]
|
||||
-= processSize; // resize the block based on the process size
|
||||
if (chosenBlockIdx != NO_ALLOCATION) { // Only if a block was chosen to store the process in it,
|
||||
sizeOfBlocks[chosenBlockIdx] -= processSize; // resize the block based on the process size
|
||||
}
|
||||
}
|
||||
return memAlloc;
|
||||
@ -220,13 +212,10 @@ class FirstFitCPU extends MemoryManagementAlgorithms {
|
||||
ArrayList<Integer> memAlloc = new ArrayList<>();
|
||||
// Do this for every process
|
||||
for (int processSize : sizeOfProcesses) {
|
||||
int chosenBlockIdx = findFirstFit(
|
||||
sizeOfBlocks, processSize); // Find the index of the memory block going to be used
|
||||
int chosenBlockIdx = findFirstFit(sizeOfBlocks, processSize); // Find the index of the memory block going to be used
|
||||
memAlloc.add(chosenBlockIdx); // Store the chosen block index in the memAlloc array list
|
||||
if (chosenBlockIdx
|
||||
!= NO_ALLOCATION) { // Only if a block was chosen to store the process in it,
|
||||
sizeOfBlocks[chosenBlockIdx]
|
||||
-= processSize; // resize the block based on the process size
|
||||
if (chosenBlockIdx != NO_ALLOCATION) { // Only if a block was chosen to store the process in it,
|
||||
sizeOfBlocks[chosenBlockIdx] -= processSize; // resize the block based on the process size
|
||||
}
|
||||
}
|
||||
return memAlloc;
|
||||
@ -238,8 +227,7 @@ class FirstFitCPU extends MemoryManagementAlgorithms {
|
||||
*/
|
||||
class NextFit extends MemoryManagementAlgorithms {
|
||||
|
||||
private int counter
|
||||
= 0; // variable that keeps the position of the last registration into the memory
|
||||
private int counter = 0; // variable that keeps the position of the last registration into the memory
|
||||
|
||||
/**
|
||||
* Method to find the index of the memory block that is going to fit the
|
||||
@ -285,13 +273,10 @@ class NextFit extends MemoryManagementAlgorithms {
|
||||
ArrayList<Integer> memAlloc = new ArrayList<>();
|
||||
// Do this for every process
|
||||
for (int processSize : sizeOfProcesses) {
|
||||
int chosenBlockIdx = findNextFit(
|
||||
sizeOfBlocks, processSize); // Find the index of the memory block going to be used
|
||||
int chosenBlockIdx = findNextFit(sizeOfBlocks, processSize); // Find the index of the memory block going to be used
|
||||
memAlloc.add(chosenBlockIdx); // Store the chosen block index in the memAlloc array list
|
||||
if (chosenBlockIdx
|
||||
!= NO_ALLOCATION) { // Only if a block was chosen to store the process in it,
|
||||
sizeOfBlocks[chosenBlockIdx]
|
||||
-= processSize; // resize the block based on the process size
|
||||
if (chosenBlockIdx != NO_ALLOCATION) { // Only if a block was chosen to store the process in it,
|
||||
sizeOfBlocks[chosenBlockIdx] -= processSize; // resize the block based on the process size
|
||||
}
|
||||
}
|
||||
return memAlloc;
|
||||
|
@ -42,8 +42,7 @@ public class MiniMaxAlgorithm {
|
||||
}
|
||||
|
||||
System.out.println(Arrays.toString(miniMaxAlgorith.getScores()));
|
||||
System.out.println(
|
||||
"The best score for " + (isMaximizer ? "Maximizer" : "Minimizer") + " is " + bestScore);
|
||||
System.out.println("The best score for " + (isMaximizer ? "Maximizer" : "Minimizer") + " is " + bestScore);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -79,8 +78,7 @@ public class MiniMaxAlgorithm {
|
||||
// (1 x 2) = 2; ((1 x 2) + 1) = 3
|
||||
// (2 x 2) = 4; ((2 x 2) + 1) = 5 ...
|
||||
if (verbose) {
|
||||
System.out.printf("From %02d and %02d, %s chooses %02d%n", score1, score2,
|
||||
(isMaximizer ? "Maximizer" : "Minimizer"), bestScore);
|
||||
System.out.printf("From %02d and %02d, %s chooses %02d%n", score1, score2, (isMaximizer ? "Maximizer" : "Minimizer"), bestScore);
|
||||
}
|
||||
|
||||
return bestScore;
|
||||
|
@ -10,8 +10,7 @@ class PageRank {
|
||||
System.out.print("Enter the Number of WebPages: ");
|
||||
nodes = in.nextInt();
|
||||
PageRank p = new PageRank();
|
||||
System.out.println(
|
||||
"Enter the Adjacency Matrix with 1->PATH & 0->NO PATH Between two WebPages: ");
|
||||
System.out.println("Enter the Adjacency Matrix with 1->PATH & 0->NO PATH Between two WebPages: ");
|
||||
for (i = 1; i <= nodes; i++) {
|
||||
for (j = 1; j <= nodes; j++) {
|
||||
p.path[i][j] = in.nextInt();
|
||||
@ -36,8 +35,7 @@ class PageRank {
|
||||
int k = 1; // For Traversing
|
||||
int ITERATION_STEP = 1;
|
||||
InitialPageRank = 1 / totalNodes;
|
||||
System.out.printf(" Total Number of Nodes :" + totalNodes
|
||||
+ "\t Initial PageRank of All Nodes :" + InitialPageRank + "\n");
|
||||
System.out.printf(" Total Number of Nodes :" + totalNodes + "\t Initial PageRank of All Nodes :" + InitialPageRank + "\n");
|
||||
|
||||
// 0th ITERATION _ OR _ INITIALIZATION PHASE //
|
||||
for (k = 1; k <= totalNodes; k++) {
|
||||
@ -57,12 +55,10 @@ class PageRank {
|
||||
}
|
||||
|
||||
for (InternalNodeNumber = 1; InternalNodeNumber <= totalNodes; InternalNodeNumber++) {
|
||||
for (ExternalNodeNumber = 1; ExternalNodeNumber <= totalNodes;
|
||||
ExternalNodeNumber++) {
|
||||
for (ExternalNodeNumber = 1; ExternalNodeNumber <= totalNodes; ExternalNodeNumber++) {
|
||||
if (this.path[ExternalNodeNumber][InternalNodeNumber] == 1) {
|
||||
k = 1;
|
||||
OutgoingLinks
|
||||
= 0; // Count the Number of Outgoing Links for each ExternalNodeNumber
|
||||
OutgoingLinks = 0; // Count the Number of Outgoing Links for each ExternalNodeNumber
|
||||
while (k <= totalNodes) {
|
||||
if (this.path[ExternalNodeNumber][k] == 1) {
|
||||
OutgoingLinks = OutgoingLinks + 1; // Counter for Outgoing Links
|
||||
@ -70,8 +66,7 @@ class PageRank {
|
||||
k = k + 1;
|
||||
}
|
||||
// Calculate PageRank
|
||||
this.pagerank[InternalNodeNumber]
|
||||
+= TempPageRank[ExternalNodeNumber] * (1 / OutgoingLinks);
|
||||
this.pagerank[InternalNodeNumber] += TempPageRank[ExternalNodeNumber] * (1 / OutgoingLinks);
|
||||
}
|
||||
}
|
||||
System.out.printf("\n After " + ITERATION_STEP + "th Step \n");
|
||||
|
@ -17,8 +17,7 @@ public class PerlinNoise {
|
||||
* @param seed used for randomizer
|
||||
* @return float array containing calculated "Perlin-Noise" values
|
||||
*/
|
||||
static float[][] generatePerlinNoise(
|
||||
int width, int height, int octaveCount, float persistence, long seed) {
|
||||
static float[][] generatePerlinNoise(int width, int height, int octaveCount, float persistence, long seed) {
|
||||
final float[][] base = new float[width][height];
|
||||
final float[][] perlinNoise = new float[width][height];
|
||||
final float[][][] noiseLayers = new float[octaveCount][][];
|
||||
|
@ -141,8 +141,7 @@ public class QueueUsingTwoStacks {
|
||||
System.out.println(myQueue.isEmpty()); // Will print false
|
||||
|
||||
System.out.println(myQueue.remove()); // Will print 1
|
||||
System.out.println(
|
||||
(myQueue.isInStackEmpty()) ? "null" : myQueue.peekBack()); // Will print NULL
|
||||
System.out.println((myQueue.isInStackEmpty()) ? "null" : myQueue.peekBack()); // Will print NULL
|
||||
// instack: []
|
||||
// outStack: [(top) 2, 3, 4]
|
||||
|
||||
|
@ -8,8 +8,7 @@ public class ReturnSubsequence {
|
||||
System.out.println("Enter String: ");
|
||||
Scanner s = new Scanner(System.in);
|
||||
String givenString = s.next(); // given string
|
||||
String[] subsequence
|
||||
= returnSubsequence(givenString); // calling returnSubsequence() function
|
||||
String[] subsequence = returnSubsequence(givenString); // calling returnSubsequence() function
|
||||
System.out.println("Subsequences : ");
|
||||
// print the given array of subsequences
|
||||
for (int i = 0; i < subsequence.length; i++) {
|
||||
@ -29,20 +28,17 @@ public class ReturnSubsequence {
|
||||
ans[0] = "";
|
||||
return ans;
|
||||
}
|
||||
String[] SmallAns = returnSubsequence(givenString.substring(
|
||||
1)); // recursive call to get subsequences of substring starting from index
|
||||
String[] SmallAns = returnSubsequence(givenString.substring(1)); // recursive call to get subsequences of substring starting from index
|
||||
// position=1
|
||||
|
||||
String[] ans = new String[2
|
||||
* SmallAns.length]; // Our answer will be an array off string of size=2*SmallAns
|
||||
String[] ans = new String[2 * SmallAns.length]; // Our answer will be an array off string of size=2*SmallAns
|
||||
int i = 0;
|
||||
for (; i < SmallAns.length; i++) {
|
||||
ans[i] = SmallAns[i]; // Copying all the strings present in SmallAns to ans string array
|
||||
}
|
||||
for (int k = 0; k < SmallAns.length; k++) {
|
||||
ans[k + SmallAns.length]
|
||||
= givenString.charAt(0) + SmallAns[k]; // Insert character at index=0 of the given
|
||||
// substring in front of every string
|
||||
ans[k + SmallAns.length] = givenString.charAt(0) + SmallAns[k]; // Insert character at index=0 of the given
|
||||
// substring in front of every string
|
||||
// in SmallAns
|
||||
}
|
||||
return ans;
|
||||
|
@ -30,8 +30,7 @@ public class SieveOfEratosthenes {
|
||||
}
|
||||
}
|
||||
|
||||
int primesCount
|
||||
= (int) Arrays.stream(numbers).filter(element -> element == Type.PRIME).count();
|
||||
int primesCount = (int) Arrays.stream(numbers).filter(element -> element == Type.PRIME).count();
|
||||
int[] primes = new int[primesCount];
|
||||
|
||||
int primeIndex = 0;
|
||||
|
@ -18,8 +18,7 @@ public class SkylineProblem {
|
||||
for (int i = 0; i < num; i++) {
|
||||
String input = sc.next();
|
||||
String[] data = input.split(",");
|
||||
this.add(
|
||||
Integer.parseInt(data[0]), Integer.parseInt(data[1]), Integer.parseInt(data[2]));
|
||||
this.add(Integer.parseInt(data[0]), Integer.parseInt(data[1]), Integer.parseInt(data[2]));
|
||||
}
|
||||
this.print(this.findSkyline(0, num - 1));
|
||||
|
||||
|
@ -64,8 +64,7 @@ public class TopKWords {
|
||||
public static void main(String[] args) {
|
||||
// you can replace the filePath with yours
|
||||
CountWords cw = new CountWords("/Users/lisanaaa/Desktop/words.txt");
|
||||
Map<String, Integer> dictionary
|
||||
= cw.getDictionary(); // get the words dictionary: {word: frequency}
|
||||
Map<String, Integer> dictionary = cw.getDictionary(); // get the words dictionary: {word: frequency}
|
||||
|
||||
// we change the map to list for convenient sort
|
||||
List<Map.Entry<String, Integer>> list = new ArrayList<>(dictionary.entrySet());
|
||||
|
@ -153,8 +153,7 @@ public class Verhoeff {
|
||||
|
||||
private static void generateAndPrint(String input) {
|
||||
String result = addVerhoeffChecksum(input);
|
||||
System.out.println(
|
||||
"Generate and add checksum to initial value '" + input + "'. Result: '" + result + "'");
|
||||
System.out.println("Generate and add checksum to initial value '" + input + "'. Result: '" + result + "'");
|
||||
}
|
||||
|
||||
private static void checkInput(String input) {
|
||||
|
Reference in New Issue
Block a user