function mult(x, y) {
var r0, r1, r2;
r0 = y[x[0]];
r1 = y[x[1]];
r2 = y[x[2]];
return [r0, r1, r2];
}
var opName = {
"u" : [1, 2, 2],
"d" : [0, 0, 1],
"U" : [2, 2, 2],
"D" : [0, 0, 0],
"X" : [0, 1, 1],
"Y" : [1, 1, 2],
"V" : [1, 1, 1],
"" : []
};
function findName(x) {
for (var n in opName) {
var y = opName[n];
if (x[0] == y[0] && x[1] == y[1] && x[2] == y[2]) {
return n;
}
}
return null;
}
function multByName(a, b) {
var x = opName[a];
var y = opName[b];
var r = mult(x, y);
var name = findName(r);
if (name) {
return name;
} else {
return r;
}
}
function makeTable() {
var names = ["u", "d", "U", "D", "X", "Y", "V"];
var table = [];
for (var i = 0; i < names.length; i++) {
var row = [];
for (var j = 0; j < names.length; j++) {
row.push([names[i] ,names[j], multByName(names[i], names[j])]);
}
table.push(row);
}
return table;
}
function convertToHatenaTable(table) {
var textList = [];
for (var i = 0; i < table.length; i++) {
var row = table[i];
var rowText = "|";
for (var j = 0; j < row.length; j++) {
rowText += " " + row[j][2] + " |";
}
rowText += "\n";
textList.push(rowText);
}
return textList;
}