I received via email a couple messages with two easy Python challenges named “Mod Divmod” and “Power – Mod Power”. Following are links to the challenges:
https://www.hackerrank.com/challenges/python-mod-divmod?utm_campaign=challenge-recommendation&utm_medium=email&utm_source=24-hour-campaign
https://www.hackerrank.com/challenges/python-power-mod-power?utm_campaign=challenge-recommendation&utm_medium=email&utm_source=24-hour-campaign
Not much to say. Following is the code for the first challenge:
# -*- coding: utf-8 -*-
# **** read integers ****
a = input()
b = input()
# **** ****
print(int(a) // int(b))
print(int(a) % int(b))
print(divmod(int(a), int(b)))
Following is the code for the second challenge:
# -*- coding: utf-8 -*-
# **** ****
a = int(input())
b = int(input())
c = int(input())
# **** ****
print(pow(a, b))
print(pow(a, b, c))
Implemented the code using the Spyder IDE shipped with Anaconda 3.
Both solutions were accepted each passing two test cases :o)
If you have comments or questions regarding this or any other post in this blog, please do not hesitate and send me a message. I will not use your name unless you explicitly tell me to do so.
John
john.canessa@gmail.com
Follow me on Twitter: @john_canessa