text:
Fundamental Solution of the Pell Equation
Given some positive integer \$n\$ that is not a square, find the fundamental solution \$(x,y)\$ of the associated Pell equation
$$x^2 - n\cdot y^2 = 1$$
Details

The fundamental \$(x,y)\$ is a pair of integers \$x,y\$ satisfying the equation where \$x\$ is minimal, and positive. (There is always the trivial solution \$(x,y)=(1,0)\$ which is not counted.)
You can assume that \$n\$ is not a square.

Examples
 n           x    y
 1           -    -
 2           3    2
 3           2    1
 4           -    -
 5           9    4
 6           5    2
 7           8    3
 8           3    1
 9           -    -
10          19    6
11          10    3
12           7    2
13         649    180
14          15    4
15           4    1
16           -    -
17          33    8
18          17    4
19         170    39
20           9    2
21          55    12
22         197    42
23          24    5
24           5    1
25           -    -
26          51    10
27          26    5
28         127    24
29        9801    1820
30          11    2
31        1520    273
32          17    3
33          23    4
34          35    6
35           6    1
36           -    -
37          73    12
38          37    6
39          25    4
40          19    3
41        2049    320
42          13    2
43        3482    531
44         199    30
45         161    24
46       24335    3588
47          48    7
48           7    1
49           -    -
50          99    14
51          50    7
52         649    90
53       66249    9100
54         485    66
55          89    12
56          15    2
57         151    20
58       19603    2574
59         530    69
60          31    4
61  1766319049    226153980
62          63    8
63           8    1
64           -    -
65         129    16
66          65    8
67       48842    5967
68          33    4
69        7775    936
70         251    30
71        3480    413
72          17    2
73     2281249    267000
74        3699    430
75          26    3
76       57799    6630
77         351    40
78          53    6
79          80    9
80           9    1
81           -    -
82         163    18
83          82    9
84          55    6
85      285769    30996
86       10405    1122
87          28    3
88         197    21
89      500001    53000
90          19    2
91        1574    165
92        1151    120
93       12151    1260
94     2143295    221064
95          39    4
96          49    5
97    62809633    6377352
98          99    10
99          10    1

Relevant OEIS sequences: A002350 A002349 A033313 A033317

Surprised that there isn't any challenge with the Pell equation yet, since it's pretty well-known I thought. At least, I do remember using it sometimes with Project Euler challenges.

@Fatalize "You can assume that $n$ is not a square." Would probably be clearer if the test cases omitted those imho, though.

@KevinCruijssen I considered that, but I thought it would be more confusing to omit some of the ns. (btw I was also surprized but I had this challenge in the sandbox for about a year)

Related: https://projecteuler.net/problem=66

Piet, 612 codels
Takes n from standard input. Outputs y then x, space-separated.
Codel size 1:
Codel size 4, for easier viewing:
Explanation
Check out this NPiet trace, which shows the program calculating the solution for an input value of 99.
I'm not sure whether I'd ever heard of Pell's equation before this challenge, so I got all of the following from Wikipedia; specifically, these sections of three articles:

Pell's equation § Fundamental solution via continued fractions
Methods of computing square roots § Continued fraction expansion
Continued fraction § Infinite continued fractions and convergents

Basically, what we do is this:

Get \$n\$ from standard input.
Find \$\lfloor\sqrt n\rfloor\$ by incrementing a counter until its square exceeds \$n\$, then decrement it once. (This is the first loop you can see in the trace, at top left.)
Set up some variables for calculating \$x\$ and \$y\$ from the continued fraction of \$\sqrt n\$.
Check whether \$x\$ and \$y\$ fit Pell's equation yet. If they do, output the values (this is the downwards branch about 2/3 of the way across) and then exit (by running into the red block at far left).
If not, iteratively update the variables and go back to step 4. (This is the wide loop out to the right, back across the bottom, and rejoining not quite halfway across.)

I frankly have no idea whether or not a brute-force approach would be shorter, and I'm not about to try it! Okay, so I tried it.

Piet, 184 codels
This is the brute-force alternative I said (in my other answer) that I didn't want to write. It takes over 2 minutes to compute the solution for n = 13. I really don't want to try it on n = 29... but it checks out for every n up to 20, so I'm confident that it's correct.
Like that other answer, this takes n from standard input and outputs y then x, space-separated.
Codel size 1:
Codel size 4, for easier viewing:
Explanation
Here's the NPiet trace for an input value of 5.
This is the most brutal of brute force, iterating over both \$x\$ and \$y\$. Other solutions might iterate over \$x\$ and then calculate \$y=\sqrt{\frac{x^2-1}{n}}\$, but they're wimps.
Starting from \$x=2\$ and \$y=1\$, this checks whether \$x\$ and \$y\$ have solved the equation yet. If it has (the fork at the bottom near the right), it outputs the values and exits.
If not, it continues left, where \$y\$ is incremented and compared to \$x\$. (Then there's some direction-twiddling to follow the zig-zag path.)
This last comparison is where the path splits around the mid-left. If they're equal, \$x\$ is incremented and \$y\$ is set back to 1. And we go back to checking if it's a solution yet.
I still have some whitespace available, so maybe I'll see if I can incorporate that square-root calculation without enlarging the program.

Haha I agree about the wimps that use square roots :D

Brachylog, 16 bytes
;1↔;Ċz×ᵐ-1∧Ċ√ᵐℕᵐ

Try it online!
Explanation
;1↔                Take the list [1, Input]
   ;Ċz             Zip it with a couple of two unknown variables: [[1,I],[Input,J]]
      ×ᵐ           Map multiply: [I, Input×J]
        -1         I - Input×J must be equal to 1
          ∧        (and)
           Ċ√ᵐ     We are looking for the square roots of these two unknown variables
              ℕᵐ   And they must be natural numbers
                   (implicit attempt to find values that match those constraints)

Pari/GP, 34 bytes
PARI/GP almost has a built-in for this: quadunit gives the fundamental unit of the quadratic field \$\mathbb{Q}(\sqrt{D})\$, where \$D\$ is the discriminant of the field. In other words, quadunit(4*n) solves the Pell's equation \$x^2 - n \cdot y^2 = \pm 1\$. So I have to take the square when its norm is \$-1\$.
I don't know what algorithm it uses, but it even works when \$n\$ is not square-free.
Answers are given in the form x + y*w, where w denotes \$\sqrt{n}\$.
n->(a=quadunit(4*n))*a^(norm(a)<0)

Try it online!

Wolfram Language (Mathematica), 46 bytes
FindInstance[x^2-y^2#==1&&x>1,{x,y},Integers]&

Try it online!

Is it assured that this always finds the fundamental solution?

@GregMartin yes, it is.This always finds the first (minimum) solution. In this case this always returns {1,0}. That is why we have to choose x>1 and get the second (fundamental) solution

I would like that to be true, but nothing in the documentation seems to indicate that....

@GregMartin I have used this function many times and already knew how it worked. My only concern was to skip the first solution and that cost me those 5 extra bytes. You can easily write a program and test it (just to confirm millions of results)

05AB1E, 17 16 14 bytes
Saved a byte thanks to Kevin Cruijssen.
Outputs [y, x]
∞.Δn*>t©1%_}®‚

Try it online!
Explanation
∞                 # from the infinite list of numbers [1 ...]
 .Δ        }      # find the first number that returns true under
   n              # square
    *             # multiply with input
     >            # increment
      t©          # sqrt (and save to register as potential x)
        1%        # modulus 1
          _       # logical negation
            ®‚    # pair result (y) with register (x)

And you beat me to it again.. had a 17 byter as well, but it didn't work because Å² is bugged with decimals.. >.< Anyway, you can remove both , and add a trailing ‚ (no, the comma's are not the same ;p) to save a byte.

@KevinCruijssen: Thanks! Yeah I also went for Å² first noticing that it didn't work as expected.

Java 8, 74 73 72 bytes
n->{int x=1;var y=.1;for(;y%1>0;)y=Math.sqrt(-x*~++x/n);return x+" "+y;}

-1 byte thanks to @Arnauld.
-1 byte thanks to @OlivierGrégoire.
Try it online.
Explanation:
n->{                 // Method with double parameter and string return-type
  int x=1;           //  Integer `x`, starting at 1
  var y=.1;          //  Double `y`, starting at 0.1
  for(;y%1>0;)       //  Loop as long as `y` contains decimal digits:
    y=               //   Set `y` to:
      Math.sqrt(     //    The square-root of:
        -x*          //     Negative `x`, multiplied by
           ~++x      //     `(-x-2)` (or `-(x+1)-1)` to be exact)
                     //     (because we increase `x` by 1 first with `++x`)
               /n);  //     Divided by the input
  return x+" "+y;}   //  After the loop, return `x` and `y` with space-delimiter as result

72 bytes, by changing n to a double, and x to an int, playing on the fact that x*x-1 is equal to (-x-1)*(-x+1).

Well, I'm actually playing on the fact that (x+1)*(x+1)-1 is equal to -x*-(x+2), to be entirely correct.

R,  66 56 54 53 52 47 45 bytes
a full program
n=scan();while((x=(1+n*T^2)^.5)%%1)T=T+1;x;+T

-1 -2  thanks to @Giuseppe
-7 thanks to @Giuseppe & @Robin Ryder
-2 @JAD

53 bytes using !!(expr) instead of (expr)!=0

@Giuseppe Tnx! could I have some more??

use .5 instead of 0.5

46 bytes. Finding the smallest value of x is equivalent to finding the smallest value of y. This allows you to save 2 bytes because expressing x in terms of y is shorter than the other way around, and 4 bytes by using the trick of using T which is initialized at 1.

@RobinRyder you might need a +T at the end to make sure that when y==1 it returns 1 instead of TRUE but I'm not entirely sure.

@Giuseppe Well spotted! You are right. That makes it 47 bytes

i love the initializing with T thingy

Seeing as you are doing mod 1, you can omit the !!, since 0 is already evaluated as FALSE

Seems to fail on n=61 (the silly large test case) due to big number issues. I think it's fine to allow for language limits, just noting the exception.

@CriminallyVulgar got an answer for 61 on my machine in less than a minutes.....

@ZahiroMor I got an answer as well, it was just wrong! If you're getting the right answer on 61 that's interesting, as I was getting 335159612, 42912791 rather than
the expected 1766319049, 226153980.
A lot of the answers here seem to be failing on it actually, so I think it's just an accepted part of the challenge now.

@CriminallyVulgar did you delete the T value between runs??

@ZahiroMor Yep, and tried running it on a fresh R instance. Seems to be some big number precision issue, as it evaluates (61 * 42912791^2) as 112331965515990544 instead of 112331965515990541, so it's off by 3 on an 18 digit number.

@ZahiroMor Again, I don't really see this as a flaw in the code, but a flaw in R, and other answers have similar problems with this particular value so I don't think it's a big deal.

n@CriminallyVulgar now I see what you mean. thank you :)

Jelly, 40 bytes
½©%1İ$<®‘¤$Ð¿¹;Ḋ$LḂ$?Ḟṭ@ṫ-ṚZæ.ʋ¥ƒØ.,U¤-ị

Try it online!
An alternative Jelly answer, less golfy but more efficient algorithmically when x and y are large. This finds the convergents of the regular continued fraction that approximate the square root of n, and then checks which solve the Pell equation. Now correctly finds the period of the regular continued fraction.
Thanks to @TimPederick, I’ve also implemented an integer-based solution which should handle any number:
Jelly, 68 bytes
U×_ƭ/;²®_$÷2ị$}ʋ¥µ;+®Æ½W¤:/$$
¹©Æ½Ø.;ÇƬṪ€F¹;Ḋ$LḂ$?ṭ@ṫ-ṚZæ.ʋ¥ƒØ.,U¤-ị

Try it online!
For example, the solution for 1234567890 has 1936 and 1932 digits for the numerator and denominator respectively.

Nice! I took the same approach in my answer. I don't read Jelly, so I'm not sure why you're having problems with 61. Are you storing each convergent as a pair of integers (numerator and denominator)?

@TimPederick Yes. Not sure where the issue arises

I tried learning how this works so I could help debug it, but I just couldn't wrap my head around it! Only thing I can suggest is taking the floor of any floats, since (if this does use the same algorithm as mine) all intermediate values should come out as integers anyway.

@TimPederick It was floating point inaccuracy. I’ve now made it stop looking for further continuation of the continued fraction once it reaches the period. This works up to 150, but above that I think again I run into floating point accuracy errors at e.g. 151

@TimPederick also it’s the generation of the continued fraction that’s problematic, not the convergents which are done with integer arithmetic.

