True color code

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
2
down vote

favorite












True color (24-bit) at Wikipedia is described in pertinent part as




24 bits almost always uses 8 bits of each of R, G, B. As of 2018
24-bit color depth is used by virtually every computer and phone
display and the vast majority of image storage formats. Almost all
cases where there are 32 bits per pixel mean that 24 are used for the
color, and the remaining 8 are the alpha channel or unused.



224 gives 16,777,216 color variations. The human eye can discriminate up to ten million colors[10] and since the gamut of a display is smaller than the range of human vision, this means this should cover that range with more detail than can be perceived. ...



...



Macintosh systems refer to 24-bit color as "millions of colors". The term "True color" is sometime used to mean what this article is calling "Direct color".[13] It is also often used to refer to all color depths greater or equal to 24.



enter image description here



All 16,777,216 colors




Task



Write a program which generates and returns all 16,777,216 color variations within an array as strings in the CSS rgb() function or RGB hexadecimal notation #RRGGBB format.



Winning criteria



Least bytes used to write the program.










share|improve this question























  • Aren't both rgb and #RRGGBB limited to the 8-bits format in their default 1 byte per pixel output? 24-bit colors are saved with 3 bytes per pixel (one for each R, G, and B). Does this mean we'll have to output the same rgb code three times each, or how do we make the differences between the three? Do you perhaps have a text-file dump of all the 16,777,216 colors we should output?
    – Kevin Cruijssen
    5 hours ago











  • @KevinCruijssen If Wikipedia is inaccurate, which is entirely possible, it must be possible to prove that by way of code. Do not have a text file dump of all the colors that should be output. File:16777216colors.png is 4096 x 4096 pixels, 4096*4096 // 16777216; if the description of the image is correct, it should technically be possible to request that image, then parse the image data of each pixel to check if there are duplicates.
    – guest271314
    4 hours ago










  • @KevinCruijssen As you said, 24-bit colors are made of 1 byte per RGB component, which is exactly what #RRGGBB describes. (Not to be confused with the shorthand form #RGB which only encodes 4096 distinct colors.) Or am I misunderstanding what you mean?
    – Arnauld
    4 hours ago










  • @Arnauld Ah wait. 16,777,216 is just 256³, so we basically output all #RRGGBB hexadecimals. Was indeed overthinking it..
    – Kevin Cruijssen
    4 hours ago














up vote
2
down vote

favorite












True color (24-bit) at Wikipedia is described in pertinent part as




24 bits almost always uses 8 bits of each of R, G, B. As of 2018
24-bit color depth is used by virtually every computer and phone
display and the vast majority of image storage formats. Almost all
cases where there are 32 bits per pixel mean that 24 are used for the
color, and the remaining 8 are the alpha channel or unused.



224 gives 16,777,216 color variations. The human eye can discriminate up to ten million colors[10] and since the gamut of a display is smaller than the range of human vision, this means this should cover that range with more detail than can be perceived. ...



...



Macintosh systems refer to 24-bit color as "millions of colors". The term "True color" is sometime used to mean what this article is calling "Direct color".[13] It is also often used to refer to all color depths greater or equal to 24.



enter image description here



All 16,777,216 colors




Task



Write a program which generates and returns all 16,777,216 color variations within an array as strings in the CSS rgb() function or RGB hexadecimal notation #RRGGBB format.



Winning criteria



Least bytes used to write the program.










share|improve this question























  • Aren't both rgb and #RRGGBB limited to the 8-bits format in their default 1 byte per pixel output? 24-bit colors are saved with 3 bytes per pixel (one for each R, G, and B). Does this mean we'll have to output the same rgb code three times each, or how do we make the differences between the three? Do you perhaps have a text-file dump of all the 16,777,216 colors we should output?
    – Kevin Cruijssen
    5 hours ago











  • @KevinCruijssen If Wikipedia is inaccurate, which is entirely possible, it must be possible to prove that by way of code. Do not have a text file dump of all the colors that should be output. File:16777216colors.png is 4096 x 4096 pixels, 4096*4096 // 16777216; if the description of the image is correct, it should technically be possible to request that image, then parse the image data of each pixel to check if there are duplicates.
    – guest271314
    4 hours ago










  • @KevinCruijssen As you said, 24-bit colors are made of 1 byte per RGB component, which is exactly what #RRGGBB describes. (Not to be confused with the shorthand form #RGB which only encodes 4096 distinct colors.) Or am I misunderstanding what you mean?
    – Arnauld
    4 hours ago










  • @Arnauld Ah wait. 16,777,216 is just 256³, so we basically output all #RRGGBB hexadecimals. Was indeed overthinking it..
    – Kevin Cruijssen
    4 hours ago












up vote
2
down vote

favorite









up vote
2
down vote

favorite











True color (24-bit) at Wikipedia is described in pertinent part as




24 bits almost always uses 8 bits of each of R, G, B. As of 2018
24-bit color depth is used by virtually every computer and phone
display and the vast majority of image storage formats. Almost all
cases where there are 32 bits per pixel mean that 24 are used for the
color, and the remaining 8 are the alpha channel or unused.



224 gives 16,777,216 color variations. The human eye can discriminate up to ten million colors[10] and since the gamut of a display is smaller than the range of human vision, this means this should cover that range with more detail than can be perceived. ...



...



Macintosh systems refer to 24-bit color as "millions of colors". The term "True color" is sometime used to mean what this article is calling "Direct color".[13] It is also often used to refer to all color depths greater or equal to 24.



enter image description here



All 16,777,216 colors




Task



Write a program which generates and returns all 16,777,216 color variations within an array as strings in the CSS rgb() function or RGB hexadecimal notation #RRGGBB format.



Winning criteria



Least bytes used to write the program.










share|improve this question















True color (24-bit) at Wikipedia is described in pertinent part as




