Programming Challenges - Page 14


Page 14 of 19 FirstFirst ... 4101112131415161718 ... LastLast
Results 196 to 210 of 279

Thread: Programming Challenges

  1. #196
    Join Date
    Jun 2002
    Posts
    1,333
    Using xwarppointer, one can easily write a shell script that moves the mouse around the screen in a sequence.

    Challenge:

    Write a program to accompany xwarppointer. When run, it simply sends a left-button click to the pointer.

  2. #197
    Join Date
    Apr 2001
    Location
    SF Bay Area, CA
    Posts
    14,947
    Well, I won't do this, because I have a few other things going on at the moment, but it shouldn't be too hard to do. You should only need the Xtst libraries, and the <X11/Xtest.h> includes. Then you can open the display, and inject an X button-press, button-release event combination into the event list.

    It's how I make sure numlock is on every time I start X -- I run a program that's linked against the Xtst library, which sends a key-press, key-release event pair pointing at the numlock key.

  3. #198
    Join Date
    Sep 2003
    Location
    Rochester, MN
    Posts
    3,607
    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

    /me picks up jaw off the floor

  4. #199
    Join Date
    Mar 2003
    Location
    Tampa, FL USA
    Posts
    2,193
    Take the sentence:
    "She sells sea shells by the sea shore"

    Reorder the words alphabetically, and do it in your favorite language.

  5. #200
    Join Date
    Jun 2002
    Location
    Parump, NV
    Posts
    859
    I found this thread again, thought it was lost..........
    here is a challenge I did a few years ago while taking a C/C++ class and figured I'd put it out and see how many different ways it could be done (perl, VB, Bash script??, etc.).........have fun

    Find a six digit number that gives its digits reversed when multiplied by an integer between 2 and 9 inclusive.

  6. #201
    Join Date
    Jun 2002
    Location
    Parump, NV
    Posts
    859
    Originally posted by Sepero
    Take the sentence:
    "She sells sea shells by the sea shore"

    Reorder the words alphabetically, and do it in your favorite language.
    this is about as easy as it gets......I guess

    Code:
    #!/usr/bin/perl
    
    @array = ("she", "sells", "sea", "shells", "by", "the", "sea", "shore");
    @array2 = sort (@array);
    
    print ("@array2\n");

  7. #202
    Join Date
    Mar 2004
    Location
    Harford County, Maryland
    Posts
    135

    This stuff needs a home...

    Just a comment, if I might. Being new to Linux and all that, I am offering a perspective consistent with the burning desire to learn anything!

    This stuff is incredible! I notice that the thread originally started almost two years ago, and yet I've just now seen it, only because someone chanced to resurrect it, and back it came to the front.

    My humble wish...that this concept rates its' own stable in the barn. A unique category. It's beautiful stuff. It's like having a window and a seat next to a bunch of ace coders, and being able to look over their shoulders and get a sense of what coding can be. It's freewheeling, and raucus, and just one heck of an education.

    Please...give this concept real status!
    Success isn't measured by how high you fly: Success is measured by how high you bounce!

  8. #203
    Join Date
    May 2001
    Location
    Uh, I'm somewhere where I don't know where I am.
    Posts
    1,228
    Originally posted by janet loves bill
    I found this thread again, thought it was lost..........
    here is a challenge I did a few years ago while taking a C/C++ class and figured I'd put it out and see how many different ways it could be done (perl, VB, Bash script??, etc.).........have fun
    Are there more than two of these? Just checking to see if i'm close...

    Oh, and can't we make this sticky? I'm sure it's one of everyone's favorites in this forum.
    Last edited by tecknophreak; 05-25-2005 at 01:22 PM.
    if (i_forgot && this_is_about_code)
    language = c++;

  9. #204
    Join Date
    Dec 2002
    Posts
    173
    Originally posted by Sepero
    Take the sentence:
    "She sells sea shells by the sea shore"

    Reorder the words alphabetically, and do it in your favorite language.

    How about:

    echo 'She sells sea shells by the sea shore' | sed -e 's/[[:space:]]/\n/g' | sort



    registered linux user #355125

    gentoo (with gentoo-dev-sources 2.6.5-r1) on Desktop
    debian 2.6.5-1-686 on laptop

  10. #205
    Join Date
    Dec 2000
    Location
    Glasgow, Scotland
    Posts
    4,361
    or:

    Code:
    Python 2.3.5 (#2, May  4 2005, 08:51:39)
    [GCC 3.3.5 (Debian 1:3.3.5-12)] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>> mystring = "She sells seas shells on the sea shore"
    >>> list = mystring.split(' ')
    >>> list
    ['She', 'sells', 'seas', 'shells', 'on', 'the', 'sea', 'shore']
    >>> list.sort()
    >>> print list
    ['She', 'on', 'sea', 'seas', 'sells', 'shells', 'shore', 'the']
    >>>
    Bearing in mind that it's a case-sensitive sort....
    mrBen "Carpe Aptenodytes"

    Linux User #216794

    My blog page

    3rd year running - get yourself to LugRadio Live 7th-8th July 2007, Wolverhampton, UK. The premier FLOSS community event.

  11. #206
    Join Date
    Dec 2002
    Posts
    173
    Haha or ruby

    irb(main):001:0> "She sells seas shells on the sea shore".split.sort
    => ["She", "on", "sea", "seas", "sells", "shells", "shore", "the"]
    Last edited by tony_yum; 05-26-2005 at 10:38 AM.


    registered linux user #355125

    gentoo (with gentoo-dev-sources 2.6.5-r1) on Desktop
    debian 2.6.5-1-686 on laptop

  12. #207
    Join Date
    Dec 2002
    Posts
    173
    Find a six digit number that gives its digits reversed when multiplied by an integer between 2 and 9 inclusive.
    Code:
    (100000..999999).each { | x |
    
        (2..9).each { |y |
            if x.to_s == (x*y).to_s.reverse then
                print "#{x} * #{y} = #{x*y}\n"
            end
        }
    }
    Output:
    109989 * 9 = 989901
    219978 * 4 = 879912

    This is fun
    Last edited by tony_yum; 05-26-2005 at 01:09 PM.


    registered linux user #355125

    gentoo (with gentoo-dev-sources 2.6.5-r1) on Desktop
    debian 2.6.5-1-686 on laptop

  13. #208
    Join Date
    Dec 2000
    Location
    Glasgow, Scotland
    Posts
    4,361
    Now might be a good time to mention http://www.pythonchallenge.com
    mrBen "Carpe Aptenodytes"

    Linux User #216794

    My blog page

    3rd year running - get yourself to LugRadio Live 7th-8th July 2007, Wolverhampton, UK. The premier FLOSS community event.

  14. #209
    Join Date
    Mar 2004
    Location
    Harford County, Maryland
    Posts
    135

    Why, thank you...

    Originally posted by mrBen
    Now might be a good time to mention http://www.pythonchallenge.com
    Actually, you chose a wonderful time to mention this link. Thank you much for doing so.
    Success isn't measured by how high you fly: Success is measured by how high you bounce!

  15. #210
    Join Date
    Aug 2003
    Location
    South Dakota and Iowa
    Posts
    242
    Originally posted by Sepero
    Take the sentence:
    "She sells sea shells by the sea shore"

    Reorder the words alphabetically, and do it in your favorite language.
    Perl6

    Code:
    "She sells sea shells by the sea shore".split.sort.say;
    
    ## disregard case
    "She sells sea shells by the sea shore".split.map:{ lc $_ }.sort.say;
    # or
    "She sells sea shells by the sea shore".split.sort:{ lc $^a cmp lc $^b }.say;
    Last edited by bryan.6; 05-29-2005 at 11:59 AM.

Posting Permissions

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