"Bridge sorting" problem
reddit.com·17w·
Discuss: r/compsci

For context, I am an amateur bridge player, and in many cases, it helps to sort my hand in 13 cards in alternating colors from greatest to least so I can see what cards I am working with, so that basically inspired this problem.

Suppose you have a list of integer tuples (a_1, b_1), (a_2, b_2), ..., (a_n, b_n). You wish to arrange the list in a certain order that meets the following three criteria:

All tuples with first element a_i are grouped together. That is, you shouldn’t have a spare a_i anywhere else. 1. Within a grouping with first element a_i, the group is ordered in decreasing order of the b_i’s. 1. Two adjacent groupings identified by elements a_i != a_j must have a_i and a_j differ in parity IF POSSIBLE. That is, if a_i is even, then all adjace…

Similar Posts

Loading similar posts...

Keyboard Shortcuts

Navigation
Next / previous item
j/k
Open post
oorEnter
Preview post
v
Post Actions
Love post
a
Like post
l
Dislike post
d
Undo reaction
u
Recommendations
Add interest / feed
Enter
Not interested
x
Go to
Home
gh
Interests
gi
Feeds
gf
Likes
gl
History
gy
Changelog
gc
Settings
gs
Browse
gb
Search
/
General
Show this help
?
Submit feedback
!
Close modal / unfocus
Esc

Press ? anytime to show this help