Awesome job evolivid! Very impressive! +50 BONUS POINTS and +3 ALTERNATIVE POINTS for bringing the command line into it!
I think for this challenge - I'm going to accept the 38c entry as shortest, since I didn't say one way or the other whether it had to be a script file or command line (right? I don't remember now...) But you definitely have given me a new idea for some challenges down the road!! THANKS!
33 Replies - 8039 Views - Last Post: 08 October 2012 - 01:47 AM
#32
Re: Perl Challenge: Code Golf!
Posted 19 February 2011 - 04:26 PM
cool.. thanks for the challenge, im looking at some of my old code in a new way now!
on to round 2!
on to round 2!
#33
Re: Perl Challenge: Code Golf!
Posted 25 September 2012 - 07:48 PM
A late post, could be 2 characters less if using -E + 'say'.
# 36 non-white space characters (38 including white spaces):
It's amazing that even though perl has to add so many '$' sign before the variables, it is still the shortest for one liner.
# 36 non-white space characters (38 including white spaces):
Spoiler
It's amazing that even though perl has to add so many '$' sign before the variables, it is still the shortest for one liner.
#34
Re: Perl Challenge: Code Golf!
Posted 08 October 2012 - 01:47 AM
jumptrooper, on 27 January 2011 - 10:25 AM, said:
Perl writers love their compact statements and one-liners, so....
Let's play a game!
It's called "Code Golf". I didn't come up with the idea - I've seen it on the web before. It's very simple:
See who can write the shortest amount of code to accomplish a given task.
That's it. Speed is inconsequential! Time is not of the essence! Just make it short! The code with the fewest number of non-whitespace characters wins! Don't worry about line numbers - just character count.
The problem is problem #1 from ProjectEuler.net**, which reads:
Your code should print the result to the screen.
This friendly game is open to anyone, using any language - But we are especially interested in your contribution if you are a Perl programmer!
*Oh - and if you are not a Perl programmer, you get BONUS POINTS if you try it in Perl!!!*
**ProjectEuler.net is a great site! There are literally hundreds of unique and interesting computational problems to work through and there's a big community around finding optimal solutions for each of them.
Let's play a game!
It's called "Code Golf". I didn't come up with the idea - I've seen it on the web before. It's very simple:
See who can write the shortest amount of code to accomplish a given task.
That's it. Speed is inconsequential! Time is not of the essence! Just make it short! The code with the fewest number of non-whitespace characters wins! Don't worry about line numbers - just character count.
The problem is problem #1 from ProjectEuler.net**, which reads:
Quote
If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.
Find the sum of all the multiples of 3 or 5 below 1000.
Find the sum of all the multiples of 3 or 5 below 1000.
Your code should print the result to the screen.
This friendly game is open to anyone, using any language - But we are especially interested in your contribution if you are a Perl programmer!
*Oh - and if you are not a Perl programmer, you get BONUS POINTS if you try it in Perl!!!*
**ProjectEuler.net is a great site! There are literally hundreds of unique and interesting computational problems to work through and there's a big community around finding optimal solutions for each of them.
my $sum;
foreach my $val(1..999){
(($val % 3) == 0 || ($val % 5) ==0) ? $sum+=$val : next ;
}
print $sum;
Attached File(s)
-
1.txt (115bytes)
Number of downloads: 14
|
|

New Topic/Question
Reply




MultiQuote



|