59
6
I keep hearing that thinking outside the box is a goal worth achieving, but how can I tell if I'm successfully doing it?
To solve this dilemma I have already wrote a Brainwave-to-ASCII-translator which in theory should produce outputs like
#
+------------+ #
| thinking | #
| | #
+------------+ #
#
or
#
+------+ #
| | thinking #
| | #
| | #
+------+ #
#
which make it fairly easy to tell whether one is thinking outside the box or not. (The #
are not part of the output and represent new lines.)
However, due to a bug sometimes only a smaller section of the output is returned:
| | #
+---------+ #
thinking #
#
+#
|#
inking |#
#
#
The Task
Please help me to automatically classify the Brainwave-to-ASCII-translator output by writing a program or function which reads an ascii-reprensentation and returns whether thinking
is in the box, outside of it or it could not tell from the input.
Input
A set of same-length strings either as a list or delimited by newlines containing
- the string
thinking
or valid pre- or suffixes thereof - the characters
+-|
forming a rectangular box or valid parts of it - spaces
- NO
#
, those are only included in the challenge to mark the ends of the input lines.
Output
- a truthy value if
thinking
is outside the box - a falsy value if
thinking
is in the box - a distinct third maybe value if it can not be determined from the input whether
thinking
is in the box or not
Examples
Truthy:
#
+------+ #
| | thinking #
| | #
| | #
+------+ #
#
| | #
+---------+ #
thinking #
#
+#
|#
|#
inking |#
thinking #
-------+ #
++ # (thinking is not in the box, so it must be outside)
++ # (this is also the smallest possible box)
+ #
t#
+----+# (The box is not wide enough to contain "thinking")
---# (The box is not high enough to contain "thinking")
---#
As string input:
" \n +------+ \n | | thinking \n | | \n | | \n +------+ \n "
" | | \n +---------+ \n thinking "
" \n +\n |\n |\ninking |"
"thinking \n-------+ "
" ++ \n ++ "
"+ \n t"
"+----+"
"---\n---"
"g++"
"k\n+"
Falsy:
#
+------------+ #
| thinking | #
| | #
+------------+ #
#
+---------------#
| #
| #
| thinking #
| #
king | #
------+ #
+---#
|thi#
+---#
-#
n#
-#
As string input:
" \n +------------+ \n | thinking | \n | | \n +------------+ \n "
" +---------------\n | \n | \n | thinking "
" | \nking | \n------+ "
"+---\n|thi\n+---"
"-\nn\n-"
Maybe:
thinking#
g|#
think#
-----#
| |# (box large enough to possibly contain the string)
| |#
+--#
| #
# (empty input)
As string input:
"thinking"
"g|"
"|t"
"-\ni"
"h\n-"
"think\n-----"
"| |\n| |"
" +--\n | "
""
Rules
- This is code-golf, so try to use as few bytes as possible.
- The maybe value can be chosen freely as long as it's different from the truthy/falsy value and is the same for all maybe-inputs. It can also be an error.
- You can assume that the input is always valid (eg. contains no other chars than
+-ghiknt|
, no more than one box, ...).
Idea for truthy test case:
+\n+
, box too small for a word – Destructible Lemon – 2016-12-04T22:42:47.693@DestructibleWatermelon Thanks, I'll add a similar test case. – Laikoni – 2016-12-04T22:48:25.823
You don't have the most basic cases in your test cases. Mind including the entire box with thinking in it, and the entire box with the entire word thinking outside it? – ATaco – 2016-12-05T00:33:53.953
Is there a possiblity of the word overlapping the box(thinking on the box)? – Mukul Kumar – 2016-12-05T03:40:43.360
@MukulKumar No,
thinking
and the box will never overlap. – Laikoni – 2016-12-05T09:13:48.557@ATaco I included them in the string testcases now. – Laikoni – 2016-12-05T09:20:49.877
Must the box have at least one
-
or|
on each side? Or can it look like+---+\n+---+
,++\n++
or even+
? – feersum – 2016-12-05T10:51:18.177@feersum The minimal box is "++\n++". – Laikoni – 2016-12-05T18:05:29.783
17This is a boundary case nightmare, jeez. – Magic Octopus Urn – 2016-12-07T22:04:23.710