Skip to content

Instantly share code, notes, and snippets.

@MysterionRise
Created December 2, 2021 15:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MysterionRise/0cff798b9652c390d4fe5cd496fadc39 to your computer and use it in GitHub Desktop.
Save MysterionRise/0cff798b9652c390d4fe5cd496fadc39 to your computer and use it in GitHub Desktop.
Cleanup1.java
package org.mystic.amthauer;
import java.io.IOException;
import java.nio.file.Paths;
import java.util.Scanner;
public class Cleanup1 {
public static void main(String[] args) throws IOException {
Scanner in = new Scanner(Paths.get("1.txt"));
String finalToken = "";
while (in.hasNextLine()) {
String line = in.nextLine();
if (!line.isEmpty()) {
if (line.startsWith("С")) {
System.out.println(line);
} else {
String[] tokens = line.split(" ");
StringBuilder result = new StringBuilder();
for (String token : tokens) {
int tokenValue = Integer.parseInt(token);
if (tokenValue >= 29 && tokenValue <= 192) {
result.append("1307").append(" ");
finalToken = token;
} else if (tokenValue >= 1306 && tokenValue <= 1309) {
finalToken = "1308";
result.append(token).append(" ");
} else {
result.append(token).append(" ");
}
}
if (!finalToken.isEmpty()) {
result.append(finalToken).append(" ");
finalToken = "";
}
System.out.println(result);
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment