Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9114563
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T04:13:44+00:00 2026-06-17T04:13:44+00:00

I couldn’t write the recurrence relation to a question like below. Given a rectangular

  • 0

I couldn’t write the recurrence relation to a question like below.

Given a rectangular grid, with dimensions 4 x n, how many ways are there to completely tile the grid with 2 x 2 and 2 x 1 dominoes?

Here for 2 x 1 rectangles it is done greatly, but I couldn’t figure out if rectangles are 2 x 1 and 2 x 2: http://www.acmgnyr.org/year2007/h.c

Any ideas?

For example for

4×1 : 1 way

4×2 : 11 ways

4×3 : 29 ways

Code below generates all possibilities using brute force. But I want to do it using dynamic programming.

https://gist.github.com/4519601

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T04:13:45+00:00Added an answer on June 17, 2026 at 4:13 am

    I think you can solve this by using a dynamic programming algorithm.

    Imagine representing the grid not as a 4 x n grid of squares, but as a 4-tuple representing the widths of each individual column. Every time you place a tile, you can try placing it somewhere such that one of its squares touches the upper-left corner of the far left side of the grid. The effect of doing this is to change the effective widths of each of the columns. For example, given this 4 x 3 grid:

    . . .
    . . .
    . . .
    . . .
    

    We would encode it as (3, 3, 3, 3). If you were to place a 2 x 2 block in the upper corner, you’d get this:

    X X .
    X X .
    . . .
    . . .
    

    This would be encoded as (1, 1, 3, 3), since the top two rows are now effectively much smaller.

    This suggests an initial (inefficient) recursive algorithm. As your base cases, the world (0, 0, 0, 0) has just one solution (namely, doing nothing). Any world where there is no legal way to place a tile that covers the topmost square of the leftmost row has no solution. Otherwise, for all possible moves, make that move, update the internal representation of the world, and recursively add in all solutions you can find in that smaller world.

    This is extremely slow (exponentially so), but can be dramatically sped up. In particular, note that the number of possible 4-tuples is (n + 1)4. This means that the maximum number of unique recursive calls is O(n4). Therefore, if you memoize your recursive calls or use dynamic programming to compute the calls backwards, you only have to make a polynomial number of calls. Memoization should be very easy to add to an existing recursive solution, and the speedup should be pretty enormous.

    If you’re looking for a more mathematically precise way of solving this problem, consider trying to write out a generating function for this problem and using it to derive a closed-form solution. Once you have that, it shouldn’t be all that hard to evaluate it directly much more efficiently than the above solution. Since I’m not an expert in generating functions, though, I’m not actually sure how you’d do this.

    Hope this helps!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Couldn't figure out how to word the question accurately, so here's an example: Given
I couldn't find a straight answer to my question and need to know it
Couldn't think of a more appropriate question title, but I'm looking for some advice
Couldn't find an answer to this question. It must be obvious, but still. I
I couldn't find out python equivalent to PHP $_SERVER. Is there any? Or, what
I couldn't find the answer to this question in SO. I'll try to explain.
I couldn't seem to find a similar question to this. I am currently looking
I couldn't find any question similar to this one, I wanted to know about
Hi couldn't find it for C#, I am trying something like that for (int
Couldn't seem to find the answer to this question - what is the haml

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.