24 bits almost always uses 8 bits of each of R, G, B. As of 2018
24-bit color depth is used by virtually every computer and phone
display and the vast majority of image storage formats. Almost all
cases where there are 32 bits per pixel mean that 24 are used for the
color, and the remaining 8 are the alpha channel or unused.



224 gives 16,777,216 color variations. The human eye can discriminate up to ten million colors[10] and since the gamut of a display is smaller than the range of human vision, this means this should cover that range with more detail than can be perceived. ...



...



Macintosh systems refer to 24-bit color as "millions of colors". The term "True color" is sometime used to mean what this article is calling "Direct color".[13] It is also often used to refer to all color depths greater or equal to 24.



enter image description here



All 16,777,216 colors




Task



Write a program which generates and returns all 16,777,216 color variations within an array as strings in the CSS rgb() function or RGB hexadecimal notation #RRGGBB format.



Winning criteria



Least bytes used to write the program.







code-golf string kolmogorov-complexity color






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 3 hours ago









Sanchises

5,66512251




5,66512251










asked 5 hours ago









guest271314

1317




1317











  • Aren't both rgb and #RRGGBB limited to the 8-bits format in their default 1 byte per pixel output? 24-bit colors are saved with 3 bytes per pixel (one for each R, G, and B). Does this mean we'll have to output the same rgb code three times each, or how do we make the differences between the three? Do you perhaps have a text-file dump of all the 16,777,216 colors we should output?
    – Kevin Cruijssen
    5 hours ago











  • @KevinCruijssen If Wikipedia is inaccurate, which is entirely possible, it must be possible to prove that by way of code. Do not have a text file dump of all the colors that should be output. File:16777216colors.png is 4096 x 4096 pixels, 4096*4096 // 16777216; if the description of the image is correct, it should technically be possible to request that image, then parse the image data of each pixel to check if there are duplicates.
    – guest271314
    4 hours ago










  • @KevinCruijssen As you said, 24-bit colors are made of 1 byte per RGB component, which is exactly what #RRGGBB describes. (Not to be confused with the shorthand form #RGB which only encodes 4096 distinct colors.) Or am I misunderstanding what you mean?
    – Arnauld
    4 hours ago










  • @Arnauld Ah wait. 16,777,216 is just 256³, so we basically output all #RRGGBB hexadecimals. Was indeed overthinking it..
    – Kevin Cruijssen
    4 hours ago
















  • Aren't both rgb and #RRGGBB limited to the 8-bits format in their default 1 byte per pixel output? 24-bit colors are saved with 3 bytes per pixel (one for each R, G, and B). Does this mean we'll have to output the same rgb code three times each, or how do we make the differences between the three? Do you perhaps have a text-file dump of all the 16,777,216 colors we should output?
    – Kevin Cruijssen
    5 hours ago











  • @KevinCruijssen If Wikipedia is inaccurate, which is entirely possible, it must be possible to prove that by way of code. Do not have a text file dump of all the colors that should be output. File:16777216colors.png is 4096 x 4096 pixels, 4096*4096 // 16777216; if the description of the image is correct, it should technically be possible to request that image, then parse the image data of each pixel to check if there are duplicates.
    – guest271314
    4 hours ago










  • @KevinCruijssen As you said, 24-bit colors are made of 1 byte per RGB component, which is exactly what #RRGGBB describes. (Not to be confused with the shorthand form #RGB which only encodes 4096 distinct colors.) Or am I misunderstanding what you mean?
    – Arnauld
    4 hours ago










  • @Arnauld Ah wait. 16,777,216 is just 256³, so we basically output all #RRGGBB hexadecimals. Was indeed overthinking it..
    – Kevin Cruijssen
    4 hours ago















Aren't both rgb and #RRGGBB limited to the 8-bits format in their default 1 byte per pixel output? 24-bit colors are saved with 3 bytes per pixel (one for each R, G, and B). Does this mean we'll have to output the same rgb code three times each, or how do we make the differences between the three? Do you perhaps have a text-file dump of all the 16,777,216 colors we should output?
– Kevin Cruijssen
5 hours ago





Aren't both rgb and #RRGGBB limited to the 8-bits format in their default 1 byte per pixel output? 24-bit colors are saved with 3 bytes per pixel (one for each R, G, and B). Does this mean we'll have to output the same rgb code three times each, or how do we make the differences between the three? Do you perhaps have a text-file dump of all the 16,777,216 colors we should output?
– Kevin Cruijssen
5 hours ago













@KevinCruijssen If Wikipedia is inaccurate, which is entirely possible, it must be possible to prove that by way of code. Do not have a text file dump of all the colors that should be output. File:16777216colors.png is 4096 x 4096 pixels, 4096*4096 // 16777216; if the description of the image is correct, it should technically be possible to request that image, then parse the image data of each pixel to check if there are duplicates.
– guest271314
4 hours ago




@KevinCruijssen If Wikipedia is inaccurate, which is entirely possible, it must be possible to prove that by way of code. Do not have a text file dump of all the colors that should be output. File:16777216colors.png is 4096 x 4096 pixels, 4096*4096 // 16777216; if the description of the image is correct, it should technically be possible to request that image, then parse the image data of each pixel to check if there are duplicates.
– guest271314
4 hours ago












@KevinCruijssen As you said, 24-bit colors are made of 1 byte per RGB component, which is exactly what #RRGGBB describes. (Not to be confused with the shorthand form #RGB which only encodes 4096 distinct colors.) Or am I misunderstanding what you mean?
– Arnauld
4 hours ago




@KevinCruijssen As you said, 24-bit colors are made of 1 byte per RGB component, which is exactly what #RRGGBB describes. (Not to be confused with the shorthand form #RGB which only encodes 4096 distinct colors.) Or am I misunderstanding what you mean?
– Arnauld
4 hours ago












@Arnauld Ah wait. 16,777,216 is just 256³, so we basically output all #RRGGBB hexadecimals. Was indeed overthinking it..
– Kevin Cruijssen
4 hours ago




