12
1
Yesterday, I left my sandwich on the table. When I got up today, there was a bite in it... Was it mine? I can't remember...
Problem:
Take a representation of the sandwich and my bite pattern and tell me if it was my bite or not.
Examples:
Example 1:
My bite pattern:
..
.
Sandwich:
#####
.####
..###
Output:
truthy
Example 2:
My bite pattern:
..
..
Sandwich:
...##
..###
.####
Output:
falsy
Example 3:
If there is at least 1 rotation that counts as truthy, the output is truthy.
My bite pattern:
.
.
.
Sandwich:
##.
#.#
.##
Output:
Two possible rotations (biting in the northeast or southwest corner).
truthy
Some valid bites:
..
.
...
.
.
.
.
.
..
. .
..
..
.
. .
Some invalid bites:
..
...
.
..
.
.
Rules:
My bite pattern orientation will always be for biting the northwest corner. And must be rotated to bite other corners;
There will always be 1 and only 1 bite in the sandwich;
The bite in the sandwich can be in any of the 4 cornes (rotated accordingly);
Bite patterns will always be symmetrical along the main diagonal;
Bite patterns will always be at least 1 wide and non empty;
The sandwich will always be a rectangle with width and height equal or greater than the width of my bite pattern;
In your input, you can choose any 2 distinct non-whitespace characters to represent the sandwich and the bite;
Spaces in the bite pattern means that my bite does not touch that part of the sandwich.
Can the bite pattern be larger than the sandwich? Can the bite pattern be empty? Can the bite pattern be the same as the sandwich? i.e.
..
,..
? – TheLethalCoder – 2017-05-19T12:48:23.087@TheLethalCoder the rules say the bite pattern will always fit the sandwich. i'll add a new rule to specify minimum size (1 width) – Felipe Nardi Batista – 2017-05-19T12:50:21.383
@TheLethalCoder and yes, the bite pattern can be the same as the sandwich – Felipe Nardi Batista – 2017-05-19T12:51:56.900