It seems like there are two styles of programming, which I call "subtractive" and "additive" (like 3D printing). permutations('A' .. 'J').filter(λ p: 'AB' in p or 'BA' in p) ^ subtractive means enumerate all possibilities, then remove constraint violations.
-
-
Show this thread
-
But subtractive is hard to reason about analytically -- how to compute len(..)? Then we rewrite additively: permutations(['AB'] + 'C' .. 'J') + permutations(['BA'] + 'C' .. 'J') Now we can easily derive the formula permutations(9) * 2.
Show this thread -
Maybe this is actually a compiler problem: how can you rewrite the subtractive program (which naturally falls out of the problem statement) into an additive one (which is easily countable)? i.e. how do you remove all conditional expressions?
Show this thread
End of conversation
New conversation -
-
-
This line of thought is near & dear to me. There's a lot of potential in "combinatorics as a pathway to computational thinking" AND in "computational thinking as a pathway to combinatorics". A few years ago I started making a "live-programming" interface for counting problems...pic.twitter.com/qcdIRrRQH9
-
this is beautiful and I want more of these types of toys
End of conversation
New conversation -
-
-
I would reframe it as arranging 9 units: (AB) and C .. J. The result is the number of permutations of 9 things × 2 — one set for AB and another for BA. I find a lot of tricky problems get simpler if you can find a non-obvious thing to treat as a first-class entity.
-
Agreed! That's the "additive" solution I mention (see down in the thread). My question: what is a general strategy to help people reach this solution from the problem statement?
- Show replies
New conversation -
-
-
if you think about perms(a, L) = { concat(L[0:i], a, L[i:len(L)]), 0 <= i < len(L) } then it's pretty natural to think about letting a = AB or BA
Thanks. Twitter will use this to make your timeline better. UndoUndo
-
-
-
my quick thoughts would be. you have A,B,C P(s) is the permutation/combination function. make a new sequence with the grouped items, here Q,C where Q=A,B then P([Q,C]) * P(Q=[A,B])
Thanks. Twitter will use this to make your timeline better. UndoUndo
-
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.
cognitive psychology. PhD