Showing posts with label KICTM 2015. Show all posts
Showing posts with label KICTM 2015. Show all posts

Sunday, August 14, 2016

Best Application to learn Difference Programming Languages Fast


App Name: Programming Hub
Package Name: com.freeit.java
Category: Education
Developer : Nexino Labs Pvt Ltd
Version: 3.0.6
Publish Date: July 30, 2016
File Size: Undefined
Installs: 1,000,000 - 5,000,000
Requires Android: 4.1 and up
Content Rating: Everyone
Developer: Visit website Email contactus@prghub.com


This is the best Application for me to Learn 18+ Programming languages such as Python, Assembly, HTML, VB.NET, C, C++, C# (CSharp), JavaScript, PHP, Ruby, R Programming, CSS, Java programming and much more! The new UI is quite interesting with new Material Design include the built-in playground where you can test your code in one app :D

With this app, i think is fastest way to learn any programming language by referring ready made programs and theory created by programming experts. Just download the language you want to learn or just request to the developer on what language you want or solutions.

Have an exam tomorrow?? :D No worries! By this app, forget your 600 page textbooks! Simply read this app essential and very precise reference material to score awesome marks!

Below is the Screenshot of this lastest app





Thursday, September 17, 2015

The Block Game (Mock KICTM UiTM Jasin 2015)

The citizens of Byteland regularly play a game. They have blocks each denoting some integer from 0 to 9. These are arranged together in a random manner without seeing to form different numbers keeping in mind that the first block is never a 0. Once they form a number they read in the reverse order to check if the number and its reverse is the same. If both are same then the player wins. We call such numbers palindrome

Ash happens to see this game and wants to simulate the same in the computer. As the first step he wants to take an input from the user and check if the number is palindrome and declare if the user wins or not

Input

The first line of the input contains T, the number of test cases. This is followed by T lines containing an integer N.

Output

For each input output "wins" if the number is a palindrome and "losses" if not.
Constraints

1<=T<=20
1<=N<=10000

Input:
3
331
666
343

Output:
losses
wins
wins


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import java.util.*;
import java.lang.*;
import java.math.*;

public class Mock4{
   public static void main(String[] args){
      Scanner scan = new Scanner(System.in);
      
      String line =System.getProperty("line.separator");
      scan.useDelimiter(line);
      
      int cases = scan.nextInt();
      
      for(int x=0;x<cases;x++){
         
         String get = scan.next();

         StringBuilder str = new StringBuilder(get);
         
         if(get.equals(str.reverse().toString()))
            System.out.println("wins");
         else
            System.out.println("loses"); 
         
      }
   }
}

Find Remainder (Mock KICTM UiTM Jasin 2015)

Write a program to find the remainder when two given numbers are divided.

Input and Output

The first line contains an integer T, total number of test cases. Then follow T lines, each line contains two integers A and B. Find remainder when A is divided by B

Constraints
1 <= T <= 1000
1 <=A,B <== 10000


Samples Input
3
1 2
100 200
10 40

Samples Output
1
100
10



 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
import java.util.*;
import java.lang.*;
import java.math.*;

public class Mock4{
   public static void main(String[] args){
      Scanner scan = new Scanner(System.in);
      
      String line =System.getProperty("line.separator");
      scan.useDelimiter(line);
      
      int cases = scan.nextInt();
      
      for(int x=0;x<cases;x++){
         
         String [] get = scan.next().split(" ");

         System.out.println(Integer.parseInt(get[0]) % Integer.parseInt(get[1]));
         
      }
   }
}

Typo! (Mock KICTM UiTM Jasin 2015)

A common typing error is to place the hands on the keyboard one row to the right of the correct position. So "Q" is typed as "W" and "J" is typed as "K" and so on. You are to decode a message typed in this manner.



Input

Input consists of several lines of text. Each line may contain digits, spaces, upper case letters (except Q, A, Z), or punctuation shown above [except back-quote (`)]. Keys labelled with words [Tab, BackSp, Control, etc.] are not represented in the input.

Output

You are to replace each letter or punctuation symbol by the one immediately to its left on the QWERTY keyboard shown above. Spaces in the input should be echoed in the output.

Sample Input

O S, GOMR YPFSU/

Sample Output

I AM FINE TODAY.



 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import java.util.*;
import java.lang.*;
import java.math.*;

public class Mock3{
   public static void main(String[] args){
      Scanner scan = new Scanner(System.in);
      
      String line =System.getProperty("line.separator");
      scan.useDelimiter(line);
      
      String get = scan.next();
      
      String str = "`1234567890-=QWERTYUIOP[]\\ASDFGHJKL;'ZXCVBNM,./";
      
      String ans="";
      for(int x=0;x<get.length();x++){
         if(get.charAt(x) != ' '){
            for(int y=0;y<str.length();y++){
               if(get.charAt(x) == str.charAt(y)){
                  ans = ans +""+ str.charAt(y-1);
                  break;
               }
            }
         }
         else{
            ans = ans + " ";
         }
      }
      
      System.out.print(ans);
    
   }
}

