Monthly Archives: August 2008

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.

The Shortest [Problem of the week]

Since i am extremely bored, and i have been staring into lots of code recently .. i have  no intention to do this in the blog .. so this weeks problem will be about the shortest code ever ..

ok .. go on .. i need the Shortest implementation of..



yeah.. strcpy().. our strcpy().. 😉

void strcpy(char *destination, const char *source);


  1. any language is welcome .. but C/C++ are preferred.
  2. any library functions or classes are absolutely not welcome..
  3. i don’t care for the return .. keep it void
  4. the function must take 2 arguments, one is the destination string and the other is the source string .. you can assume that both are valid (not null) pointers nor empty strings.. so forget your QA sprit for a while
  5. all strings are “null terminated char arrays”.. very normal “C strings”.
  6. input string must be kept intact, you can notice const char *
  7. read the first comment about the const char * 😀
  8. send me CODE .. and only CODE .. you can explain it , you can comment it .. but don’t send ideas alone 😀 .. try to code it 😀 .. this is the challenge.
  9. for the new faces .. welcome! 😀 .. you post the solution in the comments, and if it is right i will not approve it until it’s time, otherwise, i will approve it and say what went wrong.. that’s why you should read the comments before posting a solution.

after we are done ان شاء الله.. i will show you how to make use of a couple of features in C++ to solve this problem .. one of them is EXTREAMELY annoying feature..

OK .. That’s it .. let the race .. begin .. 😀

the solution can be found here

An Easier One [Problem of the week]

if you think last week’s problem from Alaa wasn’t that easy. 😀
and mine in the week before that was a little strange. 😀

so this week the problem will be a bit easier.. in spite of the fact that i couldn’t solve it right a way in an interview .. but i grew smart enough to solve it yesterday.. “i think its the salad 😎 ”
“some salad picture goes here .. but i couldn’t find any nice one”

How to detect a Cycle in a Linked List ??



  1. you are not Allowed to use any other data structures in you solution, no stacks no arrays no other lists .. nothing!
  2. the list is single linked .. a very normal list i mean
    and you are not allowed to change this class or add a Visited Boolean or any similar trick .. u can assume that the list Nodes are like…
    Class Node
        int val;        //assuming this is an integer List
        Node next;    //this is a pointer for those who doesnt know C#
  3. you can use any constant number of temporary variables or pointers .. as long as the number is constant (i want an in place algorithm) — i suggest 4 or 5 extra pointers
  4. you are not required to keep the list intact .. you may play with it or destroy it as you please 😀
  5. i don’t strictly require the source code .. just the idea .. but i may request it later if you insist that your answer is right 😀
  6. THOSE WHO ARE AFRAID OF BEING WRONG .. please go away .. if you are afraid of getting it wrong yo will never try .. then you will never get it right
  7. note 6 does not mean throwing me some idea and i have to think about it :@ .. you have to be 80% sure of your solution and think how may it go wrong and all the cases ..
  8. Read the comments -if there is any- before you post your solution .. it might remind you of some thing you forgot in your solution 😉

if you would like the next problem to be about some certain topic, then please tell me in the comments .. and it would be great if you said that in the very comment where you place your solution 😀

now to the winners:
thanks every one
and still no one requested a topic for the next week’s problems! .. seems like it will be very hard one (6) !

ملف المستحيل

malaf_new ragol_new

كثيرون اندهشوا عندما قرأوا اسم أمجد صبحى فى ملف المستقبل

و لكنهم – الكثيرون- أيضا لم يتوقعوا ان يقرأوا يوما اسم أدهم صبرى فى ملف المستقبل

هذه المره لن يكون كهلا.. و هذه المره لن يكون وحده .. و هذه المره سيجتمع الفريقين

انتظروا هذه الرواية فى معرض لكتاب القادم بأذن لله

المصادر: هنا و هنا

Can you C the trick ? [Problem of the week]

 Untitled How to write “X” so that:

int a= 0;
cout<<"a = "<<a;
//console says a = 5 Positive five!

a= 0;
cout<<"a = "<<a;
//console says a = -5 Negative five!

waiting for the answers in the comments (comments are moderated) .. i will show them after a couple of right answers..

if your answer is wrong “which is fine”, i will pass the comment..

if it is right .. i will reply on the comment or maybe to your mail telling you to stop trying..


now to the Winners (in order of who replied first):

  1. me 😀

Exceptional Software, Explained: Embrace Error [OSCON2008]

i have tried to follow the O’Reilly’s Open Source Convention (OSCON) for a bit .. but since i am not very familiar with most of the names .. i lost my interest later..

until i seen a video by GreggPollack titled Oscon in 37 minutes where every speaker summarizes his talk in 30 seconds..

i will try to cover the most interesting talks -for me- later .. but for now .. i will start with most i liked

it was by Robert ‘r0ml‘ Lefkowitz about Exceptional Software..Explained you can watch the 30 seconds from the previously mentioned video here

[viddler id=ede9eafd&w=437&h=370]

i will quote what he said

