|
Level 1 |
Level 2 |
Level 3 |
Div 1 |
Level 1 |
Level 2 |
Level 3 |
Div 2 |
Level 1 |
Level 2 |
Level 3 |
Tutorials:
Division One - Level Three:
Solution
Source Code:
Division One - Level Two:
Solution
Source Code:
Division One - Level One:
Solution
Since there is less than 26 letters or we say identity of combinations here, we use letter mapping to reconstruct the letters, which could help us easier sort the string array.
Source Code:
import java.util.Arrays;
/**
* @author: antonio081014
*/
public class TagalogDictionary {
public String[] sortWords(String[] words) {
PhilipString[] list = new PhilipString[words.length];
for (int i = 0; i < words.length; i++)
list[i] = new PhilipString(words[i]);
Arrays.sort(list);
String[] ret = new String[words.length];
for (int i = 0; i < words.length; i++) {
ret[i] = list[i].word;
}
return ret;
}
}
class PhilipString implements Comparable<PhilipString> {
public String word;
public String tran;
public PhilipString(String w) {
this.word = w;
this.tran = "";
for (int i = 0; i < w.length(); i++) {
switch (w.charAt(i)) {
case 'a':
tran += "a";
break;
case 'b':
tran += "b";
break;
case 'k':
tran += "c";
break;
case 'd':
tran += "d";
break;
case 'e':
tran += "e";
break;
case 'g':
tran += "g";
break;
case 'h':
tran += "h";
break;
case 'i':
tran += "i";
break;
case 'l':
tran += "j";
break;
case 'm':
tran += "k";
break;
case 'n':
if (i + 1 < w.length() && w.charAt(i + 1) == 'g')
tran += "n";
else
tran += "m";
break;
case 'o':
tran += "o";
break;
case 'p':
tran += "p";
break;
case 'r':
tran += "r";
break;
case 's':
tran += "s";
break;
case 't':
tran += "t";
break;
case 'u':
tran += "u";
break;
case 'w':
tran += "w";
break;
case 'y':
tran += "y";
break;
default:
break;
}
}
}
public int compareTo(PhilipString a) {
return this.tran.compareTo(a.tran);
}
}
Sivision Two - Level Three:
Solution
Source Code:
Division Two - Level Two:
Solution
Source Code:
Division Two - Level One:
Solution
Source Code:
//2009/08/22 12:49:57
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <sstream>
#include <algorithm>
using namespace std;
#define PI 3.141592653589793
class DegreesToRadians
{
public:
double convertToRadians(int degrees, int minutes, int seconds)
{
double sum = 1.0*degrees + (60.0*minutes+seconds) / 3600.0;
return sum * PI / 180.0;
}
};