Skip to content

Clever Code

Showcase your best code, your most elegant solution, or your most hard fought subtle bug you've found and fixed

This category can be followed from the open social web via the handle clever-code@forum.codeproject.com

361 Topics 3.2k Posts
  • 0 Votes
    7 Posts
    73 Views
    B
    Julien Villers wrote: Well, a brute force, however optimized, 40 minutes run on an obscure* platform isn't quite a 'solution' to a Project Euler problem, is it? ;) If the code solves the problem on the obscure platform, then it is a solution to the problem.
  • Better switch statement.

    visual-studio com business career
    4
    0 Votes
    4 Posts
    43 Views
    B
    This is clever code. Just think what would happen if a Starbucks customer typed in Venti at the prompt. :) Schenectady? What am I doing in Schenectady?
  • 0 Votes
    31 Posts
    172 Views
    D
    That doesn't mean it's always faster - it just means it is asymptotically faster. It always annoyed me that my algorithms class never dealt with this issue, being exclusively interested in the theoretical framework where "best" only meant "best for infinite-size problem" and not at all interested in real-world performance, where infinite input isn't even possible. :)
  • Clever comment?

    question
    3
    0 Votes
    3 Posts
    23 Views
    D
    You're just making it up, and we can tell since strings aren't even disposable. (Of course, you are now going to hide behind the "something like" provision. I'll maintain whatever it was, it was "nothing like" what you've posted!)
  • API Hooking

    question json
    2
    0 Votes
    2 Posts
    25 Views
    M
    Didn't you notice the "do not post programming questions in this forum" notice just above? Try the Windows API[^] board instead. 2A
  • 0 Votes
    3 Posts
    27 Views
    R
    Or (untested): for(int i = 0x80; i > 0; i >>= 1) { cout << (num & i) ? "1" : "0"; } Dunno if the code spared is worth it, though.
  • javascript for check box list

    javascript tools help
    2
    0 Votes
    2 Posts
    18 Views
    N
    Psst - this forum is NOT for questions, it's for showing off clever things we have done. Try asking this in Q&A and an answer will be forthcoming. Maybe. Panic, Chaos, Destruction. My work here is done. Drink. Get drunk. Fall over - P O'H OK, I will win to day or my name isn't Ethel Crudacre! - DD Ethel Crudacre I cannot live by bread alone. Bacon and ketchup are needed as well. - Trollslayer Have a bit more patience with newbies. Of course some of them act dumb - they're often *students*, for heaven's sake - Terry Pratchett
  • project for you

    com security help
    1
    0 Votes
    1 Posts
    9 Views
    No one has replied
  • 0 Votes
    3 Posts
    24 Views
    H
    SEO program ? Search Engine Oprimization is for websites. Here is the Links that u can study for SEO. With best wishes.. http://www.w3schools.com/web/web_search.asp[^]
  • file converstion

    question csharp
    2
    0 Votes
    2 Posts
    18 Views
    R
    The downvotes are because you are posting in the wrong place - try the Q&A[^] forum
  • Single Update Query for.....

    database question announcement
    17
    0 Votes
    17 Posts
    76 Views
    L
    ian dennis wrote: anything to the power of 1 is itself yes ian dennis wrote: so (id-1)^1 = id-1 no, that is simply never true in the programming languages I use. Including SQL. :) Luc Pattyn [My Articles] Nil Volentibus Arduum Fed up by FireFox memory leaks I switched to Opera and now CP doesn't perform its paste magic, so links will not be offered. Sorry.
  • Vim (linux) regex to create links

    php linux regex question learning
    1
    0 Votes
    1 Posts
    10 Views
    No one has replied
  • Translating a jagged array

    data-structures question
    10
    0 Votes
    10 Posts
    48 Views
    W
    Without data, who knows? If it were done .AsParallel it may be faster on certain system/jagged array combos. Then again, if you find yourself translating jagged arrays on large sets of data, it may be a sign of choosing the wrong data structure.
  • Strange

    18
    0 Votes
    18 Posts
    68 Views
    J
    Yup, math is cool.
  • Extract from Jigsaw

    csharp linq functional question
    18
    0 Votes
    18 Posts
    90 Views
    A
    Lucky you, i have just experienced a personal BSoD... My mind has just rebooted and is doing a memory test.... Lots of bad sectors found :sigh: Cogito ergo sum
  • For peer review: InputBox.

    beta-testing tutorial question code-review
    10
    0 Votes
    10 Posts
    45 Views
    P
    As promised, here is the update. (This is the tip/trick location that someone couldn't find, earlier.) InputBox: A simple user input dialog[^]
  • NTFS, win7 and 20 million files

    question com
    8
    0 Votes
    8 Posts
    45 Views
    V
    Checkout ZFS by Sun Microsystems (Now : Oralce ) .... http://hub.opensolaris.org/bin/view/Community+Group+zfs/whatis[^] Zen and the art of software maintenance : rm -rf * Math is like love : a simple idea but it can get complicated.
  • Simple Camera Tethering Using WIA

    career csharp dotnet debugging
    3
    0 Votes
    3 Posts
    19 Views
    D
    Can you edit and wrap the code in a pre block with the correct lang attribute value. Dave Find Me On: Web|Facebook|Twitter|LinkedIn Folding Stats: Team CodeProject
  • The quest for fastest strstr-like function in C

    performance css algorithms regex help
    12
    0 Votes
    12 Posts
    58 Views
    R
    In the words of Hong Kong Phooey..... Could be! If you vote me down, my score will only get lower
  • Comment Switching

    debugging discussion
    20
    0 Votes
    20 Posts
    86 Views
    K
    I agree - not only more readable, but the line #define USE_MY_SPECIAL_DEBUG_VALUE can be commented or uncommented with one mouse click - no keystrokes required! -- Regards, Ken I AM