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
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; |
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
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 |
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
::: ::: :::::::::: ::: ::: ::: ::::::::::: ::::::::: | |
:+:+: :+:+: :+: :+: :+: :+: :+: :+: :+: | |
+:+ +:+:+ +:+ +:+ +:+ +:+ +:+ +:+ +:+ +:+ | |
+#+ +:+ +#+ +#++:++# +#+ +#++:++ +#+ +#++:++#: | |
+#+ +#+ +#+ +#+ +#+ +#+ +#+ +#+ +#+ | |
#+# #+# #+# #+# #+# #+# #+# #+# #+# | |
### ### ########## ########## ### ### ########### ### ### |
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
whichfizz = fn | |
(0, 0, _) -> "FizzBuzz" | |
(0, _, _) -> "Fizz" | |
(_, 0, _) -> "Buzz" | |
(_, _, n) -> n | |
end | |
fizzbuzz = fn(n) -> | |
whichfizz.(rem(n, 3), rem(n, 5), n) | |
end |
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
# 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 |