No Brainer (Mock KICTM UiTM Jasin 2015)

Zombies love to eat brains. Yum.

Input

The first line contains a single integer n indicating the number of data sets.

The following n lines each represent a data set. Each data set will be formatted according to the following description:

A single data set consists of a line "X Y", where X is the number of brains the zombie eats and Y is the number of brains the zombie requires to stay alive.

Output

For each data set, there will be exactly one line of output. This line will be "MMM BRAINS" if the number of brains the zombie eats is greater than or equal to the number of brains the zombie requires to stay alive. Otherwise, the line will be "NO BRAINS".

Sample Input

3
4 5
3 3
4 3

Sample Output

NO BRAINS
MMM BRAINS
MMM BRAINS



 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import java.util.*;
import java.lang.*;
import java.math.*;

public class Mock2{
   public static void main(String[] args){
      Scanner scan = new Scanner(System.in);
      
      String line =System.getProperty("line.separator");
      scan.useDelimiter(line);
      
      int cases = scan.nextInt();
      
      for(int x=0;x<cases;x++){
         
         String [] get = scan.next().split(" ");
         
         if(Integer.parseInt(get[0]) < Integer.parseInt(get[1]))
            System.out.println("NO BRAINS");
         else
            System.out.println("MMM BRAINS");
         
      }
   }
}

Sum It Up (Mock KICTM UiTM Jasin 2015)

The input begins with an integer K (0<=K<=100) which denotes the numbers of the test cases. This line is followed by K lines with a list of integers. The first value, N (1<=N <= 50), indicates the numbers of integers for the list, followed by N integers with value more than 0 ans less then 999999.

Sample input
2
4 3 2 1 1
3 4 5 5

Samples Output
7
14


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import java.util.*;
import java.lang.*;
import java.math.*;

public class Mock1{
   public static void main(String[] args){
      Scanner scan = new Scanner(System.in);
      
      String line =System.getProperty("line.separator");
      scan.useDelimiter(line);
      
      int cases = scan.nextInt();
      
      for(int x=0;x<cases;x++){
         
         String [] get = scan.next().split(" ");
         
         int total=0;
         for(int y=1;y<get.length;y++){
            total = total + Integer.parseInt(get[y]);
         }
         
         System.out.println(total);
         
      }
   }
}

Jumping Mario (KICTM UiTM Jasin 2015)

Mario is in the final castle. He now needs to jump over few walls and then enter the Koopa’s Chamber where he has to defeat the monster in order to save the princess. For this problem, we are only concerned with the “jumping over the wall” part.



You will be given the heights of N walls from left to right. Mario is currently standing on the first wall. He has to jump to the adjacent walls one after another until he reaches the last one. That means, he will make (N −1) jumps. A high jump is one where Mario has to jump to a taller wall, and similarly, a low jump is one where Mario has to jump to a shorter wall. Can you find out the total number of high jumps and low jumps Mario has to make?


Input
The first line of input is an integer T (T < 30) that indicates the number of test cases. Each case starts with an integer N (0 < N < 50) that determines the number of walls. The next line gives the height of the N walls from left to right. Each height is a positive integer not exceeding 10.

Output
For each case, output the case number followed by 2 integers, total high jumps and total low jumps, respectively. Look at the sample for exact format.

Sample Input
3
8
1 4 2 2 3 5 3 4
1
9
5
1 2 3 4 5

Samples Output
Case 1: 4 2
Case 2: 0 0
Case 3: 4 0


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import java.util.*;
import java.lang.*;
import java.math.*;

public class Q10{
   public static void main(String[] args){
      Scanner scan = new Scanner(System.in);
      
      String line = System.getProperty("line.separator");
      scan.useDelimiter(line);
      
      int cases = scan.nextInt();
            
      for(int x=0;x<cases;x++){
         int getj = scan.nextInt();
         String[] get = scan.next().split(" ");
         int counth=0,countl=0;
         
         for(int y=0;y<getj-1;y++){
            if(Integer.parseInt(get[y])<Integer.parseInt(get[y+1]))
               counth++;
            else if(Integer.parseInt(get[y])>Integer.parseInt(get[y+1]))
               countl++;
         }
          System.out.println("Case "+(x+1)+": "+counth+" "+countl);
      }
   } 
}

