Programming Challenges - Page 14

1. 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. Registered User
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. Originally posted by bwkaz
Maybe, but I don't think there's any way I'll ever be able to decipher this one:

/me picks up jaw off the floor

4. Take the sentence:
"She sells sea shells by the sea shore"

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

5. 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. 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. ## 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.

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.

9. 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.

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

10. 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
>>> 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....

11. 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.

12. 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.

13. Now might be a good time to mention http://www.pythonchallenge.com

14. ## 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.

15. 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
•