P is for Practical  
PerlMonks 
Code Shortening (golf) [RESOLVED]by Young Monk (Novice) 
on Oct 18, 2010 at 18:41 UTC ( #866017=perlquestion: print w/replies, xml )  Need Help?? 
Young Monk has asked for the
wisdom of the Perl Monks concerning the following question:
Hi all. I was trying a question in SPOJ. Let me explain the question first. The input will be a single line containing capital and small letters. Lets assume the following: Capital LettersOpcode Small LettersOperands In AbcdEf, A is an opcode. The operands of A are b,c and d. Similarly, E is an opcode and its operands are f. The opcodes must be moved to the closest upper index that is a multiple of 4. So, AbcD must be AbcD, where '' means a blank (output is 1). Similarly, ABC must be ABC, so the output is 6. Similarly, AbcdeF must be AbcdeF, so the output is 3. The task is, to find the minimum number of ''s that are needed to be inserted to align the Opcodes accordingly. Here is my solution to this task: RESOLVED It is 42 chars long and its the second shortest. The first shortest is 39 chars long. Can u pls try to make it shorter? Edit: http://www.spoj.pl/problems/NOP/ Edit2: Corrected a small typo. (thanks to Ken)
Back to
Seekers of Perl Wisdom

