You may remember these drawings from when you were a child, but now it's time to let the computer draw them (in full ascii splendour). Have fun!
Description:
The input are multiple lines (terminated by a newline) which describe a 'field'. There are 'numbers' scattered across this field (seperated by whitespace). All lines can be considered to be the same length (you can pad spaces to the end).
- the numbers always start at 1
- they follow the ordering of the natural numbers: every 'next number' is incremented with 1
- every number is surrounded by (at least) one whitespace on its left and right
Task:
Draw lines between these numbers in their natural order
(1 -> 2 -> 3 -> ...N)
(assume N <= 99) with the following characteristics:
- replace a number with a '
+
' character - for horizontal lines: use '
-
' - for vertical lines: use '
|
' - going left and down or right and up:
/
- going left and up or right and down:
\
Important notes:
When drawing lines of type 4 and 5 you can assume (given the points to connect with coordinates x1, y1 and x2, y2) that
distance(x1,x2) == distance(y1,y2)
. Or in other words (as user jball commented): "consecutive elements that are not horizontally or vertically aligned always align to the slope of the slash or backslash".It is important to follow the order in which the dots are connected (newer lines can strike out older lines).
-- Sample input 1 --
8 7 6 10 9 5 3 4 11 12 13 1 2
-- Sample output 1 --
+ /| / +--+ +--------+ \ / \ / + / | / +--+ + | \ | +------------------------+ +--------------------------+
-- Sample input 2 --
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
-- Sample output 2 -- (unicorn reference)
+ /+ // // // /+--+ + + \ | + +-\+ + \ + \ + / + + \ +\ + \ \ | + | + + +/ | +--+ +-------+/ + +--+ + / \ + + | + + + / \ +\ +---+ + \ +--+ + \ /+ + +--+ / \ /+| / | |+ + /+ | / + || / // + + + || / // / \ + || / // / \ | || / +/ / \ +---+ + +\ + + | | | +| +--+ +---+ +
Winner:
Shortest solution (by code character count). Input can be read via standard input.