Automatic Answer (KICTM UiTM Jasin 2015)

Last month Alice nonchalantly entered her name in a draw for a Tapmaster 4000. Upon checking her mail today, she found a letter that read:

“Congratulations, Alice! You have won a Tapmaster 4000. To claim your prize, you must answer the following skill testing question.”

Alice’s initial feelings of surprised joy turned quickly to those of dismay. Her lifetime record for skill testing questions is an abysmal 3 right and 42 wrong.

Mad Skills, the leading skill testing question development company, was hired to provide skill testing questions for this particular Tapmaster 4000 draw. They decided to create a different skill testing question to each winner so that the winners could not collaborate to answer the question.

Can you help Alice win the Tapmaster 4000 by solving the skill testing question?

Input

The input begins with t (1 ≤ t ≤ 100), the number of test cases. Each test case contains an integer n (-1000 ≤ n ≤ 1000) on a line by itself. This n should be substituted into the skill testing question below.

Output

For each test case, output the answer to the following skill testing question on a line by itself: “Multiply n by 567, then divide the result by 9, then add 7492, then multiply by 235, then divide by 47, then subtract 498. What is the digit in the tens column?”


Input
2
637
-120

Output
1
3


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
import java.util.*;

public class Q9{
   public static void main(String[] args){
      Scanner scan = new Scanner(System.in);
      
      String line = System.getProperty("line.separator");
      scan.useDelimiter(line);
      
      int cases = scan.nextInt();                
      for(int x=0;x<cases;x++){
         int no = scan.nextInt();
         int total = ((((((no * 567)/9)+7492) * 235)/47)-498);
         String str = ""+total;
              
         int len= str.length();
         System.out.println(str.charAt(len-2));           
      }
   }
}

Relational Operator (KICTM UiTM Jasin 2015)

Some operators checks about the relationship between two values and these operators are called relational operators. Given two numerical values your job is just to find out the relationship between them that is

  • First one is greater than the second 
  • First one is less than the second 
  • First and second one is equal.


Input
First line of the input file is an integer t (t < 15) which denotes how many sets of inputs are there. Each of the next t lines contain two integers a and b (|a|,|b| < 1000000001).

Output
For each line of input produce one line of output. This line contains any one of the relational operators ‘>’, ‘<’ or ‘=’, which indicates the relation that is appropriate for the given two numbers.

Sample Input
3
10 20
20 10
10 10

Sample Output
<
>
=



 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import java.util.*;
import java.lang.*;
import java.math.*;

public class Q8{
   public static void main(String[] args){
      Scanner scan = new Scanner(System.in);
      
      String line = System.getProperty("line.separator");
      scan.useDelimiter(line);
      
      int cases = scan.nextInt();
            
      for(int x=0;x<cases;x++){
         String[] get = scan.next().split(" ");
         
         long val1 = Long.parseLong(get[0]);
         long val2 = Long.parseLong(get[1]);

         if(val1 < val2)
            System.out.println("<");
         else if(val1 > val2)
            System.out.println(">");
         else if(val1 == val2)
            System.out.println("=");
      }
   }
}

Division of Nlogonia (KICTM UiTM Jasin 2015)



After centuries of hostilities and skirmishes between the four nations living in the land generally known as Nlogonia, and years of negotiations involving diplomats, politicians and the armed forces of all interested parties, with mediation by UN, NATO, G7 and SBC, it was at last agreed by all the way to end the dispute, dividing the land into four independent territories.

It was agreed that one point, called division point, with coordinates established in the negotiations, would define the country division, in the following way. Two lines, both containing the division point, one in the North-South direction and one in the East-West direction, would be drawn on the map, dividing the land into four new countries. Starting from the Western-most, Northern-most quadrant, in clockwise direction, the new countries will be called Northwestern Nlogonia, Northeastern Nlogonia, Southeastern Nlogonia and Southwestern Nlogonia.



The UN determined that a page in the Internet should exist so that the inhabitants could check in which of the countries their homes are. You have been hired to help implementing the system.

Input
The input contains several test cases. The first line of a test case contains one integer K indicating the number of queries that will be made (0 < K ≤ 103). The second line of a test case contains two integers N and M representing the coordinates of the division point (-104 < N, M < 104). Each of the K following lines contains two integers X and Y representing the coordinates of a residence (-104 ≤ X, Y ≤ 104).

The end of input is indicated by a line containing only the number zero.

Output

