Skip to content

Instantly share code, notes, and snippets.

View keshavsaharia's full-sized avatar

Keshav Saharia keshavsaharia

View GitHub Profile
@keshavsaharia
keshavsaharia / MarkTwainWroteIt.java
Created November 9, 2014 00:40
Mark Twain wrote it
import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
public class MarkTwainWroteIt {
@keshavsaharia
keshavsaharia / conways
Created January 10, 2015 22:18
Conway's game of life utility functions
public static void step() {
boolean[][] newGrid = new boolean[50][50];
for (int x = 0 ; x < 50 ; x++) {
for (int y = 0 ; y < 50 ; y++) {
// Get how many neighbors this cell has.
int count = neighbors(x, y);
// 1. If the square is alive, but has less than two neighbors, it dies.
if (grid[x][y] == true && count < 2) {
@keshavsaharia
keshavsaharia / Card.java
Created January 10, 2015 23:10
Card.java
import zen.core.Zen;
public class Card {
public static final int HEART = 1;
public static final int DIAMOND = 2;
public static final int SPADE = 3;
public static final int CLOVER = 4;
public static final int JACK = 11;
import zen.core.Zen;
public class Play2048 {
static int[][] board;
private static final int UP = 0;
private static final int DOWN = 1;
private static final int LEFT = 2;
private static final int RIGHT = 3;
<!DOCTYPE html>
<html>
<head>
<style>
/* Style the things in the page */
body {
}
button {
@keshavsaharia
keshavsaharia / README.md
Last active February 17, 2017 05:48
problem: Fizz Buzz

Fizz Buzz

Write a program that prints the numbers from 1 to 100. However, for multiples of three, print "fizz" instead of the number. For the multiples of five, print "buzz", instead of the number. For numbers which are multiples of both three and five, print "fizzbuzz".