Programming Challenges - Page 13


Page 13 of 19 FirstFirst ... 391011121314151617 ... LastLast
Results 181 to 195 of 279

Thread: Programming Challenges

  1. #181
    Join Date
    Nov 2003
    Posts
    81
    Originally posted by Sepero
    bwkaz, don't you have anything to say about this?
    If it makes it easier......
    <><

  2. #182
    Join Date
    Apr 2001
    Location
    SF Bay Area, CA
    Posts
    14,936
    I really should.

    It might make it "easier", but there's the minor detail of how it also makes it "wrong". (At least, "wrong" in terms of what I believe the C++ committees want. I could be wrong.)

    <my standard rant on this subject: if you've already seen it, skip this bit>

    The std:: namespace was added to the C++ standard library for a reason. If you pull that entire namespace into the default namespace, you eventually will trample on symbols that you've already defined in the default namespace. This will cause no end of compiler errors, until you figure out what the underlying issue is and start doing one of the following things.

    </standard rant>

    What you can do is only import the individual symbols you require, or (this is better, but takes more work) don't import anything, just use the std:: namespace qualifier everywhere.

    And let me just say, beeps are ANNOYING.

  3. #183
    Join Date
    Nov 2003
    Posts
    81
    Originally posted by bwkaz
    And let me just say, beeps are ANNOYING.
    I'm glad you like it
    <><

  4. #184
    Join Date
    Dec 2002
    Location
    GA--United States
    Posts
    273

    Post GEEK Prize Challenge

    The Open Source Institute is offering a programming challenge for anybody interested. The winner of the contest will get an item worth up to $40 from Amazon.com. Second place winner can get an item worth up to $25.

    If you are interested in trying out your skills with over 2500 other programmers for prizes. Check out http://www.osix.net
    SAJChurchey

  5. #185
    Join Date
    May 2001
    Location
    Uh, I'm somewhere where I don't know where I am.
    Posts
    1,228
    awww, reserected just to show some other places challenges. I was all excited that it was back up. Damn, anyone have any good challenges?
    if (i_forgot && this_is_about_code)
    language = c++;

  6. #186
    Join Date
    Jan 2003
    Location
    Denver, Colorado
    Posts
    1,488

    This one should be easy

    -I use mpg123 for playing mp3's
    -It recognizes Winamp & xmms generated .m3u files.
    -Those files can be stripped down to include just the paths to the mp3 files. i.e. /mnt/Music/Seether/Seether - Broken.mp3


    So here's the challange:

    -Write a script that pipes output similar to that of ls -RN to a file with a .m3u extension.
    --each line in the file should be formatted as /directory/subdirectory/sub-subdirectory/file.mp3
    --will need to handle different levels of subdirectories such as:
    /mnt/Music/Seether/Seether - Broken.mp3
    /mnt/Music/Liz Phair/Exile In Guyville/Liz Phair - Flower.mp3

    Bonus:
    -Have the script prompt the user for the mp3 directory, for example, mine would be /mnt/Music
    -Have prompts for the user to add all subdirectories or individual ones for different artists, etc.

    The end result would enable one to generate, manipulate, and play music playlists all from the command line. How cool!
    Slackware current (Dell Latitude D610)
    CentOS 5.2 (Servers)
    Registered Linux User # 375030

  7. #187
    Join Date
    Apr 2001
    Location
    SF Bay Area, CA
    Posts
    14,936
    psych-major:

    find /path -name '*.mp3' >file.m3u

    will work, as long as none of the filenames or directories have newlines in them. (Which is actually legal in filenames, but I doubt that the m3u format can handle it.)

  8. #188
    Join Date
    Jan 2003
    Location
    Denver, Colorado
    Posts
    1,488

    Duh!!!

    Originally posted by bwkaz
    psych-major:

    find /path -name '*.mp3' >file.m3u

    will work, as long as none of the filenames or directories have newlines in them. (Which is actually legal in filenames, but I doubt that the m3u format can handle it.)
    That worked perfectly. I'm such a 'tard; I should of thought of it because I used to use an identical command for a batch file in DOS at my last job...

    Thanks, for the quick response. I'll try to come up with something a little more challenging next time!
    Slackware current (Dell Latitude D610)
    CentOS 5.2 (Servers)
    Registered Linux User # 375030

  9. #189
    Join Date
    Jun 2002
    Posts
    1,333
    Challenge:

    Write a script that prints only the first letter of each word that appears in a plaintext file. Only characters A-Z and a-z should be recognized. Carriage returns, punctionation, arabic numerals, etc. should all be ignored.

    Demonstration:

    Possible contents of the plaintext file:
    Code:
    How much wood would a woodchuck chuck
    If a woodchuck would chuck wood?
    A woodchuck would chuck all the wood he could chuck
    If a woodchuck would chuck wood.
    The result would be:
    Code:
    h
    m
    w
    w
    a
    w
    c
    i
    a
    w
    w
    c
    w
    a
    w
    w
    c
    a
    t
    w
    h
    c
    c
    i
    a
    w
    w
    c
    w

  10. #190
    Join Date
    Mar 2003
    Location
    Tampa, FL USA
    Posts
    2,193
    Nice one hop-frog. I thinking about trying it with a shell script, but when you mentioned no punctuation, that got my mind really wondering.

  11. #191
    Join Date
    Apr 2001
    Location
    SF Bay Area, CA
    Posts
    14,936
    Hrmm, let's see...

    Code:
    sed -e 's/[[:space:]]/\n/g' file.txt | sed -e 's/[^A-Za-z]//g' | cut -c 1
    perhaps?

  12. #192
    Join Date
    Mar 2003
    Location
    Tampa, FL USA
    Posts
    2,193
    bwkaz, you're like a regex guru or something. I don't know how you remember all that stuff!

  13. #193
    Join Date
    Apr 2001
    Location
    SF Bay Area, CA
    Posts
    14,936
    Maybe, but I don't think there's any way I'll ever be able to decipher this one:

    http://www.ex-parrot.com/~pdw/Mail-RFC822-Address.html


  14. #194
    Join Date
    Mar 2003
    Location
    Tampa, FL USA
    Posts
    2,193

    Question

    Originally posted by bwkaz
    Maybe, but I don't think there's any way I'll ever be able to decipher this one:

    http://www.ex-parrot.com/~pdw/Mail-RFC822-Address.html

    I can't program perl and I can't really read the code well(though, I would imagine the "?" and ":" pairs are of "if" and "else").

    It looks VERY repetitive though. Is there absolutely no way they could've reduced the code with a function or two?

  15. #195
    Join Date
    Apr 2001
    Location
    SF Bay Area, CA
    Posts
    14,936
    Well... maybe, but it's not "code" per se. It's just one enormous regular expression that's meant to be applied to a string to determine whether the string is a valid RFC-822 address. AFAIK there is no such thing as a "function" when talking about regular expressions.

    I believe the (?:) stuff isn't "if-else"; I think it introduces a "non-capturing group". It groups the characters in the string being tested, without assigning them to the Perl variables $1, $2, etc. ("capturing" them).

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •