11h
comment Optimize Sieve of Eratosthenes Further
you can use range(i * i, self.lim, 2*i).
11h
comment prime interval(PRINT) on SPOJ
compare printf("%d %d", (int)sizeof(long long int), (int)sizeof(char)). it ought to be 8 vs 1 or something. so it takes 8 times more memory than necessary, so it doesn't fit to cache as well and so works much slower. how much slower, you can measure on ideone.com. would appreciate if you'd post your results back here. :)
18h
awarded Informed
1d
comment Riddle with GNU Prolog, similar to Einstein Riddle
with library(lambda), attr(A,B):- maplist( +\(A, T^(T=N-V,memberchk(N-X,A),X=V)), B).. or after manually defining op(201,xfx,+\). , attr(A,B):- maplist( A+\T^(T=N-V,memberchk(N-X,A),X=V), B).
1d
comment Why I can't get an answer for the Ship Puzzle with Prolog?
to avoid typos, we can let the computer discover the problem's object's attributes for us.
1d
comment prime interval(PRINT) on SPOJ
the reason for TLE is your use of long long int. int will get your through, but then you need to be careful about the corner cases, they will throw them at you.
2d
revised What is this trying to tell me?
edited tags
Jun
26
comment Why does :p freeze in GHCi when I give it this corecursive value?
thanks for the link (I knew I saw something like that once!) -- a side note: so this problem here is only with pathCounts's head, by the same reasoning for zipWith as for map...
Jun
26
comment Why does :p freeze in GHCi when I give it this corecursive value?
btw in common lisp and scheme (I think, at least some dialects), and even prolog, they do have ways to show the circularity in structures...
Jun
24
comment Tags clash because of a tag synonym
@JasonMArcher and besides, I really think this answer is the way to go.
Jun
24
comment Prolog Does the order of recursion matter?
@false glad to be of help. :)
Jun
24
comment Tags clash because of a tag synonym
@JasonMArcher you mean post a question about it? I have an answer, that a lot of questions need to be retagged, but what would be the question? I'm not versed in meta ways, you see.
Jun
24
comment Prolog Does the order of recursion matter?
@false "reif" is good. it also reads in two parts, "re:if", so it's evocative. good name. can it be "re/if", is the slash allowed?
Jun
24
comment print series of prime numbers in python
@hochl you're mistaken; see primesieve.org for the counterexample.
Jun
24
revised How to make the Sieve of Eratosthenes faster?
edited tags
Jun
24
comment Prolog Does the order of recursion matter?
@false you mean for if_ and stuff? Maybe`reified_truth`? Or there was something else that I missed?
Jun
24
comment Why does this Haskell program leak space when compiled with optimizations?
great news! (of course one could say one could reasonably expect a compiler be able to do this on its own for all equivalent codes, but one would usually get scorned with " ``sufficiently smart compiler'' fallacy" references then... ;) ).
Jun
23
answered Why does this Haskell program leak space when compiled with optimizations?
Jun
23
comment Why does this Haskell program leak space when compiled with optimizations?
try ask another, more specific question, with the specific code and flags, to make it more focused. :)
Jun
23
comment Why does this Haskell program leak space when compiled with optimizations?
the trick is to cause the recomputation of suffixes, instead of their retention in memory. it's like with the powerset (x:xs) = map (x:) (powerset xs) ++ powerset xs definition, adding where clause is harmful. (or is it powerset (x:xs) = powerset xs ++ map (x:) (powerset xs) ?)
1 2 3 4 5