Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- REBOL[]
- ;** R3 only
- ;** 264 chars, works with the unicorn example.
- s: {
- 64
- 63
- 62 61
- 1 65
- 66 57 58
- 2 56 59 45
- 67 55 46
- 3 44
- 54 60 47
- 53 52 49 48
- 4 51 50 43
- 5 42
- 41
- 6 23
- 22 25 26 40
- 20 21 24 34
- 7 13 12 33
- 19 27 32
- 14 35
- 8 15
- 16
- 39
- 17 18 28 31 36
- 9 38
- 10 11 29 30 37
- }
- _:[skip]i: 1 r:[(z: n + 77 // 81)z _ _ then[v reject | r | _ p:(w/(index? p): pick"/|\-"n)end]|]
- parse s[any[79[and lf insert" "| _]_](w: copy s):w any[" "| lf | end | p:(p/1:"+" p/2:" ")_]
- 99[:s(v: load ajoin[{" }++ i{ "|" }i{ "}]n: 0)to v 0 4[(++ n)and r]]]print w
- halt
- +
- /+
- //
- //
- //
- /+--+
- + + \
- | + +-\+
- + \ + \ +
- / + + \ +\
- + \ \ | +
- | + + +/
- | +--+ +-------+/
- + +--+ +
- / \
- + +
- | +
- + + /
- \ +\ +---+ +
- \ +--+ + \ /+
- + +--+ / \ /+|
- / | |+ + /+ |
- / + || / // +
- + + || / // /
- \ + || / // /
- \ | || / +/ /
- \ +---+ + +\ +
- + | | | +|
- +--+ +---+ +
- ;******************************
- ;*** Decipher the code ***
- ;** shortcut for the 'skip rule
- _:[skip]
- ;** Counter, 1 to 99
- i: 1
- ;** Create the r rule to draw a line.
- ;** It's a recursive rule, where a failure means a success.
- ;** It traverses the path of a line (dot per dot) recursivly.
- ;** If the current dot matchs the expected end point, the whole rule is rejected.
- ;** During the fall back the path is traveled upside down and the line is drawed in the output.
- r:[(z: n + 77 // 81)z _ _ then[v reject | r | _ p:(w/(index? p): pick"/|\-"n)end]|]
- ;** Start to parse the s text
- parse s[
- ;** Enlarge each line to 79 characters, plus a line feed (lf)
- any[79[and lf insert" "| _]_]
- ;** w = output text
- (w: copy s)
- ;** clean the output text (replace all numbers by string "+ ")
- :w any[" "| lf | end | p:(p/1:"+" p/2:" ")_]
- ;** loop 99 times
- 99[
- ;** Position to the beginning of the source text
- :s
- ;** Create the v rule depending of i. (i = 1 --> v = [" 1 " | " 2 "])
- (v: load ajoin[{" }++ i{ "|" }i{ "}]n: 0)
- ;** Position to the first matching number (" 1 " or " 2 ")
- to v
- ;** 4 attempts to draw a line with n =(1, 2, 3, 4)
- ;** left diagonal "/", vertical "|", right diagonal "\", horizontal "-"
- 0 4[(++ n)and r]
- ]
- ]
- print w
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement