Muestra el resultado de hacer 8 barajos perfectos de una baraja de cartas

17

Explicación

Un barajado perfecto es cuando una baraja de cartas se divide exactamente por la mitad y las cartas de cada pila se intercalan alternativamente. Las cartas inferiores originales y la carta superior original deben conservarse después de un barajado perfecto.

Después de 8 barajadas perfectas, un mazo de 52 cartas estándar vuelve a su orden original.

Desafío

Escriba un programa que muestre el estado de una baraja de cartas a medida que pasa por 8 barajadas perfectas consecutivas. Puede usar cualquier representación legible por humanos de un mazo, siempre que muestre el número y el palo de cada carta en el mazo en orden secuencial. Debe mostrar una representación de todas las tarjetas, para los nueve estados.

Este es el código de golf , por lo que gana la solución más corta.

Salida de ejemplo

Aquí hay una salida de ejemplo producida por esta implementación de ejemplo en 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
fuente
Si bien no es un duplicado exacto, esto es esencialmente la mitad de la tarea de Mix the nuts (al menos según lo implementado por las respuestas actuales).
Peter Taylor el
1
¿Es importante el orden de inicio de las cartas?
Paul Prestidge
@chron No, las tarjetas pueden comenzar en cualquier orden.
Peter Olson

Respuestas:

15

J, 66 65 54 52 50 47 43 caracteres

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

Salida:

┌──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┐
│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│
└──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┘

Me obligan cada vez más a los tutoriales y manuales de referencia de J para seguir adelante aquí. : -S

Gareth
fuente
Sus primeras y últimas matrices son idénticas. Además, su primera carta es siempre ASy la última es todo el tiempo KH.
defhlt
1
@ArtemIce Se supone que deben ser. Se requiere en la pregunta. Vuelva a leer el primer párrafo.
Gareth
@Gareth ok lo siento
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=<<"🂡🃑🃁🂱"

Salida:

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


No sé si hay algún problema UTF-8 por aquí, no debería ... este es un volcado hexadecimal del programa

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

y de la primera línea de salida

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

( las cartas de juego unicode )

dejó de girar en sentido antihorario
fuente
2
La salida es un espacio en blanco ...
Peter Olson
1
Erm, no, no lo es! ¿Qué quieres decir?
dejó de girar en contra del reloj el
Ok, esto es interesante, directamente después de editar Stack Exchange también me muestra espacios en blanco. Extraño ... después de publicar este comentario, funciona de nuevo.
dejó de girar en contra del reloj el
3
Te falta la fuente para ver puntos de código tan encantadores como 'JUGANDO TARJETA DE CLUBS' (U + 1F0DB) .
Lars Viklund
8

Python 2, 79 caracteres

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

La salida es un poco fea, pero creo que debería contar.

[('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')]
Nolen Royalty
fuente
1
agradable product!
stand
6

Python2, 104

Esto es similar a la solución de Ev_Genus. Puse el palo antes del rango porque me permite guardar un personaje.

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

Salida

['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')
boothby
fuente
+1. [r,'10'][r>"Q"]es ingenioso No creo que necesites backticks alrededor del 10. Las cotizaciones harían bien.
Steven Rumbalski el
@StevenRumbalski, utilicé backticks para lulz. Las cotizaciones ocupan la misma cantidad de espacio.
Boothby
Si fuera permisible (no lo es) tener los resultados en orden inverso, esto funcionaría: exec'print d;d=d[::2]+d[1::2];'*9 .
Steven Rumbalski
Vergüenza para mí Me he olvidado de sum.
Ev_genus
6

APL (42)

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

La salida es de arriba hacia abajo en lugar de izquierda-derecha (pero sigue siendo legible para humanos, así que supongo que no va en contra de las reglas).

Salida:

 AS AS AS 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
fuente
5

K, 55 53 51

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

Afeitado 2 caracteres al cambiar de la representación del símbolo a una cadena

salida

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
fuente
Puedes cortar otros 2 caracteres (y vencer a J) cambiando (2;26)a2 26
skeevey el
Excelente. He estado teniendo una batalla en curso con esa solución 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}

Salida:

["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
fuente
1
Los símbolos en lugar de cadenas le ahorrarán 2 caracteresa=(0..51).map{|i|:A23456789TJQK[i/4]+:SCDH[i%4]}
defhlt
@ArtemIce Buena llamada, por alguna razón pensé que ya lo había intentado sin éxito. ¡Gracias por el consejo!
Paul Prestidge
1
¡De nada! Una idea más es que podemos usar en poplugar de slice!y guardar 6 caracteres. 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)

