# Re: [algorithms-and-data-structures] Algorithms Meetup Problem #3

 From: Nurettin D. Sent on: Sunday, September 5, 2010 11:49 AM
I found this too be a little tough. I have seen the solutions submitted but not sure if they are correct.
Recursive solution is based on
f(n) = f(n-1) + f(n-2);
f(0) = 0; f(1) = 1; f(2) = 2;

Formula seems to be working fine until n = 5 but I did not want to spend the time to manually calculate values after 6. Can someone elaborate on it?

Other solution submitted is based on a different algorithm

`def count_brick_configs (x):`
```
????if (x == 0):```
`????????return 0`
`????`
`????max_b = x / 2`
```
????retval = 1```
`????for num_b in range (1, max_b + 1):`
`????????num_a = x - (2 * num_b )`
`????????alphabet_len = num_b + num_a`
```
????????retval += factorial(alphabet_len) / ( factorial(num_a) * factorial(num_b))```
`????return retval`

It would be nice to hear what this formula is based on. Thanks

On Sun, Jul 25, 2010 at 8:25 PM, Deepankar <[address removed]> wrote:
Okay Ive pushed a hopefully correct solution. Would be great to tie it
out with answers from other peoples solutions.

On Sun, Jul 25, 2010 at 6:37 PM, Deepankar <[address removed]> wrote:
> Just noticed a mistake in my solution - please disregard the current code.
>
> On Sun, Jul 25, 2010 at 6:21 PM, Deepankar <[address removed]> wrote:
>> Added the solution to this in python. the language hardly matters on
>> this one, its about analysing and coming up with an equation which you
>> can then implement in any language.
>>
>>
>> On Sun, Jul 25, 2010 at 3:20 PM, Andy Pliszka <andy+[address removed]> wrote:
>>> Hi,
>>>
>>> It is time for another problem of the week. The problems comes from
>>> UVa's database of problems. You can find problem description here:
>>>
>>> http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=11&page=show_problem&problem=841
>>>
>>> Just a reminder, we have a github code reposotory:
>>>
>>> http://github.com/AlgorithmsNYC/AlgorithmsNYC
>>>
>>> If you would like to share your solution; send me your github profile
>>> name, and I will add you to the repository.
>>>
>>> I also create a Facebook page:
>>>
>>>
>>> We also have a Twitter account:
>>>
>>>
>>>
>>> Thanks,
>>> Andy
>>>
>>>
>>>
>>> --
>>> http://www.meetup.com/algorithms-and-data-structures/
>>> This message was sent by Andy Pliszka (andy+[address removed]) from Algorithms and Data Structures.
>>> Meetup, PO Box 4668 #37895 New York, New York[masked] | [address removed]
>>>
>>>
>>
>>
>>
>> --
>> http://www.meetup.com/algorithms-and-data-structures/
>> This message was sent by Deepankar ([address removed]) from Algorithms and Data Structures.
>> Meetup, PO Box 4668 #37895 New York, New York[masked] | [address removed]
>>
>>
>
>
>
> --
> http://www.meetup.com/algorithms-and-data-structures/
> This message was sent by Deepankar ([address removed]) from Algorithms and Data Structures.
> Meetup, PO Box 4668 #37895 New York, New York[masked] | [address removed]
>
>

--
http://www.meetup.com/algorithms-and-data-structures/
This message was sent by Deepankar ([address removed]) from Algorithms and Data Structures.
Meetup, PO Box 4668 #37895 New York, New York[masked] | [address removed]

--
Nurettin DAG

### New York, NY

Founded Jan 31, 2010

#### Organizers:

Pivotal Labs

• ##### Vendavo

Vendavo is the leader in front-line profit optimization

• ##### Wolfram Research

Mathematica is the world's ultimate application for computations.

• ##### Lyft

Free ride credit to try the service. Fast and safe way to get around.

#### People in this Meetup are also in:

• ##### Coders for Good

2,160 Coders for Good

• ##### The New York City Java Meetup Group

8,326 Java enthusiasts

• ##### NYC Technology Startups

4,412 Members

• ##### SQL NYC, The NoSQL & NewSQL Database Meetup

13,867 Data Enthusiasts

3,810 Noders

• ##### Django-NYC

2,566 Djangonauts