
May 23rd, 2010, 04:12 AM
|
|
Registered User
|
|
Join Date: May 2010
Posts: 4
Time spent in forums: 1 h 21 m 43 sec
Reputation Power: 0
|
|
|
Multiplication algorythm
Hi all,
can someone give me an idea how to make to work something like this:
For example I have:
(a,b)*(c,d)
After it has to be:
ac,ad,bc,bd
That was simple, now when I get something like this:
((a1,a2)*(b1,b3))*((d1,d2)*(e1,e2))
I must get
(a1b1,a1b3,a2b1,a2b3)*(d1e1,d1e2,d2e1,d2e2)
and then
a1b1d1e1,a1b1d1e2,a1b1d2e1,a1b1d2e2 and so on,
I see it will be very long.
Anyway, problem is, how to know how many levels I have (in the last situation only two) but it can be x, so how do I know which one to start from?
P.S. I get a string, and have to return a string as a result.
Any help is appreciated,
ty in advance
|