Hi,
I'm learning Perl and for now I'm on regexp. With my friend, we make some challnages for shortest code. We have such a task: We are given some words (of length at most 20). These words are made only from capital letters (A..Z). We want to count and print out 2**(number of letters A,B,C,D) for each line in the input (in separate lines).
Example:
AFFFBFFFFC
Answer: As there are 3 letters that interest us (A,B,C) the answer is 2**3=8, and 8 should be printed on output.
I've made it on 27 characters (counting also whitespaces), but my friends claims that it can be done on 24 chars. Programs consits of only code (no #!/usr/bin/perl needed) - they are run:
perl program.pl < input.txt
Bigger example:
Input:
AAAXXXXYYYYY
BBCCSSSSSSS
Output:
8
16
Input consist always from 10 lines.
I'm learning Perl and for now I'm on regexp. With my friend, we make some challnages for shortest code. We have such a task: We are given some words (of length at most 20). These words are made only from capital letters (A..Z). We want to count and print out 2**(number of letters A,B,C,D) for each line in the input (in separate lines).
Example:
AFFFBFFFFC
Answer: As there are 3 letters that interest us (A,B,C) the answer is 2**3=8, and 8 should be printed on output.
I've made it on 27 characters (counting also whitespaces), but my friends claims that it can be done on 24 chars. Programs consits of only code (no #!/usr/bin/perl needed) - they are run:
perl program.pl < input.txt
Bigger example:
Input:
AAAXXXXYYYYY
BBCCSSSSSSS
Output:
8
16
Input consist always from 10 lines.