hidden text
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
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 -- |
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
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] = |
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
#include <stdio.h> | |
int main () { | |
int num; | |
scanf("%d", &num); | |
if (num <= 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
/* | |
* test cases | |
* | |
* case 1. | |
* | |
* #============# | |
* #===#====#===# | |
* #==##==####### | |
* #=############ | |
* #=############ |
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
#!/usr/bin/env ruby | |
# | |
# | |
# - Water Filling Problem - | |
# | |
# Imagine we have several columns of bricks forming a | |
# wall-like structure just like this,: | |
# | |
# +-+ +-+ +-+ +-+ | |
# +-+ +-+-+-+ +-+ +-+-+ +-+-+ |
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: