True color code

12

1

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.

An image containing all 16,777,216 colors

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

5.1. The RGB functions: rgb() and rgba()

The rgb() function defines an RGB color by specifying the red, green, and blue channels directly. Its syntax is:

rgb() = rgb( <percentage>{3} [ / <alpha-value> ]? ) |
        rgb( <number>{3} [ / <alpha-value> ]? )
<alpha-value> = <number> | <percentage>

The first three arguments specify the red, green, and blue channels of the color, respectively. 0% represents the minimum value for that color channel in the sRGB gamut, and 100% represents the maximum value. A <number> is equivalent to a <percentage>, but with a different range: 0 again represents the minimum value for the color channel, but 255 represents the maximum. These values come from the fact that many graphics engines store the color channels internally as a single byte, which can hold integers between 0 and 255. Implementations should honor the precision of the channel as authored or calculated wherever possible. If this is not possible, the channel should be rounded to the closest value at the highest precision used, rounding up if two values are equally close.

The final argument, the <alpha-value>, specifies the alpha of the color. If given as a <number>, the useful range of the value is 0 (representing a fully transparent color) to 1 (representing a fully opaque color). If given as a , 0% represents a fully transparent color, while 100% represents a fully opaque color. If omitted, it defaults to 100%.

Values outside these ranges are not invalid, but are clamped to the ranges defined here at computed-value time.

For legacy reasons, rgb() also supports an alternate syntax that separates all of its arguments with commas:

rgb() = rgb( <percentage>#{3} , <alpha-value>? ) |
        rgb( <number>#{3} , <alpha-value>? )

Also for legacy reasons, an rgba() function also exists, with an identical grammar and behavior to rgb().

or RGB hexadecimal notation #RRGGBB format

5.2. The RGB hexadecimal notations: #RRGGBB

The CSS hex color notation allows a color to be specified by giving the channels as hexadecimal numbers, which is similar to how colors are often written directly in computer code. It’s also shorter than writing the same color out in rgb() notation.

The syntax of a <hex-color> is a <hash-token> token whose value consists of 3, 4, 6, or 8 hexadecimal digits. In other words, a hex color is written as a hash character, "#", followed by some number of digits 0-9 or letters a-f (the case of the letters doesn’t matter - #00ff00 is identical to #00FF00).

The number of hex digits given determines how to decode the hex notation into an RGB color:

6 digits

The first pair of digits, interpreted as a hexadecimal number, specifies the red channel of the color, where 00 represents the minimum value and ff (255 in decimal) represents the maximum. The next pair of digits, interpreted in the same way, specifies the green channel, and the last pair specifies the blue. The alpha channel of the color is fully opaque.

EXAMPLE 2
In other words, #00ff00 represents the same color as rgb(0 255 0) (a lime green).

See Editor's Draft of CSS Color Module Level 4

Examples

CSS rgb() function (space character can be substituted for comma character, e.g., rgb(0 255 0))

// `rgb()` `<percentage>` as strings in resulting array
['rgb(0%,0%,0%)', ...,'rgb(0%,255%,0)', ...'rgb(255,255,255)']

// `rgb()` `<number>` as strings in resulting array
['rgb(0,0,0)', ...,'rgb(0,255,0)', ...'rgb(255,255,255)']

CSS RGB hexadecimal notation RRGGBB

// RGB hexadecimal notation as strings in resulting array
['#000000', ...,'#00ff00', ...'#ffffff']

Winning criteria

Least bytes used to write the program.

guest271314

Posted 2018-09-24T06:21:24.283

Reputation: 1

Comments are not for extended discussion; this conversation has been moved to chat.

– Mego – 2018-09-29T13:53:47.520

Answers

8

R, 25 bytes

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

Try it online!

J.Doe

Posted 2018-09-24T06:21:24.283

Reputation: 2 379

Not familiar with R, but does this fail to output #000000? – nyanpasu64 – 2018-09-25T01:27:34.027

2No, it outputs #000000. See the TIO link – J.Doe – 2018-09-25T01:53:03.117

@jimbo1qaz a:b-c makes a vector from a-c to b-c, inclusive (it makes a vector from a to b, then subtracts c from each entry). – Arthur – 2018-09-25T08:04:04.243

2Ahh, so R specifies colons with tighter precedence than arithmetic... Unlike Python slices. – nyanpasu64 – 2018-09-25T08:05:21.970

7

Python 2, 77 40 39 37 bytes

print['#%06X'%c for c in range(8**8)]

Try it online!

-1 byte thanks to Digital Trauma

-2 bytes thanks to dylnan

TFeld

Posted 2018-09-24T06:21:24.283

Reputation: 19 246

How can we output the entire result of F[0:16777216] at TIO The output exceeded 128KiB? – guest271314 – 2018-09-24T07:22:01.713

@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 – 2018-09-24T07:23:39.497

@guest271314 If you really want all the output, run it locally – NieDzejkob – 2018-09-24T14:21:07.237

2Why do you need the lambda? The list comprehension itself is a valid answer, isn't it? – Adirio – 2018-09-24T14:42:30.377

2Try 8**8 instead of 1<<24 to save a byte – Digital Trauma – 2018-09-24T17:17:40.343

2how about print['... – dylnan – 2018-09-24T22:49:50.890

1@Adirio A value alone does not count as an implementation of a challenge. – Jonathan Frech – 2018-09-25T01:59:55.200

@dylnan I had print, but the challenge says to return the colors, so I wasn't sure if it was valid. – TFeld – 2018-09-25T07:04:26.910

A value alone in a Python terminal prints itself when not assigned to a variable, shouldn't that be equivalent to the current solution? You would still need to assign it to a variable in TIO and print some partials as you did, but if printing to the console is a valid answer i do not see why the value itself specifying that is in a Python console is different from an actual print. – Adirio – 2018-09-25T07:24:48.790

2@Adirio You yourself wrote [...] in a Python terminal [...] -- thus your submission would be written in Python 2 REPL, not Python 2. – Jonathan Frech – 2018-09-26T14:18:40.110

Oh, Python 2 REPL is considered separately, got it. I'm new to code golf as you can see. – Adirio – 2018-09-27T08:57:07.687

6

JavaScript (ES7), 65 62 61 bytes

Saved 3 4 bytes thanks to @tsh

Returns an array of #RRGGBB strings.

_=>[...Array(n=8**8)].map(_=>'#'+(n++).toString(16).slice(1))

Try it online! (truncated output)

Arnauld

Posted 2018-09-24T06:21:24.283

Reputation: 111 334

Current Python solution use 8**8 instead of 1<<24. It would work on JS too. – tsh – 2018-09-26T09:27:07.357

6

PowerShell, 28 26 bytes

1..16mb|%{"#{0:x6}"-f--$_}

Try it online!

Loops from 1 to 16mb (16777216). Each iteration, we use the -format operator acting on the current number pre-decremented --$_ against the string "#{0:x6}". Here, we're specifying hex values, padded to 6 digits, with a hash # in front. On TIO, limited to 60 seconds / 128KiB of output. Change the 1 to (16mb-5) to see how it ends.

AdmBorkBork

Posted 2018-09-24T06:21:24.283

Reputation: 41 581

5

Common Lisp, 42 bytes

(dotimes(i 16777216)(format t"#~6,'0x "i))

Try it online!

Renzo

Posted 2018-09-24T06:21:24.283

Reputation: 2 260

1May be the first format-golf I've seen. +1 on that basis alone. – Silvio Mayolo – 2018-09-25T02:08:58.690

4

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 "#"

Shaggy

Posted 2018-09-24T06:21:24.283

Reputation: 24 623

Interesting language. Any idea why the letter T is used for "0"? I get 16 -> G to save a byte, but T -> 0 doesn't accomplish the same. – Alec – 2018-09-24T20:15:24.700

@Alec Because if you replace T with 0, it joins with the 6 and becomes 06. – geokavel – 2018-09-25T04:54:28.650

Ah, gotcha. So is there one letter per digit for cases where you don't want it to join with the previous/next digit? – Alec – 2018-09-25T06:57:00.120

@Alec, as geokavel said, in this particular case, it saves me a byte in having to use a comma to delimit the 2 arguments being passed to ù. Another typical use case for it is to use it as a counter when you need to increment a variable while, for example, mapping over an array. And, of course, as it's a variable, you can simply assign a value to it too, if needed. 0 is the only single digit integer that has it's own variable, though - well, technically, 7 as the 6 input variable U-Z default to 0. The other integers assigned to variables in Japt are: -1, 10-16, 32, 64 & 100. – Shaggy – 2018-09-25T09:26:57.623

If you'd like to learn more about Japt, feel free to ping me in our chatroom.

– Shaggy – 2018-09-25T09:27:27.297

14 bytes but 8008 elements here – Luis felipe De jesus Munoz – 2018-09-25T12:09:11.123

4

Haskell, 41 bytes

l="ABCDEF"
mapM id$"#":(['0'..'9']++l<$l)

Try it online!

nimi

Posted 2018-09-24T06:21:24.283

Reputation: 34 639

3

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

Kevin Cruijssen

Posted 2018-09-24T06:21:24.283

Reputation: 67 575

3

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)

Neil

Posted 2018-09-24T06:21:24.283

Reputation: 95 035

3

C# (Visual C# Interactive Compiler), 47 bytes

Enumerable.Range(0,1<<24).Select(q=>$"#{q:X6}")

Try it online!

auhmaan

Posted 2018-09-24T06:21:24.283

Reputation: 906

2

MATL, 17 15 bytes

10W:q'#%06X,'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. Outputs a comma-separated list.

Explanation

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

Sanchises

Posted 2018-09-24T06:21:24.283

Reputation: 8 530

2

C# (.NET Core), 75 bytes

()=>{int i=1<<24;var a=new string[i];for(;i-->0;)a[i]=$"#{i:X6}";return a;}

Try it online!

Port of JAVA 10 version with C# interpolated string format

pocki_c

Posted 2018-09-24T06:21:24.283

Reputation: 121

2

K (oK), 19 bytes

Solution:

$(3#256)\'!16777216

Try it online! (limited to first 500 numbers)

Explanation:

Dump out rgb strings. Convert each number between 0 and 16777216 to base 256, then convert to strings...

$(3#256)\'!16777216 / the solution
          !16777216 / range 0..16777215
 (     )\'          / split each both
  3#256             / 256 256 256
$                   / string

streetster

Posted 2018-09-24T06:21:24.283

Reputation: 3 635

2

APL (Dyalog Unicode), 47 43 20 bytes

'#',(⎕D,⎕A)[↑,⍳6⍴16]

Try it online!

Given enough time/memory, this anonymous function will output all \$2^{24}-1\$ color codes. To see this, you can swap the 6⍴ for a 4⍴ in the code, and you'll see it output every code with up to 4 digits.

Thanks to @Dzaima and @ngn for the 23 bytes.

Uses ⎕IO←0.

How:

'#',(⎕D,⎕A)[↑,⍳6⍴16] ⍝ Main function
               ⍳6⍴16  ⍝ Generate every possible 6 digit hex number in a matrix format
              ,       ⍝ Ravel the matrix (from a 16x16x16x16x16x16 matrix to a 16^6x2 list)
             ↑        ⍝ Mix; (turns the list into a 16^6x2 matrix)
    (⎕D,⎕A)[       ] ⍝ Use that matrix to index the vector of the digits 0-9 concatenated with the alphabet.
'#',                  ⍝ Then prepend a '#' to each.

J. Sallé

Posted 2018-09-24T06:21:24.283

Reputation: 3 233

1

Ruby, 31 bytes

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

Try it online!

G B

Posted 2018-09-24T06:21:24.283

Reputation: 11 099

I’m kind of amazed % takes a string that long and an array that long. FYI you can save a byte by using a literal line break instead of \n. – Jordan – 2018-09-27T01:23:26.390

1

Batch, 69 + 4 = 73

g.cmd, 69

for /L %%A in (0,1,16777215)do cmd/kexit %%A&set #%%A=#!=exitcode:~2!

Saves the hexadecimal value with form #RRGGBB into an 'Array'.

g.cmd is to be called using cmd /V/Q/K g.cmd. This is where the + 4 comes from, /V/Q, counting as 4 additional characters compared to just cmd /K g.cmd. This sets up an environment that has the 'Array' in memory. It also takes forever to run, so use very low values to try or break execution using Ctrl+C


Breakdown

Invokation

  • /V enables delayed expansion, but is shorter than setlocal EnableDelayedExpansion, which is why we need the cmd call in the first place
  • /Q omits the output and is equivalent to @echo off
  • /K lets you execute an expression (In this case g.cmd) and does not exit afterwards, so you can check the 'Array' by using set #

g.cmd

for /L %%A IN (0,1,16777215) DO (
    cmd /k exit %%A
    set #%%A=#!=exitcode:~2!
)

This bit uses a trick documented here to convert a normal number to a hexadecimal, then saves that value into an 'Array'.


I've been calling that storing structure an 'Array' but that is not actually right as true Arrays do not exist in Batch. BUT you can name variables so that they have arraylike names, like so:

set elem[1]=First element
set elem[2]=Second one

or, like in this case:

set #1=First element
set #2=Second one

You can still access them via !#%position%!

user83079

Posted 2018-09-24T06:21:24.283

Reputation:

I'm not sure. But maybe /V/Q/K may be claimed as "arguments" for interpreter and count as "3 + 69 = 72". meta

– tsh – 2018-09-26T09:38:10.193

I didn't know that and will update my answer accordingly. Thx @tsh – None – 2018-09-26T20:11:17.557

1

V, 25 bytes

8É00lrx16777215ñÄ<C-a>ñ0<C-v>Gls#

Try it online! (replaced 16777215 by 31)

Explanation

8É0                                " insert 8 zeroes
   0l                              " move cursor to the second character
     rx                            " replace by x
       16777215ñ      ñ            " 16777215 times do ..
                Ä                  " .. duplicate line
                 <C-a>             " .. increment (leading 0x makes sure it uses hexadecimals)
                       0<C-v>      " move cursor to beginning of line and start selection
                             Gl    " select the column with 0x
                               s#  " replace by #

ბიმო

Posted 2018-09-24T06:21:24.283

Reputation: 15 345

0

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

Kevin Cruijssen

Posted 2018-09-24T06:21:24.283

Reputation: 67 575

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 – 2018-09-24T10:17:30.793

@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 – 2018-09-24T10:27:12.543

@KevinCruijssen I never knew you could do var r in Java.. – FireCubez – 2018-09-24T18:12:43.857

@FireCubez It's new since Java 10. :) Here a relevant tip to see what is and isn't possible with var in Java.

– Kevin Cruijssen – 2018-09-24T20:52:51.570

0

Groovy, 53 bytes

c={a=[];(1<<24).times{a.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!

archangel.mjj

Posted 2018-09-24T06:21:24.283

Reputation: 81

0

PHP, 68 62 bytes

This is supposed to be placed inside a file, the array is returned in the end, to be usable.

<?foreach(range(0,1<<24)as$i)$a[]=sprintf('#%06x',$i);return$a;

To have access to the array, simply give the result of the include (e.g.: $a = include 'xyz.php';) to a variable.


Thanks to @manatwork for saving me 6 bytes and fix a goof.

Ismael Miguel

Posted 2018-09-24T06:21:24.283

Reputation: 6 797

1Are you sure this will ever output hex digits with the %1$06d format string? And I see no reason for using 1$. You could reduce the length by including the “#” in the format string: #%06x. Which would come handy when adding extra characters to fix the range, as currently counts up to 16777216 = #1000000. – manatwork – 2018-09-24T15:27:22.987

Well, it would .... If I didn't forgot to change %d to %x. And completely forgot about moving the # inside the sprintf() call. You saved me 6 bytes. Thank you – Ismael Miguel – 2018-09-24T16:45:48.530

0

Lua, 47 45 bytes

for i=1,8^8 do s='#%06X'print(s:format(i))end

Try it online!

Marcio Medeiros

Posted 2018-09-24T06:21:24.283

Reputation: 51

1You could toss your variable s and save a byte. – Jonathan Frech – 2018-09-24T21:51:24.113

0

MATL, 11 bytes

'#'5Y26Z^Yc

Try it online! (with only three hex digits instead of six)

Explanation

'#'   % Push this character
5Y2   % Push '01234567890ABCDEF'
6     % Push 6
Z^    % Cartesian power. Gives a (16^6)×6 char matrix
Yc    % String concatenation. '#' is implicitly replicated
      % Implicitly display

Luis Mendo

Posted 2018-09-24T06:21:24.283

Reputation: 87 464

0

Bash + jot, 22

jot -w\#%06X $[8**8] 0

Try it online!

Digital Trauma

Posted 2018-09-24T06:21:24.283

Reputation: 64 644

0

Perl 5, 31 bytes

printf"#%06X
",$_ for 0..8**8-1

Try it online!

Xcali

Posted 2018-09-24T06:21:24.283

Reputation: 7 671

0

T-SQL, 122 117 bytes

Returns a 16,777,216-row table of #RRGGBB strings. The line break is for readability only:

WITH t AS(SELECT 0n UNION ALL SELECT n+1FROM t WHERE n<16777215)
SELECT'#'+FORMAT(n,'X6')FROM t option(maxrecursion 0)

Uses a recursive CTE for a number table from 0 to 2^24-1, then uses the built-in FORMAT command (available in SQL 2012 or later) to turn it into a 6-digit hex string. Attach the # to the front, and we're done.

Edit 1: Removed POWER() function, the number was shorter :P

BradC

Posted 2018-09-24T06:21:24.283

Reputation: 6 099

0

Jelly, 12 bytes

⁴ṖṃØHœċ6ṭ€”#

Try it online!

Mr. Xcoder

Posted 2018-09-24T06:21:24.283

Reputation: 39 774

0

Pascal (FPC), 67 65 bytes

Saved 2 bytes thanks to @tsh

var i:int32;begin for i:=1to 1<<24do writeln('#',hexStr(i,6))end.

Try it online!

Writes on standard output. It can be stored in an array using procedure, but it will be longer.

AlexRacer

Posted 2018-09-24T06:21:24.283

Reputation: 979

Loop from 1 to 1<<24 would save 2 bytes, as hexStr(1<<24,6) would be 000000. – tsh – 2018-09-26T09:44:02.813

@tsh Now it looks obvious, thanks! – AlexRacer – 2018-09-26T14:03:02.613

0

Jelly, 8 bytes

ØHṗ6”#;Ɱ

Try it online! (note: uses 2 rather than 6 as 6 times out on TIO)

Function submission (because Jelly full programs will, by default, print lists of strings with no delimiters between them, making it hard to see the boundaries). The TIO link contains a wrapper to print a list of strings using newlines to separate them.

Explanation

ØHṗ6”#;Ɱ
ØH         All hex digits (“0123456789ABCDEF”)
  ṗ6       Find all strings of 6 of them (order relevant, repeats allowed)
    ”#;    Prepend “#”
       Ɱ     to each of the resulting strings

ais523

Posted 2018-09-24T06:21:24.283

Reputation: 11

1Out of interest -- why did you make your answer a community wiki? – Jonathan Frech – 2018-09-25T01:53:04.367

@JonathanFrech: I do this for all my posts because a) it reduces the incentive for people to game the reputation system (as the post doesn't give reputation), b) I'm happy to have my posts edited and the community-wiki marker is a way to indicate that. Stack Exchange's reputation system is more or less completely broken: on a past account, I once intentionally rep-capped every day for a week to show how easy the system was to game. Nowadays I pretty much want no part in it, especially as higher reputation simply just makes the site try to persuade you to moderate it. – ais523 – 2018-09-25T02:19:32.733

Just curious -- on which stack did you achieve to game the reputation system? – Jonathan Frech – 2018-09-25T02:49:15.383

@JonathanFrech: This one. I was a 20k user, but eventually deleted my account because it was kind-of messing up my life, and because the reputation system was actively pushing me into making content that made the site worse, as opposed to better. – ais523 – 2018-09-25T02:52:57.073

0

PHP, 43 bytes

<?php for(;$i<1<<24;printf("#%06X ",$i++));

Try it online!

Logern

Posted 2018-09-24T06:21:24.283

Reputation: 845

1<<24 --> 8**8 should work here to, credits to @DigitalTrauma – Adirio – 2018-09-25T07:33:23.017

0

Perl 6, 26 bytes

{map *.fmt("#%06X"),^8**8}

Try it online!

Uses the same format as everyone else. Times out on TIO.

Or, in rgb format:

31 bytes

{map {"rgb($_)"},[X] ^256 xx 3}

Try it online!

Jo King

Posted 2018-09-24T06:21:24.283

Reputation: 38 234

I think the rgb output should be rgb(0, 0, 0) including the string rgb. – nwellnhof – 2018-09-25T13:07:19.313

@nwellnhof Updated (though it ended up shorter to do hexadecimal) – Jo King – 2018-09-26T01:26:44.650

0

Scala, 40 bytes

(1 to 1<<24).map(x=>println(f"#$x%06x"))

Try it online!

trolley813

Posted 2018-09-24T06:21:24.283

Reputation: 225

0

><>, 99 bytes

I added an extra space here to fix the layout, because of the က character, which is 4096 or sqrt(2^24) which is used in the main loop invariant.

!/ i&"ÿĀ"::*3ep4ep5ep\1+:&:5eg%n$o:4eg,:1%-5eg%n$o3eg,:1%-5eg%noo:*&:&(?;!
 >"က"a"),,(bgr"oooo&\

The idea is pretty simple: use the register as a counter n and output rgb(n%255, (n/255)%255, (n/255^2)%255).

Pretty sure some bytes can be golfed off, but it's a start.

Try it online!

PidgeyUsedGust

Posted 2018-09-24T06:21:24.283

Reputation: 631

0

Tcl, 53 bytes

time {puts #[format %06X [expr [incr i]-1]]} 16777216

Try it online!

Times out on TIO, but runs fine on my machine!

sergiol

Posted 2018-09-24T06:21:24.283

Reputation: 3 055