Extreme Programming Explained

Book Introduction XP is a style of software development focusing on excellent application of programming techniques, clear communication, and teamwork which allow us to accomplish things we previously could not even imagine. XP Includes: A philosophy of software development based on the values of communication, feedback, simplicity, courage, and respect. A body of practices proven useful in improving software development, The practices complement each er, amplifying their effects. The are chosen as expressions of the values. [Read More]

Clean Code

Book Introduction Programmers create problems for themselves when they write code solely to satisfy a compiler or interpreter. Have you ever been significantly impeded by bad code? If you’re a programmer if any experience then you’ve felt this impediment many times. Indeed, we have a name for it “wading”. Attitude Most managers want good code, even when they are obsessing about the schedule. They may defend the schedule and requirements with passion; but that’s their job. [Read More]

Best Practices

Give me a lever long enough and a fulcrum on which to place it, and I shall move the world. ~ Archimedes. Wikipedia defines it as a “method or technique that has consistently shown results superior to those achieved with other means, and that is used as a benchmark.” It is really important to use techniques and methods to guarantee quality results in processes and products in software development, so I decided to write up the software engineering practices and principles I’ve learned over the years. [Read More]

Kangaroo

There are two kangaroos on a number line ready to jump in the positive direction. Each kangaroo takes the same amount of time to make a jump, regardless of distance. That is, if kangaroo one jumps 3 meters and kangaroo two jumps 5 meters, they each do it in one second, for example. Given the starting locations and jump distances for each kangaroo, determine if and when they will land at the same location at the same time. [Read More]

Apple and Orange

Sam’s house has an apple tree and an orange tree that yield an abundance of fruit. Sam’s two children, Larry and Rob, decide to play a game in which they each climb a tree and throw fruit at their (Sam’s) house. Each fruit that lands on the house scores one point for the one who threw it. Larry climbs the tree on the left (the apple), and Rob climbs the one on the right (the orange). [Read More]

Grading Students

At HackerLand University, a passing grade is any grade 40 points or higher on a 100 point scale. Sam is a professor at the university and likes to round each student’s grade according to the following rules: If the difference between the grade and the next higher multiple of 5 is less than 3, round to the next higher multiple of 5 If the grade is less than 38, don’t bother as it’s still a failing grade Automate the rounding process then round a list of grades and print the results. [Read More]

Matrix Diagonal Difference

Input Given a square matrix of size N x N, calculate the absolute difference between the sums of its diagonals. Output Print the absolute difference between the two sums of the matrix’s diagonals as a single integer. Sample Input $$ matrix = \begin{bmatrix} 11 & 2 & 4 \newline 4 & 5 & 6 \newline 10 & 8 &-12 \end{bmatrix} $$ Sample Output 15 Explanation The primary diagonal is: $$ \begin{bmatrix} 11 \newline 5 \newline -12 \end{bmatrix} $$ [Read More]

Get Month Name

Map the given integer to a month. Explanation For month = 1, the output should be getMonthName(month) = "Jan" For month = 0, the output should be getMonthName(month) = "invalid month" Solution import java.util.Locale; import java.text.DateFormatSymbols; public class MonthNamer { private final static INVALID_MONTH_LABEL = "invalid month"; private String getMonthName(Integer month){ if(month < 1 || month > 12){ return INVALID_MONTH_LABEL; } return new DateFormatSymbols(Locale.ENGLISH).getShortMonths()[month-1]; } public static void main(String[] args){ Integer month = 1; String result = new MonthNamer(). [Read More]

Is Pangram

Given a sentence, check whether it is a pangram or not. Explanation For sentence = “The quick brown fox jumps over the lazy dog.”, the output should be isPangram(sentence) = true. For sentence = “Hello World!”, the output should be isPangram(sentence) = false. Solution public class PangramVerifier { private static final int ASCII_ALPHABET_SUM = 2015; private Boolean isPangram(String quote){ Integer sum = quote.toUpperCase().chars().filter(x -> x > 64 & x < 91). [Read More]

Stream Merger

Let’s consider the following class: import java.util.Set; import java.util.HashSet; class InputStream { int getStreamId(){ return 0; } } class OutputStream { void emitValue(int value){} } public class StreamMerger { private Set<InputStream> streams; public StreamMerger(Set<InputStream> streams){ this.streams = streams; } public void mergeInto(OutputStream stream){ } public static void main(String[] args){ new StreamMerger(new HashSet<InputStream>()); } } Our goal is to get a collection of streams order it by stream id and then merge those elements into an output stream. [Read More]