Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Day 312 #637

Closed
vaskoz opened this issue Jun 30, 2019 · 1 comment · Fixed by #638
Closed

Day 312 #637

vaskoz opened this issue Jun 30, 2019 · 1 comment · Fixed by #638
Assignees

Comments

@vaskoz
Copy link
Owner

vaskoz commented Jun 30, 2019

Good morning! Here's your coding interview problem for today.

This problem was asked by Wayfair.

You are given a 2 x N board, and instructed to completely cover the board with the following shapes:

Dominoes, or 2 x 1 rectangles.
Trominoes, or L-shapes.
For example, if N = 4, here is one possible configuration, where A is a domino, and B and C are trominoes.

A B B C
A B C C

Given an integer N, determine in how many ways this task is possible.

@vaskoz vaskoz self-assigned this Jun 30, 2019
@vaskoz vaskoz mentioned this issue Jun 30, 2019
@vaskoz
Copy link
Owner Author

vaskoz commented Jun 30, 2019

Writing this out by hand on paper showed that the pattern is Fibonacci. Below I've included the pattern worked out to N=5.

N = 1, answer = 1

1 # vertical only domino
1

N = 2, answer = 2

12 # 2 vertical dominos
12

11 # 2 horizontal dominos
22

N = 3, answer = 3

123 # 3 vertical dominos
123

113 # 2 horizontal dominos and 1 vertical domino
223

112 # 2 trominos
122

N = 4, answer = 5

1234 # 4 vertical dominos
1234

1122 # 4 horizontal dominos
3344

1134 # 2 horizontal, 2 vertical dominos
2234

1123 # 2 trominos and 1 vertical domino
1223

1122 # 2 trominos and 1 horizontal domino
1332

N = 5, answer = 8

11223 # 4 horizontal dominos and 1 vertical domino
44553

12345 # 4 vertical dominos
12345

11234 # 2 horizontal dominos and 3 vertical dominos
55234

12245 # 2 middle horizontal dominos and 3 vertical dominos 
13345

11234 # 2 vertical dominos and 2 trominos
12234

11233 # 2 horizontal dominos and 2 trominos
12244

11334 # 2 trominos, 1 vertical and 1 horizontal domino.
12234

11334 # 2 horizontal dominos and 2 trominos
12244

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant