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.*; | |
import java.io.*; | |
public class T9Spelling { | |
public String translate(String phrase) { | |
HashMap<String, String> alphaMap = getKeypadDictionary(); | |
StringBuilder sbTranslatedMessage = new StringBuilder(); | |
for(int i=0;i<phrase.length();i++) { | |
if(i != 0) { |
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.ArrayList; | |
import java.util.HashMap; | |
import java.util.Iterator; | |
import java.math.BigInteger; | |
import java.io.*; | |
public class AllYourBase { | |
public BigInteger convert(String str) { | |
BigInteger res = new BigInteger("0"); | |
int base = 0; |
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
public class AlienNumbers { | |
public String convertFromOneNumberSystemToOther(String alienNum, String srcLang, String targetLang) { | |
int iSrcLangBaseNum = srcLang.trim().length(); | |
int iTgtLangBaseNum = targetLang.trim().length(); | |
int iAlienNumInDecSystem = 0; | |
int iAlienNumLen = alienNum.length(); | |
for(int i=0;i<iAlienNumLen;i++) { | |
iAlienNumInDecSystem += srcLang.indexOf(alienNum.charAt(i)) * Math.pow(iSrcLangBaseNum,(iAlienNumLen-1-i)); |
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.*; | |
import java.io.*; | |
public class ReverseWords { | |
public String reverseWords(String phrase) { | |
List<string> wordList = Arrays.asList(phrase.split("[ ]")); | |
Collections.reverse(wordList); | |
StringBuilder sbReverseString = new StringBuilder(); | |
for(String word: wordList) { |
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
public class Googol { | |
public static void main(String[] args) { | |
long googol1 = (long) Math.pow(10,100); | |
System.out.println("Googol1 : " + googol1); | |
System.out.println("Max Value of Long : " + Long.MAX_VALUE); | |
BigDecimal googol2 = new BigDecimal(Math.pow(10,100) + ""); | |
System.out.println("Googol2 : " + googol2); | |
BigDecimal bigDecimal = googol2.multiply(new BigDecimal(Math.PI + "")); |
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.io.File; | |
import java.io.FilenameFilter; | |
import java.io.IOException; | |
import java.nio.charset.Charset; | |
import java.util.Arrays; | |
import java.util.Locale; | |
import javax.tools.Diagnostic; | |
import javax.tools.DiagnosticCollector; | |
import javax.tools.JavaCompiler; | |
import javax.tools.JavaFileObject; |
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.math.BigInteger; | |
public class BigIntTest { | |
public static void main(String[] args) { | |
BigInteger bigInt1 = new BigInteger("1000000000000000"); | |
BigInteger bigInt2 = new BigInteger("1000000000000500"); | |
//Loop from bigInt1 to bigInt2 | |
for(BigInteger bigInt = bigInt1; bigInt.compareTo(bigInt2) < 0; bigInt = bigInt.add(BigInteger.ONE)) { | |
System.out.println("I'm so big now : " + bigInt); |
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
<build> | |
<plugins> | |
<plugin> | |
<groupid>org.apache.maven.plugins</groupId> | |
<artifactid>maven-shade-plugin</artifactId> | |
<version>1.4</version> | |
<executions> | |
<execution> | |
<phase>package</phase> | |
<goals> |
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
<build> | |
<plugins> | |
<plugin> | |
<groupid>net.alchim31.maven</groupId> | |
<artifactid>yuicompressor-maven-plugin</artifactId> | |
<executions> | |
<execution> | |
<goals> | |
<goal>compress</goal> | |
</goals> |
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
<pluginrepositories> | |
<pluginrepository> | |
<name>oss.sonatype.org</name> | |
<id>oss.sonatype.org</id> | |
<url>http://oss.sonatype.org/content/groups/public</url> | |
</pluginRepository> | |
</pluginRepositories> |