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
pragma solidity ^0.4.17; | |
contract Base { | |
event Called(string name); | |
function public_fn() public { Called("Base.public_fn"); } | |
function private_fn() private { Called("Base.private_fn"); } | |
function external_fn() external { Called("Base.external_fn"); } | |
function internal_fn() internal { Called("Base.internal_fn"); } | |
function () public payable { Called("Base.fallback"); } |
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 <iostream> | |
using namespace std; | |
struct node; | |
node * const NIL = (node * const) 0; | |
struct node { | |
int value; | |
node *next; |
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
# https://leetcode.com/problems/word-search-ii/ | |
def makeTrie(): | |
newTrie = {} | |
return newTrie | |
def addWord(word, trie): | |
currentTrie = trie | |
for letter in word: | |
if not letter in currentTrie: |
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
// Command in Bash to run Spark shell. | |
spark-shell --master yarn --driver-memory 50G --num-executors 5 --executor-cores 2 --executor-memory 4G --packages com.databricks:spark-csv_2.10:1.2.0 | |
// Commands in Scala to run within the Spark shell. | |
val pageMetadataDF = sqlContext.load("/user/ealmansi/data/enwiki-20150901/parquet/page_metadata", "parquet") | |
pageMetadataDF.registerTempTable("page_metadata") | |
sql("""SELECT | |
page_id, | |
title, | |
ns, |
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 python | |
# -*- coding: utf-8 -*- | |
from itertools import permutations | |
C = ["white", "blue", "yellow", "green", "red"] # colors | |
G = ["ps3", "xbox-one", "ps4", "pc", "xbox-360"] # game | |
P = ["galaxys5", "mslumia", "galaxys6", "iphone6", "iphone5"] # phone | |
N = ["brit", "american", "swedish", "german", "french"] # nationality | |
B = ["coca-cola", "coffee", "water", "beer", "pepsi"] # beverage |
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
class String | |
def from_roman | |
ans = -1 | |
if self.length == 0 | |
ans = 0 | |
elsif self[0..0] == "M" | |
ans = 1000 + self[1..self.length].from_roman | |
elsif self[0..1] == "CM" | |
ans = 900 + self[2..self.length].from_roman | |
elsif self[0..0] == "D" |
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 <iostream> | |
#include <iomanip> | |
using namespace std; | |
// fuerza bruta | |
int main(int argc, char const *argv[]) | |
{ | |
string cs[] = {"rojo", "azul", "amarillo", "verde"}; | |
int vs[][2] = { | |
{1, 2}, {1, 3}, {1, 4}, {1, 5}, |
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 python3 | |
# -*- coding: utf-8 -*- | |
import re | |
import random | |
def myshuffle(xs): | |
for i in range(len(xs)): | |
ind = random.randint(i, len(xs) - 1) | |
xs[i], xs[ind] = xs[ind], xs[i] |
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 python3 | |
import math; | |
########################################################################################## | |
# Basado en: http://openpool.com.ar/reglamento/T.E.G.-REGLAMENTO.pdf | |
# | |
# Probabilidad de conquistar otro pais si atacamos sin frenar hasta que: | |
# i) conquistamos el otro pais, o | |
# ii) nos quedamos con una sola ficha y no podemos atacar más |
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
# -*- coding: utf-8 -*- | |
import re; | |
class Tokenizer: | |
def __init__(self, inp): | |
self.tokens = inp.lower().encode('utf8') | |
self.substitutions = [ | |
("á", "a"), ("é", "e"), ("í", "i"), ("ó", "o"), ("ú", "u"), ("[^\w]", " "), | |
("(^| )un( |$)", " uno "), ("(^| )veintiun( |$)", " veintiuno "), ("(^| )cien( |$)", " ciento "), ("(^| )millon( |$)", " millones "), ("(^| )y( |$)", " "), | |
("(^| )once( |$)", " diez uno "), ("(^| )doce( |$)", " diez dos "), ("(^| )trece( |$)", " diez tres "), ("(^| )catorce( |$)", " diez cuatro "), |