I figured, but there's an algorithm for the coefficients of the continued fraction that sticks to integers.

@TimPederick thanks. I’ve implemented this in addition to the previous floating point method.

MATL, 17 bytes
`@:Ut!G*-!1=&fts~

Try it online!
Explanation
The code keeps increasing a counter k = 1, 2, 3, ... For each k, solutions x, y with 1 ≤ x ≤ k, 1 ≤ y ≤ k are searched. The process when some solution if found.
This procedure is guaranteed to find only one solution, which is precisely the fundamental one. To see why, note that

Any solution x>0, y>0 for n>1 satisfies x>y.
If x,y is a solution and x',y' is a different solution then necessarily x≠x' and y≠y'.

As a consequence of 1 and 2,

When the procedure stops at a given k, only one solution exists for that k, because if there were two solutions one of them would been found earlier, and the process would have stopped with a smaller k.
This solution is the fundamental one, because, again, if there were a solution with smaller x it would have been found earlier.

`       % Do...while
  @:U   %   Push row vector [1^2, 2^2, ..., k^2] where k is the iteration index
  t!    %   Duplicate and transpose. Gives the column vector [1^2; 2^2; ...; k^2]
  G*    %   Multiply by input n, element-wise. Gives [n*1^2; n*2^2; ...; n*k^2]
  -     %   Subtract with broadcast. Gives a square matrix of size n
  !     %   Transpose, so that x corresponds to row index and y to column index
  1=&f  %   Push row and column indices of all entries that equal 1. There can
        %   only be (a) zero such entries, in which case the results are [], [],
        %   or (b) one such entry, in which case the results are the solution x, y
  ts~   %   Duplicate, sum, negate. This gives 1 in case (a) or 0 in case (b)
        % End (implicit). Proceed with next iteration if top of the stack is true;
        % that is, if no solution was found.
        % Display (implicit). The stack contains copies of [], and x, y on top.
        % The empty array [] is not displayed

JavaScript (ES7), 47 bytes
n=>(g=x=>(y=((x*x-1)/n)**.5)%1?g(x+1):[x,y])(2)

Try it online!
Below is an alternate 49-byte version which keeps track of \$x²-1\$ directly instead of squaring \$x\$ at each iteration:
n=>[(g=x=>(y=(x/n)**.5)%1?1+g(x+=k+=2):2)(k=3),y]

Try it online!
Or we can go the non-recursive way for 50 bytes:
n=>eval('for(x=1;(y=((++x*x-1)/n)**.5)%1;);[x,y]')

Try it online!

Haskell, 46 bytes
A straightforward brute force search. This makes use of the fact that a fundamental solution \$(x,y)\$ satisfying \$x^2 - ny^2 =  1 \$ must have \$y \leq x\$.
f n=[(x,y)|x<-[1..],y<-[1..x],x^2-n*y^2==1]!!0

Try it online!

It seems like you need to change n to x in y<-[1..n] so you can compute f 13.

@ChristianSievers Thanks for pointing it out, I corrected it!

TI-BASIC,  44  42 41 bytes
Ans→N:"√(N⁻¹(X²-1→Y₁:1→X:Repeat not(fPart(Ans:X+1→X:Y₁:End:{X,Ans

Input is \$n\$.
Output is a list whose values correspond to \$(x,y)\$.
Uses the equation \$y=\sqrt{\frac{x^2-1}{n}}\$ for \$x\ge2\$ to calculate the fundamental solution.
The current \$(x,y)\$ pair for that equation is a fundamental solution iff \$y\bmod1=0\$.
Examples:
6
               6
prgmCDGF12
           {5 2}
10
              10
prgmCDGF12
          {19 6}
13
              13
prgmCDGF12
       {649 180}

Explanation:
Ans→N:"√(N⁻¹(X²+1→Y₁:1→X:Repeat not(fPart(Ans:X+1→X:Y₁:End:{X,Ans  ;full logic

