Skip to content

Instantly share code, notes, and snippets.

# -*- coding: utf-8 -*-
"""
Created on Mon Jan 4 17:24:23 2016
@author:Aihiro
"""
import numpy as np
def f(x,y):
a = [1,2,3,4,5]
sum(a[0::2])
@AiHiro
AiHiro / checkHello
Last active February 5, 2016 15:36
def count_words(text, words):
return sum(w in text.lower() for w in words)
find_message = lambda text: ''.join(filter(str.isupper, text))
boolean=lambda x,y,o:1&~"dimpleqonx".index(o[1])>>y>>x>>y
def boolean(x, y, operation):
if operation == "conjunction":
return x and y
elif operation == "disjunction":
return x or y
elif operation == "implication":
return not x or y
elif operation == "exclusive":
return x^y
elif operation == "equivalence":
def count_inversion(sequence):
count = 0
for i in range(1,len(sequence),1):
for j in range(i,len(sequence),1):
if sequence[i-1] > sequence[j]:
count += 1
return count
def count_inversion(sequence):
return sum(sum(m<n for m in sequence[i+1:]) for i,n in enumerate(sequence))
from itertools import starmap as s, permutations as p
checkio=lambda w:any(s(str.endswith,p(w,2)))