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;








2












$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









share|improve this question











$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

















2












$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









share|improve this question











$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













2












2








2





$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









share|improve this question











$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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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












  • 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










1 Answer
1






active

oldest

votes


















8












$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:



triominoes



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:



matrix0



The next steps are:



  1. 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°.

  2. 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.

  3. We fill the holes with the 3rd color (except the 'real' hole).

Assuming that the hole is located at $(2,0)$, this gives:



enter image description here



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>








share|improve this answer











$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













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



);













draft saved

draft discarded


















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









8












$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:



triominoes



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:



matrix0



The next steps are:



  1. 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°.

  2. 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.

  3. We fill the holes with the 3rd color (except the 'real' hole).

Assuming that the hole is located at $(2,0)$, this gives:



enter image description here



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>








share|improve this answer











$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















8












$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:



triominoes



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:



matrix0



The next steps are:



  1. 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°.

  2. 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.

  3. We fill the holes with the 3rd color (except the 'real' hole).

Assuming that the hole is located at $(2,0)$, this gives:



enter image description here



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>








share|improve this answer











$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













8












8








8





$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:



triominoes



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:



matrix0



The next steps are:



  1. 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°.

  2. 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.

  3. We fill the holes with the 3rd color (except the 'real' hole).

Assuming that the hole is located at $(2,0)$, this gives:



enter image description here



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>








share|improve this answer











$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:



triominoes



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:



matrix0



The next steps are:



  1. 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°.

  2. 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.

  3. We fill the holes with the 3rd color (except the 'real' hole).

Assuming that the hole is located at $(2,0)$, this gives:



enter image description here



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>






share|improve this answer














share|improve this answer



share|improve this answer








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
















  • $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

















draft saved

draft discarded
















































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




draft saved


draft discarded














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





















































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







Popular posts from this blog

Canceling a color specificationRandomly assigning color to Graphics3D objects?Default color for Filling in Mathematica 9Coloring specific elements of sets with a prime modified order in an array plotHow to pick a color differing significantly from the colors already in a given color list?Detection of the text colorColor numbers based on their valueCan color schemes for use with ColorData include opacity specification?My dynamic color schemes

Invision Community Contents History See also References External links Navigation menuProprietaryinvisioncommunity.comIPS Community ForumsIPS Community Forumsthis blog entry"License Changes, IP.Board 3.4, and the Future""Interview -- Matt Mecham of Ibforums""CEO Invision Power Board, Matt Mecham Is a Liar, Thief!"IPB License Explanation 1.3, 1.3.1, 2.0, and 2.1ArchivedSecurity Fixes, Updates And Enhancements For IPB 1.3.1Archived"New Demo Accounts - Invision Power Services"the original"New Default Skin"the original"Invision Power Board 3.0.0 and Applications Released"the original"Archived copy"the original"Perpetual licenses being done away with""Release Notes - Invision Power Services""Introducing: IPS Community Suite 4!"Invision Community Release Notes

François Viète Contents Biography Work and thought Bibliography See also Notes Further reading External links Navigation menup. 21Google Bookspp. 75–77Google BooksDe thou (from University of Saint Andrews)ArchivedGoogle BooksGoogle BooksGoogle BooksGoogle booksGoogle Bookscc-parthenay.frL'histoire universelle (fr)Universal History (en)ArchivedAdsabs.harvard.eduPagesperso-orange.frArchive.orgChikara Sasaki. Descartes' mathematical thought p.259Google BooksGoogle BooksGoogle Bookspp. 152 and onwardGoogle BooksGoogle BooksScribd.comGoogle Books1257-7979Google BooksGoogle BooksGoogle BooksGoogle BooksGoogle BooksGoogle BooksGallica.bnf.frGoogle BooksGoogle Books"François Viète"Francois Viète: Father of Modern Algebraic NotationThe Lawyer and the GamblerAbout TarporleySite de Jean-Paul GuichardL'algèbre nouvelle"About the Harmonicon"cb120511976(data)1188044800000 0001 0913 5903n82164680ola2013766880073431702w6vt1sb70287374827140948071409480