Friday, February 15, 2019

Dictionary

The problems in this set are designed to be more accessible to beginning coders. As a learning aid, walkthroughs discussing how to solve the problems in this set are available by clicking on this link. On completion of this problem set, students should have experience at using arrays to store, search through, and manipulate large data sets.

Dictionary

Input File: dictin.txt
Output File: dictout.txt
Time Limit: 1 second
Integerland and Wholenumberland are alike in many ways: similar culture, similar traditions - they even share the same national dress (the parenthetic pyjamas). Yet despite this, the two nations have never gotten along well. It is widely believed that this is because of their greatest differences - their language. A sentence that sounds perfectly intelligible on one side of the border is complete gibberish on the other side.
For example, if an Integerlander wanted to find out the time, she would ask, "140 2 87 2 3?". On the other hand, a Wholenumberlander would ask "19 71 555 71 556?". As you can see, these languages are very distinctive. It would be impossible to mistake one for the other.
This year's regional trade talks are to be held in Australia. You have been appointed the official translator for the proceedings. Using your trusty Integerlandese-Wholenumberlandese dictionary and your rusty laptop, you must be able to fluently translate from one language to another.

Input

The first line will consist of two integers d and w, separated by a space. You are guaranteed that 0 <= dw <= 1,000.
The following d lines will each describe an entry in your bilingual dictionary. Each of these lines contains two integers separated by a space: a word in Integerlandese, and its Wholenumberlandese counterpart. All integers will be between -2,000,000,000 and 2,000,000,000 inclusive. You are guaranteed that no Integerlandese word will appear more than once in the dictionary.
The following w lines will each contain a single word in Integerlandese for you to translate.

Output

For each Integerland word you are asked to translate, you must print out a single line containing the corresponding Wholenumberland word. If there is no translation in your dictionary, you should print "C?" for that line.

Please do get the solution by the link below: 

Monday, February 11, 2019

Python Operator


What coding can do?
What coding can help?
How python help us in coding ?

Python Operator is one of those basic but "powerful" problem solving tools.
We may use it to do arithmetic operation like solving our daily Mathematics questions.
We can't deny how powerful is it when it combine with other operators like Assignment operators, Comparison operators, Logical operators, Identity operators, Membership operators and bitwise operator.

Assignment operators, we can guess what it does by its name. Simpy - it do assignment.
Wait a second! What is assignment ?
Remember = means assignment and == means equal in python.
Some  may scratch his or her head when it come to here.
Kind of confusing, huh?
Lets say we have a variable name box, and we put RM 10 into it.
Simply the equation will be as follows:
box = 10 (This is called assignment)

But, is box equal to 10 ? No! box is a container to keep the money.

Then what == do ?
We use == when we need to do comparison, which will be discussed in Comparison Operators.

If my mother give me 3 ringgit more, then i should have:
box = 10
box = box + 3 (total money I got at the moment) (= 13)
This equation is  kind of too long, it could be abbreviated as :
box += 3

Simply, x-=3 means x = x - 3
x * = 2 means x = x*2

You may explore more in the notes provided in the link below.

Okay! Now, we may continue to Comparison operator.
For instance, I would like to check if I got RM 10 in my box.
I use box == 10 (it return true if I got RM 10 else return false)
I had RM 13 now, so the equation will return false.
Obviously, box == 13 will return true.

It could be a super long story if I continue the other operator here.
You may explore more from the link below.
Please do try the humble and simple question provided in the notes as exercise.

Practise Makes Perfect!

Week3 - Python operator

Superior of partial fraction

What is complex fraction? Complex fraction is a fraction whereby its numerator or denominator or both consists of fractions. Partial frac...