The Shortest – Solved [Problem of the Week ]

OK, enough winners for this problem 😉

By far the most viewed topic in this blog!
and the most solved problem
I really have enjoyed noticing how every one tried to reduce it to 1 line .. to the extend that we don’t have a Second Place !

First Place 1 line (in order of who sent first)

  1. Alaa Shaker
  2. Mohammad Diab
  3. Mahmoud Osama

  4. Anonymous ! .. he didn’t leave a second name so i can’t really tell which Anonymous is he 😀 .. please send a name man .. a nickname is also fine 😀
  5. Tecnoyotta
  6. Amr Saqr
  7. Hatem
  8. Metal
  9. Mohamed Samy
  10. Mohamed Hesham – Filipino
  11. Mohamed Abdelghani
  12. Mohamed Abd-Elmone’m
  13. Roaa
  14. Tasniem Seliem

now to the solution 😀

while( *dest++ = *src++ );

we use a very unique feature .. a very dangerous feature .. its .. well i don’t know what do they call it 😀

its when an arithmetic expression can be converted implicitly to a boolean expression .. so its “implicit conversion”  i think (A)

i am sure that every one of us has spent hours and hours in debugging some code that doesn’t work as it should .. only to find out at the end that he left out some “=”..

if( x = 5 )
//instead of 
if( x == 5 )

right ? 😛

of course for old programmers its usually not an issue .. but for new comers .. well i think they still feel the sour of it 😀

but i think now that you have seen that feature being helpful sometimes .. you will never fall in that trap again.

2 thoughts on “The Shortest – Solved [Problem of the Week ]

  1. thanks Fouad ……..but i think it’s also useful in situations like this

    x = y = z = r ;

    instead of writing

    x = r;
    y = r;
    z = r

Leave a Reply

Your email address will not be published. Required fields are marked *