1,900 karma · joined November 18, 2012
www.xuanji.li
[ my public key: https://keybase.io/xuanji; my proof: https://keybase.io/xuanji/sigs/YyOVzG7h-Ip1eEcZdfnsvWckOKvnM-6b09PfP3q-9Y0 ]
hi
For e.g., imagine I'm trying to prove the theorem "x divides 6 => x != 5". Of course, one way would be to develop some general lemma about non-divisibility, but a different hacky way might be to say "if x divides 6 then x ∈ {1, 2, 3, 6}, split into 4 cases, check that x != 5 holds in all cases". That first step requires an algorithm to go from a given number to its list of divisors, not just an existence proof that such a finite list exists.
I don't think this is true? AIUI a developer can choose to operating using the "old business terms" even in the EU, in which case they don't have to pay the fee. https://developer.apple.com/support/core-technology-fee/ backs this up by stating that the CTF is an element of the "new business terms".
I eat breakfast when I’m strength training and don’t when I’m not, I’m not obese (16% body fat by dexa scan), so is skipping breakfast a “strategy”?
The validators need to be decentralized (i.e. prevent "harmful collusion"), but the slashers don't need to be in the same way (as long as the validators are).
It’s the same example as on the wiki page for “tritone substitution” - ‘For example, in the key of C major one can use D♭7 instead of G7.’
maybe 50ms is under the "conscious detection" threshold (debateable, IMO...) but it will definitely feels "laggy"
Maybe that particular solution is hard to come up with, but you can solve the problem without any "tricks", just basic principles. I'll try to explain which principles I'd use using python.
You can start with the trivial O(N^2) solution:
def has_2sum(lst, target):
# returns whether there are 2 (not necessarily distinct) elements in `lst` which sum to target
for a in lst:
for b in lst:
if a + b == target: return True
return False
First principle is runtime analysis. The runtime is O(N^2) because the inner loop is O(N) and runs N times. So we can try to speed up the inner loop. Second principle is to rewrite what the inner loop body as a function of the loop variable b. def has_2sum(lst, target):
for a in lst:
for b in lst:
if b == target - a: return True
return False
Third principle is pattern recognition for common functions: the code is equivalent to def has_2sum(lst, target):
for a in lst:
return (target - a) in lst
Fourth principle is to know which data structures support membership query. If you thought of hashtables, you get the O(N) solution. def has_2sum(lst, target):
set_lst = set(lst)
for a in lst:
return (target - a) in set_lst
If you thought of sorted list, you get an O(N log N) solution. import bisect
def has_2sum(lst, target):
sort(lst)
def contains(x):
# equivalent to `x in lst`
i = bisect.bisect_left(lst, x)
return (0 <= i < len(lst)) and (lst[i] == x)
for a in lst:
return contains(target - a)
If you thought of `sortedcontainers.SortedList` (a third-party python package), you get an O(N^4/3) solution (analysis: https://grantjenks.com/docs/sortedcontainers/performance-sca...)I wonder if the problem is that efficient persistent arrays aren't in racket's standard library (there are some third-party libraries implementing them though). Since racket isn't a "pure FP" language, they include cons-arrays and mutable vectors, and I imagine they felt that there wasn't a need to include efficient persistent arrays in addition to those.