|
| 1 | +import "rectangles" |
| 2 | + |
| 3 | +-- no rectangles |
| 4 | +-- == |
| 5 | +-- input { [" "] } |
| 6 | +-- output { 0 } |
| 7 | + |
| 8 | +-- one rectangle |
| 9 | +-- == |
| 10 | +-- input { ["+-+", "| |", "+-+"] } |
| 11 | +-- output { 1 } |
| 12 | + |
| 13 | +-- two rectangles without shared parts |
| 14 | +-- == |
| 15 | +-- input { [" +-+", " | |", "+-+-+", "| | ", "+-+ "] } |
| 16 | +-- output { 2 } |
| 17 | + |
| 18 | +-- five rectangles with shared parts |
| 19 | +-- == |
| 20 | +-- input { [" +-+", " | |", "+-+-+", "| | |", "+-+-+"] } |
| 21 | +-- output { 5 } |
| 22 | + |
| 23 | +-- rectangle of height 1 is counted |
| 24 | +-- == |
| 25 | +-- input { ["+--+", "+--+"] } |
| 26 | +-- output { 1 } |
| 27 | + |
| 28 | +-- rectangle of width 1 is counted |
| 29 | +-- == |
| 30 | +-- input { ["++", "||", "++"] } |
| 31 | +-- output { 1 } |
| 32 | + |
| 33 | +-- 1x1 square is counted |
| 34 | +-- == |
| 35 | +-- input { ["++", "++"] } |
| 36 | +-- output { 1 } |
| 37 | + |
| 38 | +-- only complete rectangles are counted |
| 39 | +-- == |
| 40 | +-- input { [" +-+", " |", "+-+-+", "| | -", "+-+-+"] } |
| 41 | +-- output { 1 } |
| 42 | + |
| 43 | +-- rectangles can be of different sizes |
| 44 | +-- == |
| 45 | +-- input { ["+------+----+", "| | |", "+---+--+ |", "| | |", "+---+-------+"] } |
| 46 | +-- output { 3 } |
| 47 | + |
| 48 | +-- corner is required for a rectangle to be complete |
| 49 | +-- == |
| 50 | +-- input { ["+------+----+", "| | |", "+------+ |", "| | |", "+---+-------+"] } |
| 51 | +-- output { 2 } |
| 52 | + |
| 53 | +-- large input with many rectangles |
| 54 | +-- == |
| 55 | +-- input { ["+---+--+----+", "| +--+----+", "+---+--+ |", "| +--+----+", "+---+--+--+-+", "+---+--+--+-+", "+------+ | |", " +-+"] } |
| 56 | +-- output { 60 } |
| 57 | + |
| 58 | +-- rectangles must have four sides |
| 59 | +-- == |
| 60 | +-- input { ["+-+ +-+", "| | | |", "+-+-+-+", " | | ", "+-+-+-+", "| | | |", "+-+ +-+"] } |
| 61 | +-- output { 5 } |
| 62 | + |
| 63 | +let main (strings: [][]u8): i32 = |
| 64 | + rectangles strings |
0 commit comments