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

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

Draft saved
Draft discarded
Cancel
10
  • \$\begingroup\$ One or two test cases with an odd length and an output greater than 0 would be nice. It's easy to mess the riffle in such cases if you have to write the riffle code by yourself instead of relying on builtins. \$\endgroup\$ Commented Mar 11, 2019 at 14:21
  • \$\begingroup\$ @OlivierGrégoire The [1,3,5,7,9,2,4,6,8] is of length 9, but I will add a few more for lengths 7 and 11 perhaps. EDIT: Added the test cases [1,3,5,7,2,4,6] = 2 (length 7) and [1,6,11,5,10,4,9,3,8,2,7] = 6 (length 11). Hope that helps. \$\endgroup\$ Commented Mar 11, 2019 at 14:27
  • 1
    \$\begingroup\$ Question as currently formulated seems "wrong"... a single riffle shuffle should result in the first and last cards changing, unless you're pulling some kind of con trick! i.e. [6,1,7,2,8,3,9,4,10,5] after a single shuffle of 10 cards. \$\endgroup\$ Commented Mar 12, 2019 at 11:05
  • 3
    \$\begingroup\$ @Steve I guess you're kinda right. Riffle-shuffling in general simply interleaves two halves, so both [1,6,2,7,3,8,4,9,5,10] or [6,1,7,2,8,3,9,4,10,5] are possible. In my challenge it does mean that the top card will always remain the top card, so it's indeed a bit of a con-trick.. I've never seen someone irl use only riffle-shuffles to shuffle a deck of cards however. Usually they also use other type of shuffles in between. Anyway, it's too late to change the challenge now, so for the sake of this challenge the top card will always remain the top card after a riffle-shuffle. \$\endgroup\$ Commented Mar 12, 2019 at 11:20
  • 1
    \$\begingroup\$ @Rosario Yeah, someone else mentioned the same above. As I mentioned back then, irl no one uses only riffle-shuffles to shuffle a deck of cards. Usually you do different types of shuffles in between. In this challenge, the top card will always remain the top card after a riffle-shuffle. 🤷 \$\endgroup\$ Commented Feb 12 at 19:40

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