Ans→N                                                              ;store the input in "N"
      "√(N⁻¹(X²+1→Y₁                                               ;store the aforementioned
                                                                   ; equation into the first
                                                                   ; function variable
                     1→X                                           ;store 1 in "X"
                         Repeat not(fPart(Ans          End         ;loop until "Ans" is
                                                                   ; an integer
                                              X+1→X                ;increment "X" by 1
                                                    Y₁             ;evaluate the function
                                                                   ; stored in this variable
                                                                   ; at "X" and leave the
                                                                   ; result in "Ans"
                                                           {X,Ans  ;create a list whose
                                                                   ; values contain "X" and
                                                                   ; "Ans" and leave it in
                                                                   ; "Ans"
                                                                   ;implicitly print "Ans"

Note:  TI-BASIC is a tokenized language.  Character count does not equal byte count.

Python 2, 49 bytes
a=input()**.5
x=2
while x%a*x>1:x+=1
print x,x//a

Try it online!
Finds x as the smallest number above 1 where x % sqrt(n) <= 1/x. Then, finds y from x as y = floor(x / sqrt(n)).

C# (Visual C# Interactive Compiler), 70 69 bytes
n=>{int x=1;var y=.1;for(;y%1>0;)y=Math.Sqrt(-x*~++x/n);return(x,y);}

Port of my Java 8 answer, but outputs a tuple instead of a string to save bytes.
Try it online.

Jelly, 15 bytes
‘ɼ²×³‘½µ⁺%1$¿;®

Try it online!
A full program that takes a single argument n and returns a tuple of x, y.

Husk, 12 bytes
ḟΛ¤ȯ=→*⁰□π2N

Try it online!
Explanation
ḟΛ¤ȯ=→*⁰□π2N  Input is n, accessed through ⁰.
           N  Natural numbers: [1,2,3,4,..
         π2   2-tuples, ordered by sum: [[1,1],[1,2],[2,1],[1,3],[2,2],..
ḟ             Find the first that satisfies this:
 Λ             All adjacent pairs x,y satisfy this:
  ¤     □       Square both: x²,y²
   ȯ  *⁰        Multiply second number by n: x²,ny²
     →          Increment second number: x²,ny²+1
    =           These are equal.

APL(NARS), 906 bytes
r←sqrti w;i;c;m
m←⎕ct⋄⎕ct←0⋄r←1⋄→3×⍳w≤3⋄r←2⋄→3×⍳w≤8⋄r←w÷2⋄c←0
i←⌊(2×r)÷⍨w+r×r⋄→3×⍳1≠×r-i⋄r←i⋄c+←1⋄→2×⍳c<900⋄r←⍬
⎕ct←m

r←pell w;a0;a;p;q2;p2;t;q;P;P1;Q;c;m
   r←⍬⋄→0×⍳w≤0⋄a0←a←sqrti w⋄→0×⍳a≡⍬⋄m←⎕ct⋄⎕ct←0⋄Q←p←1⋄c←P←P1←q2←p2←0⋄q←÷a
L: t←p2+a×p⋄p2←p⋄p←t
   t←q2+a×q
   :if c≠0⋄q2←q⋄:endif
   q←t
   P←(a×Q)-P
   →Z×⍳Q=0⋄Q←Q÷⍨w-P×P
   →Z×⍳Q=0⋄a←⌊Q÷⍨a0+P
   c+←1⋄→L×⍳(1≠Q×¯1*c)∧c<10000
   r←p,q
   :if c=10000⋄r←⍬⋄:endif
Z: ⎕ct←m

Above there are 2 functions sqrti function that would find the floor square root and pell function would return Zilde for error, and is based reading the page http://mathworld.wolfram.com/PellEquation.html
it would use the algo for know the sqrt of a number trhu continue fraction (even if i use one algo for know sqrt using
newton method) and stop when it find p and q such that
 p^2-w*q^2=1=((-1)^c)*Qnext

Test:
  ⎕fmt pell 1x
┌0─┐
│ 0│
└~─┘
  ⎕fmt pell 2x
┌2───┐
│ 3 2│
└~───┘
  ⎕fmt pell 3x
┌2───┐
│ 2 1│
└~───┘
  ⎕fmt pell 5x
┌2───┐
│ 9 4│
└~───┘
  ⎕fmt pell 61x
┌2────────────────────┐
│ 1766319049 226153980│
└~────────────────────┘
  ⎕fmt pell 4x
┌0─┐
│ 0│
└~─┘
  ⎕fmt pell 7373x
┌2───────────────────────────────────────────────────────────┐
│ 146386147086753607603444659849 1704817376311393106805466060│
└~───────────────────────────────────────────────────────────┘
  ⎕fmt pell 1000000000000000000000000000002x
┌2────────────────────────────────────────────────┐
│ 1000000000000000000000000000001 1000000000000000│
└~────────────────────────────────────────────────┘

There is a limit for cycles in the loop in sqrti function, and a limit for cycles for the loop in Pell function, both for the possible case  number are too much big or algo not converge... (I don't know if sqrti converge every possible input and the same the Pell function too)

MathGolf, 12 bytes
ökî²*)_°▼Þ√î

Try it online!
I'm throwing a Hail Mary when it comes to the output formatting. If it's not allowed, I have a solution which is 1 byte longer. The output format is x.0y, where .0 is the separator between the two numbers.
Explanation
ö       ▼      do-while-true with popping
 k             read integer from input
  î²           index of current loop (1-based) squared
    *          multiply the two
     )         increment (gives the potential x candidate
      _        duplicate TOS
       °       is perfect square
         Þ     discard everything but TOS
          √    square root
           î   index of previous loop (1-based)

I took some inspiration from Emigna's 05AB1E answer, but was able to find some improvements. If the separator I chose is not allowed, add a space before the last byte for a byte count of 13.

><>, 45 bytes
11v
+$\~:1
:}/!?:-1v?=1-*}:{*:@:{*:
$  naon;>

Try it online!
Brute force algorithm, searching from x=2 upwards, with y=x-1 and decrementing on each loop, incrementing x when y reaches 0. Output is x followed by y, separated by a newline.

C# (Visual C# Interactive Compiler), 69 bytes
n=>{for(int x=2,y;;x++)for(y=0;y<=x;y++)if(x*x-y*y*n==1)return(x,y);}

Try it online!

Groovy, 53 bytes
n->x=1;for(y=0.1d;y%1>0;)y=((++x*x-1)/n)**0.5;x+" "+y

Try it online!
Port of Kevin Cruijssen's Java and C# answers

Pyth, 15 bytes
fsIJ@ct*TTQ2 2J

Try it online here. Output is x then y separated by a newline.

Wolfram Language (Mathematica), 41 bytes
{1//.y_/;!NumberQ[x=√(y^2#+1)]:>y+1,x}&

√ is the 3-byte Unicode character #221A. Outputs the solution in the order (y,x) instead of (x,y). As usual with the imperfect //. and its limited iterations, only works on inputs where the true value of y is at most 65538.
Try it online!

Python 3, 75 bytes
lambda i:next((x,y)for x in range(2,i**i)for y in range(x)if~-x**2==i*y**2)

Try it online!
Explanation
Brute force. Using $$x<i^i$$ as an upper search bound, which is well below the definite upper limit of the fundamental solution to Pell's equation $$x\leq i!$$
This code would also run in Python 2. However, the range() function in Python 2 creates a list instead of a generator like in Python 3 and is thus immensely inefficient.

With inifinte time and memory, one could use a list comprehension instead of the iterator and save 3 bytes like so:
Python 3, 72 bytes
lambda i:[(x,y)for x in range(i**i)for y in range(x)if~-x**2==i*y**2][1]

Try it online!

Python 2, 64 bytes
f=lambda n,x=2,y=1:x*x-n*y*y-1and f(n,x+(x==y),y*(y<x)+1)or(x,y)

Try it online!
Returns (x, y).


text:
Generate an RGB colour grid
This! is an RGB colour grid...

Basically it's a 2-dimensional matrix in which:

The first row, and the first column, are red.
The second row, and the second column, are green.
The third row, and the third column, are blue.

Here are the colours described graphically, using the letters R, G, and B.

Here's how we calculate the colour of each space on the grid is calculated.

Red + Red = Red (#FF0000)
Green + Green = Green (#00FF00)
Blue + Blue = Blue (#0000FF)
Red + Green = Yellow (#FFFF00)
Red + Blue = Purple (#FF00FF)
Green + Blue = Teal (#00FFFF)

The Challenge

Write code to generate an RGB colour grid.
It's code golf, so attempt to do so in the smallest number of bytes.
Use any programming language or markup language to generate your grid.
Things I care about:

The result should graphically display an RGB grid with the defined colours.

Things I don't care about:

If the output is an image, HTML, SVG or other markup.
The size or shape of the colour blocks.
Borders, spacing etc between or around the blocks.
It definitely doesn't have to have labels telling you what the row and column colours should be.

Can we output an mage object native to our language, for example a Bitmap object in C#?

@EmbodimentofIgnorance sounds fine to me.

I'm waiting for the solution in Piet

@manassehkatz Is it just possible that hard-coding the data would be better golf than executing it?

@AJFaraday I'm not sure but I htink the color names you use are not standard. (At least they do not agree with e.g. CSS color names.) I just know that this caused some confusion in the MathJax answer, so maybe it would be worth adjusting the names in the challenge specs too.

@flawr I could spend a LOT of time finding every word to describe these primary and secondary colours. I'm more interested in the hex values, anyway.

I'm trying to do this on a TI-84. I'm only now starting to hate the screen resolution.

@BenjaminUrquhart The "I don't care about size or shape" point is your friend, here. They don't have to be a uniform size or shape, it could be as small as single pixels. Also, please include a photo :)

@AJFaraday You don't have to spend a lot of time (even though usually people are encouraged to spend some time writing the challenges), I just suggest using names that are widely used and not using names that are misleading. Concretely please use red, yellow, fuchsia, lime, aqua, blue. If you do not care about the names but just about the RGB codes you should say so in the specs. (and in this case preferably omit the color names completely.) Anything else just results in unnecessary confusion which is not in the sense of this site.

@AJFaraday oh that makes things easier.

@AJFaraday here you go

Not that it really matters, but I'd personally have used cyan and magenta instead of teal and purple (or anything else). As far as I know, these are the official terms used in printing or subtractive color models such as CMYK.

@Arnauld if you compare your comment to the most recent one by flaws, you’ll see why I’m not changing the names of colours in this question. You’re each asking for a different set of names as the “right” ones.

Is it allowed to use a language/platform that has a predefined color palette (like PICO-8), if its colors are at least somewhat close to the spec?

I’d say that’s probably fine.

Bash, 44

2 bytes saved thanks to @NahuelFouilleul
2 bytes saved thanks to @manatwork

printf "${f=^[[3%dm.}$f$f
" 1 3 5 3 2 6 5 6 4

Here, blocks are . characters.  ^[ is a literal ASCII escape character (0x1b).

You can recreate this script as follows:
base64 -d <<< cHJpbnRmICIke2Y9G1szJWRtLn0kZiRmCiIgMSAzIDUgMyAyIDYgNSA2IDQ= > rgbgrid.sh

what the heck? please explain :)

can save 2 bytes using shell expansion printf ${f=\\e[3%dm.}$f$f\\n 1 3 5 3 2 6 5 6 4

This one really brightened my day, thank you!

printf \\e[3%dm. 1' expands to \\e[31m. which is the ANSI escape code for red and so on and . is the character to print.

Continuing with @NahuelFouilleul's suggestion, double quote it: printf "${f=^[[3%dm.}$f$f␤" 1 3 5 3 2 6 5 6 4 (Where ^[ is a literal escape character=1 byte and ␤ a literal new line character=1 byte.)

If you could use extended ASCII instead of UTF 8 you could use "█" (Ascii 219) as it would be 1 byte.

You can use background colors (escape sequence start with 4 instead of 3) and spaces instead of dots to make it more block-like.

very neat :) I like the assignement of f followed by its use.

x86-16 machine code, IBM PC DOS, 43 bytes
00000000: be22 01b9 0100 ac8a d83c 10b8 db09 cd10  .".......<......
00000010: b403 cd10 7204 7809 b2ff 42b4 02cd 10eb  ....r.x...B.....
00000020: e2c3 0c0e 1d0e 0a1b 0d0b 91              ...........

Listing:
BE 0122     MOV  SI, OFFSET CT      ; load color bar table into [SI]
        LOOP_COLOR:
B9 0001     MOV  CX, 1              ; display 1 char and clear CH (changed by INT 10H:3)
AC          LODSB                   ; load next color byte
8A D8       MOV  BL, AL             ; move new color to BL
3C 10       CMP  AL, 010H           ; if this is third color in row: SF=0, CF=0
                                    ; else if last color: SF=1, CF=0
                                    ; else continue on same row: CF=1
B8 09DB     MOV  AX, 09DBH          ; AH=9 (write char with attr), AL=0DBH (block char)
CD 10       INT  10H                ; call PC BIOS, display color block
B4 03       MOV  AH, 3              ; get cursor position function
CD 10       INT  10H                ; call PC BIOS, get cursor
72 04       JC   NEXT_COL           ; if not last in row, move to next column
78 09       JS   EXIT               ; if last color, exit
B2 FF       MOV  DL, -1             ; otherwise move to first column and next row
        NEXT_COL:
42          INC  DX                 ; move to next column (and/or row)
B4 02       MOV  AH, 2              ; set cursor position function
CD 10       INT  10H                ; call PC BIOS, set cursor position
EB E2       JMP  LOOP_COLOR         ; loop to next color byte
        EXIT:
C3          RET                     ; return to DOS
        CT  DB   0CH, 0EH, 1DH      ; color table
            DB   0EH, 0AH, 1BH
            DB   0DH, 0BH, 91H

This uses the IBM PC BIOS INT 10H video services to write the color grid to the screen.  Unfortunately the only way to write a specific color attribute requires also writing code to place the cursor in the next correct location, so there's a lot of extra code for that.
Here's the output running on an IBM PC CGA (in 40x25 text mode to make it bigger).

TL;DR
Here's a more verbose explanation, with more detail of what some of these machine code instructions do.
Color table
The colors are stored as bytes in the color table (CTBL) with the 4-bit color value in the low nibble and a flag value in the high nibble.  A 1 in the high nibble signals the end of the row and a 9 signals the end of the list.
This is checked using a single CMP instruction which subtracts 0x10 from the color values and sets the result flags.  These operands are treated as 8-bit signed values, so the sign flag (positive or negative result) and carry flag (a subtractive borrow was required, meaning the color byte is less than 0x10) are the interesting ones here.  These flags are then checked further down for the conditional logic of whether to advance the row, the column or end the program.
Examples:
High nibble 0 means not the last in the row and not the last in the list:

0x0C - 0x10 = 0xFC -- Result is negative and a carry (borrow) was required

High nibble 1 means it is the last color in the row and not the last in the list:

0x1D - 0x10 = 0x0D --  Result is positive and no borrow

High nibble 9 means it is the last color of the list:

0x91 - 0x10 = 0x81 --  Result is negative and no borrow

Cursor movement
Using the PC BIOS or DOS API for output, the function that allows setting a character color does not automatically advance the cursor, so that has to be done by the program.  The cursor position must be fetched each time since the registers are overwritten later by the other functions.  The "get" function puts these into the 8-bit registers DL for the column, and DH for the row.  These same registers are what is used by the "set" function to move the cursor to a new location.
We can take advantage of the fact that, on x86 architecture DH and DL can be manipulated as a single 16-bit register (DX).  To advance to the next column, we increment DX which effectively only increments DL (column position).  To advance to the next column we would need to instead increment the row number and set the column to 0.  We can do this in only one additional instruction by setting the low nibble (DL) to 0xFF and then continuing the normal program flow incrementing DX.  Since we're now looking at DH/DL as a 16-bit value, DL becomes 0 and the carry from 0xFF + 1 is added to DH.
Examples:
Advance to next column:
DH   DL   DX
 1    1   0101   ; at row 1, column 1
 1    2   0102   ; add one to DX

Advance to next row, first column:
DH   DL   DX
 1    2   0102   ; at row 1, column 2
 1   FF   01FF   ; +set DL to 0xFF
 2    0   0200   ; add one to DX

Will this work in dos, prib not but would be cool if it did.

@marshalcraft Yes, in fact this will only work in DOS, or using a DOS emulator such as DOSBox, pcjs.org, etc. I've added a link to download the executable so you can give it a try.

Windows comes with limited dos emulator, probably now called command prompt, which I probably should have said, would be cool if it worked with cmd or PowerShell haha.

@marshalcraft You are correct, however since it's for DOS it's a 16-bit executable, and if you have a 32-bit version of Windows it should actually run as it has a 16-bit runtime environment. However a 64-bit edition of Windows won't run it as it only has a 32-bit runtime.

God this is a cool answer

Wolfram Language (Mathematica), 41 bytes
Image@Outer[Plus,#,#,1]&@IdentityMatrix@3

Wolfram Language (Mathematica), 68 bytes
Mathematica has built-ins for all these colors.
Image@{{Red,Yellow,Magenta},{Yellow,Green,Cyan},{Magenta,Cyan,Blue}}

80386 machine code, IBM PC DOS, 38 bytes
hex:
B0 13 CD 10 68 00 A0 1F 66 C7 06 00 00 28 2C 24
00 66 C7 06 40 01 2C 30 34 00 66 C7 06 80 02 24
34 20 00 CD 16 C3

asm:
mov al,13h
int 10h ; initialize vga 13h mode (320x200x256 colors)
push 0a000h
pop ds ; push video buffer address to ds
mov dword ptr ds:0, 242c28h ; print 3 pixels
mov dword ptr ds:320, 34302ch ; print 3 pixels
mov dword ptr ds:640, 203424h ; print 3 pixels
int 16h ; wait for any keypress
ret ; exit to os

scaled output from dosbox:

Note that mov al, 13h is incorrect unless it is guaranteed by DOSBox to have ah = 0 at the program entrypoint.

@MargaretBloom ax is 0 at start of com application in ms dos

Thanks Iłya, that's good to know!

Excel VBA (Immediate Window), 80 bytes
For i=1To 9:Cells(i Mod 3+1,(i+1)/3).Interior.ColorIndex=Mid(673486857,i,1):Next

Excel VBA (Function), 96 bytes
Sub g()
For i=1To 9
Cells(i Mod 3+1,(i+1)/3).Interior.ColorIndex=Mid(673486857,i,1)
Next
End Sub

Not a horrible tool for the job... I appreciate the fact that Excel already shows a grid so it is a matter of setting the background color.

Credit to @Neil for suggesting I use ColorIndex instead of Color leading to a 43 byte savings.
-21 bytes thanks to @Keeta
-16 bytes thanks to @Chronocidal for suggesting the "Immediate Window"
-2 bytes thanks to @i_saw_drones
Lots of changes from my original submission :)

You could probably do better with ColorIndex as that's a number from 3 to 8 here, which you could encode in a string or something.

@Neil - Indeed :) I was able to get it quite a bit shorter using that. Thanks for the tip.

I didn't see anything that stops you from changing this to Sub F() and End Sub for more savings.

You won't need the variable name in the Next statement, either.  "Next i" becomes just "Next", saving 2 bytes.

Sub g() ||
For i=2To 10 ||
Cells((i+1)Mod 3+1,i/3).Interior.ColorIndex=Mid("0367648785",i,1) ||
Next ||
End Sub || refactor to make just one for/next loop total is 99 bytes?

@Keeta - nice tips :) I'll admit VBA is not a strong suit of mine. I just thought Excel seemed like a natural place to display a grid.

I tried deleting the space between 1To and got an error. I'll try these out when I get done time though. Thanks for the tips!

For one more byte, loop 1 to 9 with: Cells(i Mod 3+1,(i+1)/3).Interior.ColorIndex=Mid("673486857",i,1)

In many BASIC dialects it’s not neccessary to indicate which FOR loop you end with NEXT, so you can just write Next instead of Next j, Next i, etc.

@dulange I think that was already commented on.

@Keeta Or change Next j and Next i to Next j,i

Don't make it a function, and run this in the Immediate Window to drop 21 bytes: for i=1 To 3:for j=1 To 3:Cells(i,j).Interior.ColorIndex=Mid("367408005",i*j,1):next j,i

You can also remove quotes from the string, VBA will coerce the number into a string automatically.

lol this answer is approaching mine but I figure what the heck, everyone deserves internet points: you can address an array of cells linearly using [A1:C3].Cells(i). This iterates across then down and removes the need for mods.

@ i_saw_drones - hah - I didn't realize there was another VBA answer here. I think if I make that change we will literally have the same answer? Looks like you can save a byte by removing a space i=1To 9.

For i=3To 11:Cells(i\3,i Mod 3+1).Interior.ColorIndex=Mid(367648785,i-2,1):Next for 79

HTML + CSS, 121 120 bytes
Worst piece of HTML I've ever wrote.
One byte save thanks to @Gust van de Wal

b{color:#ff0}a{color:cyan}i{color:lime}u{color:blue

██
███
 ██

HTML + CSS, 114 bytes (semi valid)
I'm putting this as semi-valid because the blue is not exactly #0000FF blue and also relies on not having clicked the link.
Thanks to @Lynn for the idea

b{color:#ff0}i{color:lime}c{color:cyan

██
██<c>█
 ██

You can omit the last closing bracket in the CSS. Also, incredible (and sickening) work!

You can change the tag names to avoid the default CSS formatting, e.g. <w>, <x>, <y>, and <z>.

█ will be blue by default, saving you some bytes of CSS :)

SVG, 210 182 bytes
<svg><path d="h3v3h-3" fill=#f0f/><path d="h2v2h-2" fill=#ff0/><path d="m1 1h2v2h-2" fill=#0ff/><line x2=1 stroke=red/><path d="m1 1h1v1h-1" fill=#0f0/><path d="m2 2h1v1" fill=#00f/>

Since the size or shape of the colour blocks doesn't matter, quite a few bytes can be golfed off with this slightly odd layout:

I really like the ingenuity of this solution.

GFA Basic 2.02 (Atari ST), 48 bytes
A manually edited listing in .LST format. Includes many non-printable characters, whose codes are shown within brackets.
?"[ESC]c[SOH] [ESC]c[ETX] [ESC]c[ENQ] "[CR]
?"[ESC]c[ETX] [ESC]c[STX] [ESC]c[ACK] "[CR]
?"[ESC]c[ENQ] [ESC]c[ACK] [ESC]c[EOT] "[CR]

The operating system of the Atari ST defines extended VT52 commands which are used here.
Output
The output is a block of \$24\times24\$ pixels (9 space characters of \$8\times8\$ pixels).

screenshot from Steem SSE

+1 for making me all nostalgic for my trusty old ST.

ditaa, 118 bytes
/----+----+----\
|cF00|cFF0|cF0F|
+----+----+----+
|cFF0|c0F0|c0FF|
+----+----+----+
|cF0F|c0FF|c00F|
\----+----+----/

This is the output using -E option:

Factorio Blueprint String, 705 bytes
I admit, I'm just pushing the limits of what counts as a solution.
0eNrdWNGOqyAQ/ReedeNo0daH/ZHNTYOW7ZJFNAi91zT99wua7ZpdaaT1pb40oQ6HOecwA3pGBde0kUwolJ8RK2vRovztjFp2FITb/1TXUJQjpmiFAiRIZUdtzYkMGyIoR5cAMXGg/1AOlz8BokIxxegA0w+6vdBVQaUJuAKQstSV5kTV0qA2dWvm1MKuZ3FecIA6lIf4BV8uwS+YeDKPXzBhPKAkUxjJPAy4AbG5QljZFBEqLOuqYGKa1Vc6YAQzE5Ss+b6gH+TETLQJeWdcUemQ/8Sk0oSPHOgjQkkPqMfT1kEYWzEsI2hpc2gtFtgfO2NkDTMjbIKnCOLv1SrCechJ1UzwSm7zKpksNVN78+xwnffOZKv2s2kS0akPJo4D10FslEd2UDVE9oLn6NU+1i01S/HaKqmkpvNl2DhkSGfJEK1Eha1DhWyWCmvZCzuHCtu7aj5asuQ7ynn99/GqT0f07BjAwXnnx3kohEW7XMPE5+OEs5+EUwdhiL4T0IVh3LNzHlMwfUoB+LTPeK19A2LPkoGbety1f46SUvH4BoLExTHxOCKe3mmIXTJ43ogGp5MlnS47soTR+GeryFyUscex+PzOu65IkPr0OrzW2wFkHn0Ar3c3eN6S4pt63NUH7GvtAn3AafTOo+yf3+jhbDcv9/1XgHz00SBAJ+NNn3uWRJDiDcDWXIf+Aya7oEk=

Produced output when placed in-game (low graphics settings used):

To prove that it is a valid solution you need to sample this grid of pixels which do match the specification exactly:

The rest of the image is classified as a border or a spacing which, as said in the question, doesn't matter.

Very unique! Love it!

R, 89 50 48 bytes
Newest version:
image(matrix(c(6,4,5,2:4,1,2),3),col=rainbow(6))

Not enough elements in the vector to fill the 3x3 matrix, so it wraps around and reuses the first element.
Old versions:
image(matrix(c(6,4,5,2:4,1,2,6),3),col=rainbow(6))

image(matrix(c(3,5,6,2,4,5,1:3),3),col=c('red','yellow','magenta','green','cyan','blue'))

Welcome to PPCG!

wow it's Rainbow Six!

@alephalpha Yikes, I can't believe I missed that. I went ahead and fixed the oldest version and character count

46 bytes with image(matrix(c(6,4,5,2:4,1,2),3),c=rainbow(6))

Excel-VBA, 89 73 72 70 bytes
Edit: You can use the immediate window and dispense with the Sub/End Sub to save 16 bytes:
For i=1To 9:[A:C].Cells(i).Interior.ColorIndex=Mid(367648785,i,1):Next

Original answer:
Sub a()
For i=1To 9
[A1:C3].Cells(i).Interior.ColorIndex=Mid(367648785,i,1)
Next
End Sub

This was inspired by Neil's suggestion on this answer, and is my first submission!
Result:

-2 bytes: Removal of cell row numbers - thanks to Taylor Scott!

Welcome to PPCG!

Thank you! Hopefully I'll learn some tricks from the masters :)

For i=1To 9:[A:C].Cells(i).Interior.ColorIndex=Mid(367648785,i,1):Next for 70

Perl 6 (and probably similar for many languages) (31 bytes)
{'ÿ   ÿÿÿ ÿ ÿÿ  ÿ ÿÿÿ ÿ ÿÿ  ÿ'}   # replace spaces with ASCII 00
                                  # which I can't seem to enter

This outputs a headless TIFF file, which used to be generated by Photoshop with the file extension .raw and is presumed to be square unless otherwise specified at the time of opening.  Playing around with the color depth (if allowed) could reduce this down further.

ffplay (ffmpeg), 93 bytes
ffplay -f rawvideo -s 3x3 -pix_fmt rgb24 "data:/;base64,/wAA//8A/wD///8AAP8AAP///wD/AP//AAD/"

Old:
ffplay -f lavfi -i testsrc=s=3x3,geq=r=255*not(X*Y):g=255*not((X-1)*(Y-1)):b=255*not((X-2)*(Y-2))

JavaScript, 108 102 bytes
console.log(`%c█%c█%c█
`.repeat(3),...[...`320251014`].map(c=>`color:#`+`f0ff00f0`.substr(c,3)))

No snippet because this only works in a real browser console and not the snippet's console. Edit: Thanks to @AJFaraday for the screenshot. Explanation: Browsers allow the first parameter of console.log to include substitutions. The %c substitution takes a parameter and applies it as (sanitised) CSS. Each █ block is therefore coloured using the appropriate substring of f0ff00f0 interpreted as a three-hex-digit colour code.

I don't get how this works?

@marshalcraft %c is used to create a format string, the arguments being CSS styles for the text after it

So this is basically like dos versions but with chrome browser?

Just curious but how did you go about finding the shortest possible chain of fs/0s to use?

@Marie I started by noting that ff0ff contains all the mixed colours and 00f00 contains all the pure colours. If you concatenate them you get duplicate positions for ff0 and f00 so you can then remove the first and last characters. I then wrote a short script to check all 7-character strings to ensure that 8 was optimal.

Gotcha, I did about the same thing except I had a 9 character solution. Just for reference, because I thought it was a neat solution, I checked with a script like this [...new Array(2**8).map((_,i)=>i.toString("2")).filter(s=>allColors.every(c => s.indexOf(c) > -1))

\$\Large{\mathbf{\TeX} \left(\text{MathJax}\right)},~122\,\text{bytes}\$
$$
\def\c#1{\color{#1}{\rule{5em}{5em}}}
\c{red}
\c{yellow}
\c{fuchsia} \\
\c{yellow}
\c{lime}
\c{aqua} \\
\c{fuchsia}
\c{aqua}
\c{blue}
$$
Golf'd:
$\def\c#1{\color{#1}{\rule{5em}{5em}}}\c{red}\c{yellow}\c{fuchsia}\\\c{yellow}\c{lime}\c{aqua}\\\c{fuchsia}\c{aqua}\c{blue}$

Ungolf'd:
$$
\def\coloredBox#1{\color{#1}{\rule{5em}{5em}}}
\coloredBox{red}
\coloredBox{yellow}
\coloredBox{fuchsia} \\
\coloredBox{yellow}
\coloredBox{lime}
\coloredBox{aqua}    \\
\coloredBox{fuchsia}
\coloredBox{aqua}
\coloredBox{blue}
$$

Edits:

Thanks to @flawr for pointing out how to fix the colors!
Could shave off \$14\,\text{bytes}\$ by replacing \rule{5em}{5em} with ▉, which'd look like$$
\def\d#1{\color{#1}{▉}}
\d{red}
\d{yellow}
\d{fuchsia} \\
\d{yellow}
\d{lime}
\d{aqua} \\
\d{fuchsia}
\d{aqua}
\d{blue}
$$
, but just doesn't look quite the same.
Could probably shave off a few more bytes by finding color names that acceptably resemble the intended colors.
Just to show what a decently \$\mathrm{\TeX}\text{'d}\$ version of this would look like:$$
{\newcommand{\rotate}[2]{{\style{transform-origin: center middle; display: inline-block; transform: rotate(#1deg); padding: 50px}{#2}}}}
{\def\place#1#2#3{\smash{\rlap{\hskip{#1em}\raise{#2em}{#3}}}}}
{\def\placeBox#1#2#3{\place{#1}{#2}{\color{#3}{\rule{5em}{5em}}}}}
{\def\placeLabelTop#1#2#3{\place{#1}{#2}{\large{\textbf{#3}}}}}
{\def\placeLabelLeft#1#2#3{\place{#1}{#2}{\rotate{-90}{\large{\textbf{#3}}}}}}
\placeLabelTop{1.1}{15.5}{Red}
\placeLabelTop{5.5}{15.5}{Green}
\placeLabelTop{11.2}{15.5}{Blue}
\placeLabelLeft{-6.2}{13.6}{Red}
\placeLabelLeft{-7.1}{8.5}{Green}
\placeLabelLeft{-6.5}{3.5}{Blue}
\placeBox{0}{10}{red}
\placeBox{5}{10}{yellow}
\placeBox{10}{10}{fuchsia}
\placeBox{0}{5}{yellow}
\placeBox{5}{5}{lime}
\placeBox{10}{5}{aqua}
\placeBox{0}{0}{fuchsia}
\placeBox{5}{0}{aqua}
\placeBox{10}{0}{blue}
\place{15.1}{0}{\large{.}}
\phantom{\rule{15em}{16.5em}}
$$

I think your colors are not correct. But apart from that I'd upvote your post if only for the title:)

@flawr Yeah, they look different than the ones in the question statement, but I figured that if that's how $\mathrm{\TeX}$ renders those colors by the names given in the question statement, hopefully it'll be close enough.  =P

It seems mathjax uses the css color names. So you could replace purple with fuchsia and teal with aqua and green with lime then things would be correct I think.

Just to note it: The above could be golf'd a bit more by removing some {}'s.  But that'd violate too many clean coding principles for my sanity.  =P

Just note that the PPCG community was never famous for its sanity. If anything probably for the lack thereof.

@Nat check out the HTML/CSS solution then

\rule{5em}{5em} -> \rule 5em 5em

The \color{something} command doesn't take a text argument like \textcolor{something}{tex to be coloured}, rather it's a switch, so you can save two bytes by removing the extra pair of braces around \rule: \def\c#1{\color{#1}\rule{5em}{5em}}. Also, in proper TeX ~ is an active character so you can replace all \c by ~ and save a couple more bytes. Don't know about MathJax though.

Lua + LÖVE/Love2D, 186 183 bytes
t={[0>1]=0,[0<1]=1}l=love g=l.graphics function l.draw()for i=1,3 do for j=1,3 do g.setColor(t[i<2 or j<2],t[i==2 or j==2],t[i>2 or j>2])g.rectangle('fill',j*10,i*10,10,10)end end end

Try it online!

My first code golf entry!

Welcome to Code Golf! Nice work!

I think you could use expressions in your truth table: t={[0>1]=0,[0<1]=1}.

@manatwork Smart!

another löver, nice to see you here

HTML/CSS, 278 141 137 bytes

r{color:red}y{color:#ff0}m{color:#f0f}g{color:#0f0}c{color:#0ff}l{color:#00f

<r>█<y>█<m>█
<y>█<g>█<c>█
<m>█<c>█<l>█

-137 bytes thanks to commenters, most notably @data
-4 bytes thanks to @Einacio
Uses Unicode █ (U+2588) for the "blocks", and uses CSS classes/inline style to color them.
I think the  tags could be golfed more, however changing them to a shorter tag such as  breaks the color attribute

Leave out 	, the browser is smart enough to automatically add this closing tag

If using deprecated elements, you can also specify the background color of a cell using

Maybe a noob question, but can't you avoid using the table and just print the █ and go to a new line with ?

@frarugi87 yes - 235 total: ███
███
███

@ASCII-only b{color:#ff0}u{color:#f0f}i{color:#0ff}
███
███
███
@ASCII-only then you can also golf out 18 bytes by using the  tag rather than  one

okidokes let's implement some golfing then

`a{color:#ff0}b{color:#f0f}i{color:#0f0}u{color:#0ff}s{color:#00f
███
███
███` for 138 bytes
@GustvandeWal, why do you need the font tag anyway? you can just use a custom tag, like <r> and it will work just fine for one less byte (actually I think it will work better, as it is not a deprecated tag :p)

<r>█<y>█<m>█
<y>█<g>█<c>█
<m>█<c>█<l>█``` (I'm using `<l>` for b**l**ue to avoid the default bold style, at it looks nicer now

@Einacio, oh of course. Custom tags... pre{color:red}y{color:#ff0}m{color:#f0f}g{color:#0f0}c{color:#0ff}l{color:#00f
█<y>█<m>█ <y>█<g>█<c>█ <m>█<c>█<l>█ is another byte shorter, by the way

Adding on to @GustvandeWal's comment you should be able to -3 bytes by removing the pre from the CSS statement too. Or in the case of the version you currently have posted, remove the r from CSS and the <r> tag from the HTML.

Octave/MATLAB, 57 56 40 bytes
-17 byte thanks to @ExpiredData! Check out their even golfier solution!
image(reshape(de2bi(126973007),[3,3,3]))

Try it online!

Does just image work instead of imshow? Don't have a Matlab license any more and I'm on phone so can't test it

@ExpiredData Thanks a lot, that works indeed!

You can probably do this too Try it online!

@ExpiredData ---Very nice trick, thanks a lot! :)--- why don't you post this as an own answer?

Great then here's two more bytes off Try it online!

Seriously, please post this as your own answer I feel like I did a lot less than half the work:)

Ok I will do that

MATL, 44 23 21 20 19 bytes
A direct port of my Octave answer with the suggestions from @ExpiredData and @LuisMendo.
126973007Bo7B3*e0YG

try it online

Octave, 38 bytes
image(reshape(de2bi(126973007),3,3,3))

Try it online!

HTML (GIF), 108 bytes
It's the battle of the web-based image formats! (Any TIF or JPG contenders out there?)
Answer by @A C.

HTML (BMP), 116 115 bytes
Answer by @ASCII-only.

HTML (WebP), 116 bytes
Answer by @Hohmannfan.

HTML (PNG), 151 136 135 bytes
-15 bytes thanks to @Hohmannfan.

Also, see my CSS and SVG answers.

Good idea but.. It seems to me that a 89 bytes file for a 9 pixel image is a bit too much. Maybe manually writing a BMP header can golf this down. If I'm not wrong, the bare minimum header is 26 bytes, plus 12 of actual data (3 rows of 4 pixels) can trim the image down to 38 bytes, which in base64 means 51 or 52 characters rather than 119

118: . 14 byte file header, 12 byte application header, 9 of actual data per row (+3 to pad to multiple of 4), yeah

You might be able to strip /png, since browsers will detect the file type automatically. FF 66 even allows removal of image/png.

Sorry for stupid question but is this html tag basically creating png? I just ask cause I've asked on s.e. How to make png with html and j.s. And there are other questions on it as well and typical answer was something with urls and what not. I'd like to understand this method.

@marshalcraft https://stackoverflow.com/q/2807251/4271479

I haven't counted, but I suspect that  is shorter

Here's a png file that's 15 bytes smaller when base64 encoded:
iVBORw0KGgoAAAANSUhEUgAAAAMAAAADCAIAAADZSiLoAAAAFElEQVR4AWP4z8Dw/z8DEIIodB4A4D0O8pOGuTgAAAAASUVORK5CYII=

To continue the format battle, here's a lossless WebP solution. I can't cut it down anymore without violating the spec, so it narrowly beaten by BMP at 116 bytes.

@Hohmannfan your solution shows as a broken image for me (Safari)

@BenjaminUrquhart Safari does not support the WebP format: https://caniuse.com/#search=webp

@Hohmannfan I guess I can blame apple then

Blockly turtle, 45 blocks
Try it online!
How about we play a little game of finding the most ridiculous tool for the job?
Output:

The program (as a screenshot for additional heresy):

Note: The grayed out blocks are also counted towards the metric.

I’d love that to be a standard PCG challenge! Instead it happens organically on some code golf puzzles

dc (on xterm), 64 bytes
Fi16[AP]sF36dD6r31 101dD6rD1[1CP61P[38;5;]Pn[mX]Pz3%0=Fz0<M]dsMx

You'll just get a bunch of wacky escape codes instead of colors, but you can still try it online!
By my understanding, the 16 basic ANSI colors are free to be interpreted however the terminal wants. On the other hand, the 216 colors in the xterm color cube have explicit RGB values. I am using these codes and printing a grid of Xs:

First we set the input radix to base 15 with Fi. This costs two bytes, but gives back three, so... a net gain of a byte (and a big ol' loss in readability). Next we're trying to get our color values onto the stack. In decimal, this would be 21 51 201 51 46 226 201 226 196, but we're in wacky mode so it's going to be 16 36 D6 36 31 101 D6 101 D1. We eliminate one of the spaces by slotting in a macro we need to define at some point, [AP]sF (which simply prints a line feed). We can shrink 36 D6 36 and 101 D6 101 by placing the first value on the stack, duplicating it, placing the second, and then swapping (36dD6r, 101dD6r).
Macro M handles the printing and whatnot. 1CP prints the escape character. Brackets are used to delimit strings, and as far as I know are not escapable, so we need to print the bracket with an ASCII value as well, 61P. [38;5;]P is the 'set foreground color from the numbered list' code. n prints the value from the top of the stack w/o a newline, popping it. [mX]P ends the code and prints an 'X'. z3%0=F checks the stack depth mod 3, running our line feed macro F when necessary. z0<M keeps M running as long as there's stuff on the stack. dsMx to run.
Note that if you run this in dc in an xterm, it'll leave your foreground color blue. 1CP61P74P (input shown in the screenshot) should reset this.

Node.js, 79 bytes
require('fs').writeFile(a='P',a+[...'3331100110101110010011101011001'].join` `)

Produces a file named "P" in the PPM format containing the color grid.

C#, 248 204 198 bytes
class P{static void Main(){for(int i=0;i<12;i++){foreach(dynamic n in Enum.GetValues(typeof(ConsoleColor)))if((""+n)[0]=="RYMRYGCRMCBR"[i])Console.BackgroundColor=n;Console.Write(i%4<3?" ":"\n");}}}

Output:

TI-Basic, x bytes (will score when I can)
Note: content filter is blocking me from looking up the token sizes for each of these commands. If anyone wants to score for me, go for it.
TextColor(11
Text(0,0,"0"
TextColor(19
Text(0,2,"0"
Text(2,0,"0"
TextColor(13
Text(4,0,"0"
Text(0,4,"0"
TextColor(14
Text(2,2,"0"
TextColor(18
Text(2,4,"0"
Text(4,2,"0"
TextColor(17
Text(4,4,"0"

This look really bad on my little calculator screen. But hey, shape doesn't matter :^)
Golf output:

Modified for 8x larger output:

TI-BASIC, x bytes
Using Pxl-On instead of Text:
Pxl-On(0,0,11
Pxl-On(0,1,19
Pxl-On(0,2,13
Pxl-On(1,0,19
Pxl-On(1,1,14
Pxl-On(1,2,18
Pxl-On(2,0,13
Pxl-On(2,1,18
Pxl-On(2,2,17

Output:

Blown up ~11x:

It's 180 characters, excluding line breaks.  I'm not sure how/if line breaks are counted in code golf.

Yes, but TI-BASIC is a tokenized language - for example, the interpreter sees TextColor as 2 bytes, not 9 as you would expect @Nat

[x86 Assembly], 42 bytes
org 100h
   mov al,13h
   int 10h
   push 40960
   pop es
   xor di,di
   mov bp,8
L: mov eax,[C+bp]
   stosd
   add di,316
   sub bp,4
jnc L

ret
C: dd 00203424h, 0034302ch, 00242c28h

Dump:
00000000  B013              mov al,0x13
00000002  CD10              int 0x10
00000004  6800A0            push word 0xa000
00000007  07                pop es
00000008  31FF              xor di,di
0000000A  BD0800            mov bp,0x8
0000000D  668B861E01        mov eax,[bp+0x11e]
00000012  66AB              stosd
00000014  81C73C01          add di,0x13c
00000018  83ED04            sub bp,byte +0x4
0000001B  73F0              jnc 0xd
0000001D  C3                ret
0000001E  0024              add [si],ah
00000020  3420              xor al,0x20
00000022  002C              add [si],ch
00000024  3034              xor [si],dh
00000026  0028              add [bx+si],ch
00000028  2C24              sub al,0x24

Cool answer! Can you post the byte code or xxd dump for this?

BASIC C64, 106 bytes
0 POKE53281,0
1 DATA144,28,158,156,144,13,158,30,159,144,13,156,159,31,144
2 READA:PRINTCHR$(A)+"o";:GOTO2

Jelly, 16 bytes
“IỤỵ7ỤĖm8’b4K”P;

Try it online!
Niladic link or full program that produces a portable pixmap format image of the desired grid.

C++, SFML, 177 bytes
#include<SFML/Graphics.hpp>
int d[]={255,65535,0xFF00FF,65535,65280,0xFFFF00,0xFF00FF,0xFFFF00,0xFF0000};void f(){sf::Image g;g.create(3,3,(sf::Uint8*)d);g.saveToFile("a.jpg");}

Uses sf::Image::create(int,int,unsigned char*) method to create an image with rgb values in it

You can shave off one byte by writing 0xFF0000 as 255<<16.

Taking it a bit further, you can save 13 bytes by defining the R/G/B colour values in variables before the array: int b=255<<16,g=65280,r=255,d[]={r,g|r,b|r,g|r,g,b|g,b|r,b|g,b};

PostScript, 195 bytes
Output look closer:
%!PS
/r{rlineto}def/s{newpath moveto 0 1 r 1 0 r 0 -1 r closepath setrgbcolor fill}def
1 0 0 0 2 s
1 1 0 1 2 s
1 0 1 2 2 s
1 1 0 0 1 s
0 1 0 1 1 s
0 1 1 2 1 s
1 0 1 0 0 s
0 1 1 1 0 s
0 0 1 2 0 s

To test just paste the code in a blank file and save as something.ps and open in a pdf viewer.
To enlarge the output add 50 50 scale (or some other number) on the second line of the file.

Processing 3: 191 178 161 Bytes
int l=0;void setup(){size(33,33);}void draw(){int i=l%33;int j=l/33;stroke((i%3==0||j%3==0)?255:0,(i%3==1||j%3==1)?255:0,(i%3==2||j%3==2)?255:0);point(i,j);l++;}

Since the rectangles are drawn in a for loop, I'm pretty sure you can put them in setup.

@Razetime i didn't know you could do that I will check that out

Nice first answer, welcome to the site!

@Razetime I actually worked out an even better way to do it!

CSS, 157 155 147 139 bytes

html{height:100%;background-blend-mode:screen;--:red 33%,#0f0 0 67%,blue 0;background:linear-gradient(90deg,var(--)),linear-gradient(var(--

Unlike @darrylyeo's answer no zooming is required (or possible!) I just wanted to show off background-blend-mode, despite it being far too long a keyword for code golf. Edit: Saved 2 10 bytes with help from @GustvandeWal. Saved a further 8 bytes thanks to @darrylyeo.

html can be replaced with * (3 bytes. Will make it a bit ugly) -
All offset values to some value below 10 (8 bytes. Makes it a LOT more ugly) -
Last offset value to 0 (2 bytes) -
height to 99% (1 byte) -
Omit last closing bracket (1 byte)

@GustvandeWal I decided against those changes that made the result ugly, but I was able to rearrange my CSS so that I could omit not one but two closing brackets, so thanks for the tip.

You can still change the last 67%s to 0s

@GustvandeWal Better still, I can change 4 values to 0s and I'm now tying with @darrylyeo's answer!

-8 bytes if you use CSS variables! html{height:100%;background-blend-mode:screen;--:red 33%,#0f0 0 67%,blue 0;background:linear-gradient(90deg,var(--)),linear-gradient(var(--

@darrylyeo I had wondered whether there was a way of avoiding the repetition; thanks for letting me know!

Wolfram Language (Mathematica), 72 bytes
Grid@Partition[RGBColor/@Unitize[Total/@Tuples[IdentityMatrix@3,{2}]],3]

CSS, 147 138 bytes
Uses the box-shadow and background properties.

html{width:1em;height:1em;background:#f0f;box-shadow:red 0 1em,#ff0 1em 1em,#ff0 0 2em,#0f0 1em 2em,#0ff 2em 2em,#0ff 1em 3em,#00f 2em 3em

-9 bytes (Gust van de Wal): Make background magenta to cover for two pixels instead of one.

html{width:3px;height:3px;background:#f0f;box-shadow:red 0 3px,#ff0 3px 3px,#ff0 0 6px,#0f0 3px 6px,#0ff 6px 6px,#0ff 3px 9px,#00f 6px 9px for 138 bytes

To improve visibility, replace px with em or mm. Also, use html instead of body. Here's the CSS: html{width:1em;height:1em;background:red;box-shadow:#ff0 1em 0,#f0f 2em 0,#ff0 0 1em,#0f0 1em 1em,#0ff 2em 1em,#f0f 0 2em,#0ff 1em 2em,#00f 2em 2em

Just figured that you can make the yellow and cyan shadows bigger and overlap everything: html{width:2em;height:2em;background:#f0f;box-shadow:red 0 2em,#0f0 2em 4em,#00f 4em 6em,#ff0 1em 3em 0 1em,#0ff 3em 5em 0 1em, 126 bytes

APL (dzaima/APL), 186 161 bytes
Uses dzaima's Processing integration.
G←P5.G
P5.draw←{p←G.pt
G.stroke←'00f'
p 3 3
G.stroke←'0ff'
p 2 3 3 2
G.stroke←'f0f'
p 1 3 3 1
G.stroke←'0f0'
p 2 2
G.stroke←'ff0'
p 1 2 2 1
G.stroke←'f00'
p 1 1}

-25 bytes after applying some of dzaima's suggestions and 3 character color codes.
Grid (Heavily Magnified):

Actual size:

GeoGebra Script, 157 bytes
Execute[Flatten[Sequence[Sequence[{"P"+i+j+"=("+j*.2+","+i*.2+")","SetColor[P"+i+j+","+(i==2∨j==0)+","+(i==1∨j==1)+","+(i==0∨j==2)+"]"},i,0,2],j,0,2]]]

Try it online!
Output:

Raw PPM image, 36 bytes
$ xxd image.ppm
00000000: 5036 2033 2033 2031 0a01 0000 0101 0001  P6 3 3 1........
00000010: 0001 0101 0000 0100 0001 0101 0001 0001  ................
00000020: 0100 0001

It might not fit the requirements, but it's fun to include anyway as a benchmark.

Just a reference, use P3 is 62 bytes: P3 3 3 1 1 0 0 1 1 0 1 0 1 1 1 0 0 1 0 0 1 1 1 0 1 0 1 1 0 0 1

Python 2, 74 48 47 bytes
print('\033[9%sm#'*3+'\n')*3%tuple('135326564')

Depends on system colors (this assumes 'bright' colors are pure RGB values), but works by modifying the foreground color of #s in the terminal.
-26 bytes thanks to xnor
-5 bytes by realizing the color blocks don't need to be rectangles, +4 bytes from miscounting

You don't need to use loops here, string multiplication suffices: print('\033[10%sm '*3+'\n')*3%tuple('135326564')

@xnor thanks, but it turns out I had to add \033[0m before the \n because of some interaction with \n coloring the entire next line

Python Turtle, 202 bytes, inspired by Aaron F's answer
import turtle as m
t=m.Turtle()
t.shape("square")
l=t.left
i=0
y=["#ff0","#f0f","cyan"]
for c in["red"]+y+["#0f0"]+y:t.color(c);t.stamp();a={2:270,5:90}.get(i,0);l(a);t.fd(21);l(a);i+=1
t.color("blue")

Very nice! I was wondering today whether turtle.color() accepted short colour codes :-)

x86 machine code, 16-bit, MS-DOS, EGA display, 40 39 bytes
Hexdump:
68 80 b8 07 31 ff be 1e 01 b9 09 00 2e 8a 24 46
b0 db d0 ec ab 73 04 81 c7 9a 00 e2 ef c3 18 1c
1b 1c 14 17 1a 16 02

Execution log:

It writes the "bar" character █ with various attributes to display memory, starting from address b8800 (display memory starts at b8000; I added an offset to move the output to a better place on the screen).
I could use the fact that display memory is filled with space characters, and change their background instead of overwriting them with the bar character, but for best match I needed bright colours, and they are not supported as background.
I developed the code using debug.com in a DOS emulator here. Source code:
; the following should read "push b880" but debug.com cannot emit this instruction
db 68, 80, b8
pop es
xor di, di
mov si, 11e
mov cx, 9
; 10c (loop target)
cs:
mov ah, [si]
inc si
mov al, db
shr ah, 1
stosw
jnc 11b
add di, 9a
; 11b (jump target)
loop 10c
ret
db 18, 1c, 1b, 1c, 14, 17, 1a, 16, 02

Python 123 bytes
from matplotlib.pyplot import*;r=0,1,2;imshow([[[2.if i==j==k else 1if(i==k)|(j==k)else 0for k in r]for j in r]for i in r])

Seeing no one took advantage of matplotlib in a graphical-output challenge I figured it had to be done for completion.
Explanation
We can take advantage of the fact that matplotlib will autolevel our colors if we give it floating point data instead of integer data. This means we don't have to worry about specifying specific color values, just the correct ratios. So a red pixel we can define as (2, 0 ,0) and a yellow pixel we can define as (1, 1, 0). All we have to do is make sure at least one of these elements is a float, and matplotlib will automatically scale it to the proper 255-bit color for us.
Ungolfed code for clarity.
from matplotlib.pyplot import *
r = (0, 1, 2)
image = [[[0 for i in r] for i in r] for i in r]
for i in r:
    for j in r:
        for k in r:
            if i==j==k: #matching pixel for diagonal element
                image[i][j][k] = 2.
            elif i==k or j==k: #matching pixel for partial component
                image[i][j][k] = 1
imshow(image)

Java 10, 229 bytes
import java.awt.*;v->new Frame(){{add(new Panel(){public void paint(Graphics g){var G=(Graphics2D)g;for(int i=9;i-->0;G.fillRect(i%3*4,i/3*4,4,4))G.setColor(new Color(i<4|i==6?255:0,i%2>0|i==4?255:0,i>4|i==2?255:0));}});show();}}

Screenshot of the actual 12x12 pixels result:

Screenshot of the 10 times larger 120x120 pixels result (the 4 in the fillRect are replaced with 40):

Explanation:
import java.awt.*;                // Required import for almost everything
v->                               // Method with empty unused parameter and Frame return
  new Frame(){                    //  Create the Frame
   {                              //   In an inner code-block:
     add(new Panel(){             //    Add a Panel we can draw on:
       public void paint(Graphics g){
                                  //     Overwrite its paint method:
         for(int i=9;i-->0        //      Loop `i` in the range (9,0]:
             ;                    //        After every iteration:
              G.fillRect(i%3*4,i/3*4,4,4))
                                  //         Draw a 4x4 pixel rectangle at coordinate
                                  //         x=i%3*4, y=i//3*4
           G.setColor(new Color(  //       Set the current RGB color to:
             i<4|i==6?255:0,      //        Red: 255 if `i` is 0,1,2,3,6; 0 otherwise
             i%2>0|i==4?255:0,    //        Green: 255 if `i` is 1,3,4,5,7; 0 otherwise
             i>4|i==2?255:0));}});//        Blue: 255 if `i` is 2,5,6,7,8; 0 otherwise
     show();}}                    //    And show the Frame when we're done

Ruby, 113 bytes (Ubuntu Terminal)
a=[[91,93,95],[93,32,96],[95,96,34]]
for b,c,d in a do puts"\e[#{b}m█\e[0m\e[#{c}m█\e[0m\e[#{d}m█\e[0m" end

In Terminal.app, the colors do not display properly:

According to Wikipedia, this program should fit the spec if it's run on Ubuntu, which is the only terminal which has the colors as per specifications. Can someone help me out with this?
Try it online!

Processing, 225 210 chars/bytes
Exhilarating code, I know.
fill(#FF0000);
rect(0,0,4,4);
fill(#FFFF00);
rect(0,4,4,4);
rect(4,0,4,4);
fill(#FF00FF);
rect(0,8,4,4);
rect(8,0,4,4);
fill(#00FF00);
rect(4,4,4,4);
fill(#00FFFF);
rect(4,8,4,4);
rect(8,4,4,4);
fill(#0000FF);
rect(8,8,4,4);

Unless there is something magic about 30 & 60, change to single-digit values (e.g., 4, 8 would give you the maximum) and that will save you 7 bytes.

Actually, with a=3 instead of 30, get rid of a altogether and just hardcode the 3s and remove the first line = 9 more bytes.

@manassehkatz Was able to save 15 bytes. The 30 and 60 were mainly to make the image big enough, which isn't necessary for the challenge. Thanks.

Ruby with Shoes, 89 characters
Shoes.app{n=0..2
n.map{|i|n.map{|j|fill n.map{|e|i==e||j==e ?:F:0}*''
rect i*9,j*9,9,9}}}

Sample output:

If you leave out *9 and change the other 9s to 1s, will that give 1-pixel color squares? If so, that will save 4 bytes. But if that would result in "borders without insides" then leave it as is.

@manassehkatz, unfortunately that would result only borders. nostroke would turn off the borders and the filled rectangles would appear, but not with the desired colors as kind of antialiasing would be performed on the rectangles' margins. strokewidth 0 would solve that, but would exceed the 4 characters gain. :(

HTML, 150 bytes

HTML, 151 bytes

Python 2, 216 bytes
l=[41,43,45,43,42,46,45,46,44]
print(''.join(['\033[0;37;'+`l[i+j*3]`+'m \033[0m'+'\n'*(j==2)for i in range(3)for j in range(3)]))

Unfortunately, this code does not work well with TIO, but here is a link regardless: Try it online!

Thanks for the answer, Henry. It might be nice to include a tio.run to execute this code.

@AJFaraday unfortunately, it doesn't work in TIO, but I will provide a link regardless.

A language does not need to be in TIO to be allowed. I did mine in Tcl/Tk as so many answers I posted before, and no one was rejected because of your observation.

Javascript, 134 131 111 bytes

for(n=0,i=12;--i;)document.write(i%4?'█':'
')

You can save one byte by using string interpolation for the font tag

I don't know if this is allowed. turtle is a built-in, but it relies on TK, which might not always be available (eg. TIO doesn't like this).
Anyway, it was fun to do. Tried to get it as small as possible while still using Turtle.
(269 bytes because those spaces aren't spaces, they're tabs!)
Python 2 or 3, 269 bytes
import turtle
t=turtle.Turtle()
t.shape("square")
l=t.left
i=0
y=["yellow","magenta","cyan"]
for c in ["red"]+y+["green"]+y+["blue"]:
    i+=1
    t.color(c)
    t.stamp()
    if i==9:
        break
    elif i%3==0:
        a=90 if i==6 else 270
    else:
        t.fd(21)
        continue
    l(a)
    t.fd(21)
    l(a)

I’m not that hot on the rules of code golf, but that seems fine to me. And I love that you did it this way :)

A language does not need to be in TIO to be allowed. I did mine in Tcl/Tk as so many answers I posted before, and no one was rejected because of your observation.

Pyth, 25 bytes
.wm.eXbk;mX*3]Zd=k255G=G3

The online interpreter doesn't show generated images, so this program must be run locally. It generates a 3x3 pixel image like the one in the question.

SVG, 212 bytes
Uses the CSS property mix-blend-mode: lighten.

<svg><g fill=red><path d="M0 0h3v1H0z"/><path d="M0 0h1v3H0z"/><g fill=lime><path d="M0 1h3v1H0z"/><path d="M1 0h1v3H1z"/><g fill=blue><path d="M0 2h3v1H0z"/><path d="M2 0h1v3H2z"/>

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/

sort: votes


text:
A Megachess Board
You want to create a square chessboard. Adjacent tiles must alternate black and white like a standard chessboard, and the bottom left corner can be either black or white.
Your program will take in two positive integers, the number of black and the number of white tiles. These will always be less than 1024. You don't have to use all the tiles.
Output the maximum side length of a chessboard pattern that can be constructed using the given amount of tiles.
Test Cases:
12, 15 -> 5
8, 8 -> 4
4, 0 -> 1

Hey! I've edited your question to say what I thought you meant. If it isn't, you can edit it again. Welcome to PPCG!

I think this is a nice question but, unfortunately, poorly stated. OP means that by giving you some black tiles and some white tiles (0 to 1000 for every color) find out the dimensions of the biggest chessboard that you can make out of them.Interesting test cases:  Input[10,15] and Output[4] and also Input[12,12] and Output[4]

You also posted this last week, where you were directed to the sandbox

Last test case should be 1.

Suggested test case: 12, 12.

I'm curious as to why you have accepted the javascript answer despite it not being the shortest.  Usually we only accept the shortest answer because it is the winner.  Although often we don't accept any answer.

@SriotchilismO'Zaic it gives the best explanation

@SriotchilismO'Zaic, we also sometimes accept the shortest solution in one particular language. "Best explanation", though, is not a valid criterion for accepting a solution.

JavaScript (ES7), 30 bytes
b=>w=>((b<w?b:w)*2|b!=w)**.5|0

Try it online!
Given the number of black squares \$b\$ and the number of white squares \$w\$, this computes:
$$s=\left\lfloor\sqrt{2\times\min(b,w)+k}\right\rfloor$$
with:
$$k=\begin{cases}
0&\text{if }b=w\\
1&\text{if }b\neq w
\end{cases}$$
For even sizes \$s\$, we need \$s^2/2\$ squares of each kind (e.g. for \$s=8\$: \$32\$ black squares and \$32\$ white squares).
For odd sizes \$s\$, we need \$\lfloor s^2/2\rfloor\$ squares of one kind and \$\lceil s^2/2\rceil\$ squares of the other kind (e.g. for \$s=5\$: \$12\$ black squares and \$13\$ white squares, or the other way around). The parameter \$k\$ is set to \$1\$ if \$max(b,w)\geq min(b,w)+1\$, which represents this extra square on one side.

Jelly, 6 bytes
«Ḥ+nÆ½

Try it online!
A dyadic link that returns the maximum board size.
Test suite for all permutations of numbers to 20
Explanation
«      | Minimum
 Ḥ     | Doubled
  +n   | Plus 1 if inputs not equal
    Æ½ | Integer square root

Arnauld’s answer has a good explanation for why this works; please consider upvoting him too!

Haskell, 35 bytes
x#y=floor$sqrt$min(x+y)$1+2*min x y

Try it online!
Explanation
This answer calculates the following formula:
$$\left\lfloor\sqrt{\min(a+b,2\min(a,b)+1)}\right\rfloor$$
Why does this formula work?  Well lets start by noting the following:
Every square of even side length can be tiled by \$2\times 1\$ tiles.
and
Every square of odd length can be tiled, spare a single \$1\times 1\$ square, by \$2\times 1\$ tiles.
Now we note that if we put these \$2\times 1\$ tiles on a chessboard each would lay on top of one black square and on white square.  So if we make an even chessboard every tile needs to have a pair of the other color, and if we make an odd chessboard every tile but one needs a pair of the other color.  This tells us that the answer is never more than \$\left\lfloor\sqrt{2\min(a,b)+1}\right\rfloor\$. \$2\min(a,b)\$ is the maximum number of pairs we can make and the \$+1\$ is for the last square that doesnt' need a pair.  The problem with this is that if \$a=b\$ we will not have the extra square for the odd case.  So we add another condition: Our result cannot be more than \$\left\lfloor\sqrt{a+b}\right\rfloor\$.  That is we can't make a square which has more tiles than we have available.
So we just take the lesser of the two options.
$$\left\lfloor\sqrt{\min(a+b,2\min(a,b)+1)}\right\rfloor$$
We can notice that this is the same as Arnauld's formulation since if \$a=b\$ then \$2\min(a,b)\$ is just \$a+b\$.

Ruby, 36 bytes
->x,y{'%i'%[x+y,x-~x,y-~y].min**0.5}

Try it online!
x-~x is a golfed version of 2*x+1; we're subtracting x's twos-complement negation from itself. After that I'm just using this answer's formula, but collapsing the two nested mins into one, then using string formatting to truncate to an integer.

05AB1E, 8 7 bytes
Ë≠+ß·tï

Try it online or verify all test cases.
Exlanation:
Uses a trivial derivative of the formula @Arnauld used in his JavaScript answer to save a byte:
$$s=\left\lfloor\sqrt{2\times\min(b+k,w+k)}\right\rfloor$$
with still:
$$k=\begin{cases}
0&\text{if }b=w\\
1&\text{if }b\neq w
\end{cases}$$
Ë        # Check if the two values of the (implicit) input-pair are the same
         #  (1 if truthy; 0 if falsey)
 ≠       # Falsify (!= 1), so 1 becomes 0 and vice-versa
  +      # Add that to each of the (implicit) input-values
   ß     # Only leave the minimum of that
    ·    # Double it
     t   # Take the square root
      ï  # And truncate/floor it by casting to an integer

Retina 0.8.2, 50 bytes
O#`\d+
\d+
$*
(1*),(1?\1)1*
$1$2
^(^1|11\1)*1*
$#1

Try it online! Link includes test cases. Explanation:
O#`\d+

Sort the numbers in ascending order. Let's call them l and h.
\d+
$*

Convert to unary.
(1*),(1?\1)1*
$1$2

Compute l + max(h, l + 1). This is the equivalent to 2 * min(b, w) + (b != w). See @Arnauld's answer for why this works.
^(^1|11\1)*1*
$#1

Find the highest integer square root.

Perl 6, 29 26 bytes
{0+|sqrt 2*@_.min+[!=] @_}

Thanks to Jo King for -3 bytes.
Try it online!

[min] @_ can be @_.min and you can move the [!=] to the end to save on the brackets. 26 bytes

R, 32 bytes
min(sum(n<-scan()),2*n+1)^.5%/%1

Try it online!
Takes b and w from stdin.
Uses the formula from this answer, but leveraging the behavior of min to take the minimum of all its arguments.

Japt, 11 bytes
Port of Arnauld's JS solution. Takes input as an array.
ñÍÌÑ+Ur¦)¬f

Try it
ñÍÌÑ+Ur¦)¬f     :Implicit input of array U
ñ               :Sort by
 Í              :  Subtracting from 2
  Ì             :Last element (Yes, there are more straightforward ways of getting the minimum but I like this method and it doesn't cost any bytes)
   Ñ+           :Multiply by 2 and add
     Ur         :U reduced by
       ¦        :  Testing for inequality
        )       :End reduce
         ¬      :Square root
          f     :Floor

Japt, 10 bytes
Port of Arnauld's JS solution.
mV Ñ|U¦V ¬

Try it online!

Welcome to PPCG and welcome to Japt! :) Note, though, that you need to floor the result of the square root. Otherwise this'll fail for the likes of 12, 12.

Husk, 9 bytes
⌊√+¬=³¹Dy

Try it online! Uses the logic from Arnauld's answer.

Python 3, 37 bytes
lambda a,b:(2*min(a,b)+(a!=b))**.5//1

Try it online!
Port of Arnauld's solution.

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/


text:
Slither Like a Snake
The Idea
We've done matrix spirals before, and full rotations, and even diagonal
rotations,
but not, as far as I can find, snake rotations!
What is a snake rotation?
Imagine the rows of a matrix snaking back and forth, with dividers between
them like the dividers of long queue:
    +--------------+
      1  2  3  4  5|
    +------------  |
    |10  9  8  7  6|
    |  +-----------+
    |11 12 13 14 15|
    +------------  |
     20 19 18 17 16|
    +--------------+

Now imagine rotating these items by 2.  Each item advances, like people moving
in a line, and the items at the end spill out and return to the beginning:
    +--------------+
-->  19 20  1  2  3|
    +------------  |
    | 8  7  6  5  4|
    |  +-----------+
    | 9 10 11 12 13|
    +------------  |
<--  18 17 16 15 14|
    +--------------+

If there are an odd number of rows it will exit from the right, but still wrap
to the beginning. For example, here's a 3 rotation:
    +--------------+
      1  2  3  4  5|
    +------------  |
    |10  9  8  7  6|
    |  +-----------+
    |11 12 13 14 15
    +--------------+

    +--------------+
-->  13 14 15  1  2|
    +------------  |
    | 7  6  5  4  3|
    |  +-----------+
    | 8  9 10 11 12  -->
    +--------------+

A negative rotation will take you backwards.  Here's a -2 rotation:
    +--------------+
<--   3  4  5  6  7|
    +------------  |
    |12 11 10  9  8|
    |  +-----------+
    |13 14 15  1  2  <--
    +--------------+

The Challenge
Your function or program will take 2 inputs, in any convenient format:

A matrix
A integer (positive or negative) indicating how many places to rotate it.

It will return:

The rotated matrix

Notes:

Code golf.  Fewest bytes wins.
Matrixes need not be square, but will contain at least 2 rows and 2 columns
Positive integers will rotate row 1 toward the right
Negative integers will rotate row 1 toward the left
You may reverse the meaning of positive / negative rotation numbers, if convenient
The rotation number can be larger than the number of items.  In that case, it
will wrap.  That is, it will be equivalent to the number modulo the number of
items.
The matrix will contain only integers, but it may contain any integers,
including repeats

Test Cases
Format:

Matrix
Rotation number
Expected return value

4 5
6 7

1

6 4
7 5

2  3  4  5
6  7  8  9
10 11 12 13

-3

5  9  8  7
12 11 10 6
13 2  3  4

8 8 7 7
5 5 6 6

10

5 5 8 8
6 6 7 7

Reversing meaning of +/- is fine.  I think the entrance should stay at the top left though.

This definitely needs an answer in Python.

Jelly, 10 bytes
UÐeẎṙṁ⁸UÐe

A dyadic Link accepting the marix on the left and the rotation integer on the right (uses the reverse meaning of positive / negative)
Try it online!
How?
UÐeẎṙṁ⁸UÐe - Link: matrix of integers, M; integer, R
 Ðe        - apply to even indices of M:
U          -   reverse each
   Ẏ       - tighten
    ṙ      - rotate left by R
     ṁ     - mould like:
      ⁸    -   chain's left argument, M
        Ðe - apply to even indices:
       U   -   reverse each

R, 121 110 101 bytes
function(m,n,o=t(m)){o[,j]=o[i<-nrow(o):1,j<-c(F,T)];o[(seq(o)+n-1)%%sum(1|o)+1]=o;o[,j]=o[i,j];t(o)}

Try it online!
Walkthrough
function(m,n) {           # Input: m - matrix, n - shift
  o <- t(m)               # Transpose the matrix, since R works in column-major order
                          # while our snake goes in row-major order
  i <- nrow(o):1          # Take row indices in reverse
  j <- c(F,T)             # Take even column indices (FALSE, TRUE, FALSE, TRUE, ...)
  o[,j] <- o[i,j]         # "Normalize" the matrix by reversing every second column
  o[(seq(o)+n-1) %%       # Perform the shift: add n-1 to indices,
    length(o)+1] <- o     # Modulo sequence length, and +1 again
  o[,j] <- o[i,j]         # Reverse even columns again to return to snake form
  t(o)                    # Transpose the matrix back to orginal shape and return
}

Python 3.8 (pre-releasSSSse), 119 bytes
lambda m,r,n=-1:[[m[(k:=(j+(s:=r+i)//w)%h)][::n**k][s%w]for i in range(w:=len(m[0]))][::n**j]for j in range(h:=len(m))]

An unnamed function accepting matrix, rotation which yields the new matrix.
Uses the opposite rotation sign.
Try it online!
How?
We set n=-1 upfront to save on parentheses later and take the matrix as m and the rotation as r.
A new matrix is constructed with the same dimensions as m - with a width of w (w:=len(m[0])) and a height of h (h:=len(m)).
Every other row of this matrix is reversed ([::n**j]).
The values are looked up by calculating their row and column in the original, m using the current elements row, i, and column, j...
We set s to r+i and k to (j+s//w)%h. k is the row of the original to access for our current element.
In order to easily access odd indexed rows from the right we reverse such rows before accessing their elements (with [:n**k]), this means the element of interest is at s%w.

J, 41 30 21 bytes
-11 bytes thanks to Jonah!
-9 bytes thanks to FrownyFrog & ngn !
$@]t@$(|.,@t=.|.@]/\)

Try it online!
Reversed +/-

30 bytes, +/- not reversed, but still uses helper: $@]t@$(|.,@(t=.#\,`(|.@,)/.])) (Try it online!)

correction: +/- still reversed.

@Jonah Now that's J! I remember seeing you applying the same trick with the alternating reversal recently, but apparently have forgotten about it. Thank you!
When trying &. I was loosing the left argument all the time, that's why I gave up.

21 bytes, thx @ngn

@FrownyFrog Wow, it's half the initial size now. I feel stupid... Thanks!

@FrownyFrog very nice.  i knew there were more bytes to be shaved off in the t helper, but you just Dundee'd me.

JavaScript (Node.js), 102 bytes
Takes input as (matrix)(integer). The meaning of the sign of the integer is inverted.
m=>n=>(g=m=>m.map(r=>r.sort(_=>~m,m=~m)))(m.map(r=>r.map(_=>a[(l+n++%l)%l]),l=(a=g(m).flat()).length))

Try it online!
Helper function
The helper function \$g\$ is used to 'snakify' or 'unsnakify' a matrix by reversing rows at odd indices.
g = m =>        // m[] = input matrix
  m.map(r =>    // for each row r[] in m[]:
    r.sort(_ => //   sort r[]:
      ~m,       //     using either 0 (don't reverse) or -1 (reverse)
      m = ~m    //     and toggling m before each iteration
                //     (on the 1st iteration: m[] is coerced to 0, so it yields -1)
    )           //   end of sort()
  )             // end of map()

Main function
m => n =>                    // m[] = matrix, n = integer
  g(                         // invoke g on the final result
    m.map(r =>               //   for each row r[] in m[]:
      r.map(_ =>             //     for each entry in r[]:
        a[(l + n++ % l) % l] //       get the rotated value from a[]; increment n
      ),                     //     end of inner map()
      l = (                  //     l is the length of a[]:
        a = g(m).flat()      //       a[] is the flatten result of g(m)
      ).length               //       (e.g. [[1,2],[3,4]] -> [[1,2],[4,3]] -> [1,2,4,3])
    )                        //   end of outer map()
  )                          // end of call to g

Pyth, 20 bytes
L.e_W%k2bbyclQ.>syQE

Try it online here.

Python 3, 94 bytes
lambda m,n:g(roll(g(m),n))
g=lambda b:[b[i][::(-1)**i]for i in r_[:len(b)]]
from numpy import*

Try it online!
Used the odd-row-reversal from Jonathan Allan's answer.
lambda m,n:g(roll(g(m),n))  #reverse odd rows, shift elements, then reverse odd rows again.
g=lambda b:[b[i][::(-1)**i] #reverse odd rows
    for i in r_[:len(b)]]   #r_[:x] = range(x)
from numpy import*          #roll() and r_[]

05AB1E, 16 bytes
εNFR]˜²._¹gäεNFR

Try it online!
Thanks to Emigna for -5. Unfortunately, I can't see how to golf the redundant part out. :(

Charcoal, 36 bytes
ＦＥθ⎇﹪κ²⮌ιιＦι⊞υκＩＥ⪪Ｅυ§υ⁻κηＬ§θ⁰⎇﹪κ²⮌ιι

Try it online! Link is to verbose version of code. Explanation:
Ｅθ⎇﹪κ²⮌ιι

Reverse alternate rows of the input.
Ｆ...Ｆι⊞υκ

Flatten the array.
Ｅυ§υ⁻κη

Rotate the flattened array.
⪪...Ｌ§θ⁰

Split the array back into rows.
Ｅ...⎇﹪κ²⮌ιι

Reverse alternate rows.
Ｉ...

Convert each entry to string and output in the default output format which is one number per line with rows double-spaced. (Formatting with a separator would cost the length of the separator.)

C# (Visual C# Interactive Compiler), 141 bytes
a=>n=>{for(dynamic l=a.Length,w=a.GetLength(1),i=l,j,b=a.Clone();i-->0;)a[(j=(i+n%l+l)%l)/w,j/w%2<1?j%w:w-j%w-1]=b[i/w,i/w%2<1?i%w:w-i%w-1];}

Try it online!
-5 bytes total thanks to @someone!
Anonymous function that performs an in-place modification to the input matrix.
An single loop iterates over the cells. You can scan from top to bottom and left to right using the following formulas:

row=i/w
col=i%w

Where i is a loop counter and w is the number of columns. This is varies slightly when scanning in a snake pattern.

row=i/w
col=i%w (0th, 2nd, 4th, etc. row)
col=w-i%w-1 (1st, 3nd, 5th, etc. row)

Another thing to note is that the % in C# does not convert to a positive value like it does in some other languages. A couple extra bytes are needed to account for this.
// a: input matrix
// n: number of cells to rotate
a=>n=>{
  for(
    // l: total number of cells
    // w: number of columns
    // i: loop index
    // j: offset index
    // b: copy of input matrix
    dynamic
      l=a.Length,
      w=a.GetLength(1),
      i=l,j,
      b=a.Clone();
    // iterate from i down to 0
    i-->0;
  )
    // calculate the offset `j` and use
    // the above formulas to index
    // into `a` for setting a value
    a[
      (j=(i+n%l+l)%l)/w,
      j/w%2<1?j%w:w-j%w-1
    ]=
    // use the un-offset index `i` and
    // the above formulas to read a
    // value from the input matrix
    b[
      i/w,
      i/w%2<1?i%w:w-i%w-1
    ];
}

You can save 3 bytes by merging declarations with dynamic; comment too l. Try it online!

Nice :) That declaration can be moved into the loop as well. I tend to use var for golfing which doesn't let you declare a list of variables. Probably why I missed this. Good catch!

Get rid of y entirely to save 2 bytes: Try it online!

@someone - thanks!

TIO 135 with 1d array and width input.

@someone - Interesting approach. Is that format valid? You can get it a lot shorter :)

@someone - 105

I believe that doesn't work correctly, every second row is reversed.

Ah, your right! The flat array opens up options though. Hadn't thought about that.

I think ToList() can be omitted safely (returning a IEnumerable). The declarations can also be moved for 97 bytes, a pastebin link to a TIO link, but I really can't seem to get the math to fix this right.

Japt, 28 bytes
mÏ%2©XÔªX
c éV òUÎl
W©UªßV1V

Try it
Port of Arnauld's answer. The biggest challenge was creating a reusable function. In particular, there is a helper function to reverse every other row. The approach that I am taking is to make a recursive call and depending on whether a variable is set.
Transpiled JS:
// U: first input argument (matrix)
// m: map it through a function
U = U.m(function(X, Y, Z) {
  // if the row index is even, don't alter it
  // if the row index is odd, reverse it (w)
  return Y % 2 && X.w() || X
});
V = U
  // flatten the matrix
  .c()
  // shift by the amount specified in second argument
  .é(V)
  // partition back to matrix
  .ò(
    // the number of columns should be the same as input
    U.g().l()
  );
// if W is specified, return the result from the first line
W && U ||
  // otherwise, make a recursive call with the shifted matrix
  rp(V, 1, V)

APL (Dyalog Classic), 20 bytes
↑∘t⊢∘⍴⍴⌽∘∊∘(t←⊢∘⌽\↓)

Try it online!


text:
How many right triangles can you find?
Challenge
You will be given an input represented by x, which is a string containing at least 3 characters. It will consist only of the standard numeric characters, 0 through 9. Your job is to find and output how many right triangles can be formed with the given numbers.
Rules

Numbers must be kept in the order they were given in. No mixing them up!
The numbers for each right triangle must be consecutive.
The order of numbers has to be a first, b second, and c third, and must satisfy the formula a² + b² = c². a can be greater than or less than b, as long as it satisfies the formula.
Decimal points may be added between any numbers.
Decimals require one or more numbers to be placed before them, e.g. .5 cannot be used as a number but 0.5 and 12.5 can.
Decimals with at least 4 digits after the decimal point truncated to the third digit, e.g. 1.2345 would truncated to 1.234 and 1.9999 would be truncated to 1.999.
Numbers can be used more than once in 2 or more different triangles, but cannot be used multiple times in the same triangle.
Multiple representations of the same value can count multiple times.
Repeating zeros are allowed, e.g. 000.5 counts as a number.
All possible combinations must be taken into account for your program to be valid.

Example Inputs and Outputs
Input: 345
Output: 1
This can be split into 3, 4, and 5, which, of course, form a right triangle.
Input: 534
Output: 0
While this does include the necessary numbers to form a right triangle, they are not in the correct order. It has to follow the formula a² + b² = c², but in this case it follows c² = a² + b². The order of numbers cannot be changed from the original input, so in this case no right triangles can be formed.
Input: 3415
Output: 0
This does contain a 3, 4, and a 5, which can form a right triangle, but they are not consecutive; there is a 1 splitting the 5 from the 3 and 4.
Input: 5567507
Output: 1
Because decimals can be added anywhere, it can be changed to 55.67.507, which allows splitting it into 5, 5.6, and 7.507 to form a right triangle. Remember that decimals are truncated to the third digit after the decimal point, which is how we get 7.507.
Input: 345567507
Output: 2
The first right triangle is formed by 3, 4, and 5. The second one is formed by 5567507 (read the previous example for explanation). Numbers can be used more than once, so the first 5 was used in the first and second triangles.
Input: 51125
Output: 0
Because of rule 5, you cannot use .5, 1, and 1.25. An integer is required before .5 for it to work.
Input: 051125
Output: 0
Unlike the previous example, there is a number before the first 5, so it is now legal to use 0.5, 1, and 1.25.
Input: 121418439
Output: 2
The numbers 12 and 14 would form a right triangle where side c has a length of approximately 18.43908891458577462000. Because long decimals are truncated to the third digit after the decimal point, we would be left with 18.439. This fits in with the original input, 121418439. Additionally, 1.2, 1.4, and 1.843 counts as a separate combination, thus giving us our second right triangle.
Input: 10011005
Output: 8
Numbers count separately if they're represented in different ways, so this allows for (1, 00, 1), (1.0, 0, 1), (1, 0, 01), (1, 0.01, 1), (1, 0.01, 1.0), (1, 0.01, 1.00), (1.0, 0.1, 1.005), and (1, 00.1, 1.005).

This is code golf, so shortest answer in bytes wins. Good luck!

Great challenge!  Since this is tagged as [tag:code-golf], could you add the winning criteria?

Input: 051125, Output: 0?

but "Unlike the previous example, there is a number before the first 5, so it is now legal to use 0.5, 1, and 1.25."????

@Tau from what I understood, shortest program in bytes is always the winner for code golf. But I'll edit to mention that explicitly.

@ASCII-only my mistake. Yes, that would output 1. (I'm not very good at this challenge myself...)

Should 10011005 yield 1 or 2 (i.e. 1.0, 0.1, 1.005 and 1, 00.1, 1.005)? 2. Should 101 yield 1 even though the area is 0 (i.e. 1, 0, 1) or must we special-case ignore such "triangles"?

Should 15545155452199 yield 0 or 1 (i.e. 1.5545 rounds to 1.555 so 1.555, 1.555, 2.199) or do we only round a calculated c?

@JonathanAllan 1. this would output 2 because numbers can be used multiple times, even if they have the same value. 2. Yes, this would output 1. It doesn't matter if the value is zero or not. 3. This would also output 1 because decimals are always rounded to the third decimal place.

@JonathanAllan the rounding you’ve used here is inconsistent with the example used in the question. (1.2345 to 1.234). Pikachu, what rounding rule should be used? Truncation? Rounding 0.xxx5 to even? Rounding 0.xxx5 up?

And do we round a and b and then round the square root of the sum of squares again?

121418439 has two solutions. 1.2, 1.4, 1.8439 also works.

With my (3) I was asking the same as Nick has, "And do we round a and b and then round the square root of the sum of squares again?"

Do all of the numbers have to be used? Would 3450 give one right triangle since 3,4,5.0 works, or two since you could also have 3,4,5 and discard the last digit? The example 345567507 is said to give two right triangles, but if for example it was 34556750 would this be 1 or zero? What about 34510011005? Would that be three triangles (3,4,5 and the two possible for 10011005) or four (effectively 3,4,5 and 1.0, 0.1, 1.005 plus 3,4,5 and 1, 00.1, 1.005)? I think the problem might be better without the possibility of multiple overlapping prefixes/suffixes. It needs clarification anyway.

If you keep the option for overlapping prefixes/suffixes, there are 8 possibilities for 10011005: 1, 00, 1; 1.0, 0, 1; 1, 0, 01; 1, 0.01, 1; 1, 0.01, 1.0; 1, 0.01, 1.00; 1.0, 0.1, 1.005; 1, 00.1, 1.005. If you use the Cartesian product of prefixes and suffixes there are 12 possible combinations.

I think this would be a lot simpler and easier to define without the decimals