Quantcast
Channel: code puzzle – united-coders.com
Viewing all articles
Browse latest Browse all 10

Q*Bert chrismas tree puzzle

$
0
0

This is a short coding puzzle with q*bert (who is q*bert?) and an chrismas tree.

the qbert question

qbert chrismas tree coding puzzle
The task: Our 2011 q*bert can only jump down. He start from the top and has to find the path to the bottom of the chrismas tree with collecting the most points available (while jumping left-or-right down). Find the way with the highest sum.

Input:

chrismasTree = [[75],
              [95,64],
            [17,47,82],
          [18,35,87,10],
        [20, 4,82,47,65],
      [19, 1,23,75, 3,34] ]
print qbertRun(chrismasTree)

The sum is 465 – try to solve it with a little program. The brute force method will be possible with this small tree.

Does your solution solve the task with larger data?

Project Euler offers the same question (Problem 67) with a larger triangle. Does work your solution with this data set?

tri = []
peUrl = "http://projecteuler.net/project/triangle.txt"
for line in urllib.urlopen(peUrl).readlines():
    tri.append([int(x) for x in line.strip().split(" ")])
print qbertRun(tri)

If you solved the larger data set and had fun register on project euler and try out other problems. Feel free to link your solution from you blog to this article and write a comment. My solution will published this year.

The post Q*Bert chrismas tree puzzle appeared first on united-coders.com.


Viewing all articles
Browse latest Browse all 10

Latest Images

Trending Articles





Latest Images