[Question]
  [
**The Challenge**
Given the two uppercase hexadecimal strings (both 6 characters long, XXXXXX and YYYYYY) representing RGB values (ranging from `000000` to `FFFFFF` inclusive), and a positive non-zero integer N, display a linear transition of the N+2 colors generated from XXXXXX to YYYYYY that would result in a color gradient.
## **Example**
Input
```
FF3762
F08800
9
```
Output
*Please note in our example, I've requested 9 interim steps between the two colors, therefore 11 lines will be displayed from initial color to the final color*
```
FF3762
FD3F58
FC474E
FA4F44
F9573A
F75F31
F66727
F46F1D
F37713
F17F09
F08800
```
## **Caveats**
While I've gone with a simple linear process of deriving the integer values for the interim colors before converting them back into hexadecimal, your methods may vary. Please consider [the various ways one could round up/down your numbers](https://codegolf.meta.stackexchange.com/questions/5582/things-to-consider-when-creating-a-challenge/5608#5608) accordingly.
## **Testing**
To make this interesting, I've provided a snippet to allow testing of your code, inclusive of a button to provide you with two random colors to test your code against. Displaying your results is optional, but it's encouraged!
```
c1=()=>('00000'+(Math.random()*(1<<24)|0).toString(16)).slice(-6);
$("#col").click(function(){
  alert("Your two colors are: "+c1()+" and "+c1()+".");
});
        
$("#colors").blur(function(){
  $("#test").empty();
	var colArr = $("#colors").val().split("\n");
	for(c in colArr){
  	$("#test").append('<div class="tester" style="background-color:#'+colArr[c]+';">'+colArr[c]+'</div>')
  }
  
});
```
```
.tester{height: 20px;
width: 60px;padding: 4px;border: 1px solid black;}
```
```
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<button id="col">Your two colors</button><br />
<textarea id="colors"></textarea>
<div id="test">
</div>
```
1) You can access two random colors for your test by clicking on the "Your two colors" button.
2) The number of interim steps will be the same as the number of characters in your PPCG username inclusive of spaces, in the case of "WallyWest" it would be 9 (as per my example above).
3) Run your code with the two colors and the number and once you have your generated list, you have the option of pasting your output into the textarea and tabbing away from it to get your generated color gradient.
My example is shown here:
[![Gradients](https://i.stack.imgur.com/36dL9.png)](https://i.stack.imgur.com/36dL9.png)
I must admit, that looks pretty awesome!
Please note: As I mentioned, showing your testing of your output using the snippet is optional, but it's encouraged! :)
## **Output**
The list output must be in the form of N+2 sets of 6 digit hex numbers separated by line feeds (\n) as shown in my example above. Output can be in the form of separate lines, space/comma separated list, an array or whatever is best suited for your language... *(Thanks @nimi for the heads up)* Please remember, that if you plan on testing your code with the snippet, however you separate each "color" is up to you.
## **Rules**
This is code-golf, so the shortest solution in bytes will be crowned the winner. [No loopholes](https://codegolf.meta.stackexchange.com/questions/1061/standard-loopholes-which-are-no-longer-funny), naturally. Input must accept the two strings and a number (which as I said will be equivalent to the number of letters in your username on PPCG, thus your resulting output will always be a minimum of three lines long.
  
[Answer]
## JavaScript (ES6), 130 bytes
```
g=
(f,t,n)=>[...Array(++n+1)].map((_,i)=>f.replace(/../g,(e,j)=>((`0x${e}`*(n-i)+`0x${t[j]+t[j+1]}`*i)/n|256).toString(16).slice(1)))
;
p=_=>g(f.value,t.value,+n.value).map(e=>o.insertRow().insertCell().appendChild(document.createTextNode(e)).parentNode.bgColor=e);
```
```
<input id=f value=e14f09><input id=t value=9a04f6><input id=n value=4 type=number><input type=button onclick=p() value=Go!><table id=o bgcolor=black cellpadding=4>
```
[Answer]
# [Dyalog APL](http://goo.gl/9KrKoM), 44 [bytes](https://codegolf.meta.stackexchange.com/a/9429/43319)
Prompts for **N**, then **B**eginning-color, then **E**nding-color. Needs `⎕IO←0` which is default on many systems.
```
h[↑⌊B∘+¨(⍳2+N)×(-/E B←(h←⎕D,⎕A)∘⍳¨⍞⍞)÷1+N←⎕]
```
`h[`...`]` index into **h** (which has a value when we finish evaluating the the bracket's content)
 `N←⎕` prompt for numeric **N** (4)
 `1+` add one to **N** (5)
 `(`...`)÷` use that to divide the result of...
  `⍞⍞` prompt for two character strings ["7E0E7E","FF3762"]
  `(`...`)∘⍳¨` find the indices of the each string's characters in...
   `⎕D,⎕A` **D**igits followed by **A**lphabet
   `h←` assigned to **h**
  now we have "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
  `E B←` assign the indices to **E** and **B** [[7,14,0,14,7,14],[15,15,3,7,6,2]]
  `-/` subtract and enclose **B** from **E** [[-8,-1,-3,7,1,12]]
  the result so far is [[-1.6,-0.2,-0.6,1.4,0.2,2.4]]
 `(`...`)×` multiply this by...
  `2+N` two plus **N** (6)
  `⍳` first integers [0,1,2,3,4,5]
 this gives us [[0,0,0,0,0,0],[-1.6,-0.2,-0.6,1.4,0.2,2.4],[-3.2,-0.4,-1.2,2.8,0.4,4.8],...]
 `B∘+¨` add **B** to each [[15,15,3,7,6,2],[13.4,14.8,2.4,8.4,6.2,4.4],[11.8,14.6,1.8,9.8,6.4,6.8],...]
 `⌊` round down [[15,15,3,7,6,2],[13,14,2,8,6,4],[11,14,1,9,6,6],...]
 `↑` make list of lists into table
```
[[15,15, 3, 7, 6, 2]
 [13,14, 2, 8, 6, 4]
 [11,14, 1, 9, 6, 6]
 [10,14, 1,11, 6, 9]
 [ 8,14, 0,12, 6,11]
 [ 7,14, 0,14, 7,14]]
```
here we index into **h**, giving
```
[["F","F","3","7","6","2]
 ["D","E","2","8","6","4]
 ["B","E","1","9","6","6]
 ["A","E","1","B","6","9]
 ["8","E","0","C","6","B]
 ["7","E","0","E","7","E]]
```
which is the same as
```
[["FF3762"]
 ["DE2864"]
 ["BE1966"]
 ["AE1B69"]
 ["8E0C6B"]
 ["7E0E7E"]]
```
and prints as
```
FF3762
DE2864
BE1966
AE1B69
8E0C6B
7E0E7E
```
[![gradient](https://i.stack.imgur.com/eLx7L.png)](https://i.stack.imgur.com/eLx7L.png)
[TryAPL online!](http://tryapl.org/?a=%u2395IO%u21900%20%u22C4%20%u2359%u2359%20%u2206%u2190%28%27FF3762%27%20%277E0E7E%27%29%204%20%u22C4%20h%5B%u2191%u230AB%u2218+%A8%28%u23732+N%29%D7%28-/E%20B%u2190%28h%u2190%u2395D%2C%u2395A%29%u2218%u2373%A8%u2359%u2359%29%F71+N%u2190%u2206%5D&run)
[Answer]
# Pyth - 35 bytes
Horribly golfed, just gave up.
```
j++hQsMCm.HMsM:F+dc-FdvzCmiR16cd2Qe
```
[Try it online here](http://pyth.herokuapp.com/?code=j%2B%2BhQsMCm.HMsM%3AF%2Bdc-FdvzCmiR16cd2Qe&input=%227cb472%22%2C+%2293fb8a%22%0A8&debug=0).
Example:
[![example](https://i.stack.imgur.com/n9flD.png)](https://i.stack.imgur.com/n9flD.png)
[Answer]
## PowerShell v2+, ~~176~~ ~~159~~ 150 bytes
```
param($a,$b,$n)$x=$a-split'(..)'-ne'';$a;++$n..1|%{$j=$_;-join($x=$x|%{"{0:x2}"-f(+"0x$_"-[int]((+"0x$_"-"0x$(($b-split'(..)'-ne'')[$i++%3])")/$j))})}
```
Takes the input as two strings and a number, then converts the start string into an array of strings split on every two characters, stores that into `$x`. We then output `$a` as our starting section, and loop from `++$n` to `1` (to ensure proper fenceposting).
Each iteration, sets helper `$j` to the current number (used later for ensuring we've got the right number of steps between where we're currently at to our destination) and calculates the next step based on a loop through `$x`.
Each inner loop is just an assignment. We're setting `$x` at the appropriate place equal to a new string `"{0:x2}"` using the `-f`ormat operator. The `x2` here specifies a two-digit hexadecimal output, and the input is the right-hand side of the `-f` operator. PowerShell has a native hexadecimal-to-decimal operator `0x`, so this lengthy parens-nested expression is using that operator to convert the current hex to numbers, subtracting to find the difference yet to go (done by dynamically splitting `$b` here just like we did to `$a`, and using modulo to select the right element), dividing by `$j` steps remaining, casting to an `[int]` (PowerShell does banker's rounding by default), and subtracting that step-count from the current hex to get what our next hex needs to be.
The result of that calculation is stored back into `$x` as three hex elements. That's encapsulated in parens to create a copy on the pipeline, and `-join`ed together into a single string. All those resultant strings are left on the pipeline, and output via implicit `Write-Output` happens at program execution.
---
### Example
I was given **0ba7c5** and **6c0e50** for my two colors, and **TimmyD** has 6 characters in it.
```
PS C:\Tools\Scripts\golfing> .\rgb-gradients-generation.ps1 '0ba7c5' '6c0e50' 6
0ba7c5
1991b4
277ba3
356592
434f82
513971
5f2361
6c0e50
```
[![Gradient Example](https://i.stack.imgur.com/EUojb.png)](https://i.stack.imgur.com/EUojb.png)
[Answer]
# [MATL](http://github.com/lmendo/MATL), 31 bytes
```
2+1yhjjh2e!1ZA3e!b:1&Ynk8W5Y2Za
```
This uses linear interpolation with rounding down. Input format is
```
9
FF3762
F08800
```
[**Try it online!**](http://matl.tryitonline.net/#code=MisxeWhqamgyZSExWkEzZSFiOjEmWW5rOFc1WTJaYQ&input=OQpGRjM3NjIKRjA4ODAw)
### Graphical output, 31 bytes
```
2+1yhjjh2e!1ZA3e!b:t2YG1&Ynk2ZG
```
This is the result for inputs
```
5
FF3762
F08800
```
[![enter image description here](https://i.stack.imgur.com/gBF4n.png)](https://i.stack.imgur.com/gBF4n.png)
Try it in [**MATL Online**](https://matl.io/?code=2%2B1yhjjh2e%211ZA3e%21b%3At2YG1%26Ynk2ZG&inputs=5%0AFF3762%0AF08800&version=19.1.0)! The interpreter is currently experimental. If you don't get any output refresh the page and press "Run" again.
[Answer]
# Python 2, 189 bytes
```
w='[int(%s[i:i+2],16)for i in range(0,6,2)]'
def f(a,b,n):
 l=lambda x,y:'%02x'%int((x*(n-i)+y*i)/n);c,d,e=eval(w%'a');f,g,h=eval(w%'b');n+=1
 for i in range(n+1):print l(c,f)+l(d,g)+l(e,h)
```
[![gradient screenshot](https://i.stack.imgur.com/7JBWS.png)](https://i.stack.imgur.com/7JBWS.png)
[Answer]
# [Groovy] Final Update (199 Bytes) - As per request
## Non-golf
```
def g(a,b,n){
  (0..(1.0/n)).collect{
    c->
    x={s->s.split("(?<=\\G.{2})").collect{Integer.parseInt(it,16)}};
    (0..2).collect {
      (int)(x(a).get(it)*n*c+x(b).get(it)*(1-n*c))
    }.collect {
      String.format("%X", it)
    }.join()
  }
}
g('FFFFFF','000000',1/10​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​)​​​​​​​​​​​​​​
```
## Golf
```
g(a,b,n){(0..(1.0/n)).collect{c->x={s->s.split("(?<=\\G.{2})").collect{Integer.parseInt(it,16)}};(0..2).collect {(int)(x(a).get(it)*n*c+x(b).get(it)*(1-n*c))}.collect{String.format("%X",it)}.join()}}
```
Try the final here:
<https://groovyconsole.appspot.com/script/5130696796405760>
---
# OLD VERSIONS BELOW, DECLINED BY OP
---
# Groovy (123 Bytes)
## Golf
```
def g(r,g,b,r2,g2,b2,s){(1..(1.0/s)).collect{c->[(int)(r*s*c+r2*(1-s*c)),(int)(g*s*c+g2*(1-s*c)),(int)(b*s*c+b2*(1-s*c))]}}
```
## Non-golf
```
def g(r,g,b,r2,g2,b2,s){
  (1..(1.0/s)).collect {
    c ->
    [(int)(r*s*c+r2*(1-s*c)),(int)(g*s*c+g2*(1-s*c)),(int)(b*s*c+b2*(1-s*c))]
  }
}
```
## Inputs
```
r,g,b -> Starting RGB Color
r2,g2,b2 -> Ending RGB Color
s -> Gradient step
```
## Output Example
```
(00,00,00,255,255,255,.5)
```
results in
```
[
  [255, 255, 255]
  [127, 127, 127]
  [0, 0, 0]
]
```
Try it yourself:
<https://groovyconsole.appspot.com/script/5184465357766656>
# With Hex Conversions Included
Guess I'm kind of cheating as well... Here's the script with using hex:
## New code with hex conversions:
```
​    def g(r,g,b,r2,g2,b2,s){
      (0..(1.0/s)).collect {
        c ->
        String.format("%X", ((int)(r*s*c+r2*(1-s*c)))) +  String.format("%X", ((int)(g*s*c+g2*(1-s*c)))) + "" +  String.format("%X", ((int)(b*s*c+b2*(1-s*c))))
      }
    }
    g(126,34,166,218,26,33,0.0625)​
```
## 188 characters when golfed:
```
def g(r,g,b,r2,g2,b2,s){(0..(1.0/s)).collect {c->String.format("%X",((int)(r*s*c+r2*(1-s*c))))+String.format("%X",((int)(g*s*c+g2*(1-s*c))))+String.format("%X",((int)(b*s*c+b2*(1-s*c))))}}
```
## Output for 000000 to FFFFFF and 16 (Username Length)
```
g(00,00,00,255,255,255,0.0625).each{println it}​
```
[![Monochromatic Gradient with 1/16 Steps](https://i.stack.imgur.com/wAwlq.png)](https://i.stack.imgur.com/wAwlq.png)
[Answer]
## R, 68 bytes
There is a built-in function that interpolates two colours:
```
a=scan(,'')
colorRampPalette(paste0("#",a[1:2]))(as.numeric(a[3])+2)
```
Input:
```
d9e7a5
3ef951
15
```
Output: a vector with values
```
"#D9E7A5" "#CFE89F" "#C5E99A" "#BBEA95" "#B2EB90" "#A8EC8A" "#9EED85" "#95EE80"
"#8BF07B" "#81F175" "#78F270" "#6EF36B" "#64F466" "#5BF560" "#51F65B" "#47F756"
"#3EF951"
```
Colour specification in R requires a hash symbol.
[![Colour ramp](https://i.stack.imgur.com/pIuMi.png)](https://i.stack.imgur.com/pIuMi.png)
Let’s plot something, like a function:
```
filled.contour(outer(1:20, 1:20, function(x,y) sin(sqrt(x*y)/3)),
    col = colorRampPalette(paste0("#",a[1:2]))(as.numeric(a[3])+2))
```
[![sin(sqrt(x*y)/3)](https://i.stack.imgur.com/CDXX5.png)](https://i.stack.imgur.com/CDXX5.png)
[Answer]
# C, 175 169 168 bytes
```
i;j;x[6];f(a,b,n)char*a,*b;{char*f="%2x%2x%02x";for(n++;i<=n;i++,puts(""))for(j=sscanf(a,f,x,x+1,x+2)-sscanf(b,f,x+3,x+4,x+5);j++<printf(f+6,x[j]+(x[j+3]-x[j])*i/n););}
```
Ungolfed:
```
int i, j;
int x[3], y[3];
f(char *a, char *b, int n) {
  sscanf(a, "%2x%2x%2x", &x[0], &x[1], &x[2]);
  sscanf(b, "%2x%2x%2x", &y[0], &y[1], &y[2]);
  for(i = 0, n++; i <= n; i++) {
    for(j = 0; j < 3; j++)
      printf("%02x", x[j] + (y[j] - x[j]) * i / n);
    puts("");
  }
}
```
Thanks to @h-walters for shaving off 5 bytes!
[Answer]
# sh + ImageMagick, 81 bytes
```
convert -size 1x$((2+$3)) gradient:#$1-#$2 -depth 8 txt:-|grep -o "[A-F0-9]\{6\}"
```
usage:
```
> ./grad.sh FF3762 F08800 9
FF3762
FE3F58
FC474E
FB4F45
F9573B
F86031
F66827
F5701D
F37814
F2800A
F08800
```
("-depth 8" is not necessary if your IM is compiled with 8bpp as the default)
]