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 math._ | |
val g = () => Console.readLine("Params: ").split(' ') map ((x) => x.toFloat) | |
val a = g() | |
val b = g() | |
println(pow(a(0), 2)/(pow(a(1)-b(1), 2) + pow(a(2)-b(2), 2))) |
This file has been truncated, but you can view the full file.
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
============================== | |
Methionylthreonylthreonylglutaminylarginyltyrosylglutamylserylleucylphenylalanylalanylglutaminylleuc yllysylglutamylarginyllysylglutamylglycylalanylphenylalanylvalylprolylphenylalanylvalylthreonylleucylgl ycylaspartylprolylglycylisoleucylglutamylglutaminylserylleucyllysylisoleucylaspartylthreonylleucylisoleu cylglutamylalanylglycylalanylaspartylalanylleucylglutamylleucylglycylisoleucylprolylphenylalanylseryla spartylprolylleucylalanylaspartylglycylprolylthreonylisoleucylglutaminylasparaginylalanylthreonylleucyl arginylalanylphenylalanylalanylalanylglycylvalylthreonylprolylalanylglutaminylcysteinylphenylalanylglu tamylmethionylleucylalanylleucylisoleucylarginylglutaminyllysylhistidylprolylthreonylisoleucylprolylisol eucylglycylleucylleucylmethionyltyrosylalanylasparaginylleucylvalylphenylalanylasparaginyllysylglycyli soleucylaspartylglutamylphenylalanyltyrosylalanylglutaminylcysteinylglutamyllysylvalylglycylvalylaspa rtylserylvalylleucylvalylalanylaspartylvalylprolylvalylglut |
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 adler32(string): | |
a = map(ord,string) | |
b = [sum(a[:i])+1%65521 for i in range(len(a)+1)] | |
return (sum(b) << 16) | max(b) |
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 operator import * | |
def isInt(x): | |
try: | |
a = float(x) | |
b = int(a) | |
except ValueError: | |
return False | |
else: | |
return a == b | |
def Postfix(exp): |
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 insertion(a): | |
if len(a) < 2: return | |
for i in range(len(a)): | |
k = i | |
while k > 1 and a[k] < a[k-1]: | |
a[k], a[k-1] = a[k-1], a[k] | |
k -= 1 |
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 selection(a): | |
if len(a) < 2: return | |
for i in range(0,len(a)): | |
k = i | |
for j in range(i+1,len(a)): | |
if a[j] < a[k]: k = j | |
a[i], a[k] = a[k], a[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
def bubble(a): | |
if len(a) < 2: return | |
for i in range(0,len(a)): | |
swapped = False | |
for j in range(len(a)-1,i+1,-1): | |
if a[j] < a[j-1]: | |
a[j], a[j-1], swapped = a[j-1], a[j], True | |
if not swapped: break |
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 quicksort(a): | |
if len(a) <= 1: return a | |
pivot = a.pop(len(a)/2) | |
less, greater = [], [] | |
for x in a: | |
if x <= pivot: | |
less.append(x) | |
else: | |
greater.append(x) | |
return quicksort(less) + [pivot] + quicksort(greater) |
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 Fletcher16(string): | |
a = map(ord,string) | |
b = [sum(a[:i])%255 for i in range(len(a)+1)] | |
return (sum(b) << 8) | max(b) | |
def Fletcher32(string): | |
a = map(ord,string) | |
b = [sum(a[:i])%65535 for i in range(len(a)+1)] | |
return (sum(b) << 16) | max(b) | |
def Fletcher64(string): | |
a = map(ord,string) |
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 verhoeff(string): | |
string, c = list(string)[::-1], 0 | |
d, p, inv = map(lambda x:(lambda f,s:[map(int,list(f[i:i+s])) for i in range(0,len(f),s)])("0"+str(int(x,32)),10), | |
["1pphkblhcil6aq7anvo920aj7hpi14o8nu4t71vvat8a270c2avapk1868t7300dna", | |
"labkl84c4rp10j7aqnspj1hi8k79r7o790ac4n72ok70e8uale7a", | |
"cs4c3l"]) | |
for i, v in enumerate(string): | |
c = d[c][p[i%8][int(v)]] | |
return c == 0 |
OlderNewer