An Easy Problem that is My Favourite

Bobby-Joe Bob XXVII is a physicist/scientist/genius who has transferred himself to the second dimension, where he finds an four by four grid. He needs to get from the bottom left edge to the top right edge. Assuming he only goes right or up, how many different ways can he get to the top?


The answer is 70.

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

2 solutions

Brock Brown
Jan 3, 2015

Here's a Python solution that uses strings, such as "lluluulu" or "ullluluu", to represent when Bobby-Joe Bob XXVII goes left, or if he goes up. Bobby-Joe is kept on the plane by limiting the number times he can go left or up to 4. The number of possible ways Bobby-Joe can go will be represented by the number of generated strings of length 8.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
bound = 4 # width of plane
class Directions():
    def __init__(self, steps):
        self.steps = steps
    def adj(self):
        if self.steps.count('l') < bound:
            yield Directions(self.steps+'l')
        if self.steps.count('u') < bound:
            yield Directions(self.steps+'u')
level = {0:[Directions("")]}
cur_lvl = 1
limit = bound*2
while cur_lvl <= limit:
    level[cur_lvl] = set()
    for directions in level[cur_lvl-1]:
        for new in directions.adj():
            level[cur_lvl].add(new)
    del level[cur_lvl-1]
    cur_lvl += 1
print "Answer:", len(level[limit])

Sujoy Roy
Jan 3, 2015

Total ways = 4 + 4 C 4 = 70 =^{4+4}C_4=\boxed{70}

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...