This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Programming challenge: rotating a matrix 90 degrees in place | |
// Original post: https://blog.svpino.com/2015/05/10/programming-challenge-rotating-a-matrix-90-degrees-in-place | |
public class RotatingMatrix90DegreesInPlace { | |
private static int[][] matrix = { | |
{ 1, 2, 3, 4 }, | |
{ 5, 6, 7, 8 }, | |
{ 9, 10, 11, 12 }, | |
{ 13, 14, 15, 16 } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Arrays; | |
import java.util.Comparator; | |
// Solution to Problem 4 posted in "Five programming problems every Software Engineer should be able to solve in less than 1 hour" | |
// Original post: https://blog.svpino.com/2015/05/07/five-programming-problems-every-software-engineer-should-be-able-to-solve-in-less-than-1-hour | |
public class Main { | |
private static Integer[] VALUES = { 5, 2, 1, 9, 50, 56 }; | |
public static void main(String[] args) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.ArrayList; | |
// Solution to Problem 5 in "Five programming problems every Software Engineer should be able to solve in less than 1 hour" | |
// Original post: https://blog.svpino.com/2015/05/07/five-programming-problems-every-software-engineer-should-be-able-to-solve-in-less-than-1-hour | |
public class Main { | |
private static int TARGET_SUM = 100; | |
private static int[] VALUES = { 1, 2, 3, 4, 5, 6, 7, 8, 9 }; | |
static ArrayList add(int digit, String sign, ArrayList branches) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Arrays; | |
import java.util.Comparator; | |
// Programming challenge: Merging overlapping intervals | |
// Original post: https://blog.svpino.com/2015/05/17/programming-challenge-merging-overlapping-intervals | |
public class MergingOverlappingIntervals { | |
private static Integer[][] intervals = { | |
{1, 3}, | |
{2, 6}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Programming challenge: the position of the element | |
// Original post: https://blog.svpino.com/2015/05/24/programming-challenge-the-position-of-the-element | |
public class Main { | |
private static int[] array = { 1, 3, 5, 6 }; | |
// Solution using a sequential search - O(n) | |
private static int sequential(int target) { | |
if (target < array[0]) { | |
return 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This pipeline sums up a bunch of values. That simple. | |
class SumPipeline(pipeline.Pipeline): | |
def run(self, *values): | |
return sum(values) | |
# This pipeline takes care of computing the score of one specific player | |
class PlayerScorePipeline(pipeline.Pipeline): | |
def run(self, player, level): | |
# Let's call our remote REST API to return the score | |
# of this player on the supplied level. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Programming challenge: towers of Hanoi | |
// Original post: https://blog.svpino.com/2015/06/07/programming-challenge-towers-of-hanoi | |
public class Main { | |
private static int NUMBER_OF_DISKS = 3; | |
public static void towersOfHanoi(int n, String rod1, String rod2, String rod3) { | |
if (n == 1) { | |
System.out.println("* Move disk from " + rod1 + " to " + rod3); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select date(date_add(current_date(), if(dayofweek(current_date()) = 1, -6, -(dayofweek(current_date()) - 2)), "DAY")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select date | |
from | |
(select date_add(current_date(), -1, "DAY") as date), | |
(select date_add(current_date(), -2, "DAY") as date), | |
(select date_add(current_date(), -3, "DAY") as date), | |
(select date_add(current_date(), -4, "DAY") as date), | |
(select date_add(current_date(), -5, "DAY") as date), | |
(select date_add(current_date(), -6, "DAY") as date), | |
(select date_add(current_date(), -7, "DAY") as date) | |
where dayofweek(date) >= 2 and dayofweek(date) <= 6 |
OlderNewer