Last active
August 21, 2020 15:52
-
-
Save joeygravlin/b64e103697c1ee4d5dd62270089b27ef to your computer and use it in GitHub Desktop.
Counts the min/max number of switches for SP-111 https://geekhack.org/index.php?topic=103449.0
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //#!/usr/bin/env node | |
| // Counts the min/max number of switches for SP-111 | |
| // https://geekhack.org/index.php?topic=103449.0 | |
| // | |
| // left and right arrays go from top-to-bottom rows | |
| // except the last element on right, for the arrow keys | |
| const sp111 = { | |
| switches: { | |
| max: { | |
| numpad: [4*6], | |
| left: [7, 7, 6, 6, 6+1, 5], | |
| right: [9, 10, 10, 9, 7, 5, 4] | |
| }, | |
| min: { | |
| numpad: [(4*6) - 3], | |
| left: [7, 7, 6, 6, 6, 5-1], | |
| right: [9, 10-1, 10, 9, 7-1, 5-1, 4] | |
| } | |
| }, | |
| switchCount: (x) => { | |
| return Object.keys(x).reduce((a,b) => { | |
| return a + x[b].reduce((y,z) => y + z, 0); | |
| }, 0); | |
| }, | |
| getSwitchCountsMessages: (x) => { | |
| const msgs = []; | |
| Object.keys(x).forEach( y => { | |
| let count = sp111.switchCount(x[y]); | |
| let msg = `SP-111 ${y} switchCount: ${count}`; | |
| msgs.push(msg); | |
| }); | |
| return msgs; | |
| } | |
| }; | |
| sp111.getSwitchCountsMessages(sp111.switches) | |
| .forEach(x => console.log(x)); | |
| // SP-111 max switchCount: 116 | |
| // SP-111 min switchCount: 108 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment