Skip to main content

Posts

Showing posts with the label programming

Java 8 coding challenge : Jarvis and Seven Segments

All over the world, peoples are working on energy solution. It would be a tough time for our next generation to survive if we don’t think about solution. Tony stark is working on a new project and wants to display his project using “ seven segment display - concept ”. Tony Stark gave Jarvis a task to find a number from his Favorite list of number for which the energy consumption is lowest. (Assuming that for a digit to represent Tony stark is using 7 bulbs and only those bulbs light up which are required to represent a number and rest other would be completely off. ) Help Jarvis and conserve energy. Seven segment display - https://en.wikipedia.org/wiki/Seven-segment_display Input: First line will contain the number of test cases and for every test case first line will contain length of favorite list and the second line for a test case will contain n numbers Output : For every test case print the answer. If there exist more than 1 numbers for which same number of bulbs are required than...

Java 8 coding challenge : Jarvis and Seven Segments

All over the world, peoples are working on energy solution. It would be a tough time for our next generation to survive if we don’t think about solution. Tony stark is working on a new project and wants to display his project using “ seven segment display - concept ”. Tony Stark gave Jarvis a task to find a number from his Favorite list of number for which the energy consumption is lowest. (Assuming that for a digit to represent Tony stark is using 7 bulbs and  only those bulbs light up which are required to represent a number and rest other would be completely off. ) Help Jarvis and conserve energy. Seven segment display -  https://en.wikipedia.org/wiki/Seven-segment_display Input: First line will contain the number of test cases and for every test case first line will contain length of favorite list and the second line for a test case will contain n numbers Output : For every test case print the answer. If there exist more than 1 numbers for which same number ...

Java 8 coding challenge: Addition ain't simple

Jack is awesome. His friends call him little Einstein. To test him, his friends gave him a string. They told him to add the string with its reverse string and follow these rules: Every  i th  character of string will be added to every  i th  character of reverse string. Both string will contain only lower case alphabets(a-z). Eg:- a+a=b,a+c=d,z+a=a (Refer to sample test cases for more details) Input: First line contains a value  N  denoting number of test cases. Next  N  lines contains string  str . Output: For every string  str  output the string that Jack's friends wants from him. Constraints 1 <= N <= 10 1 <= str <= 10^5 SAMPLE INPUT     4 hello codeapocalypse programming world SAMPLE OUTPUT     wqxqw hhtdmqrrqmdthh wfxtebetxfw aajaa Code: import java.io.*; import java.util.HashMap; import java.util.InputMismatchException; import java.util.Map; p...

Java 8 coding challenge: Addition ain't simple

Jack is awesome. His friends call him little Einstein. To test him, his friends gave him a string. They told him to add the string with its reverse string and follow these rules: Every i th character of string will be added to every i th character of reverse string. Both string will contain only lower case alphabets(a-z). Eg:- a+a=b,a+c=d,z+a=a (Refer to sample test cases for more details) Input: First line contains a value N denoting number of test cases. Next N lines contains string str . Output: For every string str output the string that Jack's friends wants from him. Constraints 1 <= N <= 10 1 <= str <= 10^5 SAMPLE INPUT 4 hello codeapocalypse programming world SAMPLE OUTPUT wqxqw hhtdmqrrqmdthh wfxtebetxfw aajaa Code: import java.io.*; import java.util.HashMap; import java.util.InputMismatchException; import java.util.Map; public class AdditionAintSimple { static class Print { private final BufferedWriter bw; public Print() { this.bw = new Buffere...

Java 8 Coding Challenge: COUNT NUMBERS

