Ive been learning C for a year now and ive finally made something usefull.
Ive seen it used as an exercise/tutorials in the past.
I have a grid of numbers. You start at top left and must work your way bottom right only allowed going down and right. You must find the path of maximum sum of these grid entries.
It took me ages and my source code is about 80 LOC.
Im posting this here not because im bragging but I need to know:
What sort of difficulty level are we talking about to do what I did?
I'd call it "logical puzzle-solving difficulty". High I'd say. Congrats.
However to create useful programs "practical problem-solving difficulty" is involved. That's lower but not necessarily easier. Don't look up these terms, I invented them myself although they come from personal experience.
On the scale of a "real programmer": Negligible, unless you rewrote your operating system in the process in which case negligible.
On the scale of your average beginning C/C++ professor: Difficult.
On the scale of your average advanced C/C++ professor: Medium.
On Linus Torvalds' scale: Good work using C and not C++. C++ is the spawn of the devil.
On the scale of a CS hotshot who knows nothing about CS: Pfft. I could do this while sleeping with my eyes closed.
On the scale of an average Apple user: OHMIF***INGGAWDHOWDYADOTHAT?!?!
On the scale of a algophiliac: That depends on which algorithm you used and whether it works or not.
On my scale: I don't operate on scales.
Does that answer your question? ;)
-Albatross
In a way, yes. Thanks.
I abstracted the problem by saying right =0 and down =1
If its a 5X5 grid, the "path array" will have 8 entries.
You can only go down 4 times and right 4 times in total.
So what to do?
Count from 0 upwards using binary addition.
00000000
00000001
00000010
00000011
00000100
00000101
00000110
etc etc
All these are actually arrays of 8 entries either being 1 or 0.
Binary addition will give you every possible combination of down (1) and right (0) ;-)
Then you drop all arrays that have more than or less than 4 zeros/ones because you cannot go right or down in total of more than 4 times!
So arrays like:
01110001
are legitimate
Take all these "within bounds" entries and sum their grid entries. The maximum is the best.
I'd call it "logical puzzle-solving difficulty". High I'd say. Congrats.
However to create useful programs "practical problem-solving difficulty" is involved. That's lower but not necessarily easier. Don't look up these terms, I invented them myself although they come from personal experience.