Skip to main content

Posts

Showing posts with the label coding

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: Raees's Liquor Tank

Raees wants to build a new tank to hide his illegal liquor . He comes up with some designs . Now he asks you to find out maximum units of liquor he can fill in the tank. You are given  N  elements , corresponding to heights of walls . See the figure for input 0 ,8 ,0 ,4 ,0 ,3 ,0 ,5 ,0 ,3 ,0 ,1 ,0. Maximum amount of liquor that can be filled is 5 + 1 + 5 + 2 + 5 + 3 + 1 = 22. Eg : For input 4 ,2 ,4 ,3 Output will be 2 . INPUT First line of input contains a single integer  N . Second line of input contains  N  non-negative integers (  A0  ---  A(n-1)  ). OUTPUT Single integer , answer to the Raees's question. CONSTRAINTS 1 <=  N  <= 1000 1 <=  Ai  <= 1000 SAMPLE INPUT 13 0 8 0 4 0 3 0 5 0 3 0 1 0 SAMPLE OUTPUT 22  Code: import java.io.*; import java.util.*; import java.math.*; import java.lang.*; import static java.lang.Math.*; public class Q1 {...

Java 8 Coding challenge: Raees's Liquor Tank

Raees wants to build a new tank to hide his illegal liquor . He comes up with some designs . Now he asks you to find out maximum units of liquor he can fill in the tank. You are given N elements , corresponding to heights of walls . See the figure for input 0 ,8 ,0 ,4 ,0 ,3 ,0 ,5 ,0 ,3 ,0 ,1 ,0. Maximum amount of liquor that can be filled is 5 + 1 + 5 + 2 + 5 + 3 + 1 = 22. Eg : For input 4 ,2 ,4 ,3 Output will be 2 . INPUT First line of input contains a single integer N . Second line of input contains N non-negative integers ( A0 --- A(n-1) ). OUTPUT Single integer , answer to the Raees's question. CONSTRAINTS 1 <= N <= 1000 1 <= Ai <= 1000 SAMPLE INPUT 13 0 8 0 4 0 3 0 5 0 3 0 1 0 SAMPLE OUTPUT 22  Code: import java.io.*; import java.util.*; import java.math.*; import java.lang.*; import static java.lang.Math.*; public class Q1 { static class InputReader { private InputStream stream; private byte[] buf = new byte[1024]; private int curChar; priv...

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...

Microservices at Netflix scale

Netflix took 7 years to completely transform to microservices. The traditional approach that was followed was that developers contributed to their individual jars/wars which would go through the regular sprint iteration. As can be seen above that there are issues with the velocity for delivery and reliability. Any one change in one service it would reflect into the other services which was very difficult to handle. This caused too many bugs and single point database. Few years back the production database of netflix got corrupted and the users/customers saw the following message. At netflix they want their services to isolate single point failures so here comes Hystrix.  Hystrix  is a latency and fault tolerance library designed to isolate points of access to remote systems, services and 3rd party libraries, stop cascading failure and enable resilience in complex distributed systems where failure is inevitable. They test their system w...

Microservices at Netflix scale

Netflix took 7 years to completely transform to microservices. The traditional approach that was followed was that developers contributed to their individual jars/wars which would go through the regular sprint iteration. As can be seen above that there are issues with the velocity for delivery and reliability. Any one change in one service it would reflect into the other services which was very difficult to handle. This caused too many bugs and single point database. Few years back the production database of netflix got corrupted and the users/customers saw the following message. At netflix they want their services to isolate single point failures so here comes Hystrix.  Hystrix is a latency and fault tolerance library designed to isolate points of access to remote systems, services and 3rd party libraries, stop cascading failure and enable resilience in complex distributed systems where failure is inevitable. They test their system with fault injection test framework (FIT).