code puzzle

Christian Harms's picture

Solutions for the google code jam 2012 qualify round

Google Code Jam 2012 started this weekend and this years qualification round was simpler than other years.Read more

Christian Harms's picture

facebook Hacker Cup 2012 Qualification - solution for billboards

The second problem from this year facebook hackercup sound like the classic knapsack problem. But the solution is much easier (words are in fixed sort order). Feel free to find a smarter algorithm or comment my python solution.

problem description

We are starting preparations for Hacker Cup 2013 really early. Our first step is to prepare billboards to advertise the contest. We have text for hundreds of billboards, but we need your help to design them.Read more

Christian Harms's picture

facebook Hacker Cup 2012 Qualification Round - alphabet soup

This year qualification round had three problem. The easy one was Alphabet Soup - classic character counting problem.

Image

problem description

Alfredo Spaghetti really likes soup, especially when it contains alphabet pasta. Every day he constructs a sentence from letters, places the letters into a bowl of broth and enjoys delicious alphabet soup.

Today, after constructing the sentence, Alfredo remembered that the Facebook Hacker Cup starts today! Thus, he decided to construct the phrase "HACKERCUP". As he already added the letters to the broth, he is stuck with the letters he originally selected. Help Alfredo determine how many times he can place the word "HACKERCUP" side-by-side using the letters in his soup.Read more

Christian Harms's picture

Q*Bert chrismas tree puzzle

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:

  1. chrismasTree = [[75],
  2.               [95,64],
  3.             [17,47,82],
  4.           [18,35,87,10],
  5.         [20, 4,82,47,65],
  6.       [19, 1,23,75, 3,34] ]
  7. 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.Read more

Christian Harms's picture

Snow is falling - code puzzle

Code puzzles are fun and you can solve it with some lines of code. The code puzzle on snowisfalling.com is a page showing snow is falling up instead down. After reading the code, sleeping two nights without time to solve it, the simple solution is easy:

  1.   init : function(law){
  2.     String.prototype.reverse=function(){return this.split("").reverse().join("");}
  3.     this.law = {};
  4.     for (var k in law) { this.law[k.reverse()] = law[k]; };
Read more

Nico Heid's picture

no duplicates, please

Hey, this time I have a litte quiz. The implementation will be in different languages but the task is always the same.
This is also a good interview question to see how the candidate's skills in different areas are and it's brief enough for phone interviews, as she can provide the idea on how to solve the problem and does not need to implement code.

We will use bash, some scripting or higher language and database specific solutions.Read more

Christian Harms's picture

forfeit game - ALGOL 60 solution from 1964

I found two ALGOL sniplets for the forfeit game contest. My ALGOL 60 programming book (happy birthday for the ALGOL programming language) offer for every problem the question, a problem analysis, a code structure chart, the code solution and the executing time for the ZUSE 23 computer (see a very similar Z22 on wikipedia). I converted the fast solution for the game of forfeit from ALGOL to javascript without optimizations and benchmarked it.

Opera 10.63 vs. Chrome 7/8 vs. Firefox 3.6.12/4b7

I will start with the results from the converted ALGOL solution. The new javascript engine Jägermonkey with the firefox 4b7 is a real competitor for other fast javascript engines! And the ALGOL version is (mostly) better than the clean code version. The absolute numbers are generated on my own mini-pc and used for comparing with the clean code solution.

The 1:1 conversion of the ALGOL code runs on my Intel Atom N270 3.5 million times faster than on the original ZUSE Z23.Read more

Syndicate content