For each test case in the input your program must print one line containing:

  • the word divisa (means border in Portuguese) if the residence is on one of the border lines (North-South or East-West);
  • NO (means NW in Portuguese) if the residence is in Northwestern Nlogonia;
  • NE if the residence is in Northeastern Nlogonia;
  • SE if the residence is in Southeastern Nlogonia;
  • SO (means SW in Portuguese) if the residence is in Southwestern Nlogonia.

Sample Input
3
2 1
10 10
-10 1
0 33
4
-1000 -1000
-1000 -1000
0 0
-2000 -10000
-999 -1001
0

Sample Output
NE
divisa
NO
divisa
NE
SO
SE

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import java.util.*;
import java.lang.*;
import java.math.*;

public class Q7{
   public static void main(String[] args){
      Scanner scan = new Scanner(System.in);
      
      String line = System.getProperty("line.separator");
      scan.useDelimiter(line);
  
      while(true){         
         int cases = scan.nextInt(); 
         if(cases == 0)
            break;
          
         String[] coor = scan.next().split(" ");
         int coorx = Integer.parseInt(coor[0]);
         int coory = Integer.parseInt(coor[1]);
         
         String[] input = new String[cases];
         for(int x=0;x<cases;x++){
            input[x] = scan.next();
               
            String[] get = input[x].split(" ");
            
            int getx = Integer.parseInt(get[0]);
            int gety = Integer.parseInt(get[1]);
            
            int totalx = getx-coorx;
            int totaly = gety-coory;
                        
            if(totalx == 0 || totaly == 0)
               System.out.println("divisa");
            else if(totalx >0 && totaly >0)
               System.out.println("NE");
            else if(totalx <0 && totaly >0)
               System.out.println("NO");
            else if(totalx <0 && totaly <0)
               System.out.println("SO");
            else if(totalx >0 && totaly <0)
               System.out.println("SE");
         }
      }
   }
}

The Snail (KICTM UiTM Jasin 2015)

