Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Apr 17th, 2005, 12:27 PM   #1
Sane
Programming Guru
 
Sane's Avatar
 
Join Date: Apr 2005
Location: Waterloo, Ontario
Posts: 1,885
Rep Power: 5 Sane will become famous soon enough
Send a message via MSN to Sane
Python Contest #2

- Hall of Fame -
sykkn - 76 Points - Gold Medal
thechristelegacy - 72 Points - Silver Medal
al1986 - 68 Points - Bronze Medal
Sane - 64 Points
Ooble - 51 Points

- Rules -
Contest closes next Sunday. Use whatever resources you want, just don't post the answers here. PM them to me and I'll update the standings ASAP. You can send in as many submissions as you wish.

- Challenge -
This is a bit trickier, as I want a definitely replicated result, no room for fluxuations on the output. The winner will be the one with the least amount of lines, but a tie breaker will be decided by the number of characters.

(1) 6 Even
(2) 0 Even
(3) 5 Odd
(4) 0 Even
(5) 4 Even
(6) 9 Odd
(7) 8 Even
(8) 9 Odd
(9) 4 Even
(10) 4 Even

Average: 4.9 Odd

You have to be able to change the length of outputs with a single variable change (to prevent making a manual loop into one line of code).

Just for clarification, the program outputs x amount of random integer values between 1 and 10. Lists if it is even/odd. Prints the average at the end in 1 decimal place float, and if it is even or odd (rounded up if >.4, rounded down if <.5).

This time, include declaring the variables as part of the program.

Good Luck

Last edited by Sane; Apr 17th, 2005 at 4:54 PM.
Sane is offline   Reply With Quote
Old Apr 17th, 2005, 2:50 PM   #2
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
Can we say no semicolons - every statement must be on a separate line?
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Old Apr 17th, 2005, 3:22 PM   #3
Sane
Programming Guru
 
Sane's Avatar
 
Join Date: Apr 2005
Location: Waterloo, Ontario
Posts: 1,885
Rep Power: 5 Sane will become famous soon enough
Send a message via MSN to Sane
We might try that later, but for now it's still challenging enough to get it minimal with semi-colons.
Sane is offline   Reply With Quote
Old Apr 17th, 2005, 6:02 PM   #4
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
What about whitespace? Does x = x + 1 count as 5 characters, or 3?
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Old Apr 17th, 2005, 6:36 PM   #5
thechristelegacy
Expert Programmer
 
thechristelegacy's Avatar
 
Join Date: Jul 2004
Location: Somerset, Pa
Posts: 708
Rep Power: 5 thechristelegacy is on a distinguished road
Send a message via AIM to thechristelegacy Send a message via MSN to thechristelegacy
Could someone clarify what's being asked here? I'm a bit confused on what we're suposed to do.
thechristelegacy is offline   Reply With Quote
Old Apr 17th, 2005, 7:08 PM   #6
Sane
Programming Guru
 
Sane's Avatar
 
Join Date: Apr 2005
Location: Waterloo, Ontario
Posts: 1,885
Rep Power: 5 Sane will become famous soon enough
Send a message via MSN to Sane
Nope spaces don't count.

Legacy, I said already:


The output of the program will be:
(1) 6 Even
(2) 0 Even
(3) 5 Odd
(4) 0 Even
(5) 4 Even
(6) 9 Odd
(7) 8 Even
(8) 9 Odd
(9) 4 Even
(10) 4 Even

Average: 4.9 Odd

Where:
The program outputs x amount of random integer values between 1 and 10. Lists if it is even/odd. Then at the end, prints the average in 1 decimal place float, and if it is even or odd (rounded up if >.4, rounded down if <.5).

You have to be able to change the length of outputs with a single variable change (to prevent making a manual loop into one line of code).
Sane is offline   Reply With Quote
Old Apr 17th, 2005, 7:50 PM   #7
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
Oh, and one more thing - about line breaks: if I replace every line break I can with a semicolon, I remove around three-quarters of them. Does this mean I get more points?
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Old Apr 17th, 2005, 8:59 PM   #8
Sane
Programming Guru
 
Sane's Avatar
 
Join Date: Apr 2005
Location: Waterloo, Ontario
Posts: 1,885
Rep Power: 5 Sane will become famous soon enough
Send a message via MSN to Sane
Semi-colons are equivelent to line breaks. So if you take a 20 line print program, and change it to 1 line with semicolons dividing all the print lines, it's still worth the same. However, for this challenge lines are the only thing that matters unless a tie.
Sane is offline   Reply With Quote
Old Apr 18th, 2005, 8:55 AM   #9
Moldz
Programmer
 
Moldz's Avatar
 
Join Date: Feb 2005
Posts: 54
Rep Power: 4 Moldz is on a distinguished road
I know that counting lines is an easy way to compare programs, but shouldn't a program be judged by something a little more meaningful? How about we try to come up with a program that does not swallow all my memory, that doesn't crash at the first sign of trouble, and doesn't take ten years to come up with an answer. Then, all things being equal, the simplest program wins!
Moldz is offline   Reply With Quote
Old Apr 18th, 2005, 12:10 PM   #10
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
Heh. I would say the number of clock cycles the program takes would be an accurate method of measuring it. Or perhaps the number of instructions it contains?
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 12:15 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC