Just another update
This commit is contained in:
parent
a25938f123
commit
00a190b0a6
6591 changed files with 94363 additions and 23227 deletions
|
|
@ -1,13 +1,14 @@
|
|||
import java.io.*;
|
||||
import java.nio.file.*;
|
||||
import java.util.*;
|
||||
|
||||
public class Semordnilaps {
|
||||
public class Semordnilap {
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
List<String> lst = readLines("unixdict.txt");
|
||||
public static void main(String[] args) throws Exception {
|
||||
List<String> lst = Files.readAllLines(Paths.get("unixdict.txt"));
|
||||
Set<String> seen = new HashSet<>();
|
||||
int count = 0;
|
||||
for (String w : lst) {
|
||||
w = w.toLowerCase();
|
||||
String r = new StringBuilder(w).reverse().toString();
|
||||
if (seen.contains(r)) {
|
||||
if (count++ < 5)
|
||||
|
|
@ -16,15 +17,4 @@ public class Semordnilaps {
|
|||
}
|
||||
System.out.println("\nSemordnilap pairs found: " + count);
|
||||
}
|
||||
|
||||
private static List<String> readLines(String fn) throws IOException {
|
||||
List<String> lines;
|
||||
try (BufferedReader br = new BufferedReader(new FileReader(fn))) {
|
||||
lines = new ArrayList<>();
|
||||
String line;
|
||||
while ((line = br.readLine()) != null)
|
||||
lines.add(line.trim().toLowerCase());
|
||||
}
|
||||
return lines;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue