Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Command: tr '.#:x' '12 ' <input | dc -fdc-p1.dc
- [q] sq
- ?
- [
- z1<q # more than 1 element means second section
- # stack: index
- ??? 0 # ASSSUME: pieces have three rows
- [
- r # row sum ... idx
- [
- A~ # digit rest sum ...
- 2/ 3R+ # sum+=(digit==2) rest ...
- r d0<D # loop until (row == 0)
- ] dsDx +
- # stack: sum piece* idx
- z2<I
- ] dsIx
- r1+:p
- ?? z0<L # skip blank line
- ] dsLx
- 0 # part1=0
- [
- 0 z4- # i=numPieces sum part1 targ_n targ_n-1 ... targ_1 length width
- [
- d;p
- 5R* 3R+ # sum+=piece[i]*targ_n i targ_n-1 ...
- r 1- d0<I
- ] dsIx +
- # sum part1 length width
- 4R4R* # area sum part1
- - d.1+/ + # part1 += ((sum - area) < 0)
- ? zR z1<M # read line, rotate part1 to top
- ] dsMx
- [Part 1: ]np
Advertisement
Add Comment
Please, Sign In to add comment