1 var fs = require('fs');
2 const content = fs.readFileSync('sms4.csv', 'utf8');
3 const lines = content.split("\n");
4 const validLines = lines.filter(line => line.trim());
22 let sameInputCount = 0;
24 const NEW_KEY_TIMEDIFF_THRESHOLD = 1000;
25 const N7110_KEYPAD_ZERO = 0;
26 const N7110_KEYPAD_STAR = 10;
27 const N7110_KEYPAD_MENU_RIGHT = 101
29 for (let i = 0; i < validLines.length; i++) {
30 const splitted = validLines[i].split(",");
31 const time = Number.parseInt(splitted[0]);
32 const input = Number.parseInt(splitted[1]);
34 if (lastInput === input && time - lastTime < NEW_KEY_TIMEDIFF_THRESHOLD) {
36 } else if (input === N7110_KEYPAD_MENU_RIGHT) {
37 result = result.substr(0, result.length - 1);
41 if (lastInput >= N7110_KEYPAD_ZERO && lastInput <= N7110_KEYPAD_STAR) {
42 result += keypadChars[lastInput][sameInputCount % keypadChars[lastInput].length];