Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or 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
def subsets(not_selected, selected=[]): | |
if not not_selected: | |
return [selected] | |
else: | |
current_element = not_selected[0] | |
return ( | |
subsets(not_selected[1:], selected) + \ | |
subsets(not_selected[1:], selected + [current_element]) | |
) |
This file contains hidden or 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
from random import shuffle | |
def merge(left, right, r_list=[]): | |
if not left and not right: | |
return r_list | |
elif not left: | |
r = right[0] | |
r_list.append(r) | |
return merge(left, right[1:], r_list) | |
elif not right: |
This file contains hidden or 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" | |
#include "stdlib.h" | |
#define size(x) ({ \ | |
sizeof(x) / sizeof(int); \ | |
}) | |
int main(void) { | |
int input[] = {4, -10, 2, -2, -7, 3, -3, 5, -4, -5, 1, -9, 0, -6, -1, -8}; | |
int *i, *neg, *pos; | |
int *separators[2]; // pointer to a 2x(not yet know size) array |
This file contains hidden or 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
class Node: | |
def __init__(self, num): | |
self.data = num | |
self.left = None | |
self.right = None | |
root = None | |
def add_to_tree(element, root): | |
if root == None: |
This file contains hidden or 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
//function pointer | |
fn foo(x: i32) -> i32 { | |
return x+1; | |
} | |
fn main() { | |
let mut x: fn(i32) -> i32 = foo; | |
// or x = foo; | |
println!("{}", x(10)); |