Code Golf: Ghost Leg
- by Anax
The challenge
The shortest code by character count that will output the numeric solution, given a number and a valid string pattern, using the Ghost Leg method.
Examples
Input: 3,
"| | | | | | | |
|-| |=| | | | |
|-| | |-| |=| |
| |-| |-| | |-|"
Output: 2
Input: 2,
"| | |=| |
|-| |-| |
| |-| | |"
Output: 1
Clarifications
Do not bother with input. Consider the values as given somewhere else.
Both input values are valid: the column number corresponds to an existing column and the pattern only contains the symbols |, -, = (and [space], [LF]). Also, two adjacent columns cannot both contain dashes (in the same line).
The dimensions of the pattern are unknown (min 1x1).
Clarifications #2
There are two invalid patterns: |-|-| and |=|=| which create ambiguity. The given input string will never contain those.
The input variables are the same for all; a numeric value and a string representing the pattern.
Entrants must produce a function.
Test case
Given pattern:
"|-| |=|-|=|LF| |-| | |-|LF|=| |-| | |LF| | |-|=|-|"
|-| |=|-|=|
| |-| | |-|
|=| |-| | |
| | |-|=|-|
Given value : Expected result
1 : 6
2 : 1
3 : 3
4 : 6
5 : 5
6 : 2