Split code into modules and add gulpfile

This commit is contained in:
Slava Bacherikov committed 2018-01-08 22:13:19 +02:00
1 parent c66c0a9d74
commit 1ae71673d8
17 files changed
+579 -434

No files matched your search

+22
View File
@@ -0,0 +1,22 @@
import { makeSolver } from "./utils";
/* Return password for old sony laptops
* password 7 digit number like 1234567
*/
function sonyKeygen(serial: string): string {
const table = "0987654321876543210976543210982109876543109876543221098765436543210987";
let code: string = "";
for (let i = 0; i < serial.length; i++) {
code += table.charAt(parseInt(serial.charAt(i), 10) + 10 * i);
}
return code;
}
export let sonySolver = makeSolver({
name: "Sony",
examples: ["1234567"],
inputValidator: (s) => /^\d{7}$/i.test(s),
fun: (code: string) => {
let res = sonyKeygen(code);
return res ? [res] : [];
}
});