Skip to content

Instantly share code, notes, and snippets.

@joist
joist / Puddles.java
Last active Dec 26, 2015
My naive solution to a programmer puzzle I saw on hackernews. https://news.ycombinator.com/item?id=6639839 edit: Added the smart way of doing it too
View Puddles.java
public class Puddles
{
public static void main(String[] args) throws Exception
{
//set heights, need 2 or more
int[] groundheights = {2, 5, 1, 2, 3, 4, 7, 7, 6};
String gh = "Ground heights: ";
for (int i = 0; i<groundheights.length; i++)
{
if (i == 0) {