Skip to content

Instantly share code, notes, and snippets.

@KCreate
Created July 4, 2016 16:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KCreate/f11f680af34d8187fa82212c43cc2d21 to your computer and use it in GitHub Desktop.
Save KCreate/f11f680af34d8187fa82212c43cc2d21 to your computer and use it in GitHub Desktop.
const leftpad = require('left-pad');
const fs = require('fs');
const chars = [
[
'┌─┐',
'│ │',
'│ │',
'│ │',
'└─┘',
],
[
' ╵',
' │',
' │',
' │',
' ╷',
],
[
'──┐',
' │',
'┌─┘',
'│ ',
'└──',
],
[
'──┐',
' │',
'──┤',
' │',
'──┘',
],
[
'╵ ╵',
'│ │',
'└─┤',
' │',
' ╷',
],
[
'┌──',
'│ ',
'└─┐',
' │',
'──┘',
],
[
'┌──',
'│ ',
'├─┐',
'│ │',
'└─┘',
],
[
'──┐',
' │',
' │',
' │',
' ╷',
],
[
'┌─┐',
'│ │',
'├─┤',
'│ │',
'└─┘',
],
[
'┌─┐',
'│ │',
'└─┤',
' │',
'└─┘',
],
[
' ',
' ',
'───',
' ',
' ',
],
[
' ',
' ',
' ',
' ',
'╷',
],
];
function display(number) {
number = String(number);
let line = '';
for (let i = 0; i < 5; i++) {
line = '';
number.split('').forEach((e, i2) => {
const index = {
0: 0,
1: 1,
2: 2,
3: 3,
4: 4,
5: 5,
6: 6,
7: 7,
8: 8,
9: 9,
'-': 10,
'.': 11,
}[e];
line += chars[index][i];
line += ' ';
});
console.log(line);
}
}
const input = fs.readFileSync('/dev/stdin').toString();
result = parseInt(Number(input), 2);
result = (result - 302) / 10;
display(result);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment