Multiplication Table

Multiplication Table

Alice took up the fan and gloves, and, as the hall was very hot, she kept fanning herself all the time she went on talking: 'Dear, dear! How queer everything is to-day! And yesterday things went on just as usual. I wonder if I've been changed in the night? Let me think: was I the same when I got up this morning? I almost think I can remember feeling a little different. But if I'm not the same, the next question is, Who in the world am I? Ah, THAT'S the great puzzle!' And she began thinking over all the children she knew that were of the same age as herself, to see if she could have been changed for any of them.

"I'm sure I'm not Ada," she said, "for her hair goes in such long ringlets, and mine doesn't go in ringlets at all; and I'm sure I can't be Mabel, for I know all sorts of things, and she, oh! she knows such a very little! Besides, SHE'S she, and I'm I, and--oh dear, how puzzling it all is! I'll try if I know all the things I used to know. Let me see: four times five is twelve, and four times six is thirteen, and four times seven is--oh dear! I shall never get to twenty at that rate! However, the Multiplication Table doesn't signify:...

"Alice's Adventures in Wonderland." Lewis Carroll

After reading "Alice's Adventures in Wonderland," our robots decided to create their own "Multiplication table." Stephan would lead this mission (yeah, that probably was a bad idea). He forgot how to do multiplication and tried to invent a new method. It’s a rather strange method if we may be so blunt.

In Stephan's version of multiplication, we convert numbers to binary representation without leading zeroes. Then the first number is written vertically (up to down) and the second horizontally (left to right). With that, we fill a table with various binary operations for each crossing -- AND, OR, XOR, so we end up with three tables. In each table we convert rows to decimal and summarize it, then summarize the results of three tables. Let's look at several examples.

4 x 6 =
AND
X110decsum
111066
00000
00000
OR
X110decsum
11117 19
01106
01106
XOR
X110sum
10011 13
01106
01106
6 + 19 + 13 = 38

2 x 7 =
AND
X111decsum
111177
00000
OR
X111decsum
11117 14
01117
XOR
X111sum
10000 7
01117
7 + 14 + 7 = 28

7 x 2 =
AND
X10decsum
11026
1102
1102
OR
X10decsum
1113 9
1113
1113
XOR
X10sum
1011 3
1011
1011
6 + 9 + 3 = 18

You should help Stephan write a function to calculate this "multiplication". You are given two positive integers (n > 0), be careful with order of arguments.

Input: Two arguments as integers.

Output: The result of the Stephan's "multiplication", an integer.

Example:

checkio(4, 6) == 38
checkio(2, 7) == 28
checkio(7, 2) == 18
    

How it is used: In this task we play around with logical binary operations, the basis for computer science. Maybe you can find a use for this subject in cryptography?

Precondition: 0 < x < 100
0 < y < 100

45
Settings
Code:
Other:
Invalid hot key. Each hot key should be unique and valid
Hot keys:
CheckiO Extensions

CheckiO Extensions allow you to use local files to solve missions. More info in a blog post.

In order to install CheckiO client you'll need installed Python (version at least 3.8)

Install CheckiO Client first:

pip3 install checkio_client

Configure your tool

checkio --domain=py config --key=

Sync solutions into your local folder

checkio sync

(in beta testing) Launch local server so your browser can use it and sync solution between local file end extension on the fly. (doesn't work for safari)

checkio serv -d

Alternatevly, you can install Chrome extension or FF addon

checkio install-plugin
checkio install-plugin --ff
checkio install-plugin --chromium

Read more here about other functionality that the checkio client provides. Feel free to submit an issue in case of any difficulties.

Pair Programming (Beta-version)

Welcome to Pair Programming! Engage in real-time collaboration on coding projects by starting a session and sharing the provided unique URL with friends or colleagues. This feature is perfect for joint project development, debugging, or learning new skills together. Simply click 'Start Session' to begin your collaborative coding journey!

Waiting for Pair Programming to start...

You are trying to join a pair programming session that has not started yet.

Please wait for the session creator to join.

Waiting for Pair Programming to reconnect...

It looks like the creator of the pair programming session closed the editor window.

It might happen accidentally, so that you can wait for reconnection.

×
 
 
<< <
> >>
exec show

Whats Next?

Free accounts will see Best CheckiO solutions with some delay.
Best Solutions will be opened in a moment
Become Awesome and Don't wait
The next stage is ""
Will be activated in
View More Solutions Random Review Solutions Go to the next mission