Peet Brits

Hmm, but that doesn't make any sense…

Archive for the ‘Quiz’ Category

Let’s see if you know the answer. Comments do not bite.


Posted by Peet Brits on November 1, 2008

Just for fun, I made a little quiz following my previous LINQ article.

Question 1

What is the difference in effect of the following code sections? Note that “Failed” is a nullable bit, so we will label the states as red, green and yellow (null).

// Option A
where (filter.Failed.HasValue && doc.Failed.HasValue ? filter.Failed == doc.Failed : true)
    // && (...) -- more filters here

// Option B
where (filter.Failed.HasValue ? filter.Failed == doc.Failed : true)
    // && (...) -- more filters here

Question 2

What would happen if all the queries ended with “false”?

where (... ? ... : false) && (... ? ... : false)

Question 3

Keeping both performance and readability in mind, what is the difference between grouping all the queries together (see option A), against having each in a separate section (see option B)?

// Option A
docs = from doc in docs
    where (filter.Failed.HasValue ? filter.Failed == doc.Failed : true)
        // && (...) -- more filters here
        select doc;

// Option B
if (filter.Failed.HasValue)
    docs = from doc in docs
        where filter.Failed == doc.Failed
        select doc;
// more filter blocks here

Posted in Code (Programming), Quiz | Tagged: , | 2 Comments »

I Eat Logic For Breakfast

Posted by Peet Brits on August 26, 2008

Do you love logic? Do you love riddles and board games? Would you go as far as saying that, if you could, you would even eat it for breakfast? If you answered yes, like me, then read on and find out how to include logic in your diet.

There are a few websites available on the internet with riddles, but most of them can be classified as silly: you either know the answer or not. The path of logic that would interest me in a game is something with a much more sustained challenge. Sure we have Sudoku, but somehow it never quite tickled my fancy. Then we have Klondike (Windows Solitaire), or pretty much any other solitaire-type card game (and I have played a few!), which all get rather boring after a few games.

I have since found a website with great collection logical puzzles (thanks to my dad), which can be found at If you register you get a new set of puzzles every week, of whichever flavour and difficulty you could possible prefer.  (See “My Conceptis” tab on the website).  Try it out.

Once you think you are good, there is a challenge. Attached you will find my current picture nemesis. This puzzle has resulted in hours of head-scratching, and I’m not even halfway through it! I suggest you first try some of the easier ones, but if you can beat it before me, then I will surely tip my hat for you.

At the time of writing I enjoyed Pic-a-Pix, Fill-a-Pix and Hashi. How about you?

Posted in Quiz | Tagged: , , , , , , | Leave a Comment »

Help Jonas with his job situation.

Posted by Peet Brits on July 19, 2008

Jonas is your typical manual labour, but he specializes in painting. Not only does he enjoy it, he’s also rather good at it. One day Jonas gets a job at a house in need of painting, however, he is asked to cut the grass instead. Every month when Jonas asks about painting the walls he is told that the grass takes priority, and every month the grass grows back again.

He is clearly unhappy with his job situation. What is your advice for Jonas?

Note that quitting is not an easy option, because he needs the money.

Posted in Quiz | Leave a Comment »