CodeChef Easy Problem: Odd

Still practicing for Facebook Hacker Cup 2013: ———- The captain of the ship TITANIC is a little …. off the track. He needs to select the crew for the ship. But everyone seems to be eligible. So to test their intelligence, he plays a game. The contestants have to stand in a line. They are […]

Solution to Problem 10 on Project Euler

Not the most challenging one, but still: The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17. Find the sum of all the primes below two million. My Solution #include <stdio.h> #include <math.h> int isPrime(num){   int i;   if (num==2)     return 1;   for (i=2;i<sqrt(num)+1;i++){     if (num%i==0)       return 0;     } […]

CodeChef Easy Problem: Factorial

Facebook Hacker Cup 2013 is coming up, so I started solving some problems on CodeChef.com to warm up. Here’s one of them: ——————– The most important part of a GSM network is so called Base Transceiver Station (BTS). These transceivers form the areas called cells (this term gave the name to the cellular phone) and […]

Latency Numbers Every Programmer Should Know

This is coming from GitHub: L1 cache reference                            0.5 ns Branch mispredict                             5   ns L2 cache reference                            7   ns             14x L1 cache Mutex lock/unlock                            25   ns Main memory reference                       100   ns             20x L2 cache, 200x L1 cache Compress 1K bytes with Zippy              3,000   ns Send 1K bytes over 1 Gbps network        10,000   ns    0.01 ms SSD random read                         150,000   ns Read […]

Google Code Jam 2011: Round 1C Problem 1

Here’s another problem that appeared on the 2011 Google Code Jam: You are selling beautiful geometric pictures. Each one consists of 1×1 square tiles arranged into a non-overlapping grid. For example: .##.. .#### .#### .##.. Blue tiles are represented by ‘#’ characters, and white tiles are represented by ‘.’ characters. You do not use other […]