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 -*- | |
""" | |
Created on Mon Jan 4 17:24:23 2016 | |
@author:Aihiro | |
""" | |
import numpy as np | |
def f(x,y): |
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
a = [1,2,3,4,5] | |
sum(a[0::2]) |
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
def count_words(text, words): | |
return sum(w in text.lower() for w in words) |
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
find_message = lambda text: ''.join(filter(str.isupper, text)) |
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
boolean=lambda x,y,o:1&~"dimpleqonx".index(o[1])>>y>>x>>y |
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
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": |
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
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 |
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
def count_inversion(sequence): | |
return sum(sum(m<n for m in sequence[i+1:]) for i,n in enumerate(sequence)) |
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
def checkio(words_set): | |
import re | |
a = [] | |
for m in words_set: | |
a.append(any(m != w and re.search(str(m+"$"),w) for w in words_set)) | |
return any(a) |
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
from itertools import starmap as s, permutations as p | |
checkio=lambda w:any(s(str.endswith,p(w,2))) |
OlderNewer