Given two positive numbers X and Y. Find the maximum value integer A such that:
a. A divides X i.e. X % A = 0
b. A and Y are co-prime i.e. gcd(A, Y) = 1
For example:
X = 30
Y = 12
We return
A = 5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
Write a program to print all the permutations of a given string. For example: | |
Input : ABC | |
Output: ABC ACB BAC BCA CAB CBA | |
''' | |
from itertools import permutations | |
def print_permutations(s): | |
"""Prints permutations of a given string""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
You are a professional robber planning to rob houses along a street. Each house has | |
a certain amount of money stashed, the only constraint stopping you from robbing each | |
of them is that adjacent houses have security systems connected and it will | |
automatically contact the police if two adjacent houses were broken into on the | |
same night. | |
Given a list of non-negative integers representing the amount of money of each house, | |
determine the maximum amount of money you can rob tonight without alerting the | |
police. | |
''' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
You are given a string S, you have to find all the ‘amazing’ substrings of S. | |
‘Amazing’ substring is one that starts with a vowel (a,e,i,o,u,A,E,I,O,U) | |
Example: | |
Input: ABEC | |
Output: 6 | |
Explanation: Amazing substrings of given string are : | |
1. A | |
2. AB | |
3. ABE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import urllib.request | |
from bs4 import BeautifulSoup | |
import zipfile, io | |
import os | |
url= 'http://staging.imgtranslate.com:9999/' | |
extension = ".zip" | |
r = requests.get(url) |