Peragakan hasil dari melakukan 8 pengocokan sempurna setumpuk kartu

17

Penjelasan

Acak yang sempurna adalah tempat setumpuk kartu terbelah menjadi dua dan kartu-kartu dari masing-masing tumpukan diselingi secara bergantian. Kartu bawah asli dan kartu teratas asli harus dipertahankan setelah pengocokan sempurna.

Setelah 8 mengocok sempurna, setumpuk kartu 52 standar kembali ke pesanan semula.

Tantangan

Tulis sebuah program yang menampilkan keadaan setumpuk kartu saat melewati 8 pengocokan sempurna berturut-turut. Anda dapat menggunakan representasi deck yang dapat dibaca manusia, asalkan itu menampilkan nomor dan jenis kartu di deck secara berurutan. Itu harus menampilkan representasi dari semua kartu, untuk semua sembilan negara.

Ini kode golf , jadi solusi terpendek menang.

Contoh Output

Berikut adalah contoh output yang dihasilkan oleh contoh implementasi ini dalam Javascript

AS,AC,AD,AH,2S,2C,2D,2H,3S,3C,3D,3H,4S,4C,4D,4H,5S,5C,5D,5H,6S,6C,6D,6H,7S,7C,7D,7H,8S,8C,8D,8H,9S,9C,9D,9H,10S,10C,10D,10H,JS,JC,JD,JH,QS,QC,QD,QH,KS,KC,KD,KH
AS,7D,AC,7H,AD,8S,AH,8C,2S,8D,2C,8H,2D,9S,2H,9C,3S,9D,3C,9H,3D,10S,3H,10C,4S,10D,4C,10H,4D,JS,4H,JC,5S,JD,5C,JH,5D,QS,5H,QC,6S,QD,6C,QH,6D,KS,6H,KC,7S,KD,7C,KH
AS,4C,7D,10H,AC,4D,7H,JS,AD,4H,8S,JC,AH,5S,8C,JD,2S,5C,8D,JH,2C,5D,8H,QS,2D,5H,9S,QC,2H,6S,9C,QD,3S,6C,9D,QH,3C,6D,9H,KS,3D,6H,10S,KC,3H,7S,10C,KD,4S,7C,10D,KH
AS,9S,4C,QC,7D,2H,10H,6S,AC,9C,4D,QD,7H,3S,JS,6C,AD,9D,4H,QH,8S,3C,JC,6D,AH,9H,5S,KS,8C,3D,JD,6H,2S,10S,5C,KC,8D,3H,JH,7S,2C,10C,5D,KD,8H,4S,QS,7C,2D,10D,5H,KH 
AS,5S,9S,KS,4C,8C,QC,3D,7D,JD,2H,6H,10H,2S,6S,10S,AC,5C,9C,KC,4D,8D,QD,3H,7H,JH,3S,7S,JS,2C,6C,10C,AD,5D,9D,KD,4H,8H,QH,4S,8S,QS,3C,7C,JC,2D,6D,10D,AH,5H,9H,KH 
AS,3S,5S,7S,9S,JS,KS,2C,4C,6C,8C,10C,QC,AD,3D,5D,7D,9D,JD,KD,2H,4H,6H,8H,10H,QH,2S,4S,6S,8S,10S,QS,AC,3C,5C,7C,9C,JC,KC,2D,4D,6D,8D,10D,QD,AH,3H,5H,7H,9H,JH,KH 
AS,2S,3S,4S,5S,6S,7S,8S,9S,10S,JS,QS,KS,AC,2C,3C,4C,5C,6C,7C,8C,9C,10C,JC,QC,KC,AD,2D,3D,4D,5D,6D,7D,8D,9D,10D,JD,QD,KD,AH,2H,3H,4H,5H,6H,7H,8H,9H,10H,JH,QH,KH 
AS,AD,2S,2D,3S,3D,4S,4D,5S,5D,6S,6D,7S,7D,8S,8D,9S,9D,10S,10D,JS,JD,QS,QD,KS,KD,AC,AH,2C,2H,3C,3H,4C,4H,5C,5H,6C,6H,7C,7H,8C,8H,9C,9H,10C,10H,JC,JH,QC,QH,KC,KH 
AS,AC,AD,AH,2S,2C,2D,2H,3S,3C,3D,3H,4S,4C,4D,4H,5S,5C,5D,5H,6S,6C,6D,6H,7S,7C,7D,7H,8S,8C,8D,8H,9S,9C,9D,9H,10S,10C,10D,10H,JS,JC,JD,JH,QS,QC,QD,QH,KS,KC,KD,KH 
Peter Olson
sumber
Meskipun bukan duplikat yang tepat, ini pada dasarnya sekitar setengah dari tugas dari Mix the nuts (setidaknya seperti yang diterapkan oleh jawaban saat ini).
Peter Taylor
1
Apakah urutan awal kartu penting?
Paul Prestidge
@ sink. Tidak. Kartu dapat mulai dengan urutan apa pun.
Peter Olson

Jawaban:

15

J, 66 65 54 52 50 47 43 karakter

