!52 is the number of all possible deck shuffles. The sort-order of a bridge hand as dealt is immaterial to the player.
(!52)%*/4#!13 is 53644737765488792839237440000, which, as you mention, is the cited number of different deals ignoring ordering within each hand. Both results are correct in their different ways! M On 15/10/2018 16:06, Linda Alvord wrote:
Bridge ppage: 53,644,737,765,488,792,839,237,440,000 to unique bridge deals. J : !52 8.06582e67 Not much agreement. Linda , Sent from my Verizon, Samsung Galaxy smartphone -------- Original message -------- From: 'Mike Day' via Programming <[email protected]> Date: 10/14/18 1:45 PM (GMT-05:00) To: [email protected] Subject: Re: [Jprogramming] Shuffle and deal 4 bridge hands Sorry - getting rather chatty, not much J - your deck, Linda, has faces increasing within decreasing suits, given that Bridge has the ordering spade > heart > diamond > club , so your shuffle produces suits in the "wrong" order. So redefining deck as (say): [suits =: |. u: 9824 9829 9830 9827 NB. increasing ♣♦♥♠ faces =: '23456789TJQKA' NB. increasing |:each (5&{.;_5&{.) deck =:,/suits,"0/faces NB. all increasing ┌─────┬─────┐ │♣♣♣♣♣│♠♠♠♠♠│ │23456│TJQKA│ └─────┴─────┘ NB. for a set of Whist hands: (actually done here with ?. rather than ?) 7 (]<"2 @: {~ \:~"1 @: ((4 , [) ($ ? ~@:#) ])) deck ┌──┬──┬──┬──┐ │♥A│♠K│♠A│♠T│ │♥T│♠4│♠Q│♠5│ │♥2│♦5│♠8│♥J│ │♦T│♦4│♠6│♦9│ │♣Q│♦2│♥K│♦8│ │♣3│♣A│♥7│♣K│ │♣2│♣T│♦J│♣6│ └──┴──┴──┴──┘ Use lh arg of 13 for Bridge Hands. The down-sort is now intuitive, and we don't need to reverse each column Cheers, Mike On 14/10/2018 16:27, 'Mike Day' via Programming wrote:Sorry for previous - pressed Send instead of Edit! Thanks, Linda No problems under Windows 10 in JQt 807. I'm no good at Bridge, but might be persuaded to play whist! If we want to choose Whist or Bridge, we need to specify the size of a hand. In either case, you can use draw from the row-count of deck rather than the product of x. This consideration and some other slight changes lead to: shuffle =: 13 : '<@|."2 y{~ /:~"1 x$&|. ?~#y' SO, for a game of Whist: 7 4 shuffle deck ┌──┬──┬──┬──┐ │♣8│♦7│♣6│♦A│ │♣2│♥6│♦Q│♦K│ │♦J│♥5│♦6│♦T│ │♦9│♥4│♥T│♥A│ │♦8│♥3│♥7│♥2│ │♥8│♠Q│♠J│♠K│ │♠4│♠9│♠3│♠8│ └──┴──┴──┴──┘ OR - can't we assume 4 suits? - 7 (13 :'<@|."2 y{~ /:~"1 (4,x)$ ?~#y') deck ┌──┬──┬──┬──┐ │♣A│♦K│♣Q│♣J│ │♣6│♦5│♣2│♣8│ │♦Q│♥K│♦A│♣7│ │♦T│♥Q│♦7│♣3│ │♥A│♥8│♥7│♦J│ │♥2│♥3│♥5│♥6│ │♠7│♠2│♠5│♠Q│ └──┴──┴──┴──┘ Cheers, Mike On 14/10/2018 00:47, Linda Alvord wrote:This should now work in most J environments. F=:52$'23456789TJQKA' S=:13#u: 9824 9829 9830 9827 deck=:S,.F shuf=: 13 :'<"2|."2 y {~ /:~"1 (|.x)$?~*/|.x Save code above in a file and then run the script. Here's how it looks in android. 13 4 shuf deck ┌──┬──┬──┬──┐ │♣A│♣J│♣K│♣9│ │♣Q│♣6│♣T│♣3│ │♦K│♣5│♣8│♦A│ │♦T│♣4│♣7│♦J│ │♦9│♣2│♦Q│♦8│ │♦6│♦2│♦7│♥K│ │♥A│♥Q│♦5│♥6│ │♥T│♥J│♦4│♥3│ │♥8│♥9│♦3│♠A│ │♥7│♥4│♠Q│♠K│ │♥5│♥2│♠T│♠9│ │♠8│♠J│♠7│♠6│ │♠5│♠2│♠3│♠4│ └──┴──┴──┴──┘ Linda Sent from my Verizon, Samsung Galaxy smartphone ---------------------------------------------------------------------- For information about J forums see https://eur02.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.jsoftware.com%2Fforums.htm&data=02%7C01%7C%7C8c0fbc1f2b934b0bbe5b08d631fcc859%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636751359090026248&sdata=2O%2FqOP%2FzzPISJhM30ztB0WlJ0%2FkYzN1QY44tH0PI%2Bu0%3D&reserved=0--- This email has been checked for viruses by Avast antivirus software. https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.avast.com%2Fantivirus&data=02%7C01%7C%7C8c0fbc1f2b934b0bbe5b08d631fcc859%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636751359090026248&sdata=a2NavKcihOaBgx%2BFNRy3Ke35FlQ7UEmiV%2BG57fLyVmo%3D&reserved=0 ---------------------------------------------------------------------- For information about J forums see https://eur02.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.jsoftware.com%2Fforums.htm&data=02%7C01%7C%7C8c0fbc1f2b934b0bbe5b08d631fcc859%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636751359090026248&sdata=2O%2FqOP%2FzzPISJhM30ztB0WlJ0%2FkYzN1QY44tH0PI%2Bu0%3D&reserved=0 ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
--- This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
