Skip to content

Instantly share code, notes, and snippets.

@rbreslow
Last active April 5, 2018 02:21
Show Gist options
  • Save rbreslow/41e6f74b15329321b9bcddc897f4bfa6 to your computer and use it in GitHub Desktop.
Save rbreslow/41e6f74b15329321b9bcddc897f4bfa6 to your computer and use it in GitHub Desktop.
import java.util.*;
public class Mindfuck {
public static void main(String[] args) {
reconstruct("owoztneoer"); //012
reconstruct("fviefuro"); //45
}
public static void reconstruct(String str) {
String[] numbers = {"zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"};
int[] matches = new int[10];
for(String s : str.split("")) {
for(int i = 0; i < numbers.length; i++) {
if(numbers[i].contains(s)) {
matches[i]++;
}
}
}
ArrayList<Integer> list = new ArrayList<Integer>();
for(int i = 0; i < matches.length; i++) {
if(matches[i] > numbers[i].length()) {
list.add(i);
}
}
Collections.sort(list);
for(Integer i : list) {
System.out.print(i);
}
System.out.println();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment