Tile the chessboard with four-colored triominoesWho's that Pokémon?Mandelbrot image in every languageFill the Screen with Wang TilesSumming colored graphsTile the plane with this modified circlePrint all colorings of a 3x3 gridA fiercer four-square cipherEscape a chessboardDisplay random colored pixelsFive Character ASCII MapHow to code colors in hex
How many years before enough atoms of your body are replaced to survive the sudden disappearance of the original body’s atoms?
What does the ISO setting for mechanical 35mm film cameras actually do?
Getting Lost in the Caves of Chaos
How to sort List<T> in c#
Why when the leprosy covers the entire body the leper is pronounced pure?
Is there a way to prevent the production team from messing up my paper?
Is a switch from R to Python worth it?
If someone else uploads my GPL'd code to Github without my permission, is that a copyright violation?
Why is the Vasa Museum in Stockholm so Popular?
Can you take actions after being healed at 0hp?
Tile the chessboard with four-colored triominoes
In MTG, was there ever a five-color deck that worked well?
Why do my fried eggs start browning very fast?
Examples of hyperbolic groups
Which pronoun to replace an infinitive?
Why does putting a dot after the URL remove login information?
What are the function of EM and EN spaces?
How do I get the =LEFT function in excel, to also take the number zero as the first number?
What could prevent players from leaving an island?
How to win against ants
`printf` improvement with C++ variadic templates
How does LIDAR avoid getting confused in an environment being scanned by hundreds of other LIDAR?
Could an areostationary satellite help locate asteroids?
Based on what criteria do you add/not add icons to labels within a toolbar?
Tile the chessboard with four-colored triominoes
Who's that Pokémon?Mandelbrot image in every languageFill the Screen with Wang TilesSumming colored graphsTile the plane with this modified circlePrint all colorings of a 3x3 gridA fiercer four-square cipherEscape a chessboardDisplay random colored pixelsFive Character ASCII MapHow to code colors in hex
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
$begingroup$
Task:
Consider the problem: "given a chessboard with one square missing, cut it into 21 L-triominoes". There is a well-known constructive proof that this can be done for any square chessboard size that is a power of two. It works by splitting the chessboard into a smaller chessboard with the hole in it and one big triomino and then observing that that triomino can be cut into four triominoes recursively.
In this task, you are required to cut an 8x8 chessboard into L-shaped triominoes and then to color them with four colors such that no two adjacent triominoes have the same color.
Specification:
Your input is the position of the hole, given as a pair of integers. You may choose which one is the column index and which one is the row index. You may choose if each starts at 0 or at 1 and away from which corner they increase. You may require A..H as the first coordinate instead of 0..7 or 1..8. You may also accept both coordinates packed into a single integer 0..63 or 1..64 in lexicographical order (row-major or column-major, left to right or right to left, up to down or down to up). You may write a full program, or a function.
You may output the tiling as ASCII, as colored ASCII or as graphical primitives. If you choose ASCII output, you may choose any four printable ASCII characters to represent the four colors. If you choose colored ASCII, you may choose any four printable ASCII characters or just one character other than space. The hole must be represented by the space character. If one of your characters is the space character, no triomino adjacent to the hole or at the chessboard edge may be of this color.
If you choose colored ASCII or graphical output, you may choose any four colors out of #000, #00F, #0F0, #0FF, #F00, #F0F, #FF0, #FFF or their closest equivalents available in your environment. If you choose graphical output, your graphical primitives must be filled squares at least 32x32 pixels in size and separated by no more than two pixels of other color. If the above exceeds the screen resolution of your environment, the minimum size requirement is relaxed to the largest square size that still fits on the screen.
You may choose any valid tiling of the given chessboard. You may choose any four-coloring of the tiling you choose. Your choice of four colors must be the same across all outputs, but you aren't required to use every color in every output.
Examples:
Possible output for input = [0, 0] (top left corner)
#??##??
##.?#..?
?..#??.#
??##.?##
##?..#??
#.??##.?
?..#?..#
??##??##
Another possible output of the same program (input = [0, 7]):
??#??#?
?##?##??
..xx..xx
.?x#.?x#
??##??##
..xx..xx
.?x#.?x#
??##??##
A different program may also produce, for the input of "D1" (note the nonstandard but allowed chessboard orientation),
AABBCCAA
ACBACBAC
CCAABBCC
ABBAADD
AABDABDC
BBDDBBCC
BABBACAA
AABAACCA
code-golf ascii-art graphical-output
$endgroup$
|
show 6 more comments
$begingroup$
Task:
Consider the problem: "given a chessboard with one square missing, cut it into 21 L-triominoes". There is a well-known constructive proof that this can be done for any square chessboard size that is a power of two. It works by splitting the chessboard into a smaller chessboard with the hole in it and one big triomino and then observing that that triomino can be cut into four triominoes recursively.
In this task, you are required to cut an 8x8 chessboard into L-shaped triominoes and then to color them with four colors such that no two adjacent triominoes have the same color.
Specification:
Your input is the position of the hole, given as a pair of integers. You may choose which one is the column index and which one is the row index. You may choose if each starts at 0 or at 1 and away from which corner they increase. You may require A..H as the first coordinate instead of 0..7 or 1..8. You may also accept both coordinates packed into a single integer 0..63 or 1..64 in lexicographical order (row-major or column-major, left to right or right to left, up to down or down to up). You may write a full program, or a function.
You may output the tiling as ASCII, as colored ASCII or as graphical primitives. If you choose ASCII output, you may choose any four printable ASCII characters to represent the four colors. If you choose colored ASCII, you may choose any four printable ASCII characters or just one character other than space. The hole must be represented by the space character. If one of your characters is the space character, no triomino adjacent to the hole or at the chessboard edge may be of this color.
If you choose colored ASCII or graphical output, you may choose any four colors out of #000, #00F, #0F0, #0FF, #F00, #F0F, #FF0, #FFF or their closest equivalents available in your environment. If you choose graphical output, your graphical primitives must be filled squares at least 32x32 pixels in size and separated by no more than two pixels of other color. If the above exceeds the screen resolution of your environment, the minimum size requirement is relaxed to the largest square size that still fits on the screen.
You may choose any valid tiling of the given chessboard. You may choose any four-coloring of the tiling you choose. Your choice of four colors must be the same across all outputs, but you aren't required to use every color in every output.
Examples:
Possible output for input = [0, 0] (top left corner)
#??##??
##.?#..?
?..#??.#
??##.?##
##?..#??
#.??##.?
?..#?..#
??##??##
Another possible output of the same program (input = [0, 7]):
??#??#?
?##?##??
..xx..xx
.?x#.?x#
??##??##
..xx..xx
.?x#.?x#
??##??##
A different program may also produce, for the input of "D1" (note the nonstandard but allowed chessboard orientation),
AABBCCAA
ACBACBAC
CCAABBCC
ABBAADD
AABDABDC
BBDDBBCC
BABBACAA
AABAACCA
code-golf ascii-art graphical-output
$endgroup$
2
$begingroup$
If there is input it's not really Kolmogorov complexity
$endgroup$
– Jonathan Allan
8 hours ago
$begingroup$
@JonathanAllan the tag description uses who's that pokemon as an example of a kolmogorov complexity question that takes input. It's up to you if you want to compress a set of 64 constant solutions or if you want to implement a procedure to tile the chessboard and then color it.
$endgroup$
– John Dvorak
8 hours ago
1
$begingroup$
@JonathanAllan meta discussion regarding non-constant kolmogorov complexity questions
$endgroup$
– John Dvorak
7 hours ago
1
$begingroup$
Aren't three colors enough?
$endgroup$
– Arnauld
7 hours ago
1
$begingroup$
@Arnauld I'll allow that. I'll edit.
$endgroup$
– John Dvorak
6 hours ago
|
show 6 more comments
$begingroup$
Task:
Consider the problem: "given a chessboard with one square missing, cut it into 21 L-triominoes". There is a well-known constructive proof that this can be done for any square chessboard size that is a power of two. It works by splitting the chessboard into a smaller chessboard with the hole in it and one big triomino and then observing that that triomino can be cut into four triominoes recursively.
In this task, you are required to cut an 8x8 chessboard into L-shaped triominoes and then to color them with four colors such that no two adjacent triominoes have the same color.
Specification:
Your input is the position of the hole, given as a pair of integers. You may choose which one is the column index and which one is the row index. You may choose if each starts at 0 or at 1 and away from which corner they increase. You may require A..H as the first coordinate instead of 0..7 or 1..8. You may also accept both coordinates packed into a single integer 0..63 or 1..64 in lexicographical order (row-major or column-major, left to right or right to left, up to down or down to up). You may write a full program, or a function.
You may output the tiling as ASCII, as colored ASCII or as graphical primitives. If you choose ASCII output, you may choose any four printable ASCII characters to represent the four colors. If you choose colored ASCII, you may choose any four printable ASCII characters or just one character other than space. The hole must be represented by the space character. If one of your characters is the space character, no triomino adjacent to the hole or at the chessboard edge may be of this color.
If you choose colored ASCII or graphical output, you may choose any four colors out of #000, #00F, #0F0, #0FF, #F00, #F0F, #FF0, #FFF or their closest equivalents available in your environment. If you choose graphical output, your graphical primitives must be filled squares at least 32x32 pixels in size and separated by no more than two pixels of other color. If the above exceeds the screen resolution of your environment, the minimum size requirement is relaxed to the largest square size that still fits on the screen.
You may choose any valid tiling of the given chessboard. You may choose any four-coloring of the tiling you choose. Your choice of four colors must be the same across all outputs, but you aren't required to use every color in every output.
Examples:
Possible output for input = [0, 0] (top left corner)
#??##??
##.?#..?
?..#??.#
??##.?##
##?..#??
#.??##.?
?..#?..#
??##??##
Another possible output of the same program (input = [0, 7]):
??#??#?
?##?##??
..xx..xx
.?x#.?x#
??##??##
..xx..xx
.?x#.?x#
??##??##
A different program may also produce, for the input of "D1" (note the nonstandard but allowed chessboard orientation),
AABBCCAA
ACBACBAC
CCAABBCC
ABBAADD
AABDABDC
BBDDBBCC
BABBACAA
AABAACCA
code-golf ascii-art graphical-output
$endgroup$
Task:
Consider the problem: "given a chessboard with one square missing, cut it into 21 L-triominoes". There is a well-known constructive proof that this can be done for any square chessboard size that is a power of two. It works by splitting the chessboard into a smaller chessboard with the hole in it and one big triomino and then observing that that triomino can be cut into four triominoes recursively.
In this task, you are required to cut an 8x8 chessboard into L-shaped triominoes and then to color them with four colors such that no two adjacent triominoes have the same color.
Specification:
Your input is the position of the hole, given as a pair of integers. You may choose which one is the column index and which one is the row index. You may choose if each starts at 0 or at 1 and away from which corner they increase. You may require A..H as the first coordinate instead of 0..7 or 1..8. You may also accept both coordinates packed into a single integer 0..63 or 1..64 in lexicographical order (row-major or column-major, left to right or right to left, up to down or down to up). You may write a full program, or a function.
You may output the tiling as ASCII, as colored ASCII or as graphical primitives. If you choose ASCII output, you may choose any four printable ASCII characters to represent the four colors. If you choose colored ASCII, you may choose any four printable ASCII characters or just one character other than space. The hole must be represented by the space character. If one of your characters is the space character, no triomino adjacent to the hole or at the chessboard edge may be of this color.
If you choose colored ASCII or graphical output, you may choose any four colors out of #000, #00F, #0F0, #0FF, #F00, #F0F, #FF0, #FFF or their closest equivalents available in your environment. If you choose graphical output, your graphical primitives must be filled squares at least 32x32 pixels in size and separated by no more than two pixels of other color. If the above exceeds the screen resolution of your environment, the minimum size requirement is relaxed to the largest square size that still fits on the screen.
You may choose any valid tiling of the given chessboard. You may choose any four-coloring of the tiling you choose. Your choice of four colors must be the same across all outputs, but you aren't required to use every color in every output.
Examples:
Possible output for input = [0, 0] (top left corner)
#??##??
##.?#..?
?..#??.#
??##.?##
##?..#??
#.??##.?
?..#?..#
??##??##
Another possible output of the same program (input = [0, 7]):
??#??#?
?##?##??
..xx..xx
.?x#.?x#
??##??##
..xx..xx
.?x#.?x#
??##??##
A different program may also produce, for the input of "D1" (note the nonstandard but allowed chessboard orientation),
AABBCCAA
ACBACBAC
CCAABBCC
ABBAADD
AABDABDC
BBDDBBCC
BABBACAA
AABAACCA
code-golf ascii-art graphical-output
code-golf ascii-art graphical-output
edited 6 hours ago
John Dvorak
asked 8 hours ago
John DvorakJohn Dvorak
8,7382 gold badges24 silver badges50 bronze badges
8,7382 gold badges24 silver badges50 bronze badges
2
$begingroup$
If there is input it's not really Kolmogorov complexity
$endgroup$
– Jonathan Allan
8 hours ago
$begingroup$
@JonathanAllan the tag description uses who's that pokemon as an example of a kolmogorov complexity question that takes input. It's up to you if you want to compress a set of 64 constant solutions or if you want to implement a procedure to tile the chessboard and then color it.
$endgroup$
– John Dvorak
8 hours ago
1
$begingroup$
@JonathanAllan meta discussion regarding non-constant kolmogorov complexity questions
$endgroup$
– John Dvorak
7 hours ago
1
$begingroup$
Aren't three colors enough?
$endgroup$
– Arnauld
7 hours ago
1
$begingroup$
@Arnauld I'll allow that. I'll edit.
$endgroup$
– John Dvorak
6 hours ago
|
show 6 more comments
2
$begingroup$
If there is input it's not really Kolmogorov complexity
$endgroup$
– Jonathan Allan
8 hours ago
$begingroup$
@JonathanAllan the tag description uses who's that pokemon as an example of a kolmogorov complexity question that takes input. It's up to you if you want to compress a set of 64 constant solutions or if you want to implement a procedure to tile the chessboard and then color it.
$endgroup$
– John Dvorak
8 hours ago
1
$begingroup$
@JonathanAllan meta discussion regarding non-constant kolmogorov complexity questions
$endgroup$
– John Dvorak
7 hours ago
1
$begingroup$
Aren't three colors enough?
$endgroup$
– Arnauld
7 hours ago
1
$begingroup$
@Arnauld I'll allow that. I'll edit.
$endgroup$
– John Dvorak
6 hours ago
2
2
$begingroup$
If there is input it's not really Kolmogorov complexity
$endgroup$
– Jonathan Allan
8 hours ago
$begingroup$
If there is input it's not really Kolmogorov complexity
$endgroup$
– Jonathan Allan
8 hours ago
$begingroup$
@JonathanAllan the tag description uses who's that pokemon as an example of a kolmogorov complexity question that takes input. It's up to you if you want to compress a set of 64 constant solutions or if you want to implement a procedure to tile the chessboard and then color it.
$endgroup$
– John Dvorak
8 hours ago
$begingroup$
@JonathanAllan the tag description uses who's that pokemon as an example of a kolmogorov complexity question that takes input. It's up to you if you want to compress a set of 64 constant solutions or if you want to implement a procedure to tile the chessboard and then color it.
$endgroup$
– John Dvorak
8 hours ago
1
1
$begingroup$
@JonathanAllan meta discussion regarding non-constant kolmogorov complexity questions
$endgroup$
– John Dvorak
7 hours ago
$begingroup$
@JonathanAllan meta discussion regarding non-constant kolmogorov complexity questions
$endgroup$
– John Dvorak
7 hours ago
1
1
$begingroup$
Aren't three colors enough?
$endgroup$
– Arnauld
7 hours ago
$begingroup$
Aren't three colors enough?
$endgroup$
– Arnauld
7 hours ago
1
1
$begingroup$
@Arnauld I'll allow that. I'll edit.
$endgroup$
– John Dvorak
6 hours ago
$begingroup$
@Arnauld I'll allow that. I'll edit.
$endgroup$
– John Dvorak
6 hours ago
|
show 6 more comments
1 Answer
1
active
oldest
votes
$begingroup$
JavaScript (ES6), 184 180 179 173 171 bytes
Takes input as (x)(y), with $0leq xleq7$ and $0leq yleq7$. Outputs as a string with 3 colors (marked as $0$, $1$ and $2$).
h=>v=>(a=[...'3232132031021010'],a[5+(v&4|h>3)]^=3,a[v/2<<2|h/2]=v%2*2+h%2,g=x=>y&8?'':(x<8?x-h|y-v?a[(Y=y>>1)*4|(X=x/2)]^y%2*2+x%2?X+Y&1:2:' ':(x=~!++y,`
`))+g(x+1))(y=0)
Try it online!
Method
We work on a matrix of $4times4$ triominoes.
$$beginpmatrix
t_0&t_1&t_2&t_3\
t_4&t_5&t_6&t_7\
t_8&t_9&t_10&t_11\
t_12&t_13&t_14&t_15
endpmatrix$$
Each triomino may be one of:

The initial configuration of the matrix is as follows:
$$beginpmatrix
3&2&3&2\
1&3&2&0\
3&1&0&2\
1&0&1&0
endpmatrix$$
We alternate the first 2 colors just like we would on any chessboard, which gives:

The next steps are:
- According to the quadrant in which the hole is located, we rotate one of the 4 center triominoes ($t_5$, $t_6$, $t_9$ or $t_10$) by 180°.
- We rotate the triomino on which the hole is located (it may be the same triomino as in step #1), so that it does not cover the hole.
- We fill the holes with the 3rd color (except the 'real' hole).
Assuming that the hole is located at $(2,0)$, this gives:

Graphical output
Click on the picture to set the position of the hole.
f=
h=>v=>(a=[...'3232132031021010'],a[5+(v&4|h>3)]^=3,a[v/2<<2|h/2]=v%2*2+h%2,g=x=>y&8?'':(x<8?x-h|y-v?a[(Y=y>>1)*4|(X=x/2)]^y%2*2+x%2?X+Y&1:2:' ':(x=~!++y,`
`))+g(x+1))(y=0)
;(u = (x, y) => for(out = '', a = f(x)(y).split('n'), y = 0; y < 8; y++) for(x = 0; x < 8; x++) out += `<div class="b b$a[y][x] == ' ' ? 'H' : a[y][x]"></div>`; o.innerHTML = out; )(0, 0); o.onclick = e => u(e.clientX >> 4, e.clientY >> 4)body margin: 0; padding: 0;
#o width: 128px; height: 128px;
.b float: left; width: 16px; height: 16px;
.b0 background-color: #44f;
.b1 background-color: #ffc90e;
.b2 background-color: #22b14c;
.bH background-color: #000; <div id="o"></div>$endgroup$
$begingroup$
Constructive proof that three colors are always sufficient, very nice!
$endgroup$
– John Dvorak
6 hours ago
2
$begingroup$
Love the clickable graphical output!
$endgroup$
– Kevin Cruijssen
4 hours ago
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%2f189344%2ftile-the-chessboard-with-four-colored-triominoes%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
$begingroup$
JavaScript (ES6), 184 180 179 173 171 bytes
Takes input as (x)(y), with $0leq xleq7$ and $0leq yleq7$. Outputs as a string with 3 colors (marked as $0$, $1$ and $2$).
h=>v=>(a=[...'3232132031021010'],a[5+(v&4|h>3)]^=3,a[v/2<<2|h/2]=v%2*2+h%2,g=x=>y&8?'':(x<8?x-h|y-v?a[(Y=y>>1)*4|(X=x/2)]^y%2*2+x%2?X+Y&1:2:' ':(x=~!++y,`
`))+g(x+1))(y=0)
Try it online!
Method
We work on a matrix of $4times4$ triominoes.
$$beginpmatrix
t_0&t_1&t_2&t_3\
t_4&t_5&t_6&t_7\
t_8&t_9&t_10&t_11\
t_12&t_13&t_14&t_15
endpmatrix$$
Each triomino may be one of:

The initial configuration of the matrix is as follows:
$$beginpmatrix
3&2&3&2\
1&3&2&0\
3&1&0&2\
1&0&1&0
endpmatrix$$
We alternate the first 2 colors just like we would on any chessboard, which gives:

The next steps are:
- According to the quadrant in which the hole is located, we rotate one of the 4 center triominoes ($t_5$, $t_6$, $t_9$ or $t_10$) by 180°.
- We rotate the triomino on which the hole is located (it may be the same triomino as in step #1), so that it does not cover the hole.
- We fill the holes with the 3rd color (except the 'real' hole).
Assuming that the hole is located at $(2,0)$, this gives:

Graphical output
Click on the picture to set the position of the hole.
f=
h=>v=>(a=[...'3232132031021010'],a[5+(v&4|h>3)]^=3,a[v/2<<2|h/2]=v%2*2+h%2,g=x=>y&8?'':(x<8?x-h|y-v?a[(Y=y>>1)*4|(X=x/2)]^y%2*2+x%2?X+Y&1:2:' ':(x=~!++y,`
`))+g(x+1))(y=0)
;(u = (x, y) => for(out = '', a = f(x)(y).split('n'), y = 0; y < 8; y++) for(x = 0; x < 8; x++) out += `<div class="b b$a[y][x] == ' ' ? 'H' : a[y][x]"></div>`; o.innerHTML = out; )(0, 0); o.onclick = e => u(e.clientX >> 4, e.clientY >> 4)body margin: 0; padding: 0;
#o width: 128px; height: 128px;
.b float: left; width: 16px; height: 16px;
.b0 background-color: #44f;
.b1 background-color: #ffc90e;
.b2 background-color: #22b14c;
.bH background-color: #000; <div id="o"></div>$endgroup$
$begingroup$
Constructive proof that three colors are always sufficient, very nice!
$endgroup$
– John Dvorak
6 hours ago
2
$begingroup$
Love the clickable graphical output!
$endgroup$
– Kevin Cruijssen
4 hours ago
add a comment |
$begingroup$
JavaScript (ES6), 184 180 179 173 171 bytes
Takes input as (x)(y), with $0leq xleq7$ and $0leq yleq7$. Outputs as a string with 3 colors (marked as $0$, $1$ and $2$).
h=>v=>(a=[...'3232132031021010'],a[5+(v&4|h>3)]^=3,a[v/2<<2|h/2]=v%2*2+h%2,g=x=>y&8?'':(x<8?x-h|y-v?a[(Y=y>>1)*4|(X=x/2)]^y%2*2+x%2?X+Y&1:2:' ':(x=~!++y,`
`))+g(x+1))(y=0)
Try it online!
Method
We work on a matrix of $4times4$ triominoes.
$$beginpmatrix
t_0&t_1&t_2&t_3\
t_4&t_5&t_6&t_7\
t_8&t_9&t_10&t_11\
t_12&t_13&t_14&t_15
endpmatrix$$
Each triomino may be one of:

The initial configuration of the matrix is as follows:
$$beginpmatrix
3&2&3&2\
1&3&2&0\
3&1&0&2\
1&0&1&0
endpmatrix$$
We alternate the first 2 colors just like we would on any chessboard, which gives:

The next steps are:
- According to the quadrant in which the hole is located, we rotate one of the 4 center triominoes ($t_5$, $t_6$, $t_9$ or $t_10$) by 180°.
- We rotate the triomino on which the hole is located (it may be the same triomino as in step #1), so that it does not cover the hole.
- We fill the holes with the 3rd color (except the 'real' hole).
Assuming that the hole is located at $(2,0)$, this gives:

Graphical output
Click on the picture to set the position of the hole.
f=
h=>v=>(a=[...'3232132031021010'],a[5+(v&4|h>3)]^=3,a[v/2<<2|h/2]=v%2*2+h%2,g=x=>y&8?'':(x<8?x-h|y-v?a[(Y=y>>1)*4|(X=x/2)]^y%2*2+x%2?X+Y&1:2:' ':(x=~!++y,`
`))+g(x+1))(y=0)
;(u = (x, y) => for(out = '', a = f(x)(y).split('n'), y = 0; y < 8; y++) for(x = 0; x < 8; x++) out += `<div class="b b$a[y][x] == ' ' ? 'H' : a[y][x]"></div>`; o.innerHTML = out; )(0, 0); o.onclick = e => u(e.clientX >> 4, e.clientY >> 4)body margin: 0; padding: 0;
#o width: 128px; height: 128px;
.b float: left; width: 16px; height: 16px;
.b0 background-color: #44f;
.b1 background-color: #ffc90e;
.b2 background-color: #22b14c;
.bH background-color: #000; <div id="o"></div>$endgroup$
$begingroup$
Constructive proof that three colors are always sufficient, very nice!
$endgroup$
– John Dvorak
6 hours ago
2
$begingroup$
Love the clickable graphical output!
$endgroup$
– Kevin Cruijssen
4 hours ago
add a comment |
$begingroup$
JavaScript (ES6), 184 180 179 173 171 bytes
Takes input as (x)(y), with $0leq xleq7$ and $0leq yleq7$. Outputs as a string with 3 colors (marked as $0$, $1$ and $2$).
h=>v=>(a=[...'3232132031021010'],a[5+(v&4|h>3)]^=3,a[v/2<<2|h/2]=v%2*2+h%2,g=x=>y&8?'':(x<8?x-h|y-v?a[(Y=y>>1)*4|(X=x/2)]^y%2*2+x%2?X+Y&1:2:' ':(x=~!++y,`
`))+g(x+1))(y=0)
Try it online!
Method
We work on a matrix of $4times4$ triominoes.
$$beginpmatrix
t_0&t_1&t_2&t_3\
t_4&t_5&t_6&t_7\
t_8&t_9&t_10&t_11\
t_12&t_13&t_14&t_15
endpmatrix$$
Each triomino may be one of:

The initial configuration of the matrix is as follows:
$$beginpmatrix
3&2&3&2\
1&3&2&0\
3&1&0&2\
1&0&1&0
endpmatrix$$
We alternate the first 2 colors just like we would on any chessboard, which gives:

The next steps are:
- According to the quadrant in which the hole is located, we rotate one of the 4 center triominoes ($t_5$, $t_6$, $t_9$ or $t_10$) by 180°.
- We rotate the triomino on which the hole is located (it may be the same triomino as in step #1), so that it does not cover the hole.
- We fill the holes with the 3rd color (except the 'real' hole).
Assuming that the hole is located at $(2,0)$, this gives:

Graphical output
Click on the picture to set the position of the hole.
f=
h=>v=>(a=[...'3232132031021010'],a[5+(v&4|h>3)]^=3,a[v/2<<2|h/2]=v%2*2+h%2,g=x=>y&8?'':(x<8?x-h|y-v?a[(Y=y>>1)*4|(X=x/2)]^y%2*2+x%2?X+Y&1:2:' ':(x=~!++y,`
`))+g(x+1))(y=0)
;(u = (x, y) => for(out = '', a = f(x)(y).split('n'), y = 0; y < 8; y++) for(x = 0; x < 8; x++) out += `<div class="b b$a[y][x] == ' ' ? 'H' : a[y][x]"></div>`; o.innerHTML = out; )(0, 0); o.onclick = e => u(e.clientX >> 4, e.clientY >> 4)body margin: 0; padding: 0;
#o width: 128px; height: 128px;
.b float: left; width: 16px; height: 16px;
.b0 background-color: #44f;
.b1 background-color: #ffc90e;
.b2 background-color: #22b14c;
.bH background-color: #000; <div id="o"></div>$endgroup$
JavaScript (ES6), 184 180 179 173 171 bytes
Takes input as (x)(y), with $0leq xleq7$ and $0leq yleq7$. Outputs as a string with 3 colors (marked as $0$, $1$ and $2$).
h=>v=>(a=[...'3232132031021010'],a[5+(v&4|h>3)]^=3,a[v/2<<2|h/2]=v%2*2+h%2,g=x=>y&8?'':(x<8?x-h|y-v?a[(Y=y>>1)*4|(X=x/2)]^y%2*2+x%2?X+Y&1:2:' ':(x=~!++y,`
`))+g(x+1))(y=0)
Try it online!
Method
We work on a matrix of $4times4$ triominoes.
$$beginpmatrix
t_0&t_1&t_2&t_3\
t_4&t_5&t_6&t_7\
t_8&t_9&t_10&t_11\
t_12&t_13&t_14&t_15
endpmatrix$$
Each triomino may be one of:

The initial configuration of the matrix is as follows:
$$beginpmatrix
3&2&3&2\
1&3&2&0\
3&1&0&2\
1&0&1&0
endpmatrix$$
We alternate the first 2 colors just like we would on any chessboard, which gives:

The next steps are:
- According to the quadrant in which the hole is located, we rotate one of the 4 center triominoes ($t_5$, $t_6$, $t_9$ or $t_10$) by 180°.
- We rotate the triomino on which the hole is located (it may be the same triomino as in step #1), so that it does not cover the hole.
- We fill the holes with the 3rd color (except the 'real' hole).
Assuming that the hole is located at $(2,0)$, this gives:

Graphical output
Click on the picture to set the position of the hole.
f=
h=>v=>(a=[...'3232132031021010'],a[5+(v&4|h>3)]^=3,a[v/2<<2|h/2]=v%2*2+h%2,g=x=>y&8?'':(x<8?x-h|y-v?a[(Y=y>>1)*4|(X=x/2)]^y%2*2+x%2?X+Y&1:2:' ':(x=~!++y,`
`))+g(x+1))(y=0)
;(u = (x, y) => for(out = '', a = f(x)(y).split('n'), y = 0; y < 8; y++) for(x = 0; x < 8; x++) out += `<div class="b b$a[y][x] == ' ' ? 'H' : a[y][x]"></div>`; o.innerHTML = out; )(0, 0); o.onclick = e => u(e.clientX >> 4, e.clientY >> 4)body margin: 0; padding: 0;
#o width: 128px; height: 128px;
.b float: left; width: 16px; height: 16px;
.b0 background-color: #44f;
.b1 background-color: #ffc90e;
.b2 background-color: #22b14c;
.bH background-color: #000; <div id="o"></div>f=
h=>v=>(a=[...'3232132031021010'],a[5+(v&4|h>3)]^=3,a[v/2<<2|h/2]=v%2*2+h%2,g=x=>y&8?'':(x<8?x-h|y-v?a[(Y=y>>1)*4|(X=x/2)]^y%2*2+x%2?X+Y&1:2:' ':(x=~!++y,`
`))+g(x+1))(y=0)
;(u = (x, y) => for(out = '', a = f(x)(y).split('n'), y = 0; y < 8; y++) for(x = 0; x < 8; x++) out += `<div class="b b$a[y][x] == ' ' ? 'H' : a[y][x]"></div>`; o.innerHTML = out; )(0, 0); o.onclick = e => u(e.clientX >> 4, e.clientY >> 4)body margin: 0; padding: 0;
#o width: 128px; height: 128px;
.b float: left; width: 16px; height: 16px;
.b0 background-color: #44f;
.b1 background-color: #ffc90e;
.b2 background-color: #22b14c;
.bH background-color: #000; <div id="o"></div>f=
h=>v=>(a=[...'3232132031021010'],a[5+(v&4|h>3)]^=3,a[v/2<<2|h/2]=v%2*2+h%2,g=x=>y&8?'':(x<8?x-h|y-v?a[(Y=y>>1)*4|(X=x/2)]^y%2*2+x%2?X+Y&1:2:' ':(x=~!++y,`
`))+g(x+1))(y=0)
;(u = (x, y) => for(out = '', a = f(x)(y).split('n'), y = 0; y < 8; y++) for(x = 0; x < 8; x++) out += `<div class="b b$a[y][x] == ' ' ? 'H' : a[y][x]"></div>`; o.innerHTML = out; )(0, 0); o.onclick = e => u(e.clientX >> 4, e.clientY >> 4)body margin: 0; padding: 0;
#o width: 128px; height: 128px;
.b float: left; width: 16px; height: 16px;
.b0 background-color: #44f;
.b1 background-color: #ffc90e;
.b2 background-color: #22b14c;
.bH background-color: #000; <div id="o"></div>edited 42 mins ago
answered 6 hours ago
ArnauldArnauld
89.4k7 gold badges103 silver badges365 bronze badges
89.4k7 gold badges103 silver badges365 bronze badges
$begingroup$
Constructive proof that three colors are always sufficient, very nice!
$endgroup$
– John Dvorak
6 hours ago
2
$begingroup$
Love the clickable graphical output!
$endgroup$
– Kevin Cruijssen
4 hours ago
add a comment |
$begingroup$
Constructive proof that three colors are always sufficient, very nice!
$endgroup$
– John Dvorak
6 hours ago
2
$begingroup$
Love the clickable graphical output!
$endgroup$
– Kevin Cruijssen
4 hours ago
$begingroup$
Constructive proof that three colors are always sufficient, very nice!
$endgroup$
– John Dvorak
6 hours ago
$begingroup$
Constructive proof that three colors are always sufficient, very nice!
$endgroup$
– John Dvorak
6 hours ago
2
2
$begingroup$
Love the clickable graphical output!
$endgroup$
– Kevin Cruijssen
4 hours ago
$begingroup$
Love the clickable graphical output!
$endgroup$
– Kevin Cruijssen
4 hours ago
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%2f189344%2ftile-the-chessboard-with-four-colored-triominoes%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
2
$begingroup$
If there is input it's not really Kolmogorov complexity
$endgroup$
– Jonathan Allan
8 hours ago
$begingroup$
@JonathanAllan the tag description uses who's that pokemon as an example of a kolmogorov complexity question that takes input. It's up to you if you want to compress a set of 64 constant solutions or if you want to implement a procedure to tile the chessboard and then color it.
$endgroup$
– John Dvorak
8 hours ago
1
$begingroup$
@JonathanAllan meta discussion regarding non-constant kolmogorov complexity questions
$endgroup$
– John Dvorak
7 hours ago
1
$begingroup$
Aren't three colors enough?
$endgroup$
– Arnauld
7 hours ago
1
$begingroup$
@Arnauld I'll allow that. I'll edit.
$endgroup$
– John Dvorak
6 hours ago