Published | Actual | |
Birmingham New Street | 07:10 | 07:10 |
London Euston | 08:30 | 08:30 |
As previously covered, I have been trying to prove that there are some words and phrases that are equivalent to others in some way.
v0.2
The update to the process would be to generate the hash based on the ASCII charset, this added some extra complexity as spaces have a value and a capitalised letter is 32 smaller than its lower case equivalent, the ideal solution would be to write a bit of code, bring on the Java. The program I created was functional, in no way was it meant to be elegant, in no way was it supposed to live up to OO design, it’s a quick and dirty script.
package words; import java.util.HashMap; import java.util.Map; /** * Class to generate numerical values for words and compare equivalence to other words. * * @author a */ public class WordWhackerV02 { public enum Charset { ASCII, UNICODE, POSITIONAL } public static Map<Character,Integer> letters = new HashMap<Character,Integer>(); public static Map<Character,Integer> asciiletters = new HashMap<Character,Integer>(); static { asciiletters.put('A', 65);asciiletters.put('B', 66);asciiletters.put('C', 67); asciiletters.put('D', 68);asciiletters.put('E', 69);asciiletters.put('F', 70); asciiletters.put('G', 71);asciiletters.put('H', 72);asciiletters.put('I', 73); asciiletters.put('J', 74);asciiletters.put('K', 75);asciiletters.put('L', 76); asciiletters.put('M', 77);asciiletters.put('N', 78);asciiletters.put('O', 79); asciiletters.put('P', 80);asciiletters.put('Q', 81);asciiletters.put('R', 82); asciiletters.put('S', 83);asciiletters.put('T', 84);asciiletters.put('U', 85); asciiletters.put('V', 86);asciiletters.put('W', 87);asciiletters.put('X', 88); asciiletters.put('Y', 89);asciiletters.put('Z', 90); asciiletters.put('a', 97); asciiletters.put('b', 98); asciiletters.put('c', 99); asciiletters.put('d', 100);asciiletters.put('e', 101);asciiletters.put('f', 102); asciiletters.put('g', 103);asciiletters.put('h', 104);asciiletters.put('i', 105); asciiletters.put('j', 106);asciiletters.put('k', 107);asciiletters.put('l', 108); asciiletters.put('m', 109);asciiletters.put('n', 110);asciiletters.put('o', 111); asciiletters.put('p', 112);asciiletters.put('q', 113);asciiletters.put('r', 114); asciiletters.put('s', 115);asciiletters.put('t', 116);asciiletters.put('u', 117); asciiletters.put('v', 118);asciiletters.put('w', 119);asciiletters.put('x', 120); asciiletters.put('y', 121);asciiletters.put('z', 122);asciiletters.put(' ', 20); letters.put('a', 1); letters.put('b', 2); letters.put('c', 3); letters.put('d', 4); letters.put('e', 5); letters.put('f', 6); letters.put('g', 7); letters.put('h', 8); letters.put('i', 9); letters.put('j', 10);letters.put('k', 11);letters.put('l', 12); letters.put('m', 13);letters.put('n', 14);letters.put('o', 15);letters.put('p', 16); letters.put('q', 17);letters.put('r', 18);letters.put('s', 19);letters.put('t', 20); letters.put('u', 21);letters.put('v', 22);letters.put('w', 23);letters.put('x', 24); letters.put('y', 25);letters.put('z', 26);letters.put(' ', 0); } public Charset useCharset = Charset.ASCII; /** * @param args a {@link java.lang.String}[] of program arguments */ public static void main(String[] args) { WordWhackerV02 whacker = new WordWhackerV02(); whacker.useCharset = Charset.POSITIONAL; String[] strings = new String[]{"Happiness", "Eternal Happiness", "Perpetual Happiness", "Happy Employees", "Motivational Happiness", "Creative Happiness", "Boundless Creativity"}; for(String val : strings) { System.out.println(val + " " + whacker.getWordValue(val)); } } /** * Method to return the numeric value for a given word * * @param word a {@link java.lang.String} containing the word * @return an int representing the words numeric value */ private int getWordValue(String word) { int returnable = 0; char[] chars = word.toCharArray(); for(char theChar : chars) { Integer charValue = null; switch(useCharset) { case ASCII: charValue = asciiletters.get(theChar); break; case UNICODE: charValue = Character.getNumericValue(theChar); break; case POSITIONAL: charValue = letters.get(Character.toLowerCase(theChar)); break; default: break; } if(charValue != null) { returnable = returnable + charValue; } } return returnable; } }
This script was useful for generating the values of input strings quickly but meant that I still had to think of phrases to compare against - surly an improvement to this would be to use a dictionary to search for numerically equivalent words.