Success Puzzle
I occasionally like to use Nodebox to solve puzzles on Quora. Today's solution was particularly satisfying:
Question: In how many ways can the letters of the word "success" be arranged such that no two "s" come next together?
The answer is 120. I was able to solve this in Nodebox using only six nodes:
(Refer to attached screenshot)
The make_strings node turns “success” into seven letters.
The orderings node, from my Cartan Node Library, produces all 5040 ways of reordering those seven letters.
The distinct node eliminates duplicates, leaving 420 distinct arrangements.
The contains node yields “true” for each arrangement that contains “ss”.
The equals node yields false for “ss” arrangements and true for all others
The cull nodes removes all arrangements containing “ss”, leaving the 120 possible arrangements.
NOTE: This assumes the two c’s in success are interchangeable. If you wanted to treat them as separate letters (e.g. if you colored the letters so the first c was blue and the second c was red), there would 240 possible arrangements. I double-checked this by simply changing the second c to an x in the first node.
Link to Quora answer: https://www.quora.com/In-how-many-ways-can-the-letters-of-the-word-...
-
success_screenshot.png 591 KB
- success_puzzle.ndbx.zip 6.04 KB
Keyboard shortcuts
Generic
? | Show this help |
---|---|
ESC | Blurs the current field |
Comment Form
r | Focus the comment reply box |
---|---|
^ + ↩ | Submit the comment |
You can use Command ⌘
instead of Control ^
on Mac