r/dailyprogrammer • u/rya11111 3 1 • Mar 27 '12
[3/27/2012] Challenge #31 [easy]
Write a function that takes two base-26 numbers in which digits are represented by letters with A=0, B=1, … Z=25 and returns their product using the same notation. As an example, CSGHJ × CBA = FNEUZJA.
Your task is to write the base-26 multiplication function.
Try to be very efficient in your code!
7
Upvotes
3
u/campsun Mar 27 '12 edited Mar 27 '12
My try in Python. I have no clue how efficient it is. And it doesn't do any validation.
Output:
2
u/luxgladius 0 0 Mar 27 '12
You want efficient? I'll give you efficient.
C (not Perl) with input validation and error-checking, though it doesn't check for overflow
Output
2
u/[deleted] Mar 29 '12 edited Mar 29 '12
perl script.pl CBA CSGHJ
FNEUZJA
run time: real 0m0.002s
1
u/emcoffey3 0 0 May 05 '12
Here's my solution in C#. There may be some bugs... I didn't test it all that extensively.