Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Command: perl -pe's/(.)/$1 /g;y/.O#/012/' <input | dc -fpart1.dc
- ?
- zdsn # n = size; i = n
- [
- d 2 r:a # a(i) = 2
- 1- d0<I
- ] dsIx
- + # clear i (+0)
- [
- [
- z d;a 3* 3R+ r:a # a(z) = 3*a(z) + top
- z0<L
- ] dsLx
- ? z0<M
- ] dsMx
- [ lc1+sc ] sC
- # Score: i h a(i) -> i h a(i)
- [
- rd lcd # a(i) h h c c
- 3R2* r- 1+ * # a(i) h c*(2h-c+1)
- 2/
- ls+ss
- 0sc
- r
- ] sS
- ln # i=n
- [
- d;a 0r # i h=0 a(i)
- [
- 3~ # h a(i)=a(i)/3 val=a(i)%3
- d 1=C # count if val == 1
- 2=S # score if val == 0; stack: h a(i)
- r1+r # h++
- d 0<H # loop if a(i) non-zero
- ] dsHx
- # stack: i h 0
- *+ # clear 2 (+ 0*h)
- 1- d0<I
- ] dsIx
- [Part 1: ]nlsp
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement