Add javascript/omcb-server-clocks
* commit 'd65b929b9a7abda1ae63ba6edf11114d07cd6be8': javascript(omcb-server-clocks): Play around with clock decoding
This commit is contained in:
commit
25fb6b3936
6
javascript/omcb-server-clocks/data.txt
Normal file
6
javascript/omcb-server-clocks/data.txt
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
11 3 6 4. 1 9. 6 9 8. 7 8 5 4 7. 5. 1. 2 3. 10 10.
|
||||||
|
9. 9 8 7. 8. 2. 3 4. 2 12. 11 10. 12 5.
|
||||||
|
9. 8. 9 8 7. 6. 5. 6 4 3 7 10. 3. 2. 10 1 11
|
||||||
|
6 11 1 3 ? 9. 9 8. 8 7 7. 3. 4 2. 2 4. 12. 6. 5 11.
|
||||||
|
?? 9. 9 8. 8 7. 7 3. 4. 5 5. 6 1. 2. 11 2 4 3 12 6.
|
||||||
|
??? 9. 9 8. 8 7. 2. 3 1 10. 11 3. 4 7 10 5. 6. 12 1 12.
|
0
javascript/omcb-server-clocks/numbers.txt
Normal file
0
javascript/omcb-server-clocks/numbers.txt
Normal file
34
javascript/omcb-server-clocks/script.js
Normal file
34
javascript/omcb-server-clocks/script.js
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
const fs = require("node:fs");
|
||||||
|
|
||||||
|
const data = fs.readFileSync("./data.txt", "utf8");
|
||||||
|
|
||||||
|
const numbers = [];
|
||||||
|
for (const line of data.split("\n")) {
|
||||||
|
if (line.trim() === "") continue;
|
||||||
|
const numberLine = [];
|
||||||
|
numbers.push(numberLine);
|
||||||
|
|
||||||
|
for (const segment of line.split(" ")) {
|
||||||
|
if (segment.startsWith("?")) continue;
|
||||||
|
const isMid = segment.endsWith(".");
|
||||||
|
const num = parseInt(segment);
|
||||||
|
// if (isMid) numberLine.push((num - 1) * 2 + 1);
|
||||||
|
// else numberLine.push((num - 1) * 2);
|
||||||
|
if (isMid) numberLine.push(12 + num - 1);
|
||||||
|
else numberLine.push(num - 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const alphabet = "abcdefghijklmnopqrstuvwxyz";
|
||||||
|
|
||||||
|
for (let shift = 0; shift < alphabet.length; shift++) {
|
||||||
|
for (const line of numbers) {
|
||||||
|
let res = "";
|
||||||
|
for (const num of line) {
|
||||||
|
res += alphabet[(num + shift) % alphabet.length];
|
||||||
|
}
|
||||||
|
for (let i = 0; i < res.length; i++)
|
||||||
|
if (res.substr(i).startsWith("doit")) console.log(res);
|
||||||
|
}
|
||||||
|
console.log(" ");
|
||||||
|
}
|
Loading…
Reference in a new issue