Skip to content

Instantly share code, notes, and snippets.

View glennji's full-sized avatar
🤓
Geeking out

Glenn J. Mason glennji

🤓
Geeking out
View GitHub Profile
@glennji
glennji / java-code-challenge-snippet.java
Created August 9, 2016 10:07
Java Code Challenge - Chemical Symbol
public boolean valid(String element, String shortcode) {
char [] shortcodeChars = shortcode.toLowerCase().toCharArray();
element = element.toLowerCase();
int char1 = element.indexOf(shortcodeChars[0]);
int char2 = element.substring(char1 + 1).indexOf(shortcodeChars[1]);
System.out.println(char2);
return char1 >= 0 && char2 > 0 && char1 < char2;
}

Keybase proof

I hereby claim:

To claim this, I am signing this object:

OSZAR »