iCPROM2017 CONTEST Question
iCPROM2017 CONTEST Question
iC-PROM 2017
CONTEST
This problem set contains 10 questions (A – J)
26 November 2017
Organized by
Computer Science Department, UiTM Perlis
PROBLEM A THE NEXT NUMBER
A relatively simple task for humans to do is to identify the next number in an arithmetic
sequence of numbers. For example, given the sequence of number 3, 6, and 9, we know that
the next number in sequence is 12, since each number is followed by a number increasing it
by 3.
Your task is to write a program that will deduce the next integer in a given sequence of three
integers where the same arithmetic operation is applied to each integer to produce the next.
The only arithmetic operations that will be used are addition, subtraction, multiplication, or
division.
Input
The first line of the input contains an integer N (1 ≤ N ≤ 5), the number of test cases. Following
the first line are the test cases. Each line of a test case contains three integers with each pair
of integers separated by a single space.
The input must be read from standard input.
Output
The output will print the next integer number in the corresponding input sequence. The
output is to be formatted exactly like that for the sample output given below.
A sentence consists of vowels, consonants, special characters and numbers. Imagine if you
are able to count manually how many vowels of a, e, i, o and u from a sentence or strings.
The vowel extractor codes are able to extract vowels from a sentence or string and count
number of occurrences of each vowel. The formation of vowels will be printed according to
number of occurrences of each vowel.
Input
The first line of input contains an integer number N (1 ≤ N ≤ 5) represents the number of test
cases. Following the first line are the test cases. Each line of a test case contains a sentence.
The input must be read from standard input.
Output
The output of the program should display as shown in the following sample of output.
Display the sentence of each test case before the formation of each vowel is printed.
The output must be written to standard output.
3 I love programming.
I love programming. a
Why Dr Ng Cry? e
Hmmmm... what happened if monkey i
take over the OS class? I
oo
Why Dr Ng Cry?
A binary number is a number expressed in the binary numeral system or base-2 numeral
system which represents numeric values using two different symbols: typically 0 (zero) and 1
(one). For example, the machine code consists of binary number or hexadecimal instructions
that a computer can respond directly.
The idea of this problem is to convert a binary number to the non-negative integer number.
Input
The first line of input contains an integer number N (1 ≤ N ≤ 5) represents the number of test
cases. Following the first line are the test cases. Each line of test case contains a binary
number. The length of each test case or the binary number is less than 6 digits.
The input must be read from standard input.
Output
The output of the program should display as shown in the following sample of output.
Display the integer number for each binary number. If the test case is not a binary number,
display “Invalid binary number”
Write a program that is able to calculate the number of lamp posts passed by a car when it is
driving at specified speed for a certain period of time. Each lamp post is placed 35m from
each other.
Input
1. Average travelling speed of the car.
2. Amount of time in hours.
Output
Number of lamp post.
Sequence number consists of series of numbers in any order. Amongst the most popular
sequence numbers are Arithmetic and Geometric.
Arithmetic sequence numbers are consistently having the same difference between the
consecutive number in a series. Given the following sequence number and you will realize
that the difference of each consecutive number in a series is always consistently the same.
7 11 15 19 23 27 31 35 39 43
11 - 7 15 – 11 19 - 15 23 – 19 27 - 23 31 – 27 35 - 31 39 – 35 43 – 39
4 4 4 4 4 4 4 4 4
Geometric sequence numbers are consistently having the same ratio when the current number
divided by the previous number. The following example shows the geometric sequence
numbers consistently having the same ratio proceeding the series of numbers.
The purpose of this problem is to determine the sequence number is either Arithmetic or
Geometric sequence.
Input
The first line of input contains an integer number N (1 ≤ N ≤ 5) represents the number of test
cases. Following the first line are the test cases. Each line of test case contains series of
integer numbers separated by comma (,). Number of item for each set of test cases is less
than 10 integer numbers.
The input must be read from standard input.
Output
The output of the program should display as shown in the following sample of output.
Display each test case either Arithmetic, Geometric or Invalid sequence number.
5
6,9,12,15,18,21,24,27 Arithmetic Sequence
7,14,28,56,112,224,448,896 Geometric Sequence
100,90,80,70,50,40,30 Invalid sequence
135,100,65,30,-5,-40 Arithmetic Sequence
2000,1000,500,250,125 Geometric Sequence
To rotate an array elements means to move all elements in the array from the beginning and
transfer them to the end according to the number of movements required by user.
Input
The first line of the input contains 5 integers stored in an array. Following the first line is the
number of movements the array should perform.
The input must be read from standard input.
Output
The output of the program should print the array’s elements after the rotation.
The output must be written to standard output.
1 2 3 4 5 3 4 5 1 2
2
10 20 30 40 50 40 50 10 20 30
3
100 150 200 250 300 300 100 150 200 250
4
In Artificial Intelligence, there is a subset field called machine learning which provides the
computer the ability to automatically learn and improve from experience without being explicitly
programmed.
One of such simple and very popular technique is k-NN (K-Nearest Neighbours).
k-NN works by searching the k nearest points (neighbours) to the desired point. By getting the
nearest points, k-NN will try to make an assumption based on the nearest points’ classes and
use that to predict the class of the desired point. In A.I. this is also called classifying problem
as we want to predict the class of the desired point.
k=7
For example, above is set of points with two classes (A = black circle, B = transparent circle).
X is a point that we desired to predict. k is number of nearest points that we want to find (which
in this case is 7). By searching the distances between X and all points, we then sort out the
result. Based on the nearest seven points to the X, we found out that there are 2 and in class
A and 5 are in the class B. By getting this information, k-NN will choose the highest frequency
among all the classes and uses that determine class of X (which in case X = class B).
Input
First line of input has P (5 ≤ P ≤ 20), which represent number of points in the cartesian plane.
For each P lines, there will contain three input X, Y, C where the first two input represent the
coordinate of the point and C represent its class.
X (0 ≤ X ≤ 10), Y (0 ≤ Y ≤ 10), C (1 ≤ C ≤ 2).
Next line will contain T (1 ≤ P ≤ 5), where it represents the number of test case(s). For each
next T lines, there will be three value I, J and K, where I and J represent location of point
where we want to predict, and K represent how much nearest nodes we want to compare.
I (0 ≤ I ≤ 10), J (0 ≤ J ≤ 10), K (1 ≤ K ≤ P) and K is odd number.
Output
Print the the case number ‘Case #n:’; n is test case number followed by class predicted by
your k-NN algorithm. Please note that there will be only two classes, 1 and 2.
5 Case #1: 1
4 2 1 Case #2: 2
7 2 2 Case #3: 1
3 6 1
7 4 2
2 3 1
3
3 4 1
5 4 3
4 4 5
Hint:
Write a program that is able to list out all the even and odd numbers in a number ranging
from 100,000 to 999,999.
Input:
An integer number from 100,000 to 999,000.
Output:
2 lists of numbers; 1 list of even numbers and another list of odd numbers.
Solve above equation will get x = 1, y = 2 and z = 3. Using this value, you can solve the above
equations.
Input
The first line of the input contains an integer T (T ≤ 100), number of test cases. Each of the
following T lines will input the size of matrix n (n ≤ 10), the following n lines will contain n+1
value which in the form of augmented matrix.
Output
For each test case, the output contains a line in the format Case #x: M, where x is the case
number (starting from 1) and M is the variable values in one decimal point separated by space.
When we divide two integer numbers, we will get a quotient and a remainder. You are asked
to write a program to find a quotient and a remainder, when a bigger number is being divided
by the smaller number (do not assume that the numbers are entered in any order). For
example, when numbers 4 and 2 are entered, the answer is Q 2 R 0 or, when 2 and 7 are
entered, it will give the answer is Q 3 R 1 (where, Q represents a quotient and R represents a
remainder.
Input
The first line of the input contains an integer N (1 ≤ N ≤ 5), the number of test cases. Following
the first line are the test cases. Each line of a test case contains two non-negative integer
numbers.
The input must be read from standard input.
Output
The output of the program should display the answer in the form Q <quotient> R<remainder>.
The output must be written to standard output.