I hereby claim:
- I am scottoasis on github.
- I am scottoasis (https://keybase.io/scottoasis) on keybase.
- I have a public key ASC2moFGfe3C14Y3b-DN0tsEl_ewiCd9jptDOylJpu8Tkwo
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
#!/usr/bin/env ruby | |
# | |
# | |
# - Water Filling Problem - | |
# | |
# Imagine we have several columns of bricks forming a | |
# wall-like structure just like this,: | |
# | |
# +-+ +-+ +-+ +-+ | |
# +-+ +-+-+-+ +-+ +-+-+ +-+-+ |
/* | |
* test cases | |
* | |
* case 1. | |
* | |
* #============# | |
* #===#====#===# | |
* #==##==####### | |
* #=############ | |
* #=############ |
#include <stdio.h> | |
int main () { | |
int num; | |
scanf("%d", &num); | |
if (num <= 0) { |
object InsertSort { | |
type T = Int | |
def apply(xs: Seq[T]) = insertSort (Nil) (xs) | |
def insertSort(xs: Seq[T])(ys: Seq[T]): Seq[T] = | |
if (ys isEmpty) xs | |
else insertSort (insertWhile (x => x >= ys.head) (ys.head) (xs)) (ys.tail) | |
def insertWhile(crit: T => Boolean)(x: T)(xs: Seq[T]): Seq[T] = |
object PlayWithString { | |
def isMatching(pat: String)(str: String): Boolean = | |
/* | |
-- termination -- | |
*/ | |
if (pat == "*" || (pat.isEmpty && str.isEmpty)) true | |
else if ((pat.isEmpty && !str.isEmpty) || (str.isEmpty)) false | |
/* | |
-- induction -- |