Your task is pretty simple , given a string  S  , find the total count of numbers present in the digit. Input The first line contains  T  , the number of test cases. The first line of each and every testc ase will contain a integer  N  , the length of the string . The second line of each and every test case will contain a string  S  of length  N . Output For each and every testcase , output the total count of numbers present in the string. Constraints 0<T<200 0<N<10000 SAMPLE INPUT     1 26 sadw96aeafae4awdw2wd100awd SAMPLE OUTPUT     4   Explanation For the first test case , the string given is "sadw96aeafae4awdw2wd100awd". There are total of 4 numbers in the string - [96,4,2,100]. So , we output 4. Code import java.io.BufferedReader; import java.io.InputStreamReader; class TestClass { public static void main(String args[] ) throws Exception { Buf...

Java 8 Coding Challenge: COUNT NUMBERS

Your task is pretty simple , given a string S , find the total count of numbers present in the digit. Input The first line contains T , the number of test cases. The first line of each and every testc ase will contain a integer N , the length of the string . The second line of each and every test case will contain a string S of length N . Output For each and every testcase , output the total count of numbers present in the string. Constraints 0<T<200 0<N<10000 SAMPLE INPUT 1 26 sadw96aeafae4awdw2wd100awd SAMPLE OUTPUT 4 Explanation For the first test case , the string given is "sadw96aeafae4awdw2wd100awd". There are total of 4 numbers in the string - [96,4,2,100]. So , we output 4. Code import java.io.BufferedReader; import java.io.InputStreamReader; class TestClass { public static void main(String args[] ) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int T = Integer.parseInt(br.readLine()); boolean bit...

Higher order infrastructure

Developer need not to worry about the underlying infrastructure, all he/she has to look into is the services running on them and the stack they write. You do not have to worry about where your code is running. Which leads to faster rollouts, faster releases, faster deployments. Even rollbacks have become piece of cake with having docker on your infrastructure. If there is any change in your service all you have to do is change the YAML (yet another markup language) file and you will have a completely new service in minutes.  Docker was build for scalabilty and high availability. It is very easy to load balance your services in docker, scale up and scale down as per your requirements.  The most basic application that is demoed by docker, is the following cat and dog polling polygot application. Each part of this application will be written and maintained by a different team. Add it will just get collaborated by docker. The above are the compone...

Higher order infrastructure

Developer need not to worry about the underlying infrastructure, all he/she has to look into is the services running on them and the stack they write. You do not have to worry about where your code is running. Which leads to faster rollouts, faster releases, faster deployments. Even rollbacks have become piece of cake with having docker on your infrastructure. If there is any change in your service all you have to do is change the YAML (yet another markup language) file and you will have a completely new service in minutes.  Docker was build for scalabilty and high availability. It is very easy to load balance your services in docker, scale up and scale down as per your requirements. The most basic application that is demoed by docker, is the following cat and dog polling polygot application. Each part of this application will be written and maintained by a different team. Add it will just get collaborated by docker. The above are the components required to get the docker application u...

Java 8 coding challenge: Count Divisors

Problem: You have been given  3  integers  l ,  r  and  k . Find how many numbers between  l  and  r  (both inclusive) are divisible by  k . You do not need to print these numbers, you just have to find their count. Input Format The first and only line of input contains 3 space separated integers  l ,  r  and  k . Output Format Print the required answer on a single line. Constraints 1 ≤ l ≤ r ≤ 1000 1≤l≤r≤1000 1 ≤ k ≤ 1000 1≤k≤1000 SAMPLE INPUT     1 10 1 SAMPLE OUTPUT     10 Code: /* IMPORTANT: Multiple classes and nested static classes are supported */ /* * uncomment this if you want to read input. //imports for BufferedReader import java.io.BufferedReader; import java.io.InputStreamReader; //import for Scanner and other utility classes import java.util.*; */ import java.util.Scanner; class TestClass { public static void main(String args[] ) thro...

Java 8 coding challenge: Count Divisors

Problem: You have been given 3  integers l , r and k . Find how many numbers between l  and r  (both inclusive) are divisible by k . You do not need to print these numbers, you just have to find their count. Input Format The first and only line of input contains 3 space separated integers l , r and k . Output Format Print the required answer on a single line. Constraints 1 ≤ l ≤ r ≤ 1000 1≤l≤r≤1000 1 ≤ k ≤ 1000 1≤k≤1000 SAMPLE INPUT 1 10 1 SAMPLE OUTPUT 10 Code: /* IMPORTANT: Multiple classes and nested static classes are supported */ /* * uncomment this if you want to read input. //imports for BufferedReader import java.io.BufferedReader; import java.io.InputStreamReader; //import for Scanner and other utility classes import java.util.*; */ import java.util.Scanner; class TestClass { public static void main(String args[] ) throws Exception { Scanner sc = new Scanner(System.in); int l = sc.nextInt(); int r = sc.nextInt(); int k = sc.nextInt(); sc.close(); int count = 0; ...

Java 8 coding challenge: Magical Word

Problem: Dhananjay has recently learned about  ASCII  values.He is very fond of experimenting. With his knowledge of  ASCII  values and character he has developed a special word and named it Dhananjay's Magical word. A word which consist of alphabets whose  ASCII  values is a prime number is an Dhananjay's Magical word. An alphabet is Dhananjay's Magical alphabet if its  ASCII  value is prime. Dhananjay's nature is to boast about the things he know or have learnt about. So just to defame his friends he gives few string to his friends and ask them to convert it to Dhananjay's Magical word. None of his friends would like to get insulted. Help them to convert the given strings to Dhananjay's Magical Word. Rules for converting: 1.Each character should be replaced by the nearest Dhananjay's Magical alphabet. 2.If the character is equidistant with 2 Magical alphabets. The one with lower  ASCII  value will be considered as its re...