blob: 784b4f926de2f1a4a3f6a60eeb8b07853cb22f23 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
```ruby
s = '
+++++ +++++
[
> +++++ +++++ + > +++++ +++++ +
> +++++ +++++ > +++++ +++++
<<<< -
]
> . > +++++ . >> ++ . < +++++ . < . > . < .
'
m=[c=p=0,0,0,0,0];(k=s[c])=='>'?p+=1:k=='<'?p-=1:
k=='+'?m[p]+=1:k=='-'?m[p]-=1:k=='.'?putc(m[p]):
k=='['?(0until s[c+=1]==']'if m[p]==0):
k==']'?(0until s[c-=1]=='['if m[p]!=0):0while s[c+=1]
```
|