Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [q] sQ
- [ d l1+ s1 q] sP
- # Find and score error (stack: count)
- [
- d;f lh r- 1+ # half - f(count) + 1
- r d;l lh - # l(count) - half
- 3R* 0<P # call P (score) if (h - f(c) + 1) * (l(c) - h) is +'ve
- 1- d 0<E # count--, loop if > 0
- ] sE
- # Set f(pri) to index, stack: pri rest
- [
- zr # push index of item, rotate pri up
- d_3R # dup pri, tuck under index
- :l # l(pri) = index
- ] sS
- # Loop (stack: items)
- [
- 32~ r 3- 26*- # convert item to priority
- d;l 0=S # check l(pri) == 0, set; stack: pri rest
- z r:f # push index, f(pri) = index
- z 0<L
- ] sL
- # Main loop
- [
- ? # get line
- z d2/ sh # h = half length
- 0=Q # quit if 0
- lLx # parse to build f() and l() arrays
- 52 # counter
- lEx s. # find error item and score, clear count
- 0Sf 0Sl # clear f and l
- lMx
- ] sM
- lMx
- [Part 1: ]n l1p
- [<END>]ps.
- [<stack>]ps. f [<bottom>]ps.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement