Tomer Gabel's annoying spot on the 'net RSS 2.0
# Friday, September 08, 2006

A friend sent me this riddle (which I imagine isn't his, but nevermind) via mail, and I thought it cute enough to share:

Find three ways to change/insert/delete a single character in the following code, so that the resulting code will print 20 star characters (*). Remember, for each solution you can only change one character, and there are at least three different solutions.

#include <stdio.h>

int main()
{
    int i, N = 20;
    for ( i = 0 ; i < N ; i-- )
        printf( "*" );
    return 0;
}

I'll post the solution in a few days, feel free to yell "eureka" in the comment section or whatever.

Friday, September 08, 2006 6:26:24 PM (Jerusalem Standard Time, UTC+02:00)  #    Comments [3] -
Development
Tracked by:
"Solution: A cute riddle in C" (Useless Inc.) [Trackback]
Sunday, September 10, 2006 12:00:08 PM (Jerusalem Standard Time, UTC+02:00)
Eureka!
Thanks - I really enjoyed this one. It took me some time to think of the third one, but I enjoyed every minute.
Ilan
Sunday, September 10, 2006 12:01:58 PM (Jerusalem Standard Time, UTC+02:00)
Yeah, it was fun riddle :-) Know any more of those that are worth the bother?...
Thursday, September 28, 2006 10:58:29 PM (Jerusalem Standard Time, UTC+02:00)
This is a great riddle, but there's a harder variant (think of it as bonus points):
Change a single character, so that the resulting code will print 21(!) star characters.
It's quite hard.
I'll post the answer in a few days.
Omer Mor
OpenID
Please login with either your OpenID above, or your details below.
Name
E-mail
Home page

Comment (Some html is allowed: a@href@title, b, blockquote@cite, em, i, strike, strong, sub, super, u) where the @ means "attribute." For example, you can use <a href="" title=""> or <blockquote cite="Scott">.  

Live Comment Preview
Me!
Send mail to the author(s) Be afraid.
Archive
<February 2012>
SunMonTueWedThuFriSat
2930311234
567891011
12131415161718
19202122232425
26272829123
45678910
All Content © 2012, Tomer Gabel
Based on the Business theme for dasBlog created by Christoph De Baene (delarou)