-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
44 lines (32 loc) · 799 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
module.exports = function(txt) {
var base = "++++++++++["
var end = "";
var print = "";
var chars = txt.split('');
var cells = [];
var codes = [];
for(var i = 0; i <= chars.length-1; i++) {
cells.push(Math.round(chars[i].charCodeAt(0) /10));
codes.push(chars[i].charCodeAt(0));
}
for(var i = 0; i <= cells.length-1; i++) {
base = base + ">"
end = end + "<";
for(var x = 0; x <= cells[i]-1; x++) {
base = base + "+";
}
print = print + ">"
var _ = codes[i] - cells[i] * 10
if(_ < 0) _ = -_
for(var z = 0; z <= _-1; z++) {
var val = codes[i] - cells[i] * 10
if(val <= 0) {
print = print + "-"
} else print = print + "+"
}
print = print + "."
}
end = end + "-]"
var code = base + end + print;
return code;
}