Last active
April 5, 2018 02:21
-
-
Save rbreslow/41e6f74b15329321b9bcddc897f4bfa6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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