title-img


Integers Come In All Sizes Python

Integers in Python can be as big as the bytes in your machine's memory. There is no limit in size as there is: 2^31-1 (c++ int) or 2^63-1 (C++ long long int). As we know, the result of a^b grows really fast with increasing b. Let's do some calculations on very large integers. Task: Read four numbers, a, b, c, and d, and print the result of a^b+c^d. Input Format: Integers a, b, c, and d are given on four separate lines, respectively. Constraints: 1. 1<=a<=1000 2.

View Solution →

Triangle Quest Python

You are given a positive integer N. Print a numerical triangle of height N-1 like the one below: 1 22 333 4444 55555 ...... Can you do it using only arithmetic operations, a single for loop and print statement? Use no more than two lines. The first line (the for statement) is already written for you. You have to complete the print statement. Note: Using anything related to strings will give a score of 0. Input Format: A single line containing integer, N. Constraints:

View Solution →

Triangle Quest 2 Python

You are given a positive integer N. Your task is to print a palindromic triangle of size N. For example, a palindromic triangle of size 5 is: 1 121 12321 1234321 123454321 You can't take more than two lines. The first line (a for-statement) is already written for you. You have to complete the code using exactly one print statement. Note: Using anything related to strings will give a score of 0. Using more than one for-statement will give a score of 0. Input Format: A

View Solution →

Java Generics

Generic methods are a very efficient way to handle multiple datatypes using a single method. This problem will test your knowledge on Java Generic methods. Let's say you have an integer array and a string array. You have to write a single method printArray that can print all the elements of both arrays. The method should be able to accept both integer arrays or string arrays. You are given code in the editor. Complete the code so that it prints the following lines: 1 2 3 Hello World Do

View Solution →

Java Comparator

Comparators are used to compare two objects. In this challenge, you'll create a comparator and use it to sort an array. The Player class is provided for you in your editor. It has 2 fields: a name String and a score integer. Given an array of n Player objects, write a comparator that sorts them in order of decreasing score; if 2 or more players have the same score, sort those players alphabetically by name. To do this, you must create a Checker class that implements the Comparator interface, t

View Solution →