Combinatorics problem: you're arranging 10 people (A .. J) in a row. A and B must sit next to each other. How many arrangements? How could writing this problem as a program help scaffold the problem-solving process?
What about: sum([ permutations([f'A{p}B'] + 'C' .. 'J' - [p]) + permutations([f'B{p}A'] + 'C' .. 'J' - [p]) for p in 'C' .. 'J' ]) Inner loop is 8! * 2, 8 iterations of outer loop, so count is 8 * 8! * 2.
-
-
I agree there's definitely insight required to generate the additive solution. But once you have an additive solution, I think it's fairly mechanical to analytically derive the count.
-
Yeah! I should've mentioned, my interface was called "Construct 'n' Count". I agree with you that "Constructing" is usually where insight is necessary. Fortunately, it's concrete, so it's also where a computer can help the most – "you missed one!" or "you counted one twice!".
End of conversation
New conversation -
-
-
Sec, confirming with MiniZinc
-
- Show replies
New conversation -
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