Code Golf ChallengeWednesday 13 December
On Wednesday 13th December Seed Software held an open afternoon for second year Computer Science students who are interested in applying for our 2018/2019 Internship Programme.
We gave them a code golf challenge to enter into, with the winner taking home a Raspberry Pi 3 and 3D Xmas tree…
“You are tasked to create a program that can parse important information from a string.
You do not know what this data represents, only that it represents a numeric value.
You are only given the encoding scheme and some sample data:
- A vowel represents 1
- A consonant represents 2
- Any character that is not a letter represents 3
- The letters j, x, m and z are 'filler' characters and have no value.
- For each time AFTER the second occurrence of a particular character - the character counts as double its normal value.
The sum of these give the encoded number.
"a" should return 1
"aa" should return 2
"aaa" should return 4 (1 for the first occurrence, 1 for the second and 2 for the third)
"aaaa" should return 6 (1 for the first occurrence, 1 for the second, 2 for the third and 2 for the fourth)
"aaba" should return 6 (a : 4 b : 2)
"abcdefghijklmnopqrstuvwxyz" should return 39 (vowels : 5 x 1 = 5 consonants (excluding fillers) : 17 x 2 = 34)
"seed software" should return 23 ( s : 4 e : 4 d : 2 space : 3 o : 1 f : 2 t : 2 w : 2 a : 1 r : 2)
The string data will always be given in lower-case and will be passed in as a command-line argument when running your program.
Because of the highly-sensitive nature of this program, obfuscation is important, and readability is not.
You should create a valid C# Console Application that can be run from the Command Line eg. MyProgram.exe "this is some test input"
Your program should print the output to the Console window.
Your program's Source Code should contain the fewest amount of characters as possible.
All characters will be counted, including; but not limited to;
- Variable names
- Using statements
The name of the program i.e. The name that is typed in at the Command Prompt is not included.
You are not permitted to use any Library or Code that is not part of the .NET framework.”
Our current lowest character count is 266. Can you beat it? Let us know via our Facebook or Twitter account. Good luck!