#QBasic 4.5, (削除) 114 (削除ここまで)(削除) 142 (削除ここまで) 127 bytes
QBasic 4.5, (削除) 114 (削除ここまで)(削除) 142 (削除ここまで) 127 bytes
#QBasic 4.5, (削除) 114 (削除ここまで)(削除) 142 (削除ここまで) 127 bytes
QBasic 4.5, (削除) 114 (削除ここまで)(削除) 142 (削除ここまで) 127 bytes
If we add this snippet to our code, we can see what is puntput into r$:
dim r$(54) ' create a 54-slot array for our results
FOR i=1TO 52 ' Loop through the numbers 1-52 in var i
m=i MOD 13 ' Take i mod 13 to select a value (saved as m)
' , and (not saved) i intdiv 13 to get a suit
r$(i)= ' assigns to slot i in the result array
MID$("JQKA2345678910" ' a sunstringsubstring from the string with all the values
,1+m ' from position 1-13 (13 % 13 = 0, but QBasic strings are 1-based.
' Hence the + 1)
,1-(m=12)) ' taking 1 char by default, and 2 for the Ten
' Note that m=12 evaluates to 0 for 0-11, and to -1 for 12
+ MID$("CDHS",(i-1)13円+1,1) ' and take 1 char from the suits-string
NEXT
r$(53)="J ' Then append 2 jokers
r$(54)="J ' These strings are auto-closed by the QBasic compiler.
If we add this snippet to our code, we can see what is punt into r$:
dim r$(54) ' create a 54-slot array for our results
FOR i=1TO 52 ' Loop through the numbers 1-52 in var i
m=i MOD 13 ' Take i mod 13 to select a value (saved as m)
' , and (not saved) i intdiv 13 to get a suit
r$(i)= ' assigns to slot i in the result array
MID$("JQKA2345678910" ' a sunstring from the string with all the values
,1+m ' from position 1-13 (13 % 13 = 0, but QBasic strings are 1-based.
' Hence the + 1)
,1-(m=12)) ' taking 1 char by default, and 2 for the Ten
' Note that m=12 evaluates to 0 for 0-11, and to -1 for 12
+ MID$("CDHS",(i-1)13円+1,1) ' and take 1 char from the suits-string
NEXT
r$(53)="J ' Then append 2 jokers
r$(54)="J ' These strings are auto-closed by the QBasic compiler.
If we add this snippet to our code, we can see what is put into r$:
dim r$(54) ' create a 54-slot array for our results
FOR i=1TO 52 ' Loop through the numbers 1-52 in var i
m=i MOD 13 ' Take i mod 13 to select a value (saved as m)
' , and (not saved) i intdiv 13 to get a suit
r$(i)= ' assigns to slot i in the result array
MID$("JQKA2345678910" ' a substring from the string with all the values
,1+m ' from position 1-13 (13 % 13 = 0, but QBasic strings are 1-based.
' Hence the + 1)
,1-(m=12)) ' taking 1 char by default, and 2 for the Ten
' Note that m=12 evaluates to 0 for 0-11, and to -1 for 12
+ MID$("CDHS",(i-1)13円+1,1) ' and take 1 char from the suits-string
NEXT
r$(53)="J ' Then append 2 jokers
r$(54)="J ' These strings are auto-closed by the QBasic compiler.
#QBasic 4.5, (削除) 114 (削除ここまで) 142(削除) 142 (削除ここまで) 127 bytes
a$="CDHS
b$="A2345678910JQK
dim r$(54)
FOR i=1TO 52
m=i MOD 13
r$(i)=MID$(b$"JQKA2345678910",1+m-(m>9),1-(m=9m=12))+MID$(a$"CDHS",(i-1)13円+1,1)
NEXT
r$(53)="J
r$(54)="J
Misread the challenge requirements, so switched to a more expensive array r$. All the rest of the code is pretty much the same.Release Notes:
- V1.0 Initial deploy
- V1.1 Misread the challenge requirements, so switched to a more expensive array
r$. All the rest of the code is pretty much the same. - V1.2 Suggestions from @TaylorScott lead to a complete rewrite saving 15 bytes!
for i = 1 to ubound(r$)
?r$(i)
next
QC
KC
AC
2C
3C
4C
5C
6C
7C
8C
9C
10C
JC
QC
KC
AC
2DQD
3DKD
4DAD
[... snip ...]
KS6S
AS7S
8S
9S
10S
JS
J
J
dim r$(54) ' create a 54-slot array for our results
FOR i=1TO 52 ' Loop through allthe numbers 1-52 cardsin var i
m=i MOD 13 Make m the position in' deTake currenti suit
?mod 13 to select a value (saved as m)
PRINT
MID$ ' , and (not saved) i intdiv a13 substringto of
get a suit
r$(i)= (b,ドル the' valuesassigns ofto theslot cards,i startingin atthe result array
MID$("JQKA2345678910" ' a sunstring 1from the string with all the values
,1+m one +m ' from plusposition the1-13 index(13 of% the13 card= (0, forbut Ace,QBasic 1-12strings forare 21-king)based.
-(m>9) plus one if this is above the Ten (= returns -1 for True)
' Hence the + 1)
,1-(m=9m=12)) And take 1 character, plus one if this is the Ten
;' taking 1 char by default, and 2 for the Ten
Also print (without linebreaks or tabs)
MID$ ' Note that m=12 evaluates ato substring0 of
for 0-11, and to -1 (a,ドルfor 12
+ MID$("CDHS",(i-1)13円+1,1) ' and take 1 char thefrom suitthe namessuits-string
NEXT
r$(53)="J (i-1)13円+1,1) for' 1Then characterappend starting2 atjokers
r$(54)="J 0+1 through 3+1
NEXT
?"J ' These strings are auto-closed PRINTby the Jokers
?"JQBasic compiler.
#QBasic 4.5, (削除) 114 (削除ここまで) 142 bytes
a$="CDHS
b$="A2345678910JQK
dim r$(54)
FOR i=1TO 52
m=i MOD 13
r$(i)=MID$(b$,1+m-(m>9),1-(m=9))+MID$(a$,(i-1)13円+1,1)
NEXT
r$(53)="J
r$(54)="J
Misread the challenge requirements, so switched to a more expensive array r$. All the rest of the code is pretty much the same.
for i = 1 to ubound(r$)
?r$(i)
next
2C
3C
4C
5C
6C
7C
8C
9C
10C
JC
QC
KC
AC
2D
3D
4D
[.. snip ...]
KS
AS
J
J
FOR i=1TO 52 Loop through all 52 cards
m=i MOD 13 Make m the position in de current suit
? PRINT
MID$ a substring of
(b,ドル the values of the cards, starting at
1 one +m plus the index of the card (0 for Ace, 1-12 for 2-king)
-(m>9) plus one if this is above the Ten (= returns -1 for True)
,1-(m=9)) And take 1 character, plus one if this is the Ten
; Also print (without linebreaks or tabs)
MID$ a substring of
(a,ドル the suit names
(i-1)13円+1,1) for 1 character starting at 0+1 through 3+1
NEXT
?"J PRINT the Jokers
?"J
#QBasic 4.5, (削除) 114 (削除ここまで) (削除) 142 (削除ここまで) 127 bytes
dim r$(54)
FOR i=1TO 52
m=i MOD 13
r$(i)=MID$("JQKA2345678910",1+m,1-(m=12))+MID$("CDHS",(i-1)13円+1,1)
NEXT
r$(53)="J
r$(54)="J
Release Notes:
- V1.0 Initial deploy
- V1.1 Misread the challenge requirements, so switched to a more expensive array
r$. All the rest of the code is pretty much the same. - V1.2 Suggestions from @TaylorScott lead to a complete rewrite saving 15 bytes!
for i = 1 to ubound(r$)
?r$(i)
next
QC
KC
AC
2C
3C
4C
5C
6C
7C
8C
9C
10C
JC
QD
KD
AD
[... snip ...]
6S
7S
8S
9S
10S
JS
J
J
dim r$(54) ' create a 54-slot array for our results
FOR i=1TO 52 ' Loop through the numbers 1-52 in var i
m=i MOD 13 ' Take i mod 13 to select a value (saved as m)
' , and (not saved) i intdiv 13 to get a suit
r$(i)= ' assigns to slot i in the result array
MID$("JQKA2345678910" ' a sunstring from the string with all the values
,1+m ' from position 1-13 (13 % 13 = 0, but QBasic strings are 1-based.
' Hence the + 1)
,1-(m=12)) ' taking 1 char by default, and 2 for the Ten
' Note that m=12 evaluates to 0 for 0-11, and to -1 for 12
+ MID$("CDHS",(i-1)13円+1,1) ' and take 1 char from the suits-string
NEXT
r$(53)="J ' Then append 2 jokers
r$(54)="J ' These strings are auto-closed by the QBasic compiler.