Part of Code Golf Advent Calendar 2022 event. See the linked meta post for details.
Christmas is coming up, and Santa hasn't kept to his diet very well this year. Due to his size, he is getting the elves to collect a list of all the chimneys he will be able to fit down. Unfortunately, chimneys these days are a bit of a maze, and he can't just drop straight down like he used to.
Task: Given Santas width as an integer and a binary matrix representing the chimney, output whether or not Santa will be able to fit down the chimney.
Rules
- Santa is able to "fit" down the chimney if he can enter it at the top and exit at the bottom, while only moving downwards or sideways through the cavity sections of the chimney.
- Santa cannot move up
- Assume Santa's height is always 1
- There will only be one entrance to the chimney, and one exit from the chimney
- The matrix representing the chimney should consist of two values, one for brick (which Santa can't move through) and one for cavities (which Santa can move through). These can be of type
integer
,string
,float
or any other type, as long as a distinction can be made between the two. - The format of the matrix is flexible - any standard subsitution for a matrix (list of strings, list of lists etc) is allowed
- The output can be any valid truthy/falsy output, or two values/states chosen to represent the truthy falsy output (i.e output
1
/None
,1
/Error
)
Standard code-golf rules apply. The shortest code in bytes wins.
Test Cases
Truthy
Width = 1
Chimney=[
"101",
"101",
"101"
]
Width = 2
Chimney = [
"110011",
"110011",
"100011",
"100111",
"100001",
"110001",
"111001",
"111001",
]
Falsy
Width = 1
Chimney=[
"101",
"010",
"101"
]
Width = 2
Chimney = [
"100111"
"100110"
"100110"
"100010"
"111010"
"111010"
"111010"
"111010"
]
Width = 1
Chimney = [
"0111",
"1110",
"1110",
]
Width = 1
Chimney = [
"1011111",
"1011111",
"1010001",
"1000101",
"1111101",
"1111101",
"1111101",
"1111101",
]