The Square Within

Description

Discuss (3 comments)
Bobby is an interior designer on Times Square. As such he often faces the difficulty of dividing up the space to fill it with furniture. The goal of this puzzle is to help him determine how many possibilities he has.

We modelize the problem the following way.
  1. the room is a square of size NxN unit 1 ft square
  2. an object can occupy a single square, or a group of squares which form a square of size MxM (with M lesser than or equal to N in order to fit it in the room)
For example, if the room is of size 2x2:
  1. a 1x1 square can be put at position (0,0) or at position (1,0) or at position (0,1) or at position (1,1)
  2. a 2x2 square can be put at position (0,0) only.
Consequently there are 5 ways of placing squares in the room (4 ways for size 1x1, and 1 way for size 2x2).
Your program will take a list of room sizes and print their corresponding number of ways to place squares in them.

Input Specifications

Your program must take one command line argument:
  1. the file name of the input file containing the various room sizes
The input file contains one integer per line, to represent a room size N. For example:
1
4
2

Output Specifications

Your program must print the number of ways to place squares in each of the room sizes given in input. Your program must print to the standard output (stdout/printf/echo/puts). It should print one integer per line. Using the above example, the output must be:
1
30
5
© CoderCharts - All Rights Reserved
Type Puzzle Pass 380 Fail 18
Scoring Language Level Easy Points 100
Tags combinational analysis, placement

Source code editor

Unit Tests

Name CPU Unit Memory Unit

Feature test

Tests if the computations are correct for a set of values
1s
100 MB

Confirm that you want to switch languages
Your current edits will be lost.

Confirm that you wish to load a previous submission
Your current edits will be lost.