one of the things we are trying to do is encourage large enterprises to adopt the open source practices..

difficulty that .. although we have open source practices .. we don’t have open source methodology..

large companies are used to methodologies like Rational Unified Process or the Microsoft Solutions Framework or SCRUM or eXtreme Programming .. that define “how it is that you go about it”

and there is NO open source methodology for HOW YOU DEFINE SOFTWARE ?

and then you think that “MAN .. this is going to get very boring” .. but you must watch the 30 seconds and then you will get why it is not .. especially that he presents a totally new methodology other than what we are used to

i have dug for the complete talk .. and found it here

the talk is extremely fun .. and very insightful

you can download most of the presentations from here

Reblog this post [with Zemanta]

tools i use..

since you might be digging the internet for a notepad replacement or an explorer extension that makes searching files easier..

i thought to save u some bandwidth .. and tell you about some tools i like

most of these are Free Software. برامج حرة

Exploring, Navigation and GUI

    1. Launchy
      no need to Dig through Start>All Programs or fill the desktop with millions if files .. or look for Calc each time you need to add 55 + 78 …find your programs and run them in no time

    1. ClipX
      use Ctrl+Shift+V .. to paste stuff that you copied and overwritten .. like office Clipboard but cooler
    2. PowerMenu
      if you like HackIt .. you will love PM, send any window to System Tray, makes it transparent or On Top
    3. Rocket Dock
      Coolest app from the Mac World
    4. TeraCopy
      Copy, Pause, Cancel and Resume in Windows Explorer and On Lan, hundreds of files.

    1. StExBar
      adds a Toolbar in your Explorer, with some handy stuff (open ComandLine here, copy all pathes, copy names, rename all) .. extremely useful.

  • GrepWin
    if you are a Linux fan .. then u know grep .. and u also know that windows search is useless .. grepWin Lets you search inside files with a RegEx or for normal Text



No matter what you do .. u can never rely on that.. so i will mention NONE

Network and Chat

    1. FireFox
      u can see a cant be bias here

    1. eMule
      P2P file sharing program .. very configurable
      Image via


    1. Orbit / Free Download Manager

    1. CrossLoop
      may be slower than LogMeIn.. lets you share the desktop with your friend.. very helpfull for remote assistance

    1. Pidgin
      aside the fact that current GTK+ release on windows is extremely buggy, Pidgin is All In One Chat Client, very light, very cool .. simply you can have 2 Gtalk accounts + 1 yahoo + 3 MSN in one window, one program

    1. uTorrent
      the smallest of all, compared to its feature richness.

Firefox Addons

    1. Firebug
      helps you to analyze HTML, find problems with your website, debug javascript
    2. FireFTP .. obvious

    1. Foxmarks
      Sync your bookmarks across machines and even access them online
    2. FoxyProxy
      Proxy management, go TOR or any other Proxy in seconds

  1. QuickDrag
    Drag and Drop any link in a new background tab .. instead of Ctrl+Click every time
  2. Shareaholic Found something awesome and cant wait to pass it on ? share over GReader, digg or anyother..

  3. SpeedDial
    bookmarks in a smart way
  4. Sxipper Manages your passwords and fills-web forms .. extremely SMART

  5. TabMixPlus
    want to make your tabs at the bottom of the page , control ordering , force 1 instance of FF ?
  6. Zemanta a blogger ? .. u MUST try this

General Purpose

    1. Foxit Reader
      compared to Adobe reader ? .. this one should be rated (999/5)

  1. WordWeb
    aka Churchill, a compact Dictionary, with shourtcut keys , just select, press ALT+T and u see the meaning. the last version is wierd, but its free any way
  2. Notepad++
    take alook for yourself, it can replace Notpad interly by the way

Audio Vedio

    1. Winamp ..

    1. Audacity
      A Free, Cross-Platform Digital Audio Editor under GPL

    1. MediaCoder
      Convert from any thing to any thing.. another verygood OSS

Burners, ZipFiles

    1. InfraRecorder
      OpenSource Image Burner .. a free/Light Nero alternative and works great!
    2. Daemon Tools
      OpenSource, Simulates a CD from an image, much compact than PowerISO and VirtualCD

    1. 7-Zip
      Tired of the “your evaluation Copy expired” every time you open a zip file in WinRAR ?, 7-zip is the OpenSource alternative

Now to the best part

Development Tools

    1. pInvoke VS addon
      get the pinvok signature of any function from PInvoke.Net

    1. VisualAssistX
      Not Free, but simply addictive

    1. ProcessExplorer
      gives you every detail about any process in your system

    1. DependencyWalker
      Know what DLL’s your program loads.. know what symbols are exported by your DLL, TakeALook

  • TortoiseSVN
    Source Control Management .. if you are still makeing copies of your code and sending them through mail in zip files to your friends .. then you should start using SVN


  • CMake
    convert Makefiles into VS Solutions


  • WinMerge
    merge two code files or folders, see what changed , bla bla .. the best windows diff tool


i think that’s all.. you want to share a tool you like ? .. place it in the comments

Zemanta Pixie