Emite líneas como en la tarea.

Formato nativo 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)

La salida es como en la versión Ruby.

Ev_genus
fuente
1
Creo que puedes guardar un personaje dejando el espacio entre importy *: ideone.com/kQTbs
Cristian Lupascu
Si usa 2.x, debería poder soltar la primera lista (), ya que map () devuelve una lista, no un generador.
Joel Cornett
3

GolfScript, 51 50 46 caracteres

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

Este código de GolfScript produce el siguiente resultado (ver aquí ):

["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
fuente
1
Como las tarjetas pueden comenzar en cualquier orden, y dado que gcd (13, 4) = 1, puede reemplazar {...}%por 4*.
Peter Taylor
@PeterTaylor Gracias. No leí ese comentario "en ningún orden".
Howard
3

Perl, 91 caracteres

¿Alguna sugerencia sobre una forma más concisa de construir el mazo inicial? Mi enfoque utiliza 2 sustituciones para construir $_y luego una coincidencia global en el contexto de la lista para inicializar @_.

El barajado continuación se realiza mediante varias ocasiones spliceing @_hacia @ay entrelazado con las dos listas mapde nuevo en @_.

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

Mathematica 131 129 120 114 100 86 caracteres

Con la ayuda de Mr.Wizard:

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

Salida:

baraja

DavidC
fuente
MrWizard sugiere reducir esto a 86 caracteres comoNestList[Riffle@@#~Partition~26&,#<>""&/@Tuples@Characters@{"A23456789TJQK","HDCS"},8]
Peter Taylor
Yo hice. Muy buena racionalización. Me gustó especialmente el truco para reducir StringJoin.
DavidC
2

CJam, 34 bytes

CJam es más nuevo que la pregunta, por lo que esta respuesta no compite por la marca de verificación verde, pero pensé que sería un buen problema intentarlo en CJam.

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

Pruébalo aquí.

Imprime la salida como

["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"]

Explicación

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
fuente
¿Podría por favor explicar su código? Soy curioso.
Thrax
@Thrax Hecho. Se olvidó por completo de eso.
Martin Ender
Genial gracias. Gran solución, me encanta A,2>obtener los números, ¡buen pensamiento!
Thrax
1

R , 97 bytes

Guardado unos pocos bytes con un conveniente mazo fuera de servicio

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))))

Pruébalo en línea!

J.Doe
fuente
0

/// , 753 bytes

/*/\/\///}/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

Pruébalo en línea!

Utiliza la salida de ejemplo (es bastante adecuada para este propósito) sin los espacios finales.

Erik el Outgolfer
fuente
0

05AB1E , 24 bytes

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

Utiliza tarjetas en minúsculas para guardar 2 bytes con compresión, ya que se permite cualquier salida legible por humanos.
El mazo inicial / final es:

['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']

Pruébelo en línea (PS: utiliza el TIO heredado porque es mucho más rápido. Sin embargo, todos los componentes incorporados que se utilizaron en esta respuesta son los mismos tanto en el legado de Python como en las versiones de reescritura de Elixir de 05AB1E).

Explicación:

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

Consulte este consejo mío de 05AB1E (sección ¿Cómo comprimir cadenas que no forman parte del diccionario? ) Para comprender por qué .•-Ÿ•es "ajqk"y .•ôì•es "cdhs".

Kevin Cruijssen
fuente
0

Japt , 31 bytes

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

¡Intentalo!

Aunque Japt tiene una función razonable de "intercalar dos listas", no tiene una gran opción de "separar en mitades". En su lugar, opté por mezclar un mazo y simplemente mostrar esos pasos en reversa.

Explicación:

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

Podría ahorrar 2 bytes si pudiera usar 1 para ases en lugar de A, pero ninguna de las otras respuestas hizo eso

Kamil Drakari
fuente
0

Perl 6 , 69 bytes

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

Pruébalo en línea!

  • { .say; .[flat ^26 Z 26..*] } es una función anónima que imprime su lista de argumentos, luego devuelve una combinación aleatoria perfecta de esa lista
  • xx 9 produce una lista que contiene nueve copias de esa función anónima
  • [o] reduce esa lista con el operador de composición de funciones o , produciendo una función que llama a la función anónima original nueve veces, pasando la lista aleatoria por cada nivel
  • Finalmente, el mazo original sin mezclar se pasa a esa función compuesta. «A {2..10} J Q K»es una lista de los rangos, <S C D H>es una lista de los trajes y X~produce el producto cruzado de esas listas con el operador de concatenación de cadenas ~.
Sean
fuente
65 bytes
Jo King