Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

Return to Answer

added 63 characters in body
Source Link
Jonathan Allan
  • 115.4k
  • 8
  • 68
  • 293

Jelly, 3938 bytes

×ばつtṭ‘Ä©8ịðiị"\Œg’D¤ṃ"FRB"ṄȧƲị®œ×ばつtṭ‘Ä©8ịðiị(BgDݤṃ"FRB"ṄȧƲị®œ?8ðƒ®

Try it online! Try it online!

×ばつtṭ‘Ä©8ịðiị"\Œg’D¤ṃ"FRB"ṄȧƲị®œ×ばつtṭ‘Ä©8ịðiị(BgDݤṃ"FRB"ṄȧƲị®œ?8ðƒ® - Link: list of integers, Faces×ばつtṭ‘ - code page indices -> [1,224,132,17,116,224]
 Ä - cumulative sums -> [1,225,357,374,490,714]
 = the permutation indices of:
 [no-op, F, RF, RB, B, FF] from [1,2,3,4,5,6]
 © - ...and copy that to the register
 8ị - Faces indexed into {that} -> P
 ð ðƒ® - starting with the register, reduce P by - f(Current, PValue):
 i - 1-index of {PValue} in {Current}
 Ʋ - last four links as a monad - SideEffect(X=that):
 ị - 1-index {X} into:
 ¤ - nilad followed by links as a nilad
 "\Œg’(Bg  - 31760417604
 D - to decimal -> [3[1,7,6,0,4]
 Ż - prefix with a zero -> [0,1,7,6,0,4]
 ṃ"FRB" - convert to base three with digits 120 as FRB
 Ṅ - print {that} to stdout and yield {that}
  ȧ - {that} logical AND {X} -> X
 ị® - 1-index {X} into the register
 œ?8 - permutation of {Current} at {that} index -> Next

Jelly, 39 bytes

×ばつtṭ‘Ä©8ịðiị"\Œg’D¤ṃ"FRB"ṄȧƲị®œ?8ðƒ®

Try it online!

×ばつtṭ‘Ä©8ịðiị"\Œg’D¤ṃ"FRB"ṄȧƲị®œ?8ðƒ® - Link: list of integers, Faces×ばつtṭ‘ - code page indices -> [1,224,132,17,116,224]
 Ä - cumulative sums -> [1,225,357,374,490,714]
 = the permutation indices of:
 [no-op, F, RF, RB, B, FF] from [1,2,3,4,5,6]
 © - ...and copy that to the register
 8ị - Faces indexed into {that} -> P
 ð ðƒ® - starting with the register, reduce P by - f(Current, PValue):
 i - 1-index of {PValue} in {Current}
 Ʋ - last four links as a monad - SideEffect(X=that):
 ị - 1-index {X} into:
 ¤ - nilad followed by links as a nilad
 "\Œg’ - 317604
 D - to decimal -> [3,1,7,6,0,4]
 ṃ"FRB" - convert to base three with digits 120 as FRB
 Ṅ - print that to stdout ȧ - {that} logical AND {X} -> X
 ị® - 1-index {X} into the register
 œ?8 - permutation of {Current} at {that} index -> Next

Jelly, 38 bytes

×ばつtṭ‘Ä©8ịðiị(BgDݤṃ"FRB"ṄȧƲị®œ?8ðƒ®

Try it online!

×ばつtṭ‘Ä©8ịðiị(BgDݤṃ"FRB"ṄȧƲị®œ?8ðƒ® - Link: list of integers, Faces×ばつtṭ‘ - code page indices -> [1,224,132,17,116,224]
 Ä - cumulative sums -> [1,225,357,374,490,714]
 = the permutation indices of:
 [no-op, F, RF, RB, B, FF] from [1,2,3,4,5,6]
 © - ...and copy that to the register
 8ị - Faces indexed into {that} -> P
 ð ðƒ® - starting with the register, reduce P by - f(Current, PValue):
 i - 1-index of {PValue} in {Current}
 Ʋ - last four links as a monad - SideEffect(X=that):
 ị - 1-index {X} into:
 ¤ - nilad followed by links as a nilad
 (Bg  - 17604
 D - to decimal -> [1,7,6,0,4]
 Ż - prefix with a zero -> [0,1,7,6,0,4]
 ṃ"FRB" - convert to base three with digits 120 as FRB
 Ṅ - print {that} to stdout and yield {that}
  ȧ - {that} logical AND {X} -> X
 ị® - 1-index {X} into the register
 œ?8 - permutation of {Current} at {that} index -> Next
Source Link
Jonathan Allan
  • 115.4k
  • 8
  • 68
  • 293

Jelly, 39 bytes

×ばつtṭ‘Ä©8ịðiị"\Œg’D¤ṃ"FRB"ṄȧƲị®œ?8ðƒ®

A monadic Link that accepts a list of face numbers (not starting with 1 and without any equal neighbours) and prints to stdout as a side effect (and yields a list of numbers, which may be ignored).

Try it online!

How?

Permute some permutation indices :)

×ばつtṭ‘Ä©8ịðiị"\Œg’D¤ṃ"FRB"ṄȧƲị®œ?8ðƒ® - Link: list of integers, Faces×ばつtṭ‘ - code page indices -> [1,224,132,17,116,224]
 Ä - cumulative sums -> [1,225,357,374,490,714]
 = the permutation indices of:
 [no-op, F, RF, RB, B, FF] from [1,2,3,4,5,6]
 © - ...and copy that to the register
 8ị - Faces indexed into {that} -> P
 ð ðƒ® - starting with the register, reduce P by - f(Current, PValue):
 i - 1-index of {PValue} in {Current}
 Ʋ - last four links as a monad - SideEffect(X=that):
 ị - 1-index {X} into:
 ¤ - nilad followed by links as a nilad
 "\Œg’ - 317604
 D - to decimal -> [3,1,7,6,0,4]
 ṃ"FRB" - convert to base three with digits 120 as FRB
 Ṅ - print that to stdout
 ȧ - {that} logical AND {X} -> X
 ị® - 1-index {X} into the register
 œ?8 - permutation of {Current} at {that} index -> Next

AltStyle によって変換されたページ (->オリジナル) /