26({.,@,.}.)^:(i.9),{'A23456789TJQK';'SCDH'

Keluaran:

┌──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┐
│AS│AC│AD│AH│2S│2C│2D│2H│3S│3C│3D│3H│4S│4C│4D│4H│5S│5C│5D│5H│6S│6C│6D│6H│7S│7C│7D│7H│8S│8C│8D│8H│9S│9C│9D│9H│TS│TC│TD│TH│JS│JC│JD│JH│QS│QC│QD│QH│KS│KC│KD│KH│
├──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┤
│AS│7D│AC│7H│AD│8S│AH│8C│2S│8D│2C│8H│2D│9S│2H│9C│3S│9D│3C│9H│3D│TS│3H│TC│4S│TD│4C│TH│4D│JS│4H│JC│5S│JD│5C│JH│5D│QS│5H│QC│6S│QD│6C│QH│6D│KS│6H│KC│7S│KD│7C│KH│
├──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┤
│AS│4C│7D│TH│AC│4D│7H│JS│AD│4H│8S│JC│AH│5S│8C│JD│2S│5C│8D│JH│2C│5D│8H│QS│2D│5H│9S│QC│2H│6S│9C│QD│3S│6C│9D│QH│3C│6D│9H│KS│3D│6H│TS│KC│3H│7S│TC│KD│4S│7C│TD│KH│
├──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┤
│AS│9S│4C│QC│7D│2H│TH│6S│AC│9C│4D│QD│7H│3S│JS│6C│AD│9D│4H│QH│8S│3C│JC│6D│AH│9H│5S│KS│8C│3D│JD│6H│2S│TS│5C│KC│8D│3H│JH│7S│2C│TC│5D│KD│8H│4S│QS│7C│2D│TD│5H│KH│
├──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┤
│AS│5S│9S│KS│4C│8C│QC│3D│7D│JD│2H│6H│TH│2S│6S│TS│AC│5C│9C│KC│4D│8D│QD│3H│7H│JH│3S│7S│JS│2C│6C│TC│AD│5D│9D│KD│4H│8H│QH│4S│8S│QS│3C│7C│JC│2D│6D│TD│AH│5H│9H│KH│
├──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┤
│AS│3S│5S│7S│9S│JS│KS│2C│4C│6C│8C│TC│QC│AD│3D│5D│7D│9D│JD│KD│2H│4H│6H│8H│TH│QH│2S│4S│6S│8S│TS│QS│AC│3C│5C│7C│9C│JC│KC│2D│4D│6D│8D│TD│QD│AH│3H│5H│7H│9H│JH│KH│
├──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┤
│AS│2S│3S│4S│5S│6S│7S│8S│9S│TS│JS│QS│KS│AC│2C│3C│4C│5C│6C│7C│8C│9C│TC│JC│QC│KC│AD│2D│3D│4D│5D│6D│7D│8D│9D│TD│JD│QD│KD│AH│2H│3H│4H│5H│6H│7H│8H│9H│TH│JH│QH│KH│
├──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┤
│AS│AD│2S│2D│3S│3D│4S│4D│5S│5D│6S│6D│7S│7D│8S│8D│9S│9D│TS│TD│JS│JD│QS│QD│KS│KD│AC│AH│2C│2H│3C│3H│4C│4H│5C│5H│6C│6H│7C│7H│8C│8H│9C│9H│TC│TH│JC│JH│QC│QH│KC│KH│
├──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┼──┤
│AS│AC│AD│AH│2S│2C│2D│2H│3S│3C│3D│3H│4S│4C│4D│4H│5S│5C│5D│5H│6S│6C│6D│6H│7S│7C│7D│7H│8S│8C│8D│8H│9S│9C│9D│9H│TS│TC│TD│TH│JS│JC│JD│JH│QS│QC│QD│QH│KS│KC│KD│KH│
└──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┘

Saya dipaksa lebih jauh dan lebih jauh ke dalam tutorial dan manual referensi J untuk tetap menjadi yang terdepan di sini. : -S

Gareth
sumber
Array 1 dan terakhir Anda identik. Selain itu, kartu pertama Anda selalu ASdan terakhir selalu ada KH.
defhlt
1
@ ArtemIce Seharusnya begitu. Itu diperlukan dalam pertanyaan. Baca kembali paragraf pertama.
Gareth
@ Gareth ok maaf
defhlt
9

Haskell, 103

m(a:s,b:t)=a:b:m(s,t);m _=[]
main=mapM_ putStrLn.take 9.iterate(m.splitAt 26)$take 13.enumFrom=<<"🂡🃑🃁🂱"

Keluaran:

🂡🂢🂣🂤🂥🂦🂧🂨🂩🂪🂫🂬🂭🃑🃒🃓🃔🃕🃖🃗🃘🃙🃚🃛🃜🃝🃁🃂🃃🃄🃅🃆🃇🃈🃉🃊🃋🃌🃍🂱🂲🂳🂴🂵🂶🂷🂸🂹🂺🂻🂼🂽
🂡🃁🂢🃂🂣🃃🂤🃄🂥🃅🂦🃆🂧🃇🂨🃈🂩🃉🂪🃊🂫🃋🂬🃌🂭🃍🃑🂱🃒🂲🃓🂳🃔🂴🃕🂵🃖🂶🃗🂷🃘🂸🃙🂹🃚🂺🃛🂻🃜🂼🃝🂽
🂡🃑🃁🂱🂢🃒🃂🂲🂣🃓🃃🂳🂤🃔🃄🂴🂥🃕🃅🂵🂦🃖🃆🂶🂧🃗🃇🂷🂨🃘🃈🂸🂩🃙🃉🂹🂪🃚🃊🂺🂫🃛🃋🂻🂬🃜🃌🂼🂭🃝🃍🂽
🂡🃇🃑🂷🃁🂨🂱🃘🂢🃈🃒🂸🃂🂩🂲🃙🂣🃉🃓🂹🃃🂪🂳🃚🂤🃊🃔🂺🃄🂫🂴🃛🂥🃋🃕🂻🃅🂬🂵🃜🂦🃌🃖🂼🃆🂭🂶🃝🂧🃍🃗🂽
🂡🃔🃇🂺🃑🃄🂷🂫🃁🂴🂨🃛🂱🂥🃘🃋🂢🃕🃈🂻🃒🃅🂸🂬🃂🂵🂩🃜🂲🂦🃙🃌🂣🃖🃉🂼🃓🃆🂹🂭🃃🂶🂪🃝🂳🂧🃚🃍🂤🃗🃊🂽
🂡🂩🃔🃜🃇🂲🂺🂦🃑🃙🃄🃌🂷🂣🂫🃖🃁🃉🂴🂼🂨🃓🃛🃆🂱🂹🂥🂭🃘🃃🃋🂶🂢🂪🃕🃝🃈🂳🂻🂧🃒🃚🃅🃍🂸🂤🂬🃗🃂🃊🂵🂽
🂡🂥🂩🂭🃔🃘🃜🃃🃇🃋🂲🂶🂺🂢🂦🂪🃑🃕🃙🃝🃄🃈🃌🂳🂷🂻🂣🂧🂫🃒🃖🃚🃁🃅🃉🃍🂴🂸🂼🂤🂨🂬🃓🃗🃛🃂🃆🃊🂱🂵🂹🂽
🂡🂣🂥🂧🂩🂫🂭🃒🃔🃖🃘🃚🃜🃁🃃🃅🃇🃉🃋🃍🂲🂴🂶🂸🂺🂼🂢🂤🂦🂨🂪🂬🃑🃓🃕🃗🃙🃛🃝🃂🃄🃆🃈🃊🃌🂱🂳🂵🂷🂹🂻🂽
🂡🂢🂣🂤🂥🂦🂧🂨🂩🂪🂫🂬🂭🃑🃒🃓🃔🃕🃖🃗🃘🃙🃚🃛🃜🃝🃁🃂🃃🃄🃅🃆🃇🃈🃉🃊🃋🃌🃍🂱🂲🂳🂴🂵🂶🂷🂸🂹🂺🂻🂼🂽


Tidak tahu apakah ada masalah UTF-8 di sekitar sini, tidak seharusnya ... ini adalah dump hex program

0000000 286d 3a61 2c73 3a62 2974 613d 623a 6d3a
0000010 7328 742c 3b29 206d 3d5f 5d5b 6d0a 6961
0000020 3d6e 616d 4d70 205f 7570 5374 7274 6e4c
0000030 742e 6b61 2065 2e39 7469 7265 7461 2865
0000040 2e6d 7073 696c 4174 2074 3632 2429 6174
0000050 656b 3120 2e33 6e65 6d75 7246 6d6f 3c3d
0000060 223c 9ff0 a182 9ff0 9183 9ff0 8183 9ff0
0000070 b182 0a22                              
0000074

dan dari jalur output pertama

0000000 9ff0 a182 9ff0 a282 9ff0 a382 9ff0 a482
0000010 9ff0 a582 9ff0 a682 9ff0 a782 9ff0 a882
0000020 9ff0 a982 9ff0 aa82 9ff0 ab82 9ff0 ac82
0000030 9ff0 ad82 9ff0 9183 9ff0 9283 9ff0 9383
0000040 9ff0 9483 9ff0 9583 9ff0 9683 9ff0 9783
0000050 9ff0 9883 9ff0 9983 9ff0 9a83 9ff0 9b83
0000060 9ff0 9c83 9ff0 9d83 9ff0 8183 9ff0 8283
0000070 9ff0 8383 9ff0 8483 9ff0 8583 9ff0 8683
0000080 9ff0 8783 9ff0 8883 9ff0 8983 9ff0 8a83
0000090 9ff0 8b83 9ff0 8c83 9ff0 8d83 9ff0 b182
00000a0 9ff0 b282 9ff0 b382 9ff0 b482 9ff0 b582
00000b0 9ff0 b682 9ff0 b782 9ff0 b882 9ff0 b982
00000c0 9ff0 ba82 9ff0 bb82 9ff0 bc82 9ff0 bd82
00000d0 000a                                   
00000d1

( kartu bermain unicode )

berhenti mengubah counterclockwis
sumber
2
Keluarannya adalah spasi putih ...
Peter Olson
1
Eh, tidak bukan! Apa maksudmu?
Berhenti menghidupkan counterclockwis
Ok ini menarik, langsung setelah mengedit Stack Exchange juga menunjukkan ruang kosong. Aneh ... setelah memposting komentar ini berfungsi lagi.
Berhenti menghidupkan counterclock dengan
3
Anda tidak memiliki font untuk melihat titik-titik codep yang indah seperti 'PLAYING CARD JACK OF CLUBS' (U + 1F0DB) .
Lars Viklund
8

Python 2, 79 karakter

d=zip("23456789TJQKA"*4,"CDHS"*13)
exec'print d;d[::2],d[1::2]=d[:26],d[26:];'*9

Outputnya agak jelek tapi saya yakin itu harus diperhitungkan.

[('2', 'C'), ('3', 'D'), ('4', 'H'), ('5', 'S'), ('6', 'C'), ('7', 'D'), ('8', 'H'), ('9', 'S'), ('T', 'C'), ('J', 'D'), ('Q', 'H'), ('K', 'S'), ('A', 'C'), ('2', 'D'), ('3', 'H'), ('4', 'S'), ('5', 'C'), ('6', 'D'), ('7', 'H'), ('8', 'S'), ('9', 'C'), ('T', 'D'), ('J', 'H'), ('Q', 'S'), ('K', 'C'), ('A', 'D'), ('2', 'H'), ('3', 'S'), ('4', 'C'), ('5', 'D'), ('6', 'H'), ('7', 'S'), ('8', 'C'), ('9', 'D'), ('T', 'H'), ('J', 'S'), ('Q', 'C'), ('K', 'D'), ('A', 'H'), ('2', 'S'), ('3', 'C'), ('4', 'D'), ('5', 'H'), ('6', 'S'), ('7', 'C'), ('8', 'D'), ('9', 'H'), ('T', 'S'), ('J', 'C'), ('Q', 'D'), ('K', 'H'), ('A', 'S')]
[('2', 'C'), ('2', 'H'), ('3', 'D'), ('3', 'S'), ('4', 'H'), ('4', 'C'), ('5', 'S'), ('5', 'D'), ('6', 'C'), ('6', 'H'), ('7', 'D'), ('7', 'S'), ('8', 'H'), ('8', 'C'), ('9', 'S'), ('9', 'D'), ('T', 'C'), ('T', 'H'), ('J', 'D'), ('J', 'S'), ('Q', 'H'), ('Q', 'C'), ('K', 'S'), ('K', 'D'), ('A', 'C'), ('A', 'H'), ('2', 'D'), ('2', 'S'), ('3', 'H'), ('3', 'C'), ('4', 'S'), ('4', 'D'), ('5', 'C'), ('5', 'H'), ('6', 'D'), ('6', 'S'), ('7', 'H'), ('7', 'C'), ('8', 'S'), ('8', 'D'), ('9', 'C'), ('9', 'H'), ('T', 'D'), ('T', 'S'), ('J', 'H'), ('J', 'C'), ('Q', 'S'), ('Q', 'D'), ('K', 'C'), ('K', 'H'), ('A', 'D'), ('A', 'S')]
[('2', 'C'), ('2', 'D'), ('2', 'H'), ('2', 'S'), ('3', 'D'), ('3', 'H'), ('3', 'S'), ('3', 'C'), ('4', 'H'), ('4', 'S'), ('4', 'C'), ('4', 'D'), ('5', 'S'), ('5', 'C'), ('5', 'D'), ('5', 'H'), ('6', 'C'), ('6', 'D'), ('6', 'H'), ('6', 'S'), ('7', 'D'), ('7', 'H'), ('7', 'S'), ('7', 'C'), ('8', 'H'), ('8', 'S'), ('8', 'C'), ('8', 'D'), ('9', 'S'), ('9', 'C'), ('9', 'D'), ('9', 'H'), ('T', 'C'), ('T', 'D'), ('T', 'H'), ('T', 'S'), ('J', 'D'), ('J', 'H'), ('J', 'S'), ('J', 'C'), ('Q', 'H'), ('Q', 'S'), ('Q', 'C'), ('Q', 'D'), ('K', 'S'), ('K', 'C'), ('K', 'D'), ('K', 'H'), ('A', 'C'), ('A', 'D'), ('A', 'H'), ('A', 'S')]
[('2', 'C'), ('8', 'C'), ('2', 'D'), ('8', 'D'), ('2', 'H'), ('9', 'S'), ('2', 'S'), ('9', 'C'), ('3', 'D'), ('9', 'D'), ('3', 'H'), ('9', 'H'), ('3', 'S'), ('T', 'C'), ('3', 'C'), ('T', 'D'), ('4', 'H'), ('T', 'H'), ('4', 'S'), ('T', 'S'), ('4', 'C'), ('J', 'D'), ('4', 'D'), ('J', 'H'), ('5', 'S'), ('J', 'S'), ('5', 'C'), ('J', 'C'), ('5', 'D'), ('Q', 'H'), ('5', 'H'), ('Q', 'S'), ('6', 'C'), ('Q', 'C'), ('6', 'D'), ('Q', 'D'), ('6', 'H'), ('K', 'S'), ('6', 'S'), ('K', 'C'), ('7', 'D'), ('K', 'D'), ('7', 'H'), ('K', 'H'), ('7', 'S'), ('A', 'C'), ('7', 'C'), ('A', 'D'), ('8', 'H'), ('A', 'H'), ('8', 'S'), ('A', 'S')]
[('2', 'C'), ('5', 'C'), ('8', 'C'), ('J', 'C'), ('2', 'D'), ('5', 'D'), ('8', 'D'), ('Q', 'H'), ('2', 'H'), ('5', 'H'), ('9', 'S'), ('Q', 'S'), ('2', 'S'), ('6', 'C'), ('9', 'C'), ('Q', 'C'), ('3', 'D'), ('6', 'D'), ('9', 'D'), ('Q', 'D'), ('3', 'H'), ('6', 'H'), ('9', 'H'), ('K', 'S'), ('3', 'S'), ('6', 'S'), ('T', 'C'), ('K', 'C'), ('3', 'C'), ('7', 'D'), ('T', 'D'), ('K', 'D'), ('4', 'H'), ('7', 'H'), ('T', 'H'), ('K', 'H'), ('4', 'S'), ('7', 'S'), ('T', 'S'), ('A', 'C'), ('4', 'C'), ('7', 'C'), ('J', 'D'), ('A', 'D'), ('4', 'D'), ('8', 'H'), ('J', 'H'), ('A', 'H'), ('5', 'S'), ('8', 'S'), ('J', 'S'), ('A', 'S')]
[('2', 'C'), ('T', 'C'), ('5', 'C'), ('K', 'C'), ('8', 'C'), ('3', 'C'), ('J', 'C'), ('7', 'D'), ('2', 'D'), ('T', 'D'), ('5', 'D'), ('K', 'D'), ('8', 'D'), ('4', 'H'), ('Q', 'H'), ('7', 'H'), ('2', 'H'), ('T', 'H'), ('5', 'H'), ('K', 'H'), ('9', 'S'), ('4', 'S'), ('Q', 'S'), ('7', 'S'), ('2', 'S'), ('T', 'S'), ('6', 'C'), ('A', 'C'), ('9', 'C'), ('4', 'C'), ('Q', 'C'), ('7', 'C'), ('3', 'D'), ('J', 'D'), ('6', 'D'), ('A', 'D'), ('9', 'D'), ('4', 'D'), ('Q', 'D'), ('8', 'H'), ('3', 'H'), ('J', 'H'), ('6', 'H'), ('A', 'H'), ('9', 'H'), ('5', 'S'), ('K', 'S'), ('8', 'S'), ('3', 'S'), ('J', 'S'), ('6', 'S'), ('A', 'S')]
[('2', 'C'), ('6', 'C'), ('T', 'C'), ('A', 'C'), ('5', 'C'), ('9', 'C'), ('K', 'C'), ('4', 'C'), ('8', 'C'), ('Q', 'C'), ('3', 'C'), ('7', 'C'), ('J', 'C'), ('3', 'D'), ('7', 'D'), ('J', 'D'), ('2', 'D'), ('6', 'D'), ('T', 'D'), ('A', 'D'), ('5', 'D'), ('9', 'D'), ('K', 'D'), ('4', 'D'), ('8', 'D'), ('Q', 'D'), ('4', 'H'), ('8', 'H'), ('Q', 'H'), ('3', 'H'), ('7', 'H'), ('J', 'H'), ('2', 'H'), ('6', 'H'), ('T', 'H'), ('A', 'H'), ('5', 'H'), ('9', 'H'), ('K', 'H'), ('5', 'S'), ('9', 'S'), ('K', 'S'), ('4', 'S'), ('8', 'S'), ('Q', 'S'), ('3', 'S'), ('7', 'S'), ('J', 'S'), ('2', 'S'), ('6', 'S'), ('T', 'S'), ('A', 'S')]
[('2', 'C'), ('4', 'H'), ('6', 'C'), ('8', 'H'), ('T', 'C'), ('Q', 'H'), ('A', 'C'), ('3', 'H'), ('5', 'C'), ('7', 'H'), ('9', 'C'), ('J', 'H'), ('K', 'C'), ('2', 'H'), ('4', 'C'), ('6', 'H'), ('8', 'C'), ('T', 'H'), ('Q', 'C'), ('A', 'H'), ('3', 'C'), ('5', 'H'), ('7', 'C'), ('9', 'H'), ('J', 'C'), ('K', 'H'), ('3', 'D'), ('5', 'S'), ('7', 'D'), ('9', 'S'), ('J', 'D'), ('K', 'S'), ('2', 'D'), ('4', 'S'), ('6', 'D'), ('8', 'S'), ('T', 'D'), ('Q', 'S'), ('A', 'D'), ('3', 'S'), ('5', 'D'), ('7', 'S'), ('9', 'D'), ('J', 'S'), ('K', 'D'), ('2', 'S'), ('4', 'D'), ('6', 'S'), ('8', 'D'), ('T', 'S'), ('Q', 'D'), ('A', 'S')]
[('2', 'C'), ('3', 'D'), ('4', 'H'), ('5', 'S'), ('6', 'C'), ('7', 'D'), ('8', 'H'), ('9', 'S'), ('T', 'C'), ('J', 'D'), ('Q', 'H'), ('K', 'S'), ('A', 'C'), ('2', 'D'), ('3', 'H'), ('4', 'S'), ('5', 'C'), ('6', 'D'), ('7', 'H'), ('8', 'S'), ('9', 'C'), ('T', 'D'), ('J', 'H'), ('Q', 'S'), ('K', 'C'), ('A', 'D'), ('2', 'H'), ('3', 'S'), ('4', 'C'), ('5', 'D'), ('6', 'H'), ('7', 'S'), ('8', 'C'), ('9', 'D'), ('T', 'H'), ('J', 'S'), ('Q', 'C'), ('K', 'D'), ('A', 'H'), ('2', 'S'), ('3', 'C'), ('4', 'D'), ('5', 'H'), ('6', 'S'), ('7', 'C'), ('8', 'D'), ('9', 'H'), ('T', 'S'), ('J', 'C'), ('Q', 'D'), ('K', 'H'), ('A', 'S')]
Royalti yang Dicuri
sumber
1
bagus product!
Stanby
6

Python2, 104

Ini mirip dengan solusi Ev_Genus. Saya menempatkan setelan di depan pangkat karena itu memungkinkan saya untuk menyelamatkan karakter.

d=[s+[r,`10`][r>"Q"]for r in'A23456789ZJQK'for s in"SCDH"]
exec'print d;d=sum(zip(d[:26],d[26:]),());'*9

Keluaran

['SA', 'CA', 'DA', 'HA', 'S2', 'C2', 'D2', 'H2', 'S3', 'C3', 'D3', 'H3', 'S4', 'C4', 'D4', 'H4', 'S5', 'C5', 'D5', 'H5', 'S6', 'C6', 'D6', 'H6', 'S7', 'C7', 'D7', 'H7', 'S8', 'C8', 'D8', 'H8', 'S9', 'C9', 'D9', 'H9', 'S10', 'C10', 'D10', 'H10', 'SJ', 'CJ', 'DJ', 'HJ', 'SQ', 'CQ', 'DQ', 'HQ', 'SK', 'CK', 'DK', 'HK']
('SA', 'D7', 'CA', 'H7', 'DA', 'S8', 'HA', 'C8', 'S2', 'D8', 'C2', 'H8', 'D2', 'S9', 'H2', 'C9', 'S3', 'D9', 'C3', 'H9', 'D3', 'S10', 'H3', 'C10', 'S4', 'D10', 'C4', 'H10', 'D4', 'SJ', 'H4', 'CJ', 'S5', 'DJ', 'C5', 'HJ', 'D5', 'SQ', 'H5', 'CQ', 'S6', 'DQ', 'C6', 'HQ', 'D6', 'SK', 'H6', 'CK', 'S7', 'DK', 'C7', 'HK')
('SA', 'C4', 'D7', 'H10', 'CA', 'D4', 'H7', 'SJ', 'DA', 'H4', 'S8', 'CJ', 'HA', 'S5', 'C8', 'DJ', 'S2', 'C5', 'D8', 'HJ', 'C2', 'D5', 'H8', 'SQ', 'D2', 'H5', 'S9', 'CQ', 'H2', 'S6', 'C9', 'DQ', 'S3', 'C6', 'D9', 'HQ', 'C3', 'D6', 'H9', 'SK', 'D3', 'H6', 'S10', 'CK', 'H3', 'S7', 'C10', 'DK', 'S4', 'C7', 'D10', 'HK')
('SA', 'S9', 'C4', 'CQ', 'D7', 'H2', 'H10', 'S6', 'CA', 'C9', 'D4', 'DQ', 'H7', 'S3', 'SJ', 'C6', 'DA', 'D9', 'H4', 'HQ', 'S8', 'C3', 'CJ', 'D6', 'HA', 'H9', 'S5', 'SK', 'C8', 'D3', 'DJ', 'H6', 'S2', 'S10', 'C5', 'CK', 'D8', 'H3', 'HJ', 'S7', 'C2', 'C10', 'D5', 'DK', 'H8', 'S4', 'SQ', 'C7', 'D2', 'D10', 'H5', 'HK')
('SA', 'S5', 'S9', 'SK', 'C4', 'C8', 'CQ', 'D3', 'D7', 'DJ', 'H2', 'H6', 'H10', 'S2', 'S6', 'S10', 'CA', 'C5', 'C9', 'CK', 'D4', 'D8', 'DQ', 'H3', 'H7', 'HJ', 'S3', 'S7', 'SJ', 'C2', 'C6', 'C10', 'DA', 'D5', 'D9', 'DK', 'H4', 'H8', 'HQ', 'S4', 'S8', 'SQ', 'C3', 'C7', 'CJ', 'D2', 'D6', 'D10', 'HA', 'H5', 'H9', 'HK')
('SA', 'S3', 'S5', 'S7', 'S9', 'SJ', 'SK', 'C2', 'C4', 'C6', 'C8', 'C10', 'CQ', 'DA', 'D3', 'D5', 'D7', 'D9', 'DJ', 'DK', 'H2', 'H4', 'H6', 'H8', 'H10', 'HQ', 'S2', 'S4', 'S6', 'S8', 'S10', 'SQ', 'CA', 'C3', 'C5', 'C7', 'C9', 'CJ', 'CK', 'D2', 'D4', 'D6', 'D8', 'D10', 'DQ', 'HA', 'H3', 'H5', 'H7', 'H9', 'HJ', 'HK')
('SA', 'S2', 'S3', 'S4', 'S5', 'S6', 'S7', 'S8', 'S9', 'S10', 'SJ', 'SQ', 'SK', 'CA', 'C2', 'C3', 'C4', 'C5', 'C6', 'C7', 'C8', 'C9', 'C10', 'CJ', 'CQ', 'CK', 'DA', 'D2', 'D3', 'D4', 'D5', 'D6', 'D7', 'D8', 'D9', 'D10', 'DJ', 'DQ', 'DK', 'HA', 'H2', 'H3', 'H4', 'H5', 'H6', 'H7', 'H8', 'H9', 'H10', 'HJ', 'HQ', 'HK')
('SA', 'DA', 'S2', 'D2', 'S3', 'D3', 'S4', 'D4', 'S5', 'D5', 'S6', 'D6', 'S7', 'D7', 'S8', 'D8', 'S9', 'D9', 'S10', 'D10', 'SJ', 'DJ', 'SQ', 'DQ', 'SK', 'DK', 'CA', 'HA', 'C2', 'H2', 'C3', 'H3', 'C4', 'H4', 'C5', 'H5', 'C6', 'H6', 'C7', 'H7', 'C8', 'H8', 'C9', 'H9', 'C10', 'H10', 'CJ', 'HJ', 'CQ', 'HQ', 'CK', 'HK')
('SA', 'CA', 'DA', 'HA', 'S2', 'C2', 'D2', 'H2', 'S3', 'C3', 'D3', 'H3', 'S4', 'C4', 'D4', 'H4', 'S5', 'C5', 'D5', 'H5', 'S6', 'C6', 'D6', 'H6', 'S7', 'C7', 'D7', 'H7', 'S8', 'C8', 'D8', 'H8', 'S9', 'C9', 'D9', 'H9', 'S10', 'C10', 'D10', 'H10', 'SJ', 'CJ', 'DJ', 'HJ', 'SQ', 'CQ', 'DQ', 'HQ', 'SK', 'CK', 'DK', 'HK')
stan
sumber
+1. [r,'10'][r>"Q"]bagus. Saya tidak berpikir Anda perlu backticks di sekitar 10. Harga akan baik-baik saja.
Steven Rumbalski
@ StevenRumbalski, saya menggunakan backticks untuk lulz. Harga mengambil jumlah ruang yang sama.
stan
Jika itu yang diijinkan (tidak) memiliki hasil dalam urutan terbalik, ini akan bekerja: exec'print d;d=d[::2]+d[1::2];'*9.
Steven Rumbalski
Malu pada saya. Saya sudah lupa tentang sum.
Ev_genus
6

APL (42)

{↑{⍉2 26⍴⍵}⍣⍵,'A23456789TJQK'∘.,'SCDH'}¨⍳9

Output top-down bukan kiri-kanan (tapi masih dapat dibaca manusia jadi saya kira itu tidak melanggar aturan).

Keluaran:

 AS AS AS AS AS AS AS 
 7D 4C 9S 5S 3S 2S AD AC 7D 

 AC 7D 4C 9S 5S 3S 2S AD AC 
 7H TH QC KS 7S 4S 2D AH 7H 

 AD AC 7D 4C 9S 5S 3S 2S AD 
 8S 4D 2H 8C JS 6S 3D 2C 8S 

 AH 7H TH QC KS 7S 4S 2D AH 
 8C JS 6S 3D 2C 8S 4D 2H 8C 

 2S AD AC 7D 4C 9S 5S 3S 2S 
 8D 4H 9C JD 6C TS 5D 3C 8D 

 2C 8S 4D 2H 8C JS 6S 3D 2C 
 8H JC QD 6H TC QS 6D 3H 8H 

 2D AH 7H TH QC KS 7S 4S 2D 
 9S 5S 3S 2S AD AC 7D 4C 9S 

 2H 8C JS 6S 3D 2C 8S 4D 2H 
 9C JD 6C TS 5D 3C 8D 4H 9C 

 3S 2S AD AC 7D 4C 9S 5S 3S 
 9D 5C 9D 5C 9D 5C 9D 5C 9D 

 3C 8D 4H 9C JD 6C TS 5D 3C 
 9H JH QH KC KD 7C TD 5H 9H 

 3D 2C 8S 4D 2H 8C JS 6S 3D 
 TS 5D 3C 8D 4H 9C JD 6C TS 

 3H 8H JC QD 6H TC QS 6D 3H 
 TC QS 6D 3H 8H JC QD 6H TC 

 4S 2D AH 7H TH QC KS 7S 4S 
 TD 5H 9H JH QH KC KD 7C TD 

 4C 9S 5S 3S 2S AD AC 7D 4C 
 TH QC KS 7S 4S 2D AH 7H TH 

 4D 2H 8C JS 6S 3D 2C 8S 4D 
 JS 6S 3D 2C 8S 4D 2H 8C JS 

 4H 9C JD 6C TS 5D 3C 8D 4H 
 JC QD 6H TC QS 6D 3H 8H JC 

 5S 3S 2S AD AC 7D 4C 9S 5S 
 JD 6C TS 5D 3C 8D 4H 9C JD 

 5C 9D 5C 9D 5C 9D 5C 9D 5C 
 JH QH KC KD 7C TD 5H 9H JH 

 5D 3C 8D 4H 9C JD 6C TS 5D 
 QS 6D 3H 8H JC QD 6H TC QS 

 5H 9H JH QH KC KD 7C TD 5H 
 QC KS 7S 4S 2D AH 7H TH QC 

 6S 3D 2C 8S 4D 2H 8C JS 6S 
 QD 6H TC QS 6D 3H 8H JC QD 

 6C TS 5D 3C 8D 4H 9C JD 6C 
 QH KC KD 7C TD 5H 9H JH QH 

 6D 3H 8H JC QD 6H TC QS 6D 
 KS 7S 4S 2D AH 7H TH QC KS 

 6H TC QS 6D 3H 8H JC QD 6H 
 KC KD 7C TD 5H 9H JH QH KC 

 7S 4S 2D AH 7H TH QC KS 7S 
 KD 7C TD 5H 9H JH QH KC KD 

 7C TD 5H 9H JH QH KC KD 7C 
 KH KH KH KH KH KH KH KH KH 

marinus
sumber
5

K, 55 53 51

{$,/(,').`$2 26#x}\[8;,/"A23456789TJQK",/:\:"SCDH"]

Mencukur 2 karakter dengan mengubah dari representasi simbol ke string

keluaran

k){$,/(,').`$(2 26)#x}\[8;,/"A23456789TJQK",/:\:"SCDH"]
"AS" "AC" "AD" "AH" "2S" "2C" "2D" "2H" "3S" "3C" "3D" "3H" "4S" "4C" "4D" "4H" "5S" "5C" "5D" "5H" "6S" "6C" "6D" "6H" "7S" "7C" "7D" "7H" "8S" "8C" "8D" "8H" "9S" "9C" "9D" "9H" "TS" "TC" "TD" "TH" "JS" "JC" "JD" "JH" "QS" "QC" "QD" "QH" "KS" "KC" "KD" "KH"
"AS" "7D" "AC" "7H" "AD" "8S" "AH" "8C" "2S" "8D" "2C" "8H" "2D" "9S" "2H" "9C" "3S" "9D" "3C" "9H" "3D" "TS" "3H" "TC" "4S" "TD" "4C" "TH" "4D" "JS" "4H" "JC" "5S" "JD" "5C" "JH" "5D" "QS" "5H" "QC" "6S" "QD" "6C" "QH" "6D" "KS" "6H" "KC" "7S" "KD" "7C" "KH"
"AS" "4C" "7D" "TH" "AC" "4D" "7H" "JS" "AD" "4H" "8S" "JC" "AH" "5S" "8C" "JD" "2S" "5C" "8D" "JH" "2C" "5D" "8H" "QS" "2D" "5H" "9S" "QC" "2H" "6S" "9C" "QD" "3S" "6C" "9D" "QH" "3C" "6D" "9H" "KS" "3D" "6H" "TS" "KC" "3H" "7S" "TC" "KD" "4S" "7C" "TD" "KH"
"AS" "9S" "4C" "QC" "7D" "2H" "TH" "6S" "AC" "9C" "4D" "QD" "7H" "3S" "JS" "6C" "AD" "9D" "4H" "QH" "8S" "3C" "JC" "6D" "AH" "9H" "5S" "KS" "8C" "3D" "JD" "6H" "2S" "TS" "5C" "KC" "8D" "3H" "JH" "7S" "2C" "TC" "5D" "KD" "8H" "4S" "QS" "7C" "2D" "TD" "5H" "KH"
"AS" "5S" "9S" "KS" "4C" "8C" "QC" "3D" "7D" "JD" "2H" "6H" "TH" "2S" "6S" "TS" "AC" "5C" "9C" "KC" "4D" "8D" "QD" "3H" "7H" "JH" "3S" "7S" "JS" "2C" "6C" "TC" "AD" "5D" "9D" "KD" "4H" "8H" "QH" "4S" "8S" "QS" "3C" "7C" "JC" "2D" "6D" "TD" "AH" "5H" "9H" "KH"
"AS" "3S" "5S" "7S" "9S" "JS" "KS" "2C" "4C" "6C" "8C" "TC" "QC" "AD" "3D" "5D" "7D" "9D" "JD" "KD" "2H" "4H" "6H" "8H" "TH" "QH" "2S" "4S" "6S" "8S" "TS" "QS" "AC" "3C" "5C" "7C" "9C" "JC" "KC" "2D" "4D" "6D" "8D" "TD" "QD" "AH" "3H" "5H" "7H" "9H" "JH" "KH"
"AS" "2S" "3S" "4S" "5S" "6S" "7S" "8S" "9S" "TS" "JS" "QS" "KS" "AC" "2C" "3C" "4C" "5C" "6C" "7C" "8C" "9C" "TC" "JC" "QC" "KC" "AD" "2D" "3D" "4D" "5D" "6D" "7D" "8D" "9D" "TD" "JD" "QD" "KD" "AH" "2H" "3H" "4H" "5H" "6H" "7H" "8H" "9H" "TH" "JH" "QH" "KH"
"AS" "AD" "2S" "2D" "3S" "3D" "4S" "4D" "5S" "5D" "6S" "6D" "7S" "7D" "8S" "8D" "9S" "9D" "TS" "TD" "JS" "JD" "QS" "QD" "KS" "KD" "AC" "AH" "2C" "2H" "3C" "3H" "4C" "4H" "5C" "5H" "6C" "6H" "7C" "7H" "8C" "8H" "9C" "9H" "TC" "TH" "JC" "JH" "QC" "QH" "KC" "KH"
"AS" "AC" "AD" "AH" "2S" "2C" "2D" "2H" "3S" "3C" "3D" "3H" "4S" "4C" "4D" "4H" "5S" "5C" "5D" "5H" "6S" "6C" "6D" "6H" "7S" "7C" "7D" "7H" "8S" "8C" "8D" "8H" "9S" "9C" "9D" "9H" "TS" "TC" "TD" "TH" "JS" "JC" "JD" "JH" "QS" "QC" "QD" "QH" "KS" "KC" "KD" "KH"

k)@[a;0]~@[;8]a:{$,/(,').`$(2 26)#x}\[8;,/"A23456789TJQK",/:\:"SCDH"]  /8th iteration identical to the first?
1b
tmartin
sumber
Anda dapat memotong 2 karakter selanjutnya (dan mengalahkan J) dengan mengubah (2;26)ke2 26
skeevey pada
Luar biasa. Saya telah mengalami pertempuran yang berkelanjutan dengan solusi J. 65-55-54-53-52-51
tmartin
4

Ruby 1.9 (95 93 87)

a=(0..51).map{|i|:A23456789TJQK[i/4]+:SCDH[i%4]}
9.times{p a;a=a.zip(a.pop 26).flatten}

Keluaran:

["AS", "AC", "AD", "AH", "2S", "2C", "2D", "2H", "3S", "3C", "3D", "3H", "4S", "4C", "4D", "4H", "5S", "5C", "5D", "5H", "6S", "6C", "6D", "6H", "7S", "7C", "7D", "7H", "8S", "8C", "8D", "8H", "9S", "9C", "9D", "9H", "TS", "TC", "TD", "TH", "JS", "JC", "JD", "JH", "QS", "QC", "QD", "QH", "KS", "KC", "KD", "KH"]
["AS", "7D", "AC", "7H", "AD", "8S", "AH", "8C", "2S", "8D", "2C", "8H", "2D", "9S", "2H", "9C", "3S", "9D", "3C", "9H", "3D", "TS", "3H", "TC", "4S", "TD", "4C", "TH", "4D", "JS", "4H", "JC", "5S", "JD", "5C", "JH", "5D", "QS", "5H", "QC", "6S", "QD", "6C", "QH", "6D", "KS", "6H", "KC", "7S", "KD", "7C", "KH"]
["AS", "4C", "7D", "TH", "AC", "4D", "7H", "JS", "AD", "4H", "8S", "JC", "AH", "5S", "8C", "JD", "2S", "5C", "8D", "JH", "2C", "5D", "8H", "QS", "2D", "5H", "9S", "QC", "2H", "6S", "9C", "QD", "3S", "6C", "9D", "QH", "3C", "6D", "9H", "KS", "3D", "6H", "TS", "KC", "3H", "7S", "TC", "KD", "4S", "7C", "TD", "KH"]
["AS", "9S", "4C", "QC", "7D", "2H", "TH", "6S", "AC", "9C", "4D", "QD", "7H", "3S", "JS", "6C", "AD", "9D", "4H", "QH", "8S", "3C", "JC", "6D", "AH", "9H", "5S", "KS", "8C", "3D", "JD", "6H", "2S", "TS", "5C", "KC", "8D", "3H", "JH", "7S", "2C", "TC", "5D", "KD", "8H", "4S", "QS", "7C", "2D", "TD", "5H", "KH"]
["AS", "5S", "9S", "KS", "4C", "8C", "QC", "3D", "7D", "JD", "2H", "6H", "TH", "2S", "6S", "TS", "AC", "5C", "9C", "KC", "4D", "8D", "QD", "3H", "7H", "JH", "3S", "7S", "JS", "2C", "6C", "TC", "AD", "5D", "9D", "KD", "4H", "8H", "QH", "4S", "8S", "QS", "3C", "7C", "JC", "2D", "6D", "TD", "AH", "5H", "9H", "KH"]
["AS", "3S", "5S", "7S", "9S", "JS", "KS", "2C", "4C", "6C", "8C", "TC", "QC", "AD", "3D", "5D", "7D", "9D", "JD", "KD", "2H", "4H", "6H", "8H", "TH", "QH", "2S", "4S", "6S", "8S", "TS", "QS", "AC", "3C", "5C", "7C", "9C", "JC", "KC", "2D", "4D", "6D", "8D", "TD", "QD", "AH", "3H", "5H", "7H", "9H", "JH", "KH"]
["AS", "2S", "3S", "4S", "5S", "6S", "7S", "8S", "9S", "TS", "JS", "QS", "KS", "AC", "2C", "3C", "4C", "5C", "6C", "7C", "8C", "9C", "TC", "JC", "QC", "KC", "AD", "2D", "3D", "4D", "5D", "6D", "7D", "8D", "9D", "TD", "JD", "QD", "KD", "AH", "2H", "3H", "4H", "5H", "6H", "7H", "8H", "9H", "TH", "JH", "QH", "KH"]
["AS", "AD", "2S", "2D", "3S", "3D", "4S", "4D", "5S", "5D", "6S", "6D", "7S", "7D", "8S", "8D", "9S", "9D", "TS", "TD", "JS", "JD", "QS", "QD", "KS", "KD", "AC", "AH", "2C", "2H", "3C", "3H", "4C", "4H", "5C", "5H", "6C", "6H", "7C", "7H", "8C", "8H", "9C", "9H", "TC", "TH", "JC", "JH", "QC", "QH", "KC", "KH"]
["AS", "AC", "AD", "AH", "2S", "2C", "2D", "2H", "3S", "3C", "3D", "3H", "4S", "4C", "4D", "4H", "5S", "5C", "5D", "5H", "6S", "6C", "6D", "6H", "7S", "7C", "7D", "7H", "8S", "8C", "8D", "8H", "9S", "9C", "9D", "9H", "TS", "TC", "TD", "TH", "JS", "JC", "JD", "JH", "QS", "QC", "QD", "QH", "KS", "KC", "KD", "KH"]
Paul Prestidge
sumber
1
Simbol bukan string akan menyelamatkan Anda 2 karaktera=(0..51).map{|i|:A23456789TJQK[i/4]+:SCDH[i%4]}
defhlt
@ArtemIce Panggilan yang bagus, untuk beberapa alasan saya pikir saya sudah mencoba yang tidak berhasil. Terima kasih atas tipnya!
Paul Prestidge
1
Sama sama! Satu ide lagi adalah kita bisa menggunakan dan popbukannya slice!menyimpan 6 karakter. 9.times{p a;a=a.zip(a.pop 26).flatten}
defhlt
3

Python3, 180 179

from itertools import*;i=list(map("".join,product("A23456789XJQK","SCDH")));exec('print(",".join(i).replace("X","10"));i=list(chain(*zip(islice(i,0,26,1),islice(i,26,52,1))));'*8)

Garis output seperti dalam tugas.

Format Asli 151

from itertools import*;i=list(map("".join,product("A23456789TJQK","SCDH")));exec('print(i);i=list(chain(*zip(islice(i,0,26,1),islice(i,26,52,1))));'*8)

Outputnya seperti dalam versi Ruby.

Ev_genus
sumber
1
Saya pikir Anda dapat menghemat char dengan menjatuhkan spasi di antara importdan *: ideone.com/kQTbs
Cristian Lupascu
Jika Anda menggunakan 2.x, Anda seharusnya dapat menjatuhkan daftar pertama (), karena peta () mengembalikan daftar bukan generator.
Joel Cornett
3

GolfScript, 51 50 46 karakter

"A23456789TJQK"4*"SCDH"13*]{zip""*2/.p 26/}9*;

Kode GolfScript ini menghasilkan output berikut (lihat di sini ):

["AS" "2C" "3D" "4H" "5S" "6C" "7D" "8H" "9S" "TC" "JD" "QH" "KS" "AC" "2D" "3H" "4S" "5C" "6D" "7H" "8S" "9C" "TD" "JH" "QS" "KC" "AD" "2H" "3S" "4C" "5D" "6H" "7S" "8C" "9D" "TH" "JS" "QC" "KD" "AH" "2S" "3C" "4D" "5H" "6S" "7C" "8D" "9H" "TS" "JC" "QD" "KH"]
["AS" "AD" "2C" "2H" "3D" "3S" "4H" "4C" "5S" "5D" "6C" "6H" "7D" "7S" "8H" "8C" "9S" "9D" "TC" "TH" "JD" "JS" "QH" "QC" "KS" "KD" "AC" "AH" "2D" "2S" "3H" "3C" "4S" "4D" "5C" "5H" "6D" "6S" "7H" "7C" "8S" "8D" "9C" "9H" "TD" "TS" "JH" "JC" "QS" "QD" "KC" "KH"]
["AS" "AC" "AD" "AH" "2C" "2D" "2H" "2S" "3D" "3H" "3S" "3C" "4H" "4S" "4C" "4D" "5S" "5C" "5D" "5H" "6C" "6D" "6H" "6S" "7D" "7H" "7S" "7C" "8H" "8S" "8C" "8D" "9S" "9C" "9D" "9H" "TC" "TD" "TH" "TS" "JD" "JH" "JS" "JC" "QH" "QS" "QC" "QD" "KS" "KC" "KD" "KH"]
["AS" "7S" "AC" "7C" "AD" "8H" "AH" "8S" "2C" "8C" "2D" "8D" "2H" "9S" "2S" "9C" "3D" "9D" "3H" "9H" "3S" "TC" "3C" "TD" "4H" "TH" "4S" "TS" "4C" "JD" "4D" "JH" "5S" "JS" "5C" "JC" "5D" "QH" "5H" "QS" "6C" "QC" "6D" "QD" "6H" "KS" "6S" "KC" "7D" "KD" "7H" "KH"]
["AS" "4S" "7S" "TS" "AC" "4C" "7C" "JD" "AD" "4D" "8H" "JH" "AH" "5S" "8S" "JS" "2C" "5C" "8C" "JC" "2D" "5D" "8D" "QH" "2H" "5H" "9S" "QS" "2S" "6C" "9C" "QC" "3D" "6D" "9D" "QD" "3H" "6H" "9H" "KS" "3S" "6S" "TC" "KC" "3C" "7D" "TD" "KD" "4H" "7H" "TH" "KH"]
["AS" "9S" "4S" "QS" "7S" "2S" "TS" "6C" "AC" "9C" "4C" "QC" "7C" "3D" "JD" "6D" "AD" "9D" "4D" "QD" "8H" "3H" "JH" "6H" "AH" "9H" "5S" "KS" "8S" "3S" "JS" "6S" "2C" "TC" "5C" "KC" "8C" "3C" "JC" "7D" "2D" "TD" "5D" "KD" "8D" "4H" "QH" "7H" "2H" "TH" "5H" "KH"]
["AS" "5S" "9S" "KS" "4S" "8S" "QS" "3S" "7S" "JS" "2S" "6S" "TS" "2C" "6C" "TC" "AC" "5C" "9C" "KC" "4C" "8C" "QC" "3C" "7C" "JC" "3D" "7D" "JD" "2D" "6D" "TD" "AD" "5D" "9D" "KD" "4D" "8D" "QD" "4H" "8H" "QH" "3H" "7H" "JH" "2H" "6H" "TH" "AH" "5H" "9H" "KH"]
["AS" "3D" "5S" "7D" "9S" "JD" "KS" "2D" "4S" "6D" "8S" "TD" "QS" "AD" "3S" "5D" "7S" "9D" "JS" "KD" "2S" "4D" "6S" "8D" "TS" "QD" "2C" "4H" "6C" "8H" "TC" "QH" "AC" "3H" "5C" "7H" "9C" "JH" "KC" "2H" "4C" "6H" "8C" "TH" "QC" "AH" "3C" "5H" "7C" "9H" "JC" "KH"]
["AS" "2C" "3D" "4H" "5S" "6C" "7D" "8H" "9S" "TC" "JD" "QH" "KS" "AC" "2D" "3H" "4S" "5C" "6D" "7H" "8S" "9C" "TD" "JH" "QS" "KC" "AD" "2H" "3S" "4C" "5D" "6H" "7S" "8C" "9D" "TH" "JS" "QC" "KD" "AH" "2S" "3C" "4D" "5H" "6S" "7C" "8D" "9H" "TS" "JC" "QD" "KH"]
Howard
sumber
1
Karena kartu dapat mulai dalam urutan apa pun, dan karena gcd (13, 4) = 1, Anda dapat menggantinya {...}%dengan 4*.
Peter Taylor
@PeterTaylor Terima kasih. Tidak membaca komentar "dalam urutan apa pun".
Howard
3

Perl, 91 karakter

Adakah saran tentang cara yang lebih ringkas untuk membangun dek awal? Pendekatan saya menggunakan 2 substitusi untuk membangun $_dan kemudian kecocokan global dalam konteks daftar untuk menginisialisasi @_.

Menyeret ini kemudian dilakukan dengan berulang kali spliceing @_ke @adan interleaving dua daftar dengan mapkembali ke @_.

s//A23456789TJQK/,s/(.)/$1S$1C$1D$1H/g,@_=/../g;say@_=map{shift@_,$_}@a=splice@_,26for 0..8
ardnew
sumber
3

Mathematica 131 129 120 120 114 100 86 karakter

Dengan bantuan dari Mr.Wizard:

NestList[Riffle @@ #~Partition~26 &, # <> "" & /@ Tuples@Characters@
{"A23456789TJQK", "HDCS"}, 8]

Keluaran:

mengocok

DavidC
sumber
MrWizard menyarankan untuk mengurangi ini menjadi 86 karakter sebagaiNestList[Riffle@@#~Partition~26&,#<>""&/@Tuples@Characters@{"A23456789TJQK","HDCS"},8]
Peter Taylor
Aku melakukannya. Perampingan yang sangat bagus. Saya terutama menyukai trik untuk mengurangi StringJoin.
DavidC
2

CJam, 34 byte

CJam lebih baru dari pertanyaan, jadi jawaban ini tidak bersaing untuk tanda centang hijau, tapi saya pikir ini akan menjadi masalah yang bagus untuk dicoba di CJam.

A,2>s"TJQKA"+"SCDH"m*{_p26/z:~}8*p

Uji di sini.

Ini mencetak output seperti

["2S" "2C" "2D" "2H" "3S" "3C" "3D" "3H" "4S" "4C" "4D" "4H" "5S" "5C" "5D" "5H" "6S" "6C" "6D" "6H" "7S" "7C" "7D" "7H" "8S" "8C" "8D" "8H" "9S" "9C" "9D" "9H" "TS" "TC" "TD" "TH" "JS" "JC" "JD" "JH" "QS" "QC" "QD" "QH" "KS" "KC" "KD" "KH" "AS" "AC" "AD" "AH"]
["2S" "8D" "2C" "8H" "2D" "9S" "2H" "9C" "3S" "9D" "3C" "9H" "3D" "TS" "3H" "TC" "4S" "TD" "4C" "TH" "4D" "JS" "4H" "JC" "5S" "JD" "5C" "JH" "5D" "QS" "5H" "QC" "6S" "QD" "6C" "QH" "6D" "KS" "6H" "KC" "7S" "KD" "7C" "KH" "7D" "AS" "7H" "AC" "8S" "AD" "8C" "AH"]
["2S" "5C" "8D" "JH" "2C" "5D" "8H" "QS" "2D" "5H" "9S" "QC" "2H" "6S" "9C" "QD" "3S" "6C" "9D" "QH" "3C" "6D" "9H" "KS" "3D" "6H" "TS" "KC" "3H" "7S" "TC" "KD" "4S" "7C" "TD" "KH" "4C" "7D" "TH" "AS" "4D" "7H" "JS" "AC" "4H" "8S" "JC" "AD" "5S" "8C" "JD" "AH"]
["2S" "TS" "5C" "KC" "8D" "3H" "JH" "7S" "2C" "TC" "5D" "KD" "8H" "4S" "QS" "7C" "2D" "TD" "5H" "KH" "9S" "4C" "QC" "7D" "2H" "TH" "6S" "AS" "9C" "4D" "QD" "7H" "3S" "JS" "6C" "AC" "9D" "4H" "QH" "8S" "3C" "JC" "6D" "AD" "9H" "5S" "KS" "8C" "3D" "JD" "6H" "AH"]
["2S" "6S" "TS" "AS" "5C" "9C" "KC" "4D" "8D" "QD" "3H" "7H" "JH" "3S" "7S" "JS" "2C" "6C" "TC" "AC" "5D" "9D" "KD" "4H" "8H" "QH" "4S" "8S" "QS" "3C" "7C" "JC" "2D" "6D" "TD" "AD" "5H" "9H" "KH" "5S" "9S" "KS" "4C" "8C" "QC" "3D" "7D" "JD" "2H" "6H" "TH" "AH"]
["2S" "4S" "6S" "8S" "TS" "QS" "AS" "3C" "5C" "7C" "9C" "JC" "KC" "2D" "4D" "6D" "8D" "TD" "QD" "AD" "3H" "5H" "7H" "9H" "JH" "KH" "3S" "5S" "7S" "9S" "JS" "KS" "2C" "4C" "6C" "8C" "TC" "QC" "AC" "3D" "5D" "7D" "9D" "JD" "KD" "2H" "4H" "6H" "8H" "TH" "QH" "AH"]
["2S" "3S" "4S" "5S" "6S" "7S" "8S" "9S" "TS" "JS" "QS" "KS" "AS" "2C" "3C" "4C" "5C" "6C" "7C" "8C" "9C" "TC" "JC" "QC" "KC" "AC" "2D" "3D" "4D" "5D" "6D" "7D" "8D" "9D" "TD" "JD" "QD" "KD" "AD" "2H" "3H" "4H" "5H" "6H" "7H" "8H" "9H" "TH" "JH" "QH" "KH" "AH"]
["2S" "2D" "3S" "3D" "4S" "4D" "5S" "5D" "6S" "6D" "7S" "7D" "8S" "8D" "9S" "9D" "TS" "TD" "JS" "JD" "QS" "QD" "KS" "KD" "AS" "AD" "2C" "2H" "3C" "3H" "4C" "4H" "5C" "5H" "6C" "6H" "7C" "7H" "8C" "8H" "9C" "9H" "TC" "TH" "JC" "JH" "QC" "QH" "KC" "KH" "AC" "AH"]
["2S" "2C" "2D" "2H" "3S" "3C" "3D" "3H" "4S" "4C" "4D" "4H" "5S" "5C" "5D" "5H" "6S" "6C" "6D" "6H" "7S" "7C" "7D" "7H" "8S" "8C" "8D" "8H" "9S" "9C" "9D" "9H" "TS" "TC" "TD" "TH" "JS" "JC" "JD" "JH" "QS" "QC" "QD" "QH" "KS" "KC" "KD" "KH" "AS" "AC" "AD" "AH"]

Penjelasan

A,2>s"TJQKA"+"SCDH"m*{_p26/z:~}8*p
A,                                 "Get the range from 0 to 9.";
  2>                               "Slice off first two elements.";
    s                              "Convert to string '23456789'.";
     "TJQKA"+                      "Append this string.";
             "SCDH"                "Push the suits.";
                   m*              "Take the Cartesian product. This yields the first line.";
                     {        }8*  "Execute this block 8 times.";
                      _p           "Duplicate the last line and print it.";
                        26/        "Split the array into halves.";
                           z       "Zip, i.e. transpose the array.";
                            :~     "Flatten the array.";
                                 p "Print the final deck.";
Martin Ender
sumber
Bisakah Anda jelaskan kode Anda? Saya penasaran.
Thrax
@Thrax Selesai. Benar-benar lupa tentang itu.
Martin Ender
Terima kasih banyak. Solusi hebat, saya suka A,2>mendapatkan angka, pemikiran yang bagus!
Thrax
1

R , 97 byte

Menyimpan beberapa byte dengan dek out-of-order nyaman

d=paste(rep(c(2:10,"A","J","Q","K"),4),quote(S(C,D,H)))
for(i in 1:9)print(d<-c(t(matrix(d,26))))

Cobalah online!

J.Apakah
sumber
0

/// , 753 byte

/*/\/\///}/S,*'/C,*"/D,*;/H,*b/A'*c/A"*d/A;*e/2}*f/2'*g/2"*h/2;*i/3}*j/3'*k/3"*l/3;*m/4}*n/4'*o/4"*p/4;*q/5}*r/5'*s/5"*t/5;*u/6}*v/6'*w/6"*x/6;*y/7}*z/7'*-/7"*B/7;*+/8}*!/8'*E/8"*F/8;*G/9}*@/9'*I/9"*_/9;*(/10}*L/10'*M/10"*N/10;*O/J}*P/J'*)/J"*R/J;*$/Q}*T/Q'*U/Q"*V/Q;*W/K}*X/K'*Y/K"*{/KH
A}/A}bcdefghijklmnopqrstuvwxyz-B+!EFG@I_(LMNOP)R$TUVWXY{-bBc+d!eEfFgGh@iIj_k(lLmMnNoOpPq)rRs$tTuUvVwWxXyYz{n-NboBOcp+Pdq!)erERfsF$gtGThu@UivIVjw_Wkx(XlyLYmzM{GnT-hNub@oUBiOvcIpV+jPwd_qW!k)xe(rXElRyfLsYFm$zgMt{qGWn!Tk-)hxNeu(br@XoEUlBRiyOfvLcsIYpFVm+$jzPgwMdt_{iqyGOWfnv!LTcks-I)YhpxFNVemu+($bjrz@PXgowEMUdltB_R{eimquy+G(O$Wbfjnrvz!@LPTXcgkosw-EIM)UYdhlptxBF_NRV{cegikmoqsuwy-+EGI(MO)$UWYbdfhjlnprtvxzB!F@_LNPRTVX{bcdefghijklmnopqrstuvwxyz-B+!EFG@I_(LMNOP)R$TUVWXYKH

Cobalah online!

Menggunakan contoh output (cukup pas untuk tujuan ini) tanpa spasi tambahan.

Erik the Outgolfer
sumber
0

05AB1E , 24 byte

2TŸ.•-Ÿ•S«.•ôì•âJ9F=2äζ˜

Menggunakan kartu huruf kecil untuk menghemat 2 byte dengan kompresi, karena output apa pun yang dapat dibaca manusia diizinkan.
Dek awal / akhir adalah:

['2c','2d','2h','2s','3c','3d','3h','3s','4c','4d','4h','4s','5c','5d','5h','5s','6c','6d','6h','6s','7c','7d','7h','7s','8c','8d','8h','8s','9c','9d','9h','9s','10c','10d','10h','10s','ac','ad','ah','as','jc','jd','jh','js','qc','qd','qh','qs','kc','kd','kh','ks']

Cobalah online (PS: Menggunakan TIO lawas karena jauh lebih cepat .. Semua bawaan yang digunakan dalam jawaban ini sama di kedua versi Python legacy dan Elixir menulis ulang versi 05AB1E.)

Penjelasan:

2TŸ           # List in the range [2,10]: [2,3,4,5,6,7,8,9,10]
   .•-Ÿ•      # Compressed string "ajqk"
        S     # As a list of characters: ["a","j","q","k"]
         «    # Merge the lists together: [2,3,4,5,6,7,8,9,10,"a","j","q","k"] 
.•ôì•         # Compressed string "cdhs"
     â        # Create each possible pair (cartesian product)
      J       # Join each pair together (now we have our deck of cards)
9F            # Loop 9 times:
  =           #  Print the deck with trailing newline, without popping the deck
   2ä         #  Split it in two equal parts
     ζ        #  Zip it (swap rows/columns)
      ˜       #  Flatten the list of lists

Lihat tip tambang 05AB1E ini (bagian Bagaimana mengompresi string bukan bagian dari kamus? ) Untuk memahami mengapa .•-Ÿ•ini "ajqk"dan .•ôì•itu "cdhs".

Kevin Cruijssen
sumber
0

Japt , 31 byte

9o åÈó c}"SCDH"ï"TJQKA"i2ò9 ¬¹w

Cobalah!

Meskipun Japt memiliki fungsi "interleave dua daftar" yang masuk akal, ia tidak memiliki opsi "terpisah menjadi dua" yang bagus. Alih-alih, saya memilih unshuffle deck dan hanya menampilkan langkah-langkah itu secara terbalik.

Penjelasan:

9o                           ¹     Generate 9 rows, starting with...
         "SCDH"                      The suits
               ï                     Cartesian product with...
                "TJQKA"                The "special" card values
                       i               Concatenated with...
                        2ò9 ¬          Digits 2-9 as a string; i.e. "23456789"
   å    }                          And getting each subsequent row by "unshuffling":
    Èó                               Separate every-other card; e.g. [1,2,3,4,5,6] -> [[1,3,5],[2,4,6]]
       c                             and flatten the two lists; e.g. [[1,3,5],[2,4,6]] -> [1,3,5,2,4,6]
                              w    Display in reverse order

Saya bisa menghemat 2 byte jika saya bisa menggunakan 1 untuk ace, bukan A, tetapi tidak ada jawaban lain yang melakukannya

Kamil Drakari
sumber
0

Perl 6 , 69 byte

([o] {.say;.[flat ^26 Z 26..*]}xx 9)(«A {2..10} J Q K»X~ <S C D H>)

Cobalah online!

  • { .say; .[flat ^26 Z 26..*] } adalah fungsi anonim yang mencetak daftar argumennya, lalu mengembalikan acak daftar itu
  • xx 9 menghasilkan daftar yang berisi sembilan salinan dari fungsi anonim itu
  • [o] mengurangi daftar itu dengan operator komposisi fungsi o , menghasilkan fungsi yang memanggil fungsi anonim asli sembilan kali, melewati daftar yang dikocok di setiap tingkat
  • Akhirnya, dek unshuffled asli dilewatkan ke fungsi tersusun. «A {2..10} J Q K»adalah daftar pangkat, <S C D H>adalah daftar jas, dan X~menghasilkan produk silang dari daftar tersebut dengan operator rangkaian string ~.
Sean
sumber
65 byte
Jo King