Hi! Im a newbie to PERL.
I came across a size contest in spoj. The Problem was:
The number of inputs will be given as the first input.
After that, a series of numbers both positive and negative are given. The program has to count only the values of the positive numbers and display the result. Eg,
For this problem, i wrote a Perl Program. This was my Program:
$a=<>; ($x=<>)>0 ? $_ += $x : 0 while $a--; print
I've heard Perl excels in short programs. But i cant make it any shorter!
Can u guys help me make it shorter???
Btw, the shortest solution length was a mind boggling "6" characters long!!!! OMG!!!
Note: Actually the characters whose ASCII values are >=32 are only counted as characters
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.
| & || & |
| < || < |
| > || > |
| [ || [ |
| ] || ] ||