Querying the Document C
A document is represented as a collection paragraphs, a paragraph is represented as a collection of sentences, a sentence is represented as a collection of words and a word is represented as a collection of lower-case ([a-z]) and upper-case ([A-Z]) English characters. You will convert a raw text document into its component paragraphs, sentences and words. To test your results, queries will ask you to return a specific paragraph, sentence or word as described below. Alicia is studying the C
View Solution →Boxes through a Tunnel C
You are transporting some boxes through a tunnel, where each box is a parallelepiped, and is characterized by its length, width and height. The height of the tunnel 41 feet and the width can be assumed to be infinite. A box can be carried through the tunnel only if its height is strictly less than the tunnel's height. Find the volume of each box that can be successfully transported to the other end of the tunnel. Note: Boxes cannot be rotated. Input Format The first line contains a sing
View Solution →String Formatting Python
Given an integer, n, print the following values for each integer i from 1 to n: 1. Decimal 2. Octal 3. Hexadecimal (capitalized) 4. Binary The four values must be printed on a single line in the order specified above for each i from 1 to n. Each value should be space-padded to match the width of the binary value of n. Input Format: A single integer denoting n. Constraints: 1<=n<=99 Output Format: Print n lines where each line i (in the range 1<
View Solution →Mod Divmod Python
One of the built-in functions of Python is divmod, which takes two arguments a and b and returns a tuple containing the quotient of a/b first and then the remainder a. For example: >>> print divmod(177,10) (17, 7) Here, the integer division is 177/10 => 17 and the modulo operator is 177%10 => 7. Task: Read in two integers, a and b, and print three lines. The first line is the integer division a//b (While using Python2 remember to import division from __future__). The second line
View Solution →Power-Mod Power Python
So far, we have only heard of Python's powers. Now, we will witness them! Powers or exponents in Python can be calculated using the built-in power function. Call the power function a^b as shown below: >>> pow(a,b) or >>> a**b It's also possible to calculate a^b mod m. >>> pow(a,b,m) This is very helpful in computations where you have to print the resultant % mod. Note: Here, a and b can be floats or negatives, but, if a third argument is present, b cannot be negative. Not
View Solution →