Are there any other sources of programming type riddles on the internet?
I started my set of daily programming riddles, jokes, and quotes partly to help myself and my team grown in some technical areas... like new .NET 3.5 features, design patterns, anti-patterns, code smells, etc.
I would love to find other short programming riddles o...
My friend was given this free google website optimizer tshirt and came to me to try and figure out what the front logo meant.
t-shirt
So, I have a couple of guesses as to what it means, but I was just wondering if there is something more.
My first guess is that each block represents a page layout, and the logo "You should test that" j...
You are shown two envelopes and told that they both contain money, one twice as much as the other. You select one of them at random - it contains $100. Now you are given the choice to either keep the $100 or the contents of the other envelope instead.
Question: is it better for you to switch, or better not to switch?
This is a case of ...
I just got a question that I can't answer.
Suppose you have this loop definition in Java:
while (i == i) ;
What is the type of i and the value of i if the loop is not an infinite loop and the program is using only one thread?
...
Start with three variables, all are System.DateTime.
a: 10/2/2009 2:30:00 PM
b: 10/2/2009 2:30:00 PM
c: 10/2/2009 2:30:00 PM
Compare them to each other.
a=b: True
b=c: True
c=a: True
Ok, we have established that all three dates are equal. So when we convert them all to Universal time, we will get the same result. Right?
a.ToUniver...
I was recently asked in a job interview to resolve a programming puzzle that I thought it would be interesting to share. It's about translating Excel column letters to actual numbers, if you recall, Excel names its columns with letters from A to Z, and then the sequence goes AA, AB, AC... AZ, BA, BB, etc.
You have to write a function th...
Ok, goal by example : a command-line app that does this:
Countdown.exe 7
prints 7 6 5 4 3 2 1
No form of subtracting (including use of the minus sign) or string reverse what so ever is allowed.
waaaaay too easy apparently :-) An overview of the answers (the principles at least)
By adding and recursion
By using modulo
By pushing an...
I'm looking for a site or book or any other source of tiny programming tasks one can implement in preferred language. Would be great if examples are present too. And would be superb if there're people who may review my code. May be there's a wiki of such tasks. I've tried to google, but found nothing that suits my needs.
I want to impro...
From this question I learned Double.NaN is not equal to itself.
I was verifying this for myself and noticed this is not the case if you wrap Double.NaN in a Double instance. For example:
public class DoubleNaNTest {
public static void main(String[] args) {
double primitive = Double.NaN;
Double object = new Double(pr...
UPDATE :
This question is not homework. And not waterproof apparantly...
I wanted a discussion about internal representation.
Of course : the add1000 ought to add 1000.
**Please answer in the spirit of this question... Making this waterproof would make this question longer without no reason.. **
You can beat a pure decimal represen...
I have the following code:
<?php
$cups = array();
for($i=0; $i<500; $i++){
$cups[$i] = 0;
}
for($x=1; $x<500; $x++){
for($y=$x; $y<500; $y+=$x){
$cups[$y] = !$cups[$y];
}
}
foreach($cups as $key => $value){
if($value == 1){
echo "{$key}, ";
}
}
?>
As you can see, I fill up an array with 500 zeroes, lo...
Someone told me this bit of code prints 29. Why is that?
int *a = 17;
printf("%d", a+3);
...