Binary Numbers Magic Trick
$begingroup$
The challenge is simply; output the following six 2D integer arrays:
[[ 1, 11, 21, 31, 41, 51],
[ 3, 13, 23, 33, 43, 53],
[ 5, 15, 25, 35, 45, 55],
[ 7, 17, 27, 37, 47, 57],
[ 9, 19, 29, 39, 49, 59]]
[[ 2, 11, 22, 31, 42, 51],
[ 3, 14, 23, 34, 43, 54],
[ 6, 15, 26, 35, 46, 55],
[ 7, 18, 27, 38, 47, 58],
[10, 19, 30, 39, 50, 59]]
[[ 4, 13, 22, 31, 44, 53],
[ 5, 14, 23, 36, 45, 54],
[ 6, 15, 28, 37, 46, 55],
[ 7, 20, 29, 38, 47, 60],
[12, 21, 30, 39, 52]]
[[ 8, 13, 26, 31, 44, 57],
[ 9, 14, 27, 40, 45, 58],
[10, 15, 28, 41, 46, 59],
[11, 24, 29, 42, 47, 60],
[12, 25, 30, 43, 56]]
[[16, 21, 26, 31, 52, 57],
[17, 22, 27, 48, 53, 58],
[18, 23, 28, 49, 54, 59],
[19, 24, 29, 50, 55, 60],
[20, 25, 30, 51, 56]]
[[32, 37, 42, 47, 52, 57],
[33, 38, 43, 48, 53, 58],
[34, 39, 44, 49, 54, 59],
[35, 40, 45, 50, 55, 60],
[36, 41, 46, 51, 56]]
What are these 2D integer arrays? These are the numbers used in a magic trick with cards containing these numbers:
The magic trick asks someone to think of a number in the range [1, 60], and give the one performing the magic trick all the cards which contain this number. The one performing the magic trick can then sum the top-left numbers (all a power of 2) of the given cards to get to the number the person was thinking of. Some additional explanation of why this works can be found here.
Challenge rules:
- You can output the six 2D integer arrays in any reasonable format. Can be printed with delimiters; can be a 3D integer array containing the six 2D integer arrays; can be a string-list of lines; etc.
- You are allowed to fill the bottom right position of the last four cards with a negative value in the range
[-60, -1]
or character'*'
instead of leaving it out to make the 2D integer arrays rectangular matrices (no, you are not allowed to fill them with0
or a non-integer likenull
/undefined
as alternative, with the exception of*
since a star is also used in the actual cards). - The order of the numbers in the matrices is mandatory. Although it doesn't matter for the physical magic trick, I see this challenge mainly as a matrix-kolmogorov-complexity one, hence the restriction on order.
The order of the matrices themselves in the output list can be in any order, since it's clear from the top-left card which matrix is which.
General rules:
- This is code-golf, so shortest answer in bytes wins.
Don't let code-golf languages discourage you from posting answers with non-codegolfing languages. Try to come up with an as short as possible answer for 'any' programming language.
Standard rules apply for your answer with default I/O rules, so you are allowed to use STDIN/STDOUT, functions/method with the proper parameters and return-type, full programs. Your call.
Default Loopholes are forbidden.- If possible, please add a link with a test for your code (i.e. TIO).
- Also, adding an explanation for your answer is highly recommended.
code-golf number kolmogorov-complexity matrix
$endgroup$
add a comment |
$begingroup$
The challenge is simply; output the following six 2D integer arrays:
[[ 1, 11, 21, 31, 41, 51],
[ 3, 13, 23, 33, 43, 53],
[ 5, 15, 25, 35, 45, 55],
[ 7, 17, 27, 37, 47, 57],
[ 9, 19, 29, 39, 49, 59]]
[[ 2, 11, 22, 31, 42, 51],
[ 3, 14, 23, 34, 43, 54],
[ 6, 15, 26, 35, 46, 55],
[ 7, 18, 27, 38, 47, 58],
[10, 19, 30, 39, 50, 59]]
[[ 4, 13, 22, 31, 44, 53],
[ 5, 14, 23, 36, 45, 54],
[ 6, 15, 28, 37, 46, 55],
[ 7, 20, 29, 38, 47, 60],
[12, 21, 30, 39, 52]]
[[ 8, 13, 26, 31, 44, 57],
[ 9, 14, 27, 40, 45, 58],
[10, 15, 28, 41, 46, 59],
[11, 24, 29, 42, 47, 60],
[12, 25, 30, 43, 56]]
[[16, 21, 26, 31, 52, 57],
[17, 22, 27, 48, 53, 58],
[18, 23, 28, 49, 54, 59],
[19, 24, 29, 50, 55, 60],
[20, 25, 30, 51, 56]]
[[32, 37, 42, 47, 52, 57],
[33, 38, 43, 48, 53, 58],
[34, 39, 44, 49, 54, 59],
[35, 40, 45, 50, 55, 60],
[36, 41, 46, 51, 56]]
What are these 2D integer arrays? These are the numbers used in a magic trick with cards containing these numbers:
The magic trick asks someone to think of a number in the range [1, 60], and give the one performing the magic trick all the cards which contain this number. The one performing the magic trick can then sum the top-left numbers (all a power of 2) of the given cards to get to the number the person was thinking of. Some additional explanation of why this works can be found here.
Challenge rules:
- You can output the six 2D integer arrays in any reasonable format. Can be printed with delimiters; can be a 3D integer array containing the six 2D integer arrays; can be a string-list of lines; etc.
- You are allowed to fill the bottom right position of the last four cards with a negative value in the range
[-60, -1]
or character'*'
instead of leaving it out to make the 2D integer arrays rectangular matrices (no, you are not allowed to fill them with0
or a non-integer likenull
/undefined
as alternative, with the exception of*
since a star is also used in the actual cards). - The order of the numbers in the matrices is mandatory. Although it doesn't matter for the physical magic trick, I see this challenge mainly as a matrix-kolmogorov-complexity one, hence the restriction on order.
The order of the matrices themselves in the output list can be in any order, since it's clear from the top-left card which matrix is which.
General rules:
- This is code-golf, so shortest answer in bytes wins.
Don't let code-golf languages discourage you from posting answers with non-codegolfing languages. Try to come up with an as short as possible answer for 'any' programming language.
Standard rules apply for your answer with default I/O rules, so you are allowed to use STDIN/STDOUT, functions/method with the proper parameters and return-type, full programs. Your call.
Default Loopholes are forbidden.- If possible, please add a link with a test for your code (i.e. TIO).
- Also, adding an explanation for your answer is highly recommended.
code-golf number kolmogorov-complexity matrix
$endgroup$
$begingroup$
Related. (As in, it's referring to the same magic trick, but not really useful to get inspiration from for this challenge I think. That challenge asks to output a truthy/falsey value whether numbern
appears on thek
'th card; where my challenge is a KC-challenge to output the six matrices.)
$endgroup$
– Kevin Cruijssen
1 hour ago
add a comment |
$begingroup$
The challenge is simply; output the following six 2D integer arrays:
[[ 1, 11, 21, 31, 41, 51],
[ 3, 13, 23, 33, 43, 53],
[ 5, 15, 25, 35, 45, 55],
[ 7, 17, 27, 37, 47, 57],
[ 9, 19, 29, 39, 49, 59]]
[[ 2, 11, 22, 31, 42, 51],
[ 3, 14, 23, 34, 43, 54],
[ 6, 15, 26, 35, 46, 55],
[ 7, 18, 27, 38, 47, 58],
[10, 19, 30, 39, 50, 59]]
[[ 4, 13, 22, 31, 44, 53],
[ 5, 14, 23, 36, 45, 54],
[ 6, 15, 28, 37, 46, 55],
[ 7, 20, 29, 38, 47, 60],
[12, 21, 30, 39, 52]]
[[ 8, 13, 26, 31, 44, 57],
[ 9, 14, 27, 40, 45, 58],
[10, 15, 28, 41, 46, 59],
[11, 24, 29, 42, 47, 60],
[12, 25, 30, 43, 56]]
[[16, 21, 26, 31, 52, 57],
[17, 22, 27, 48, 53, 58],
[18, 23, 28, 49, 54, 59],
[19, 24, 29, 50, 55, 60],
[20, 25, 30, 51, 56]]
[[32, 37, 42, 47, 52, 57],
[33, 38, 43, 48, 53, 58],
[34, 39, 44, 49, 54, 59],
[35, 40, 45, 50, 55, 60],
[36, 41, 46, 51, 56]]
What are these 2D integer arrays? These are the numbers used in a magic trick with cards containing these numbers:
The magic trick asks someone to think of a number in the range [1, 60], and give the one performing the magic trick all the cards which contain this number. The one performing the magic trick can then sum the top-left numbers (all a power of 2) of the given cards to get to the number the person was thinking of. Some additional explanation of why this works can be found here.
Challenge rules:
- You can output the six 2D integer arrays in any reasonable format. Can be printed with delimiters; can be a 3D integer array containing the six 2D integer arrays; can be a string-list of lines; etc.
- You are allowed to fill the bottom right position of the last four cards with a negative value in the range
[-60, -1]
or character'*'
instead of leaving it out to make the 2D integer arrays rectangular matrices (no, you are not allowed to fill them with0
or a non-integer likenull
/undefined
as alternative, with the exception of*
since a star is also used in the actual cards). - The order of the numbers in the matrices is mandatory. Although it doesn't matter for the physical magic trick, I see this challenge mainly as a matrix-kolmogorov-complexity one, hence the restriction on order.
The order of the matrices themselves in the output list can be in any order, since it's clear from the top-left card which matrix is which.
General rules:
- This is code-golf, so shortest answer in bytes wins.
Don't let code-golf languages discourage you from posting answers with non-codegolfing languages. Try to come up with an as short as possible answer for 'any' programming language.
Standard rules apply for your answer with default I/O rules, so you are allowed to use STDIN/STDOUT, functions/method with the proper parameters and return-type, full programs. Your call.
Default Loopholes are forbidden.- If possible, please add a link with a test for your code (i.e. TIO).
- Also, adding an explanation for your answer is highly recommended.
code-golf number kolmogorov-complexity matrix
$endgroup$
The challenge is simply; output the following six 2D integer arrays:
[[ 1, 11, 21, 31, 41, 51],
[ 3, 13, 23, 33, 43, 53],
[ 5, 15, 25, 35, 45, 55],
[ 7, 17, 27, 37, 47, 57],
[ 9, 19, 29, 39, 49, 59]]
[[ 2, 11, 22, 31, 42, 51],
[ 3, 14, 23, 34, 43, 54],
[ 6, 15, 26, 35, 46, 55],
[ 7, 18, 27, 38, 47, 58],
[10, 19, 30, 39, 50, 59]]
[[ 4, 13, 22, 31, 44, 53],
[ 5, 14, 23, 36, 45, 54],
[ 6, 15, 28, 37, 46, 55],
[ 7, 20, 29, 38, 47, 60],
[12, 21, 30, 39, 52]]
[[ 8, 13, 26, 31, 44, 57],
[ 9, 14, 27, 40, 45, 58],
[10, 15, 28, 41, 46, 59],
[11, 24, 29, 42, 47, 60],
[12, 25, 30, 43, 56]]
[[16, 21, 26, 31, 52, 57],
[17, 22, 27, 48, 53, 58],
[18, 23, 28, 49, 54, 59],
[19, 24, 29, 50, 55, 60],
[20, 25, 30, 51, 56]]
[[32, 37, 42, 47, 52, 57],
[33, 38, 43, 48, 53, 58],
[34, 39, 44, 49, 54, 59],
[35, 40, 45, 50, 55, 60],
[36, 41, 46, 51, 56]]
What are these 2D integer arrays? These are the numbers used in a magic trick with cards containing these numbers:
The magic trick asks someone to think of a number in the range [1, 60], and give the one performing the magic trick all the cards which contain this number. The one performing the magic trick can then sum the top-left numbers (all a power of 2) of the given cards to get to the number the person was thinking of. Some additional explanation of why this works can be found here.
Challenge rules:
- You can output the six 2D integer arrays in any reasonable format. Can be printed with delimiters; can be a 3D integer array containing the six 2D integer arrays; can be a string-list of lines; etc.
- You are allowed to fill the bottom right position of the last four cards with a negative value in the range
[-60, -1]
or character'*'
instead of leaving it out to make the 2D integer arrays rectangular matrices (no, you are not allowed to fill them with0
or a non-integer likenull
/undefined
as alternative, with the exception of*
since a star is also used in the actual cards). - The order of the numbers in the matrices is mandatory. Although it doesn't matter for the physical magic trick, I see this challenge mainly as a matrix-kolmogorov-complexity one, hence the restriction on order.
The order of the matrices themselves in the output list can be in any order, since it's clear from the top-left card which matrix is which.
General rules:
- This is code-golf, so shortest answer in bytes wins.
Don't let code-golf languages discourage you from posting answers with non-codegolfing languages. Try to come up with an as short as possible answer for 'any' programming language.
Standard rules apply for your answer with default I/O rules, so you are allowed to use STDIN/STDOUT, functions/method with the proper parameters and return-type, full programs. Your call.
Default Loopholes are forbidden.- If possible, please add a link with a test for your code (i.e. TIO).
- Also, adding an explanation for your answer is highly recommended.
code-golf number kolmogorov-complexity matrix
code-golf number kolmogorov-complexity matrix
edited 1 hour ago
Kevin Cruijssen
asked 1 hour ago
![](https://i.stack.imgur.com/MefSP.jpg?s=32&g=1)
![](https://i.stack.imgur.com/MefSP.jpg?s=32&g=1)
Kevin CruijssenKevin Cruijssen
43.7k573222
43.7k573222
$begingroup$
Related. (As in, it's referring to the same magic trick, but not really useful to get inspiration from for this challenge I think. That challenge asks to output a truthy/falsey value whether numbern
appears on thek
'th card; where my challenge is a KC-challenge to output the six matrices.)
$endgroup$
– Kevin Cruijssen
1 hour ago
add a comment |
$begingroup$
Related. (As in, it's referring to the same magic trick, but not really useful to get inspiration from for this challenge I think. That challenge asks to output a truthy/falsey value whether numbern
appears on thek
'th card; where my challenge is a KC-challenge to output the six matrices.)
$endgroup$
– Kevin Cruijssen
1 hour ago
$begingroup$
Related. (As in, it's referring to the same magic trick, but not really useful to get inspiration from for this challenge I think. That challenge asks to output a truthy/falsey value whether number
n
appears on the k
'th card; where my challenge is a KC-challenge to output the six matrices.)$endgroup$
– Kevin Cruijssen
1 hour ago
$begingroup$
Related. (As in, it's referring to the same magic trick, but not really useful to get inspiration from for this challenge I think. That challenge asks to output a truthy/falsey value whether number
n
appears on the k
'th card; where my challenge is a KC-challenge to output the six matrices.)$endgroup$
– Kevin Cruijssen
1 hour ago
add a comment |
4 Answers
4
active
oldest
votes
$begingroup$
Perl 6, 63 bytes
say(grep(+*.base(2).flip.comb[$_],^61)[$_,*+5...*for ^5])for ^6
Try it online!
Outputs as 2D arrays on multiple lines, with the last array of each one cut off if necessary.
$endgroup$
add a comment |
$begingroup$
JavaScript (ES6), 90 bytes
_=>[1,2,4,8,16,32].map(n=>(g=i=>i<60?g(++i,i&n&&(m[y%5]=m[y++%5]||).push(i)):m)(y=m=))
Try it online!
$endgroup$
add a comment |
$begingroup$
C (gcc), 105 bytes
f(int o[6][5][6]){for(int i=0,j,k;i<6;++i){o[i][4][5]=-1;for(j=k=0;j<60;)++j&1<<i?o[i][k%5][k++/5]=j:0;}}
Try it online!
Returns the matrices as a 3D int array in o.
The last 4 matrices have -1 as their last value.
$endgroup$
$begingroup$
You can save 2 bytes by changingo[i][4][5]=-1;for(j=k=0;
tofor(o[i][4][5]=-1,j=k=0;
so the brackets can be removed. Nice answer btw, +1 from me.
$endgroup$
– Kevin Cruijssen
17 mins ago
add a comment |
$begingroup$
Charcoal, 26 bytes
E⁶E⁵⪫E⁶§⁺§⪪Φ⁶¹&πX²ι⁵ν⟦*⟧λ
Try it online! Link is to verbose version of code. I tried calculating the entries directly but this was already 27 bytes before adjusting for the *
in the bottom right. Outputs each row joined with spaces and a blank line between cards. Explanation:
E⁶ Loop over 6 cards
E⁵ Loop over 5 rows
E⁶ Loop over 6 columns
Φ⁶¹ Filter over 0..60 where
π Current value
& Bitwise And
² Literal 2
X Raised to power
ι Card index
⪪ ⁵ Split into groups of 5
§ ν Indexed by column
⁺ Concatenated with
* Literal string `*`
⟦ ⟧ Wrapped in an array
§ λ Indexed by row
⪫ Joined with spaces
Implicitly print
$endgroup$
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "200"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f184853%2fbinary-numbers-magic-trick%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
4 Answers
4
active
oldest
votes
4 Answers
4
active
oldest
votes
active
oldest
votes
active
oldest
votes
$begingroup$
Perl 6, 63 bytes
say(grep(+*.base(2).flip.comb[$_],^61)[$_,*+5...*for ^5])for ^6
Try it online!
Outputs as 2D arrays on multiple lines, with the last array of each one cut off if necessary.
$endgroup$
add a comment |
$begingroup$
Perl 6, 63 bytes
say(grep(+*.base(2).flip.comb[$_],^61)[$_,*+5...*for ^5])for ^6
Try it online!
Outputs as 2D arrays on multiple lines, with the last array of each one cut off if necessary.
$endgroup$
add a comment |
$begingroup$
Perl 6, 63 bytes
say(grep(+*.base(2).flip.comb[$_],^61)[$_,*+5...*for ^5])for ^6
Try it online!
Outputs as 2D arrays on multiple lines, with the last array of each one cut off if necessary.
$endgroup$
Perl 6, 63 bytes
say(grep(+*.base(2).flip.comb[$_],^61)[$_,*+5...*for ^5])for ^6
Try it online!
Outputs as 2D arrays on multiple lines, with the last array of each one cut off if necessary.
answered 1 hour ago
Jo KingJo King
27.7k366134
27.7k366134
add a comment |
add a comment |
$begingroup$
JavaScript (ES6), 90 bytes
_=>[1,2,4,8,16,32].map(n=>(g=i=>i<60?g(++i,i&n&&(m[y%5]=m[y++%5]||).push(i)):m)(y=m=))
Try it online!
$endgroup$
add a comment |
$begingroup$
JavaScript (ES6), 90 bytes
_=>[1,2,4,8,16,32].map(n=>(g=i=>i<60?g(++i,i&n&&(m[y%5]=m[y++%5]||).push(i)):m)(y=m=))
Try it online!
$endgroup$
add a comment |
$begingroup$
JavaScript (ES6), 90 bytes
_=>[1,2,4,8,16,32].map(n=>(g=i=>i<60?g(++i,i&n&&(m[y%5]=m[y++%5]||).push(i)):m)(y=m=))
Try it online!
$endgroup$
JavaScript (ES6), 90 bytes
_=>[1,2,4,8,16,32].map(n=>(g=i=>i<60?g(++i,i&n&&(m[y%5]=m[y++%5]||).push(i)):m)(y=m=))
Try it online!
answered 21 mins ago
![](https://i.stack.imgur.com/HifFH.jpg?s=32&g=1)
![](https://i.stack.imgur.com/HifFH.jpg?s=32&g=1)
ArnauldArnauld
82.4k798339
82.4k798339
add a comment |
add a comment |
$begingroup$
C (gcc), 105 bytes
f(int o[6][5][6]){for(int i=0,j,k;i<6;++i){o[i][4][5]=-1;for(j=k=0;j<60;)++j&1<<i?o[i][k%5][k++/5]=j:0;}}
Try it online!
Returns the matrices as a 3D int array in o.
The last 4 matrices have -1 as their last value.
$endgroup$
$begingroup$
You can save 2 bytes by changingo[i][4][5]=-1;for(j=k=0;
tofor(o[i][4][5]=-1,j=k=0;
so the brackets can be removed. Nice answer btw, +1 from me.
$endgroup$
– Kevin Cruijssen
17 mins ago
add a comment |
$begingroup$
C (gcc), 105 bytes
f(int o[6][5][6]){for(int i=0,j,k;i<6;++i){o[i][4][5]=-1;for(j=k=0;j<60;)++j&1<<i?o[i][k%5][k++/5]=j:0;}}
Try it online!
Returns the matrices as a 3D int array in o.
The last 4 matrices have -1 as their last value.
$endgroup$
$begingroup$
You can save 2 bytes by changingo[i][4][5]=-1;for(j=k=0;
tofor(o[i][4][5]=-1,j=k=0;
so the brackets can be removed. Nice answer btw, +1 from me.
$endgroup$
– Kevin Cruijssen
17 mins ago
add a comment |
$begingroup$
C (gcc), 105 bytes
f(int o[6][5][6]){for(int i=0,j,k;i<6;++i){o[i][4][5]=-1;for(j=k=0;j<60;)++j&1<<i?o[i][k%5][k++/5]=j:0;}}
Try it online!
Returns the matrices as a 3D int array in o.
The last 4 matrices have -1 as their last value.
$endgroup$
C (gcc), 105 bytes
f(int o[6][5][6]){for(int i=0,j,k;i<6;++i){o[i][4][5]=-1;for(j=k=0;j<60;)++j&1<<i?o[i][k%5][k++/5]=j:0;}}
Try it online!
Returns the matrices as a 3D int array in o.
The last 4 matrices have -1 as their last value.
answered 21 mins ago
Matej MulejMatej Mulej
712
712
$begingroup$
You can save 2 bytes by changingo[i][4][5]=-1;for(j=k=0;
tofor(o[i][4][5]=-1,j=k=0;
so the brackets can be removed. Nice answer btw, +1 from me.
$endgroup$
– Kevin Cruijssen
17 mins ago
add a comment |
$begingroup$
You can save 2 bytes by changingo[i][4][5]=-1;for(j=k=0;
tofor(o[i][4][5]=-1,j=k=0;
so the brackets can be removed. Nice answer btw, +1 from me.
$endgroup$
– Kevin Cruijssen
17 mins ago
$begingroup$
You can save 2 bytes by changing
o[i][4][5]=-1;for(j=k=0;
to for(o[i][4][5]=-1,j=k=0;
so the brackets can be removed. Nice answer btw, +1 from me.$endgroup$
– Kevin Cruijssen
17 mins ago
$begingroup$
You can save 2 bytes by changing
o[i][4][5]=-1;for(j=k=0;
to for(o[i][4][5]=-1,j=k=0;
so the brackets can be removed. Nice answer btw, +1 from me.$endgroup$
– Kevin Cruijssen
17 mins ago
add a comment |
$begingroup$
Charcoal, 26 bytes
E⁶E⁵⪫E⁶§⁺§⪪Φ⁶¹&πX²ι⁵ν⟦*⟧λ
Try it online! Link is to verbose version of code. I tried calculating the entries directly but this was already 27 bytes before adjusting for the *
in the bottom right. Outputs each row joined with spaces and a blank line between cards. Explanation:
E⁶ Loop over 6 cards
E⁵ Loop over 5 rows
E⁶ Loop over 6 columns
Φ⁶¹ Filter over 0..60 where
π Current value
& Bitwise And
² Literal 2
X Raised to power
ι Card index
⪪ ⁵ Split into groups of 5
§ ν Indexed by column
⁺ Concatenated with
* Literal string `*`
⟦ ⟧ Wrapped in an array
§ λ Indexed by row
⪫ Joined with spaces
Implicitly print
$endgroup$
add a comment |
$begingroup$
Charcoal, 26 bytes
E⁶E⁵⪫E⁶§⁺§⪪Φ⁶¹&πX²ι⁵ν⟦*⟧λ
Try it online! Link is to verbose version of code. I tried calculating the entries directly but this was already 27 bytes before adjusting for the *
in the bottom right. Outputs each row joined with spaces and a blank line between cards. Explanation:
E⁶ Loop over 6 cards
E⁵ Loop over 5 rows
E⁶ Loop over 6 columns
Φ⁶¹ Filter over 0..60 where
π Current value
& Bitwise And
² Literal 2
X Raised to power
ι Card index
⪪ ⁵ Split into groups of 5
§ ν Indexed by column
⁺ Concatenated with
* Literal string `*`
⟦ ⟧ Wrapped in an array
§ λ Indexed by row
⪫ Joined with spaces
Implicitly print
$endgroup$
add a comment |
$begingroup$
Charcoal, 26 bytes
E⁶E⁵⪫E⁶§⁺§⪪Φ⁶¹&πX²ι⁵ν⟦*⟧λ
Try it online! Link is to verbose version of code. I tried calculating the entries directly but this was already 27 bytes before adjusting for the *
in the bottom right. Outputs each row joined with spaces and a blank line between cards. Explanation:
E⁶ Loop over 6 cards
E⁵ Loop over 5 rows
E⁶ Loop over 6 columns
Φ⁶¹ Filter over 0..60 where
π Current value
& Bitwise And
² Literal 2
X Raised to power
ι Card index
⪪ ⁵ Split into groups of 5
§ ν Indexed by column
⁺ Concatenated with
* Literal string `*`
⟦ ⟧ Wrapped in an array
§ λ Indexed by row
⪫ Joined with spaces
Implicitly print
$endgroup$
Charcoal, 26 bytes
E⁶E⁵⪫E⁶§⁺§⪪Φ⁶¹&πX²ι⁵ν⟦*⟧λ
Try it online! Link is to verbose version of code. I tried calculating the entries directly but this was already 27 bytes before adjusting for the *
in the bottom right. Outputs each row joined with spaces and a blank line between cards. Explanation:
E⁶ Loop over 6 cards
E⁵ Loop over 5 rows
E⁶ Loop over 6 columns
Φ⁶¹ Filter over 0..60 where
π Current value
& Bitwise And
² Literal 2
X Raised to power
ι Card index
⪪ ⁵ Split into groups of 5
§ ν Indexed by column
⁺ Concatenated with
* Literal string `*`
⟦ ⟧ Wrapped in an array
§ λ Indexed by row
⪫ Joined with spaces
Implicitly print
answered 7 mins ago
NeilNeil
83.3k745179
83.3k745179
add a comment |
add a comment |
If this is an answer to a challenge…
…Be sure to follow the challenge specification. However, please refrain from exploiting obvious loopholes. Answers abusing any of the standard loopholes are considered invalid. If you think a specification is unclear or underspecified, comment on the question instead.
…Try to optimize your score. For instance, answers to code-golf challenges should attempt to be as short as possible. You can always include a readable version of the code in addition to the competitive one.
Explanations of your answer make it more interesting to read and are very much encouraged.…Include a short header which indicates the language(s) of your code and its score, as defined by the challenge.
More generally…
…Please make sure to answer the question and provide sufficient detail.
…Avoid asking for help, clarification or responding to other answers (use comments instead).
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f184853%2fbinary-numbers-magic-trick%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
$begingroup$
Related. (As in, it's referring to the same magic trick, but not really useful to get inspiration from for this challenge I think. That challenge asks to output a truthy/falsey value whether number
n
appears on thek
'th card; where my challenge is a KC-challenge to output the six matrices.)$endgroup$
– Kevin Cruijssen
1 hour ago