A snail is at the bottom of a 6-foot well and wants to climb to the top. The snail can climb 3 feet while the sun is up, but slides down 1 foot at night while sleeping. The snail has a fatigue factor of 10%, which means that on each successive day the snail climbs 10% $\times$ 3 = 0.3 feet less than it did the previous day. (The distance lost to fatigue is always 10% of the first day's climbing distance.) On what day does the snail leave the well, i.e., what is the first day during which the snail's height exceeds 6 feet? (A day consists of a period of sunlight followed by a period of darkness.) As you can see from the following table, the snail leaves the well during the third day.


Your job is to solve this problem in general. Depending on the parameters of the problem, the snail will eventually either leave the well or slide back to the bottom of the well. (In other words, the snail's height will exceed the height of the well or become negative.) You must find out which happens first and on what day.

Input 
The input file contains one or more test cases, each on a line by itself. Each line contains four integers H, U, D, and F, separated by a single space. If H = 0 it signals the end of the input; otherwise, all four numbers will be between 1 and 100, inclusive. H is the height of the well in feet, U is the distance in feet that the snail can climb during the day, D is the distance in feet that the snail slides down during the night, and F is the fatigue factor expressed as a percentage. The snail never climbs a negative distance. If the fatigue factor drops the snail's climbing distance below zero, the snail does not climb at all that day. Regardless of how far the snail climbed, it always slides D feet at night.

Output 
For each test case, output a line indicating whether the snail succeeded (left the well) or failed (slide back to the bottom) and on what day. Format the output exactly as shown in the example.

Sample Input 
6 3 1 10
10 2 1 50
50 5 3 14
50 6 4 1
50 6 3 1
1 1 1 1
0 0 0 0

Sample Output 
success on day 3
failure on day 4
failure on day 7
failure on day 68
success on day 20
failure on day 2



 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import java.util.*;
import java.lang.*;
import java.math.*;

public class Q6{
   public static void main(String[] args){
      Scanner scan = new Scanner(System.in);
      
      String line = System.getProperty("line.separator");
      scan.useDelimiter(line);
      
      int x=0;
      while (true){
         String init = scan.next();
         String [] get = init.split(" ");
         
         if(init.equals("0 0 0 0")){
            break;
         }
         
         int well = Integer.parseInt(get[0]);
         float hei = Integer.parseInt(get[1]);
         float slid = Integer.parseInt(get[2]);
         float perce = Integer.parseInt(get[3]);
         
         float total =0;
         int day= 1;
         float less = hei*(perce/100);
         while(true){
            if(day != 1){
               hei = hei-less;
            }
            total = total+hei; 
            if(total>well){
               System.out.println("success on day "+(day));
               break;
            }
            total =total - slid;
            if(total<0){
               System.out.println("failure on day "+(day));
               break;
            }
            
            day++;
         }
         x++;
      }     
   }
}

Money Changing Problem (KICTM UiTM Jasin 2015)

A small local shop is having a problem because the assistants find it hard to work out how much change to give to customers. You have been asked to help them by writing a program that does all the work! Notes and coins available are as follows:

Notes: $20, $10, $5, $2, $1.
Coins: 50c, 20c, 10c, 5c.

As the smallest coin available is 5c, the cost of the purchase may need to be rounded to the nearest 5c, using the so-called Swedish rounding method. The rules for rounding are as follows:

1 or 2 cents = rounded down to 0.
3 or 4 cents = rounded up to 5.
6 or 7 cents = rounded down to 5.
8 or 9 cents = rounded up to 10.

The program must work out the change required and specify the notes and coins to use. In each case, the smallest possible number of notes and coins must be used.

Input 
Each line of input will represent a single transaction, and will contain 2 decimal numbers in the range 0.05 to 1000.00, each with two digits after the decimal point, and separated by a single space. The first number is the cost of a purchase, the second the amount the customer offers at the till. As mentioned, the cost of the purchase may need to be rounded, and, of course, the amount offered by the customer is a multiple of 5 cents. A line consisting of two 0.00 numbers marks the end of the input.

Output 
Your program must output one line for each transaction. Where the amount of money offered by the customer is not enough to cover the rounded purchase price, your program must output

Not enough money offered.

Where the amount of money offered by the customer is exactly the rounded purchase price, your program must output

Exact amount.

In all other cases output the sequence describing the change. Each sequence item starts with a note or coin value in the format described earlier (e.g., $2 or 10c), followed by a multiplication sign (i.e., an asterisk, `*') and ends with a repetition count (a number >= 1). Items are listed in order of decreasing values and are separated by single spaces.

Sample Input 

20.03 20.00
20.07 20.05
20.08 25.00
0.09 0.10
0.00 0.00

Sample Output 

Not enough money offered.
Exact amount.
$2*2 50c*1 20c*2
Exact amount.



 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
import java.util.*;
import java.lang.*;
import java.math.*;
import java.text.*;

public class Q5{
   public static void main(String[] args){
      Scanner scan = new Scanner(System.in);
      
      DecimalFormat df = new DecimalFormat("0.00");
      String line = System.getProperty("line.separator");
      scan.useDelimiter(line);
      
      while (true){
         String get = scan.next();
         String[] init = get.split(" ");
         
         if(get.equals("0.00 0.00"))
            break;
         
         int bil = Integer.parseInt(""+init[0].charAt(init[0].length()-1));
         
         if(bil == 1 || bil == 2)
            init[0] = init[0].substring(0,init[0].length()-1)+"0";
         else if(bil ==3 || bil == 4)
            init[0] = init[0].substring(0,init[0].length()-1)+"5";
         else if(bil ==6 || bil == 7)
            init[0] = init[0].substring(0,init[0].length()-1)+"5";
         else if(bil ==8 || bil == 9){
            init[0] = df.format(Float.parseFloat(init[0])+0.1);
            init[0] = init[0].substring(0,init[0].length()-1)+"0";
         }

         if(Float.parseFloat(init[0])>Float.parseFloat(init[1]))
            System.out.println("Not enough money offered.");
         else if(init[0].equals(init[1]))
            System.out.println("Exact amount.");
         else{
            String total = df.format(Float.parseFloat(init[1]) - Float.parseFloat(init[0]));
            System.out.println(findMin(Float.parseFloat(total)));
         }
      }  
   }
   
   public static String findMin(float total){
      float n = total*100;
      int [] sets = new int[]{5,10,20,50,100,200,500,1000,2000};
      List<String> list = new ArrayList<String>();
      int counta=0;
      
      while(n>0){
         int max = sets[0]; 
         //review my blog title "minumum coin change"  
         //find list of minumum coin change (sorted coins list)
         for(int x=sets.length-1;x>=0;x--){
            if(sets[x]<=n){
               max = sets[x];
               break;
            }
         }
         
         if(max>=100){
            //convert cents to dollar
            int rev = max/100;
            list.add("$"+rev);
         }
         else
            list.add(max+"c");

         n=n-max;
      }
      
      StringBuilder str = new StringBuilder();

      Set<String> set = new HashSet<String>(list); 
      String []newstr = new String[set.size()];
      set.toArray(newstr);
      
      for(int x=0;x<newstr.length;x++){
          for(int y=0;y<list.size();y++){
             if(newstr[x].equals(list.get(y))){
                counta++;
             }
          }
          str.append(newstr[x]+"*"+counta+" ");
          counta=0;
      }      
      return str.toString();
   }
   
   
}