@Arnauld Ah wait. 16,777,216 is just 256³, so we basically output all #RRGGBB hexadecimals. Was indeed overthinking it..
– Kevin Cruijssen
4 hours ago










10 Answers
10






active

oldest

votes

















up vote
4
down vote














Python 2, 77 40 bytes





lambda:['#%06X'%c for c in range(1<<24)]


Try it online!






share|improve this answer






















  • How can we output the entire result of F[0:16777216] at TIO The output exceeded 128KiB?
    – guest271314
    4 hours ago










  • @guest271314 TIO's output size is limited. That's why TFeld added the F[:10] to see the first 10 items of the list, and F[-10:] to see the last ten items of the list. And he also proved it contained all 16,777,216 items by outputting the length of the result-list.
    – Kevin Cruijssen
    4 hours ago

















up vote
3
down vote













JavaScript (ES8), 65 bytes



Returns an array of #RRGGBB strings.





_=>[...Array(1<<24)].map((_,n)=>'#'+n.toString(16).padStart(6,0))


Try it online!
(limited to the first 4096 ones, so that it can actually run)






share|improve this answer



























    up vote
    3
    down vote














    05AB1E, 15 14 10 bytes



    15Ýh6ãJ'#ì


    Try it online.



    Explanation:



    15Ý # Create a list in the range [0, 15]
    h # Convert each to a hexadecimal value
    6ã # Create each possible sextuple combination of the list
    J # Join them together to a single string
    '#ì # And prepend a "#" before each of them





    share|improve this answer





























      up vote
      2
      down vote














      R, 25 bytes





      sprintf("#%06X",1:2^24-1)


      Try it online!






      share|improve this answer





























        up vote
        1
        down vote













        Batch, 87 bytes



        @set s= in (0,1,255)do @
        @for /l %%r%s%for /l %%g%s%for /l %%b%s%echo rgb(%%r,%%g,%%b)


        Outputs in CSS format. The variable substitution happens before the for statement is parsed so the the actual code is as follows:



        @for /l %%r in (0,1,255)do @for /l %%g in (0,1,255)do @for /l %%b in (0,1,255)do @echo rgb(%%r,%%g,%%b)





        share|improve this answer



























          up vote
          0
          down vote














          MATL, 17 16 bytes



          24W:q'#%06Xn'YD


          Try it online!



          The TIO version displays the first 2^10 only as not to time out. I included the final iteration in the footer to show that it indeed terminates at #FFFFFF. Saved one byte by changing to fprintf instead of manually assembling the string.



          Explanation



          24W:q % Range from 0 to 2^24-1
          '#%06Xn' % fprintf format spec (# followed by hexadecimal, zero-padded, fixed-width, followed by newline)
          YD % Call fprintf. Internally loops over range.





          share|improve this answer





























            up vote
            0
            down vote














            Ruby, 31 bytes





            $><<("#%06xn"*d=2**24)%[*0..d]


            Try it online!






            share|improve this answer



























              up vote
              0
              down vote













              Japt, 14 bytes



              Outputs as #rrggbb.



              G²³ÇsG ùT6 i'#


              Try it (Limited to the first 4096 elements)




              Explanation



              G :16
              ² :Squared
              ³ :Cubed
              Ç :Map the range [0,result)
              sG : Convert to base-16 string
              ù : Left pad
              T : With 0
              6 : To length 6
              i'# : Prepend "#"





              share|improve this answer





























                up vote
                0
                down vote














                Groovy, 53 bytes



                c=a=;(1<<24).timesa.add "".format("#%06x",it);a


                Function definition. c() returns an ArrayList (I assume that's fine, even through the question asks for an array).



                Ungolfed, with implicit types:



                ArrayList<String> c = 
                ArrayList<String> a =
                (1 << 24).times
                a.add("".format("#%06x", it)) // add the hex-formatted number to the list.

                return a



                Try it online!






                share|improve this answer



























                  up vote
                  0
                  down vote













                  Java 10, 87 84 bytes





                  v->int i=1<<24;var r=new String[i];for(;i-->0;)r[i]="".format("#%06X",i);return r;


                  -3 bytes thanks to @archangel.mjj.



                  Try it online (limited to the first 4,096 items).



                  Explanation:



                  v-> // Method with empty unused parameter & String-array return-type
                  int i=1<<24; // Integer `i`, starting at 16,777,216
                  var r=new String[i]; // Result String-array of that size
                  for(;i-->0;) // Loop `i` in the range (16777216, 0]
                  r[i]= // Set the `i`'th item in the array to:
                  "".format("#%06X",i);// `i` converted to a hexadecimal value (of size 6)
                  return r; // Return the result-array





                  share|improve this answer






















                  • Ah, you posted this while I was writing my post, so we have very similar answers. You can improve by three bytes with r[i]="".format("#%06X",i);
                    – archangel.mjj
                    1 hour ago










                  • @archangel.mjj Ah, I'm an idiot. Thanks! I actually had "".format("#%06X",i) before since I saw it in the Python answer, but I dropped the answer because I couldn't get it to work fast enough for TIO. Then I saw everyone just outputting the first 4,096 items on TIO, so I wrote the answer again, forgetting about "#%06X"... >.<
                    – Kevin Cruijssen
                    1 hour ago










                  Your Answer




                  StackExchange.ifUsing("editor", function ()
                  return StackExchange.using("mathjaxEditing", function ()
                  StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix)
                  StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["\$", "\$"]]);
                  );
                  );
                  , "mathjax-editing");

                  StackExchange.ifUsing("editor", function ()
                  StackExchange.using("externalEditor", function ()
                  StackExchange.using("snippets", function ()
                  StackExchange.snippets.init();
                  );
                  );
                  , "code-snippets");

                  StackExchange.ready(function()
                  var channelOptions =
                  tags: "".split(" "),
                  id: "200"
                  ;
                  initTagRenderer("".split(" "), "".split(" "), channelOptions);

                  StackExchange.using("externalEditor", function()
                  // Have to fire editor after snippets, if snippets enabled
                  if (StackExchange.settings.snippets.snippetsEnabled)
                  StackExchange.using("snippets", function()
                  createEditor();
                  );

                  else
                  createEditor();

                  );

                  function createEditor()
                  StackExchange.prepareEditor(
                  heartbeatType: 'answer',
                  convertImagesToLinks: false,
                  noModals: false,
                  showLowRepImageUploadWarning: true,
                  reputationToPostImages: null,
                  bindNavPrevention: true,
                  postfix: "",
                  onDemand: true,
                  discardSelector: ".discard-answer"
                  ,immediatelyShowMarkdownHelp:true
                  );



                  );













                   

                  draft saved


                  draft discarded


















                  StackExchange.ready(
                  function ()
                  StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f172716%2ftrue-color-code%23new-answer', 'question_page');

                  );

                  Post as a guest






























                  10 Answers
                  10






                  active

                  oldest

                  votes








                  10 Answers
                  10






                  active

                  oldest

                  votes









                  active

                  oldest

                  votes






                  active

                  oldest

                  votes








                  up vote
                  4
                  down vote














                  Python 2, 77 40 bytes





                  lambda:['#%06X'%c for c in range(1<<24)]


                  Try it online!






                  share|improve this answer






















                  • How can we output the entire result of F[0:16777216] at TIO The output exceeded 128KiB?
                    – guest271314
                    4 hours ago










                  • @guest271314 TIO's output size is limited. That's why TFeld added the F[:10] to see the first 10 items of the list, and F[-10:] to see the last ten items of the list. And he also proved it contained all 16,777,216 items by outputting the length of the result-list.
                    – Kevin Cruijssen
                    4 hours ago














                  up vote
                  4
                  down vote














                  Python 2, 77 40 bytes





                  lambda:['#%06X'%c for c in range(1<<24)]


                  Try it online!






                  share|improve this answer






















                  • How can we output the entire result of F[0:16777216] at TIO The output exceeded 128KiB?
                    – guest271314
                    4 hours ago










                  • @guest271314 TIO's output size is limited. That's why TFeld added the F[:10] to see the first 10 items of the list, and F[-10:] to see the last ten items of the list. And he also proved it contained all 16,777,216 items by outputting the length of the result-list.
                    – Kevin Cruijssen
                    4 hours ago












                  up vote
                  4
                  down vote










                  up vote
                  4
                  down vote










                  Python 2, 77 40 bytes





                  lambda:['#%06X'%c for c in range(1<<24)]


                  Try it online!






                  share|improve this answer















                  Python 2, 77 40 bytes





                  lambda:['#%06X'%c for c in range(1<<24)]


                  Try it online!







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited 4 hours ago

























                  answered 4 hours ago









                  TFeld

                  11.8k2833




                  11.8k2833











                  • How can we output the entire result of F[0:16777216] at TIO The output exceeded 128KiB?
                    – guest271314
                    4 hours ago










                  • @guest271314 TIO's output size is limited. That's why TFeld added the F[:10] to see the first 10 items of the list, and F[-10:] to see the last ten items of the list. And he also proved it contained all 16,777,216 items by outputting the length of the result-list.
                    – Kevin Cruijssen
                    4 hours ago
















                  • How can we output the entire result of F[0:16777216] at TIO The output exceeded 128KiB?
                    – guest271314
                    4 hours ago










                  • @guest271314 TIO's output size is limited. That's why TFeld added the F[:10] to see the first 10 items of the list, and F[-10:] to see the last ten items of the list. And he also proved it contained all 16,777,216 items by outputting the length of the result-list.
                    – Kevin Cruijssen
                    4 hours ago















                  How can we output the entire result of F[0:16777216] at TIO The output exceeded 128KiB?
                  – guest271314
                  4 hours ago




                  How can we output the entire result of F[0:16777216] at TIO The output exceeded 128KiB?
                  – guest271314
                  4 hours ago












                  @guest271314 TIO's output size is limited. That's why TFeld added the F[:10] to see the first 10 items of the list, and F[-10:] to see the last ten items of the list. And he also proved it contained all 16,777,216 items by outputting the length of the result-list.
                  – Kevin Cruijssen
                  4 hours ago




                  @guest271314 TIO's output size is limited. That's why TFeld added the F[:10] to see the first 10 items of the list, and F[-10:] to see the last ten items of the list. And he also proved it contained all 16,777,216 items by outputting the length of the result-list.
                  – Kevin Cruijssen
                  4 hours ago










                  up vote
                  3
                  down vote













                  JavaScript (ES8), 65 bytes



                  Returns an array of #RRGGBB strings.





                  _=>[...Array(1<<24)].map((_,n)=>'#'+n.toString(16).padStart(6,0))


                  Try it online!
                  (limited to the first 4096 ones, so that it can actually run)






                  share|improve this answer
























                    up vote
                    3
                    down vote













                    JavaScript (ES8), 65 bytes



                    Returns an array of #RRGGBB strings.





                    _=>[...Array(1<<24)].map((_,n)=>'#'+n.toString(16).padStart(6,0))


                    Try it online!
                    (limited to the first 4096 ones, so that it can actually run)






                    share|improve this answer






















                      up vote
                      3
                      down vote










                      up vote
                      3
                      down vote









                      JavaScript (ES8), 65 bytes



                      Returns an array of #RRGGBB strings.





                      _=>[...Array(1<<24)].map((_,n)=>'#'+n.toString(16).padStart(6,0))


                      Try it online!
                      (limited to the first 4096 ones, so that it can actually run)






                      share|improve this answer












                      JavaScript (ES8), 65 bytes



                      Returns an array of #RRGGBB strings.





                      _=>[...Array(1<<24)].map((_,n)=>'#'+n.toString(16).padStart(6,0))


                      Try it online!
                      (limited to the first 4096 ones, so that it can actually run)







                      share|improve this answer












                      share|improve this answer



                      share|improve this answer










                      answered 4 hours ago









                      Arnauld

                      64.8k581274




                      64.8k581274




















                          up vote
                          3
                          down vote














                          05AB1E, 15 14 10 bytes



                          15Ýh6ãJ'#ì


                          Try it online.



                          Explanation:



                          15Ý # Create a list in the range [0, 15]
                          h # Convert each to a hexadecimal value
                          6ã # Create each possible sextuple combination of the list
                          J # Join them together to a single string
                          '#ì # And prepend a "#" before each of them





                          share|improve this answer


























                            up vote
                            3
                            down vote














                            05AB1E, 15 14 10 bytes



                            15Ýh6ãJ'#ì


                            Try it online.



                            Explanation:



                            15Ý # Create a list in the range [0, 15]
                            h # Convert each to a hexadecimal value
                            6ã # Create each possible sextuple combination of the list
                            J # Join them together to a single string
                            '#ì # And prepend a "#" before each of them





                            share|improve this answer
























                              up vote
                              3
                              down vote










                              up vote
                              3
                              down vote










                              05AB1E, 15 14 10 bytes



                              15Ýh6ãJ'#ì


                              Try it online.



                              Explanation:



                              15Ý # Create a list in the range [0, 15]
                              h # Convert each to a hexadecimal value
                              6ã # Create each possible sextuple combination of the list
                              J # Join them together to a single string
                              '#ì # And prepend a "#" before each of them





                              share|improve this answer















                              05AB1E, 15 14 10 bytes



                              15Ýh6ãJ'#ì


                              Try it online.



                              Explanation:



                              15Ý # Create a list in the range [0, 15]
                              h # Convert each to a hexadecimal value
                              6ã # Create each possible sextuple combination of the list
                              J # Join them together to a single string
                              '#ì # And prepend a "#" before each of them






                              share|improve this answer














                              share|improve this answer



                              share|improve this answer








                              edited 3 hours ago

























                              answered 4 hours ago









                              Kevin Cruijssen

                              30.4k553167




                              30.4k553167




















                                  up vote
                                  2
                                  down vote














                                  R, 25 bytes





                                  sprintf("#%06X",1:2^24-1)


                                  Try it online!






                                  share|improve this answer


























                                    up vote
                                    2
                                    down vote














                                    R, 25 bytes





                                    sprintf("#%06X",1:2^24-1)


                                    Try it online!






                                    share|improve this answer
























                                      up vote
                                      2
                                      down vote










                                      up vote
                                      2
                                      down vote










                                      R, 25 bytes





                                      sprintf("#%06X",1:2^24-1)


                                      Try it online!






                                      share|improve this answer















                                      R, 25 bytes





                                      sprintf("#%06X",1:2^24-1)


                                      Try it online!







                                      share|improve this answer














                                      share|improve this answer



                                      share|improve this answer








                                      edited 2 hours ago

























                                      answered 3 hours ago









                                      J.Doe

                                      8619




                                      8619




















                                          up vote
                                          1
                                          down vote













                                          Batch, 87 bytes



                                          @set s= in (0,1,255)do @
                                          @for /l %%r%s%for /l %%g%s%for /l %%b%s%echo rgb(%%r,%%g,%%b)


                                          Outputs in CSS format. The variable substitution happens before the for statement is parsed so the the actual code is as follows:



                                          @for /l %%r in (0,1,255)do @for /l %%g in (0,1,255)do @for /l %%b in (0,1,255)do @echo rgb(%%r,%%g,%%b)





                                          share|improve this answer
























                                            up vote
                                            1
                                            down vote













                                            Batch, 87 bytes



                                            @set s= in (0,1,255)do @
                                            @for /l %%r%s%for /l %%g%s%for /l %%b%s%echo rgb(%%r,%%g,%%b)


                                            Outputs in CSS format. The variable substitution happens before the for statement is parsed so the the actual code is as follows:



                                            @for /l %%r in (0,1,255)do @for /l %%g in (0,1,255)do @for /l %%b in (0,1,255)do @echo rgb(%%r,%%g,%%b)





                                            share|improve this answer






















                                              up vote
                                              1
                                              down vote










                                              up vote
                                              1
                                              down vote









                                              Batch, 87 bytes



                                              @set s= in (0,1,255)do @
                                              @for /l %%r%s%for /l %%g%s%for /l %%b%s%echo rgb(%%r,%%g,%%b)


                                              Outputs in CSS format. The variable substitution happens before the for statement is parsed so the the actual code is as follows:



                                              @for /l %%r in (0,1,255)do @for /l %%g in (0,1,255)do @for /l %%b in (0,1,255)do @echo rgb(%%r,%%g,%%b)





                                              share|improve this answer












                                              Batch, 87 bytes



                                              @set s= in (0,1,255)do @
                                              @for /l %%r%s%for /l %%g%s%for /l %%b%s%echo rgb(%%r,%%g,%%b)


                                              Outputs in CSS format. The variable substitution happens before the for statement is parsed so the the actual code is as follows:



                                              @for /l %%r in (0,1,255)do @for /l %%g in (0,1,255)do @for /l %%b in (0,1,255)do @echo rgb(%%r,%%g,%%b)






                                              share|improve this answer












                                              share|improve this answer



                                              share|improve this answer










                                              answered 2 hours ago









                                              Neil

                                              75.6k744170




                                              75.6k744170




















                                                  up vote
                                                  0
                                                  down vote














                                                  MATL, 17 16 bytes



                                                  24W:q'#%06Xn'YD


                                                  Try it online!



                                                  The TIO version displays the first 2^10 only as not to time out. I included the final iteration in the footer to show that it indeed terminates at #FFFFFF. Saved one byte by changing to fprintf instead of manually assembling the string.



                                                  Explanation



                                                  24W:q % Range from 0 to 2^24-1
                                                  '#%06Xn' % fprintf format spec (# followed by hexadecimal, zero-padded, fixed-width, followed by newline)
                                                  YD % Call fprintf. Internally loops over range.





                                                  share|improve this answer


























                                                    up vote
                                                    0
                                                    down vote














                                                    MATL, 17 16 bytes



                                                    24W:q'#%06Xn'YD


                                                    Try it online!



                                                    The TIO version displays the first 2^10 only as not to time out. I included the final iteration in the footer to show that it indeed terminates at #FFFFFF. Saved one byte by changing to fprintf instead of manually assembling the string.



                                                    Explanation



                                                    24W:q % Range from 0 to 2^24-1
                                                    '#%06Xn' % fprintf format spec (# followed by hexadecimal, zero-padded, fixed-width, followed by newline)
                                                    YD % Call fprintf. Internally loops over range.





                                                    share|improve this answer
























                                                      up vote
                                                      0
                                                      down vote










                                                      up vote
                                                      0
                                                      down vote










                                                      MATL, 17 16 bytes



                                                      24W:q'#%06Xn'YD


                                                      Try it online!



                                                      The TIO version displays the first 2^10 only as not to time out. I included the final iteration in the footer to show that it indeed terminates at #FFFFFF. Saved one byte by changing to fprintf instead of manually assembling the string.



                                                      Explanation



                                                      24W:q % Range from 0 to 2^24-1
                                                      '#%06Xn' % fprintf format spec (# followed by hexadecimal, zero-padded, fixed-width, followed by newline)
                                                      YD % Call fprintf. Internally loops over range.





                                                      share|improve this answer















                                                      MATL, 17 16 bytes



                                                      24W:q'#%06Xn'YD


                                                      Try it online!



                                                      The TIO version displays the first 2^10 only as not to time out. I included the final iteration in the footer to show that it indeed terminates at #FFFFFF. Saved one byte by changing to fprintf instead of manually assembling the string.



                                                      Explanation



                                                      24W:q % Range from 0 to 2^24-1
                                                      '#%06Xn' % fprintf format spec (# followed by hexadecimal, zero-padded, fixed-width, followed by newline)
                                                      YD % Call fprintf. Internally loops over range.






                                                      share|improve this answer














                                                      share|improve this answer



                                                      share|improve this answer








                                                      edited 2 hours ago

























                                                      answered 3 hours ago









                                                      Sanchises

                                                      5,66512251




                                                      5,66512251




















                                                          up vote
                                                          0
                                                          down vote














                                                          Ruby, 31 bytes





                                                          $><<("#%06xn"*d=2**24)%[*0..d]


                                                          Try it online!






                                                          share|improve this answer
























                                                            up vote
                                                            0
                                                            down vote














                                                            Ruby, 31 bytes





                                                            $><<("#%06xn"*d=2**24)%[*0..d]


                                                            Try it online!






                                                            share|improve this answer






















                                                              up vote
                                                              0
                                                              down vote










                                                              up vote
                                                              0
                                                              down vote










                                                              Ruby, 31 bytes





                                                              $><<("#%06xn"*d=2**24)%[*0..d]


                                                              Try it online!






                                                              share|improve this answer













                                                              Ruby, 31 bytes





                                                              $><<("#%06xn"*d=2**24)%[*0..d]


                                                              Try it online!







                                                              share|improve this answer












                                                              share|improve this answer



                                                              share|improve this answer










                                                              answered 1 hour ago









                                                              G B

                                                              6,5571324




                                                              6,5571324




















                                                                  up vote
                                                                  0
                                                                  down vote













                                                                  Japt, 14 bytes



                                                                  Outputs as #rrggbb.



                                                                  G²³ÇsG ùT6 i'#


                                                                  Try it (Limited to the first 4096 elements)




                                                                  Explanation



                                                                  G :16
                                                                  ² :Squared
                                                                  ³ :Cubed
                                                                  Ç :Map the range [0,result)
                                                                  sG : Convert to base-16 string
                                                                  ù : Left pad
                                                                  T : With 0
                                                                  6 : To length 6
                                                                  i'# : Prepend "#"





                                                                  share|improve this answer


























                                                                    up vote
                                                                    0
                                                                    down vote













                                                                    Japt, 14 bytes



                                                                    Outputs as #rrggbb.



                                                                    G²³ÇsG ùT6 i'#


                                                                    Try it (Limited to the first 4096 elements)




                                                                    Explanation



                                                                    G :16
                                                                    ² :Squared
                                                                    ³ :Cubed
                                                                    Ç :Map the range [0,result)
                                                                    sG : Convert to base-16 string
                                                                    ù : Left pad
                                                                    T : With 0
                                                                    6 : To length 6
                                                                    i'# : Prepend "#"





                                                                    share|improve this answer
























                                                                      up vote
                                                                      0
                                                                      down vote










                                                                      up vote
                                                                      0
                                                                      down vote









                                                                      Japt, 14 bytes



                                                                      Outputs as #rrggbb.



                                                                      G²³ÇsG ùT6 i'#


                                                                      Try it (Limited to the first 4096 elements)




                                                                      Explanation



                                                                      G :16
                                                                      ² :Squared
                                                                      ³ :Cubed
                                                                      Ç :Map the range [0,result)
                                                                      sG : Convert to base-16 string
                                                                      ù : Left pad
                                                                      T : With 0
                                                                      6 : To length 6
                                                                      i'# : Prepend "#"





                                                                      share|improve this answer














                                                                      Japt, 14 bytes



                                                                      Outputs as #rrggbb.



                                                                      G²³ÇsG ùT6 i'#


                                                                      Try it (Limited to the first 4096 elements)




                                                                      Explanation



                                                                      G :16
                                                                      ² :Squared
                                                                      ³ :Cubed
                                                                      Ç :Map the range [0,result)
                                                                      sG : Convert to base-16 string
                                                                      ù : Left pad
                                                                      T : With 0
                                                                      6 : To length 6
                                                                      i'# : Prepend "#"






                                                                      share|improve this answer














                                                                      share|improve this answer



                                                                      share|improve this answer








                                                                      edited 1 hour ago

























                                                                      answered 2 hours ago









                                                                      Shaggy

                                                                      16.8k21661




                                                                      16.8k21661




















                                                                          up vote
                                                                          0
                                                                          down vote














                                                                          Groovy, 53 bytes



                                                                          c=a=;(1<<24).timesa.add "".format("#%06x",it);a


                                                                          Function definition. c() returns an ArrayList (I assume that's fine, even through the question asks for an array).



                                                                          Ungolfed, with implicit types:



                                                                          ArrayList<String> c = 
                                                                          ArrayList<String> a =
                                                                          (1 << 24).times
                                                                          a.add("".format("#%06x", it)) // add the hex-formatted number to the list.

                                                                          return a



                                                                          Try it online!






                                                                          share|improve this answer
























                                                                            up vote
                                                                            0
                                                                            down vote














                                                                            Groovy, 53 bytes



                                                                            c=a=;(1<<24).timesa.add "".format("#%06x",it);a


                                                                            Function definition. c() returns an ArrayList (I assume that's fine, even through the question asks for an array).



                                                                            Ungolfed, with implicit types:



                                                                            ArrayList<String> c = 
                                                                            ArrayList<String> a =
                                                                            (1 << 24).times
                                                                            a.add("".format("#%06x", it)) // add the hex-formatted number to the list.

                                                                            return a



                                                                            Try it online!






                                                                            share|improve this answer






















                                                                              up vote
                                                                              0
                                                                              down vote










                                                                              up vote
                                                                              0
                                                                              down vote










                                                                              Groovy, 53 bytes



                                                                              c=a=;(1<<24).timesa.add "".format("#%06x",it);a


                                                                              Function definition. c() returns an ArrayList (I assume that's fine, even through the question asks for an array).



                                                                              Ungolfed, with implicit types:



                                                                              ArrayList<String> c = 
                                                                              ArrayList<String> a =
                                                                              (1 << 24).times
                                                                              a.add("".format("#%06x", it)) // add the hex-formatted number to the list.

                                                                              return a



                                                                              Try it online!






                                                                              share|improve this answer













                                                                              Groovy, 53 bytes



                                                                              c=a=;(1<<24).timesa.add "".format("#%06x",it);a


                                                                              Function definition. c() returns an ArrayList (I assume that's fine, even through the question asks for an array).



                                                                              Ungolfed, with implicit types:



                                                                              ArrayList<String> c = 
                                                                              ArrayList<String> a =
                                                                              (1 << 24).times
                                                                              a.add("".format("#%06x", it)) // add the hex-formatted number to the list.

                                                                              return a



                                                                              Try it online!







                                                                              share|improve this answer












                                                                              share|improve this answer



                                                                              share|improve this answer










                                                                              answered 1 hour ago









                                                                              archangel.mjj

                                                                              813




                                                                              813




















                                                                                  up vote
                                                                                  0
                                                                                  down vote













                                                                                  Java 10, 87 84 bytes





                                                                                  v->int i=1<<24;var r=new String[i];for(;i-->0;)r[i]="".format("#%06X",i);return r;


                                                                                  -3 bytes thanks to @archangel.mjj.



                                                                                  Try it online (limited to the first 4,096 items).



                                                                                  Explanation:



                                                                                  v-> // Method with empty unused parameter & String-array return-type
                                                                                  int i=1<<24; // Integer `i`, starting at 16,777,216
                                                                                  var r=new String[i]; // Result String-array of that size
                                                                                  for(;i-->0;) // Loop `i` in the range (16777216, 0]
                                                                                  r[i]= // Set the `i`'th item in the array to:
                                                                                  "".format("#%06X",i);// `i` converted to a hexadecimal value (of size 6)
                                                                                  return r; // Return the result-array





                                                                                  share|improve this answer






















                                                                                  • Ah, you posted this while I was writing my post, so we have very similar answers. You can improve by three bytes with r[i]="".format("#%06X",i);
                                                                                    – archangel.mjj
                                                                                    1 hour ago










                                                                                  • @archangel.mjj Ah, I'm an idiot. Thanks! I actually had "".format("#%06X",i) before since I saw it in the Python answer, but I dropped the answer because I couldn't get it to work fast enough for TIO. Then I saw everyone just outputting the first 4,096 items on TIO, so I wrote the answer again, forgetting about "#%06X"... >.<
                                                                                    – Kevin Cruijssen
                                                                                    1 hour ago














                                                                                  up vote
                                                                                  0
                                                                                  down vote













                                                                                  Java 10, 87 84 bytes





                                                                                  v->int i=1<<24;var r=new String[i];for(;i-->0;)r[i]="".format("#%06X",i);return r;


                                                                                  -3 bytes thanks to @archangel.mjj.



                                                                                  Try it online (limited to the first 4,096 items).



                                                                                  Explanation:



                                                                                  v-> // Method with empty unused parameter & String-array return-type
                                                                                  int i=1<<24; // Integer `i`, starting at 16,777,216
                                                                                  var r=new String[i]; // Result String-array of that size
                                                                                  for(;i-->0;) // Loop `i` in the range (16777216, 0]
                                                                                  r[i]= // Set the `i`'th item in the array to:
                                                                                  "".format("#%06X",i);// `i` converted to a hexadecimal value (of size 6)
                                                                                  return r; // Return the result-array





                                                                                  share|improve this answer






















                                                                                  • Ah, you posted this while I was writing my post, so we have very similar answers. You can improve by three bytes with r[i]="".format("#%06X",i);
                                                                                    – archangel.mjj
                                                                                    1 hour ago










                                                                                  • @archangel.mjj Ah, I'm an idiot. Thanks! I actually had "".format("#%06X",i) before since I saw it in the Python answer, but I dropped the answer because I couldn't get it to work fast enough for TIO. Then I saw everyone just outputting the first 4,096 items on TIO, so I wrote the answer again, forgetting about "#%06X"... >.<
                                                                                    – Kevin Cruijssen
                                                                                    1 hour ago












                                                                                  up vote
                                                                                  0
                                                                                  down vote










                                                                                  up vote
                                                                                  0
                                                                                  down vote









                                                                                  Java 10, 87 84 bytes





                                                                                  v->int i=1<<24;var r=new String[i];for(;i-->0;)r[i]="".format("#%06X",i);return r;


                                                                                  -3 bytes thanks to @archangel.mjj.



                                                                                  Try it online (limited to the first 4,096 items).



                                                                                  Explanation:



                                                                                  v-> // Method with empty unused parameter & String-array return-type
                                                                                  int i=1<<24; // Integer `i`, starting at 16,777,216
                                                                                  var r=new String[i]; // Result String-array of that size
                                                                                  for(;i-->0;) // Loop `i` in the range (16777216, 0]
                                                                                  r[i]= // Set the `i`'th item in the array to:
                                                                                  "".format("#%06X",i);// `i` converted to a hexadecimal value (of size 6)
                                                                                  return r; // Return the result-array





                                                                                  share|improve this answer














                                                                                  Java 10, 87 84 bytes





                                                                                  v->int i=1<<24;var r=new String[i];for(;i-->0;)r[i]="".format("#%06X",i);return r;


                                                                                  -3 bytes thanks to @archangel.mjj.



                                                                                  Try it online (limited to the first 4,096 items).



                                                                                  Explanation:



                                                                                  v-> // Method with empty unused parameter & String-array return-type
                                                                                  int i=1<<24; // Integer `i`, starting at 16,777,216
                                                                                  var r=new String[i]; // Result String-array of that size
                                                                                  for(;i-->0;) // Loop `i` in the range (16777216, 0]
                                                                                  r[i]= // Set the `i`'th item in the array to:
                                                                                  "".format("#%06X",i);// `i` converted to a hexadecimal value (of size 6)
                                                                                  return r; // Return the result-array






                                                                                  share|improve this answer














                                                                                  share|improve this answer



                                                                                  share|improve this answer








                                                                                  edited 1 hour ago

























                                                                                  answered 1 hour ago









                                                                                  Kevin Cruijssen

                                                                                  30.4k553167




                                                                                  30.4k553167











                                                                                  • Ah, you posted this while I was writing my post, so we have very similar answers. You can improve by three bytes with r[i]="".format("#%06X",i);
                                                                                    – archangel.mjj
                                                                                    1 hour ago










                                                                                  • @archangel.mjj Ah, I'm an idiot. Thanks! I actually had "".format("#%06X",i) before since I saw it in the Python answer, but I dropped the answer because I couldn't get it to work fast enough for TIO. Then I saw everyone just outputting the first 4,096 items on TIO, so I wrote the answer again, forgetting about "#%06X"... >.<
                                                                                    – Kevin Cruijssen
                                                                                    1 hour ago
















                                                                                  • Ah, you posted this while I was writing my post, so we have very similar answers. You can improve by three bytes with r[i]="".format("#%06X",i);
                                                                                    – archangel.mjj
                                                                                    1 hour ago










                                                                                  • @archangel.mjj Ah, I'm an idiot. Thanks! I actually had "".format("#%06X",i) before since I saw it in the Python answer, but I dropped the answer because I couldn't get it to work fast enough for TIO. Then I saw everyone just outputting the first 4,096 items on TIO, so I wrote the answer again, forgetting about "#%06X"... >.<
                                                                                    – Kevin Cruijssen
                                                                                    1 hour ago















                                                                                  Ah, you posted this while I was writing my post, so we have very similar answers. You can improve by three bytes with r[i]="".format("#%06X",i);
                                                                                  – archangel.mjj
                                                                                  1 hour ago




                                                                                  Ah, you posted this while I was writing my post, so we have very similar answers. You can improve by three bytes with r[i]="".format("#%06X",i);
                                                                                  – archangel.mjj
                                                                                  1 hour ago












                                                                                  @archangel.mjj Ah, I'm an idiot. Thanks! I actually had "".format("#%06X",i) before since I saw it in the Python answer, but I dropped the answer because I couldn't get it to work fast enough for TIO. Then I saw everyone just outputting the first 4,096 items on TIO, so I wrote the answer again, forgetting about "#%06X"... >.<
                                                                                  – Kevin Cruijssen
                                                                                  1 hour ago




                                                                                  @archangel.mjj Ah, I'm an idiot. Thanks! I actually had "".format("#%06X",i) before since I saw it in the Python answer, but I dropped the answer because I couldn't get it to work fast enough for TIO. Then I saw everyone just outputting the first 4,096 items on TIO, so I wrote the answer again, forgetting about "#%06X"... >.<
                                                                                  – Kevin Cruijssen
                                                                                  1 hour ago

















                                                                                   

                                                                                  draft saved


                                                                                  draft discarded















































                                                                                   


                                                                                  draft saved


                                                                                  draft discarded














                                                                                  StackExchange.ready(
                                                                                  function ()
                                                                                  StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f172716%2ftrue-color-code%23new-answer', 'question_page');

                                                                                  );

                                                                                  Post as a guest













































































                                                                                  Comments

                                                                                  Popular posts from this blog

                                                                                  What does second last employer means? [closed]

                                                                                  List of Gilmore Girls characters

                                                                                  Confectionery