Skip to content

Instantly share code, notes, and snippets.

import java.util.Arrays;
class PancakeSort {
/* Reverses arr[0..i] */
static void flip(int arr[], int k) {
int tmp, start = 0, end = k;
while (start < end) {
tmp = arr[start];
arr[start] = arr[end];
arr[end] = tmp;
package main
import "fmt"
// fibonacci is a function that returns
// a function that returns an int.
func fibonacci() func() int {
f0, f1 := 0, 1
return func() (fib int) {
fib = f0
::: ::: :::::::::: ::: ::: ::: ::::::::::: :::::::::
:+:+: :+:+: :+: :+: :+: :+: :+: :+: :+:
+:+ +:+:+ +:+ +:+ +:+ +:+ +:+ +:+ +:+ +:+
+#+ +:+ +#+ +#++:++# +#+ +#++:++ +#+ +#++:++#:
+#+ +#+ +#+ +#+ +#+ +#+ +#+ +#+ +#+
#+# #+# #+# #+# #+# #+# #+# #+# #+#
### ### ########## ########## ### ### ########### ### ###
whichfizz = fn
(0, 0, _) -> "FizzBuzz"
(0, _, _) -> "Fizz"
(_, 0, _) -> "Buzz"
(_, _, n) -> n
end
fizzbuzz = fn(n) ->
whichfizz.(rem(n, 3), rem(n, 5), n)
end
@melkir
melkir / MinimaxSticks.py
Last active July 29, 2016 00:16
Stick with minimax IA and Python
# Credit : Trevor Payne https://www.youtube.com/watch?v=fInYh90YMJU&noredirect=1
from sys import maxsize
class Node(object):
def __init__(self, i_depth, i_playerNum, i_sticksRemaining, i_value=0):
self.i_depth = i_depth
self.i_playerNum = i_playerNum
self.i_sticksRemaining = i_sticksRemaining
self.i_value = i_value