Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- for a cycle transition of character cost 'k' for a string of length 'n'
- [k chars to change][n - k chars kept] => [n - k chars kept][reversed k part]
- e.g:
- k = 2
- ab cde => cde ba
- we have n k=1 cycles for each k=2 cycle; n-1 k=2 cycles for each k=3 cycle; n-2 k=3 cycles for each k=4 cycle; etc. until k=5 since that loop back to the beginning (we always end up with the fully reversed starting string,
- fully reversing that would bring us back at the beginning)
- e.g:
- for n=5
- we got 1 k=5 cycle containing 2 k=4 cycles each containing 3 k=3 cycles each containing 4 k=2 cycles each containing 5 k=1 cycles
- so that makes 1 * 2 * 3 * 4 * 5 different combinations, all of them.
- note: each cycles end up a transition away from looping back at the beginning of the corresponding cycle
- n = 1
- 1
- \\\
- 1
- n = 2
- 12
- 21
- \\\\\
- 121
- n = 3
- 123
- 231
- 312
- 213
- 132
- 321
- \\\\\\\\\\\\
- 123121321
- n = 4
- 1234
- 2341
- 3412
- 4123
- 2314
- 3142
- 1423
- 4231
- 3124
- 1243
- 2431
- 4312
- ---------------------
- 2134
- 1342
- 3421
- 4213
- 1324
- 3241
- 2413
- 4132
- 3214
- 2143
- 1432
- 4321
- \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
- 123412314231243121342132413214321
- n = 5
- 12345
- 23451
- 34512
- 45123
- 51234
- 23415
- 34152
- 41523
- 15234
- 52341
- 34125
- 41253
- 12534
- 25341
- 53412
- 41235
- 12354
- 23541
- 35412
- 54123
- ------------------------------
- 23145
- 31452
- 14523
- 45231
- 52314
- 31425
- 14253
- 42531
- 25314
- 53142
- 14235
- 42351
- 23514
- 35142
- 51423
- 42315
- 23154
- 31542
- 15423
- 54231
- ----------------------------------------------------
- 31245
- 12453
- 24531
- 45312
- 53124
- 12435
- 24351
- 43512
- 35124
- 51243
- 24315
- 43152
- 31524
- 15243
- 52431
- 43125
- 31254
- 12543
- 25431
- 54312
- ==============================================================================
- 21345
- 13452
- 34521
- 45213
- 52134
- 13425
- 34251
- 42513
- 25134
- 51342
- 34215
- 42153
- 21534
- 15342
- 53421
- 42135
- 21354
- 13542
- 35421
- 54213
- ----------------------------------------------------------------------------------------------------------
- 13245
- 32451
- 24513
- 45132
- 51324
- 32415
- 24153
- 41532
- 15324
- 53241
- 24135
- 41352
- 13524
- 35241
- 52413
- 41325
- 13254
- 32541
- 25413
- 54132
- ---------------------------------------------------------------------------------------------------------------------------------
- 32145
- 21453
- 14532
- 45321
- 53214
- 21435
- 14352
- 43521
- 35214
- 52143
- 14325
- 43251
- 32514
- 25143
- 51432
- 43215
- 32154
- 21543
- 15432
- 54321
- \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
- 123451234152341253412354123145231425314235142315423124531243512431524312543121345213425134215342135421324513241532413524132541321453214352143251432154321
Advertisement
Add Comment
Please, Sign In to add comment