Teacup rim text: Difference between revisions

m
(Added C solution)
Line 1,235:
'''
def go(ws):
returndef concatMapf(xs):
lambda xs:return [
[snd(x) for x in xs]
] if n <= len(xs) >= len(xs[0][0]) else []
return concatMap(f)(groupBy(fst)(sorted(
groupBy[(fst)''.join(sorted(w)), w) for w in ws],
sorted(key=fst
)))
[(''.join(sorted(w)), w) for w in ws],
return lambda s: go(s)
key=fst
)
)
)
return lambda ws: go(ws)
 
 
Line 1,285 ⟶ 1,281:
(0, True, rotated(w))
)[1]
return lambda ws: go(ws)
 
return lambda s: go(s)
 
 
Line 1,306 ⟶ 1,301:
(using an empty list to represent computational failure).
'''
return lambdadef go(xs): list(
return chain.from_iterable(map(f, xs))
)return go
 
 
Line 1,323 ⟶ 1,318:
in terms of the key function f.
'''
return lambdadef go(xs): [
return )[
list(x[1]) for x in groupby(xs, key=f)
list(x[1]) for x in groupby(xs, key=fstf)
]
return go
 
 
Line 1,377 ⟶ 1,374:
over a start value of x.
'''
def go(f, x):
def g(a, ix):
vdef = fh(a) if, i else x):
return (v, v = f(a) if i else x
return mapAccumL(gv, v)(x)(
range(0,return 1 + nmapAccumL(h)(x)(
)[ range(0, 1] + n)
return lambda f: lambda x: go(f, x )[1]
return g
return go
 
 
Line 1,392 ⟶ 1,391:
The initial seed value is x.
'''
def go(f, x):
v =def g(x):
while not p( v): = x
vwhile =not fp(v):
return v = f(v)
return lambda f: lambda x: go(f, x) return v
return g
return go
 
 
9,655

edits