Hi everybody, today I want to share some hack challenges I worked on at the Hacker Olympics*, an event that took place last weekend in New York City.
Why you should read this? Because you are hacker and want to see if you are able to solve the hack challenges. Or because you are curious about what hackers do on weekends. Or maybe you are in charge of hiring hackers and to see how you can test people in interviews.
If you are trying to solve the challenge and test yourself, only read what it is within the dashed lines (the challenge), then try to compare to how I did it.
——————————————————————————
Challenge Wheel of Doom - Time to solve it: 10 minutes.
Write a script that, every 45 minutes, select a number between 1 and X, makes a sound and display the number.
——————————————————————————
How did I solve it? I used JavaScript that uses the SetInterval() method to generate the time span. Then I made a function to generate a random number using the Math.random() method. And the sound? To generate the sound, I embedded a beep sound in the document and used Play() to make a noise.
Can you see the code? Sure, download in zip or git from github
—————————————————————————-
Challenge StarWars.CSS - Time to solve it: 10 minutes
For a given text, replicate the opening to Star wars.
——————————————————————————
10 minutes!! f!*#!! this is going to be hard.
I couldn’t finished on time, but a guy next to me did it, and this is how he solved it (I don’t really know his name, sorry): Take a text in a <div> and transform it using webkit transformations to build the perspective effect and then animate to make the <div> move up. It’s not a perfect StarWars effect but it’s a valid hack for a 10 minute challenge, don’t you think?
I didn’t see his code, but trying to apply the idea, I used “perspective” and “rotate” webkit properties. Once perspective is there, the next step is to animate the <div> to move it up. For the animation, I used JQuery animate() method to change the top property of the <div> within a time span.
The code is here: git or zip
—————————————————————————————
Challenge Fibonacci Sums and Daughters - Time to solve it : 5 min
Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be: 1,2,3,5,8,13,21,34,55,89… By considering the terms i the Fibonacci sequence whose values do not exceed four four million, find the sum of the even-valued terms.
—————————————————————————————
No JavaScript for this one! We need more power. That’s why I solved it with a simple python script: a “while” loop would create the Fibonacci series for numbers less than four million. Within the while, I filtered even-value terms so I could make the sum.
Code for the Fibonacci even-value sum here.
——————————————————————————————
Challenge Ned, I am a Maiden - Time to solve it : 10min
A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 x 99. Fin the largets palindrome made from the product o two 3-digit numbers.
——————————————————————————————
My teammate @raycohen solved this one in less than 10 minutes, awesome!. It took me more time but better later than never, right? Let’s see what we need to do
1. Make a product of two 3-digit numbers x, y.
2. Find out if the product is palindrome or not.
3. If it’s palindrome and it is the largets one, store it as the largest, for all other cases go to step 1 to test with a different combination of numbers x, y.
You have to do this loop until you test all the combinations of two 3-digit numbers x,y.
It sounds easy right? Well, if you never faced this problem before, it’s not. The challenge for me was to find an easy way to discover whether a number is palindrome or not.
After chew it up for some minutes and propose a couple of solutions I came up with a good one:
Reverse the number and compare it with itself. So if you have 1234, then you reverse it to 4321. After that you do 1234 ==4321 getting a False statement. On the other hand when you do the same procedure to 4004 you will get TRUE a statement.
Once you solve that you are pretty much done. If you want to check the code, it is here, written in Python.
And of course, let me give you the answer: the largets palindrome made from the product o two 3-digit numbers is 906609 !
I hope you enjoy the challenges as I did. If you have your own challenges, share them please.
@jefreybulla