Edit: for context, the parent found an XSS issue. It was patched within a few hours. The patch was incomplete, and this one still worked. So, not only do they get it wrong for launch. When presented with an exploit they don't even patch the full vulnerability. I'll trust my data with someone who understands security, thank you very much.
After performing en passant the computer went crazy and the King started taking all the pieces between down row 8. I ended up with a very easy checkmate as I walked my pawn the remaining three rows, unfettered even when it was under double pressure from the night and queen.
I wonder if this is perhaps an issue caused by the fact I used OS X's BSD sed.
Edit: Hmm, can't seem to format it right. Anyways, the bug seems to be present in gnu sed as well. Really the whole game was screwy. I started with e2 e4 and it all went down hill from their for my opponent :).
Interesting. Either way my opening seemed to be more problematic as the computer still went out of its way to checkmate itself without the en passant. Still a cool achievement.
Complete solution to today's problem in one line of python
def gen(univ, n=5): return univ if n == 1 else [x+y for y in gen(univ,n-1) for x in univ if all([(x+y)[start:start+upto] != (x+y)[start+upto:start+upto*2] for start in range(len(x+y)) for upto in range(1,(len(x+y)-start+2)/2)])]
sub solutions {
my ( $target_length, $alphabet, $head ) = @_;
$head //= '';
# Base Case our head is the right length
return $head if (length $head) == $target_length;
# General Case
return
map { generate( $target_length, $alphabet, $_ ) }
grep { ! /(.{2})\1/ }
map { $head . $_ }
@$alphabet;
}
Or if the regexp engine manages to do that automatically.
[UPDATE: it is slower to provide your own max length. the perl regexp engine is badass. repeating timings on my mac pro with a target_length of 12 show the plain {2,} version is 15% quicker].
(also, you've a minor typo as you recurse into "generate" instead of "solutions", I assume b/c you renamed the function at the very end to make the eg: code scan better).
Here is an ugly iterative solution, in one lambda:
from itertools import product
f = lambda n: [
s for s in
map(''.join, product("abc", repeat=n))
if not any(a==b
for a,b in
[(s[a:b], s[b:c])
for a,b,c in
[(i,i+w,i+2*w)
for w in range(1,len(s)/2+1)
for i in range(len(s)-2*w+1)]])]
>>> f(5)
['abaca', 'abacb', 'abcab', 'abcac', 'abcba', 'acaba',
'acabc', 'acbab', 'acbac', 'acbca', 'babca', 'babcb',
'bacab', 'bacba', 'bacbc', 'bcaba', 'bcabc', 'bcacb',
'bcbab', 'bcbac', 'cabac', 'cabca', 'cabcb', 'cacba',
'cacbc', 'cbabc', 'cbaca', 'cbacb', 'cbcab', 'cbcac']
Relevant quote: "It's bad behavior you want to keep out more than bad people. User behavior turns out to be surprisingly malleable. If people are expected to behave well, they tend to; and vice versa."
http://www.paulgraham.com/hackernews.html
One of the authors of that book taught a class earlier this year at Berkeley. If you learn best listening, the lectures might help. I found them a bit easy, but a nice overview of the book.
I don't know why you're saying it isn't NP-complete. For an arbitrary set of coins, it's definitely NP-complete. You could easily reduce 0-1 ILP to it, or subset-sum.
Why is this comment being downvoted? It's not aggressive, rude or otherwise mean. It's also not factually incorrect (because it's talking about a possible future).
I agree that I don't believe this future is likely, but that's no reason to downvote him.
https://hulbee.com/?query=%3C%2Fscript%3E%3Cimg%20src%3Dsdf%...
It runs on Chrome and bypasses the filter.
Edit: for context, the parent found an XSS issue. It was patched within a few hours. The patch was incomplete, and this one still worked. So, not only do they get it wrong for launch. When presented with an exploit they don't even patch the full vulnerability. I'll trust my data with someone who understands security, thank you very much.