text:
Count the reviews!
Introduction and Credit
Imagine you're Amazon. Imagine you have a large number of products for which a lot of people have written reviews scoring 1-5 stars. Now you need to give your customers a summary for each product based on the simple product-scoring association. Because you're Amazon, time is money and as such you need to fit this into the smallest code possible because that's the code you can write the fastest.
Credit: This task appeared in 2014 in a programming mid-term exam in the functional programming course at my university and since then an example solution has been provided. I have the lecturer's and author's (same person) permission to post this question publicly.

Input
Your input will be a list of pairs of natural numbers, where the second value of each pair is always either 1, 2, 3, 4 or 5. Take the input using your preferred, generally accepted way.
Output
Your output will be a list of pairs of a number and a list of 5 numbers. Give the output using your preferred, generally accepted way.
What to do?
Given the (unsorted) list of product-id and scoring pairs, count for each product how often each score appears and return the amounts in the second list of the output pair at the appropriate position.
So for product #5 with 10x 1-star, 15x 2-star, 25x 3-star, 50x 4-star and 150x 5-star would result in the entry [5 [10 15 25 50 150]].
Potential Corner Cases
The input list may be empty in which case your output should be as well.
You don't need to consider the case where the input violates the above constraints.
You can safely assume all numbers to be representable by a signed 32-bit integer.
If you have no review(s) for a product (ie it doesn't appear in the output) it must not appear in the output either, i.e. 5x zeroes doesn't happen and can always be dropped.
Who wins?
This is code-golf so the shortest answer in bytes wins. Built-ins are allowed and standard rules apply.

Examples
Example input:
[(1,4),(2,5),(1,5),(1,1),(1,5),(1,4)]

Example corresponding output:
[
(1,[1, 0, 0, 2, 2]),
(2,[0, 0, 0, 0, 1])
]

Other test vectors:
[] -> []
[(1,1),(2,2),(3,3),(4,4),(5,5)] ->
[(1, [1,0,0,0,0]),(2, [0,1,0,0,0]),(3, [0,0,1,0,0]),(4, [0,0,0,1,0]),(5, [0,0,0,0,1])]

Can / must we output a list of 5 zeros for product 2 if only products 1 are given in the input? Or can we assume that will never happen?

@LuisMendo if you have no reviews for a product "it doesn't exist". Or in another way: If you have no review then there's no way for you to tell product 2 or 3 or 4 is a thing and thus you can obviously leave it out. Also see the edit.

Would a JS object such as {"1":[1,0,0,2,2],"2":[0,0,0,0,1]} be a valid output?

@Arnauld well, you pair the item number with a list so it's OK.

MATL, 8 bytes
5B#uilZ?

Input format is a column array of products followed by a column array of scores:
[1; 2; 1; 1; 1; 1]
[4; 5; 5; 1; 5; 4]

Output format is a vertical array of products followed by a matrix of score occurrences:
1
2
1 0 0 2 2
0 0 0 0 1

Try it online!
Explanation
5B#u   % Implicitly input array of products. Push unique values and integer labels
       % of the input entries. So input [1; 3; 1; 1; 1] would give outputs [1; 3]
       % and [1; 2; 1; 1; 1]. The latter is lik the input but without "holes", i.e.
       % uses consecutive integers. This is required to avoid rows of zeros in the
       % result for non-existing intermediate products
i      % Input array of scores
l      % Push 1
Z?     % Build sparse matrix with those row indices, column indices, and value 1.
       % Implicitly display

R, 64 bytes
function(m)`if`(length(m)>1,by(m[,2],m[,1],tabulate,n=5),list())

This solution works if the I/O is somewhat flexible. It's an unnamed function that works by taking an R-matrix as input and tabulates the frequency of each type of review. The only problem is dealing with the empty list. We need to introduce a control whether this is actually the case and because an empty matrix matrix() is not actually empty, we return an empty list() instead.
Try it on R-fiddle
Example output for the last test case:
m[, 1]: 1
[1] 1 0 0 0 0
---------------------------------------------------------------------------------------------
m[, 1]: 2
[1] 0 1 0 0 0
---------------------------------------------------------------------------------------------
m[, 1]: 3
[1] 0 0 1 0 0
---------------------------------------------------------------------------------------------
m[, 1]: 4
[1] 0 0 0 1 0
---------------------------------------------------------------------------------------------
m[, 1]: 5
[1] 0 0 0 0 1

Nice, didn't know you could use 'if' that way.

@JarkoDubbeldam I was surprised too when I found out. It also appears to be completely undocumented. But it basically works as a non-vectorized ifelse()

I knew that you could use it on binary operators: 1+1 -> '+'(1,1), but this is more useful.

Python 2 - 88 72 71 69 67 bytes
def s(l,d={}):
 for p,s in l:d.setdefault(p,[0]*5)[s-1]+=1
 print d

Input to the function:
[(1,4),(2,5),(1,5),(1,1),(1,5),(1,4)]

Output:
{1: [1, 0, 0, 2, 2], 2: [0, 0, 0, 0, 1]}

Edits:

Thanks to nedla2004 for saving 16 bytes!
Changed to Python 2 to save 1 byte :D
Saved 3 bytes by taking newline byte count as 1 byte.
Thanks flp-tkc for saving 2 bytes. (There was an unnecessary extra space too :D)

Golfing suggestions are welcome :)

You could put the forth line on the same line as the for loop.

@nedla2004 Thanks.I did not know that we do that with for loops.

Not sure, but you might be able to print d instead of returning it.

Yea, print(d) also works. I'll leave it as it is, because of no byte count change.

Does this work in Python 2? I don't see why not.

Now that you are using Python 2, making this a full program would be shorter.

Could you save bytes using def s(l,d={})?

Mathematica, 68 bytes
{#[[1,1]],Last/@Tally@Join[Range@5,#2&@@@#]-1}&/@GatherBy[#,#&@@#&]&

Unnamed function taking as input a list of ordered pairs of integers such as {{1, 4}, {2, 5}, {1, 5}, {1, 1}, {1, 5}, {1, 4}}. To start, GatherBy[#,#&@@#&] groups together all the pairs with the same first element (which can be any identifier, actually, not just an integer).
Each of those groups is then operated on by the function {#[[1,1]],Last/@Tally@Join[Range@5,#2&@@@#]-1}, which produces a two-element list as output, the first element of which is just the common identifier. Join[Range@5,#2&@@@#] generates a list of integers starting with 1,2,3,4,5 and ending with all of the scores corresponding to the given identifier. Last/@Tally then computes how many time each score was found, returning the appropriate 5-tuple; then -1 makes up for the fact that we introduced each score one extra time, leaving zeros for any missing score (which otherwise would be skipped completely).

Jelly, 18 17 bytes
Fm2QṢµ5,@þċ@€€³ż@

TryItOnline!
How?
Fm2QṢµ5,@þċ@€€³ż@ - Main link: List of (id, score) pairs
F                 - flatten
 m2               - mod 2 of list (gets the IDs)
   Q              - unique items by first appearance (one of each ID)
    Ṣ             - sorted (IDs in order)
     µ            - monadic chain separation (call the above z)
         þ        - table the result of
       ,@         -    pair z (with reversed @rguments) with
      5           -    5 (implicit range, so [1,2,3,4,5]) ...we now have:
                  -        [[id,1],[id,2],[id,3],[id,4],[id,5]] for every id, in order.
          ċ@€€    - count occurrences of (with reversed @rguments) for €ach for €ach in
              ³   - the first input (the list of (id, score) pairs)
               ż@ - zip (with reversed @rguments) with z

JavaScript (ES6), 58 bytes
Returns an object whose keys are the product IDs, associated to a list of review scores.
a=>a.map(([i,n])=>(o[i]=o[i]||[0,0,0,0,0])[n-1]++,o={})&&o

Test cases

let f =

a=>a.map(([i,n])=>(o[i]=o[i]||[0,0,0,0,0])[n-1]++,o={})&&o

console.log(JSON.stringify(f([])));
console.log(JSON.stringify(f([[1,4],[2,5],[1,5],[1,1],[1,5],[1,4]])));
console.log(JSON.stringify(f([[1,1],[2,2],[3,3],[4,4],[5,5]])));

Lua, 114 112 103 bytes
function(t,o)for i=1,#t do v=t[i]n,r=v[1],v[2]o[n]=o[n]or{n,{0,0,0,0,0}}o[n][2][r]=o[n][2][r]+1 end end

Try it online!
Explanation
function(t,o) -- Anonymous function taking a table and the output table
    for i=1,#t do -- For every number from 1 to the length of t
        v = t[i] -- Get the current entree
        n, r = v[1], v[2] -- Item Number and Rating
        o[n] = o[n] or {n,{0,0,0,0,0}} -- Make sure the item exists in the output
        o[n][2][r] = o[n][2][r] + 1 -- Add 1 to that rating
    end
-- Tables are always passed by reference, so no need to return
end

Clojure, 79 bytes
(fn[c](reduce(fn[r[i v]](update r i #(update(or %[0 0 0 0 0])(dec v)inc))){}c))

Must called with a sequence of vectors so that item id and ratinv value are correctly mapped to function arguments. Returns a hash-map of vectors.
(def f (fn[c]( ... )))
(f [[1 4] [2 5] [1 5] [1 1] [1 5] [1 4]])
{1 [1 0 0 2 2], 2 [0 0 0 0 1]}

Husk, 18 bytes
m§,o←←oλm#⁰ḣ5)m→k←

Try it online!

Wolfram Language (Mathematica), 37 35 bytes
Merge[Rule@@@#,#~BinCounts~{1,6}&]&

Try it online!

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


text:
Display a Digital Clock
Display a Digital Clock
(I see there are many clock challenges, I have tried to read them all, I'm pretty sure this is unique)
Write some code that continuously updates a digital clock displayed in the format h:m:s where h, m, and s can occupy 1 or 2 characters each. The restrictions in simple terms as @BlueEyedBeast put it, I basically want it to replace the time shown.

Newlines are not allowed
Trailing spaces are allowed
Other trailing characters are not allowed
No seconds should be missed (57 -> 59 is not allowed)
Numbers beginning with "0" are allowed, as long as they don't occupy more than 2 characters
The code must not accept any input
If your language can't get the current time without input, you may use for input up to 8 bytes in a standardly allowed way
Output must be to stdout
This is codegolf so the shortest answer wins!

Example
I'm working on a language named *><> (starfish) because programs like this aren't possible in ><> (just wait for file i/o) . Here's a working digital clock program in it (ungolfed). This program is written in *><>:
s":"m":"hnonon"   "ooo88888888888ooooooooooo1S

Note: Everything is identical to ><> in this except, s = second, m = minute, h = hour, S = sleep(100ms*x)
This outputs:
14:44:31

Updating every 100ms until terminated.
Disallowed Examples
The following are not allowed:
1:
14:44:3114:44:32

2:
14:44:31 14:44:32

3:
14:44:31
14:44:32

The time must remain on the first line it was outputted with no visible trailing characters. Clearing the terminal though, would be allowed as that still wouldn't have any trailing characters.

do we have to wait 100ms or can we just update constantly forever?

you don't have to wait, the wait is just what the example does.

The challenge requirements seem too strict to me.

I just thought without restricting the output this would have been too easy. There are a multitude of ways to write the time to one line. Why is this too strict?

@mbomb007 I removed "The program must be able to exit on user input that isn't a signal/interrupt" as the current answers didn't seem to follow it anyways.

Does it have to be in local time?

How does your example program stop when enter key is hit? Is it the S? And why do you print three spaces after the time? (Just curiosities)

Can the program rely on a specific local setting of the OS?

@Leo ah an older revision did that. I updated the description to no longer say it exits on enter (It used to have i1+?; or something).

@Winny, it can be any timezone as long as it's actually the time (or at least reasonably close, so it can be used to tell time).

@raznagul, I'm not sure what you mean, do you have an example? I'll probably allow it.

@redstarcoder: In C# DateTime.Now.ToString("T") would return 19:43:16 on my PC as the region setting is set to Germany. But on a PC with a region setting of US the result would be 7:43:16 PM.

@raznagul, that's fine, just specify the conditions to make your output valid!

Isn't this the same as "output the current time"? I'm on a phone so cant edit a link, sorry

@ev3commander it's similar, but not the same.

Pyke, 6 bytes
Ctr\ J

Try it here!
I think this is valid. Replace the space character with carriage return for valid output (does not work online)

Sorry it's not. No newlines are allowed or trailing characters after the time. I'll put 2 examples to be more explicit.

I don't see that in the spec?

The first line says newlines are not allowed, the third says no trailing characters. I'm sorry if that's unclear, I'd appreciate advice on fixing it.

So you want it to replace the old time shown?

Yes exactly! Your current code seems perfect.

HTML + JS (ES6), 8 + 60 = 68 bytes
Tested in Chrome.

setInterval`a.innerHTML=new Date().toLocaleTimeString('fr')`

-1 byte (@ETHProductions): Use French time format instead of .toTimeString().slice(0,8)

HTML + JS (ES6), 8 + 62 = 70 bytes
This will work in FireFox.

setInterval('a.innerHTML=new Date().toLocaleTimeString`fr`',0)

-3 bytes (@ETHProductions): Use French time format instead of .toTimeString().slice(0,8)

How does this work? I've never seen the backtick syntax before. I can't find anything on it either after some quick searching.

Working for me in Inox (Chromium)

@Carcigenicate It's part of the latest JavaScript spec, ECMAScript6. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals

@darrylyeo Thanks. I could find things on the literal syntax, but I couldn't see how it was applied here. I need to read the spec again. I still don't understand how the function that precedes the backtick is used.

@edc65 Aww man!

The second snippet is missing its HTML ;-)

You can save 3 bytes in the Firefox one with new Date().toLocaleTimeString`fr`  (1 byte in the Chrome one with ...TimeString('fr'))

Wow, I never would have thought of using the French time format!

@Carcigenicate you already are in the right place http://codegolf.stackexchange.com/a/52204/21348 read the comments too

Hey Darryl! Funny seeing you here. :3
That template literal syntax blew me away!

Huh? Isn't 60 + 8 68?

@Oliver Whoops, not sure how that happened!

Python 2, 50 bytes
(Python 2.1+ for ctime with no argument)
import time
while 1:print'\r'+time.ctime()[11:19],

time.ctime() yields a formatted string, from which the hh:mm:ss may be sliced using [11:19] (it remains in the same location whatever the date and time).
printing the carriage return '\r' before the text and making the text the first item of a tuple with , effectively suppresses the implicit trailing '\n' and overwrites the previously written output.
while 1 loops forever.

I think this needs a , at the end to supress the newline otherwise in Python 2.7.12 I get newlines.

Oops, yes you are correct... updated

Mathematica, 48 41 37 28 bytes
Do[s=Now[[2]],∞]~Monitor~s

The output will be a TimeObject, refreshing continuously.
Looks like this:
Alternative versions
48 bytes:
Dynamic@Refresh[TimeObject[],UpdateInterval->.1]

53 bytes:
Dynamic@Refresh[DateString@"Time",UpdateInterval->.1]

With it updating every second, did you ensure that it never skips seconds? (Ex: 11:11:11 -> 11:11:13)

Dynamic@{DateString@TimeObject[], Clock[]}[[1]]

@redstarcoder it updates every ~1.002s, so I changed to updating every 100ms

Welp, I just realized I don't actually need Pause.

Dynamic@{Now,Clock[]}[[1]] is 26 bytes and shows a datetime object. Dynamic@{DateString@"Time",Clock[]}[[1]] is 40 bytes and outputs only hh:mm:ss

I see that the requirement for a non-signal UI input to stop the program has been removed.  So now we can do:
Bash + coreutils, 28
yes now|date -f- +$'\e[2J'%T

yes continuously outputs the string "now", once per line, into a pipe.
date -f- reads interprets each "now" as the current time, then outputs in the required format.  The format string includes the ANSI escape sequence to clear the screen.  date does output a newline after the date - I'm not sure if this disqualifies, since the screen is cleared every time anyway.
If it disqualifies, then we can use tr instead:
Bash + coreutils, 31
yes now|date -f- +%T|tr \\n \\r

Previous Answers:
Bash + X, 32
xclock -d -update 1 -strftime %T

Unfortunately this can only update every second.  If that disqualifies, then we can do this instead:
Bash + coreutils, 43
until read -t0
do printf `date +%T`\\r
done

Updating every second is fine, as long as it doesn't ever skip seconds (IE: 12-> 14).

I'll allow your newline! I never expected this case to happen heh.

Is this allowed? date +$'\e[2J'%T;$0

@EvanChen no, because each iteration recursively spawns a new process and will eventually use up available memory or PID space, analogous to a stack overflow.  However you could do date +$'\e[2J'%T;exec $0 for 24 bytes...

Bash + watch, 19 bytes
watch is not a part of coreutils, but is available  out of the box on virtually every Linux distro.
Golfed
watch -tn1 date +%T

Try it online !

QBIC, 6 bytes
{_C?_d

{      Starts a DO-loop
 _C    CLS
   ?   PRINT
    _d TIME$

Constantly clears the screen and prints the system time in the format 22:03:41.

PHP, 28 bytes
for(;;)echo date("\rH:i:s");

The date function prints everything literally that it doesn´t recognize.
\r is the carriage return, sets the cursor to the first column.
Run with -r.

SmileBASIC 3.3.2, 38 bytes
@L?TIME$;" ";
GOTO@L

UTF-16 sucks :(
Anyway, this repeatedly prints the local time in HH:MM:SS with a space after it, no newline afterward. It doesn't update every second though, it just repeatedly prints forever.

Sorry this isn't valid, it needs to replace the output, this doesn't. Setting the first line to  @L?TIME$ and appending a line after (for a total of 3 lines) that reads LOCATE 0, 0 does the trick (does SmileBASIC support carriage return?).

Also you forgot to score the newline, making this 40 bytes (UTF-16 is brutal for code golf). You can get the character length very easilly via Python REPL len(""" YOUR CODE HERE """), then just do *2 for UTF-16.

No SB doesn't do CR actually, I would have to drop a LOCATE statement into there which would absolutely destroy my score :P Or a CLS:VSYNC which is just as bad.

Yeah, sadly this solution is invalid without it. Good news though! SmileBASIC is scored as UTF-8.

MATL, 11 bytes
`XxZ'13XODT

Infinite loop that clears the screen and prints the time in the specified format.
You can try it at MATL Online!. This compiler is experimental; if it doesn't work refresh the page and press "Run" again.

Clojure, 150 136 141 bytes
V3: 141 bytes :(
+5 bytes to fix a bug. Since the times aren't zero padded, the clock can "shrink" and expand when the time changes. It was "smearing" when it shrunk because the last digit was no longer being cleared. Fixed it by adding some spaces at the end to ensure everything is being overwritten.
#(while true(flush)(print(str(apply str(repeat 9"\b"))(.format(java.text.SimpleDateFormat."H:m:s")(java.util.Date.))"   "))(Thread/sleep 99))

V2: 136 bytes
#(while true(flush)(print(str(apply str(repeat 9"\b"))(.format(java.text.SimpleDateFormat."H:m:s")(java.util.Date.))))(Thread/sleep 99))

-14 bytes by switching to using SimpleDateFormat to format the date. Still huge.
V1: 150 bytes
#(while true(let[d(java.util.Date.)](flush)(print(str(apply str(repeat 9 "\b"))(.getHours d)":"(.getMinutes d)":"(.getSeconds d)))(Thread/sleep 100)))

I realized I'm probably using the worst way possible to get the date. Definitely room for improvement here.
Ungolfed:
(defn -main []
  (while true
    (let [d (java.util.Date.)]
      (flush)
      (print
        (str
          (apply str (repeat 9 "\b"))
          (.getHours d)":"(.getMinutes d)":"(.getSeconds d)))
      (Thread/sleep 100))))

C, 134 116 89 80 76 75 73 bytes
main(n){for(;time(&n);)printf("\r%02d:%02d:%02d",n/3600%24,n/60%60,n%60);}

---- Old versions:
main(n){for(;;)n=time(0),printf("\r%02d:%02d:%02d",n/3600%24,n/60%60,n%60);}

n;main(){for(;;)n=time(0),printf("\r%02d:%02d:%02d",n/3600%24,n/60%60,n%60);}

----

n;main(){for(;;)n=time(0),printf("\r%02d:%02d:%02d",n/3600%24,n/60%60,n%60);}

----

Saved 9 more bytes thanks to @nmjcman101 again:
n;main(){for(;;)n=time(0),printf("\r%02d:%02d:%02d",(n/3600)%24,(n/60)%60,n%60);}

----

Saved 27 bytes thanks to @nmjcman101
n,b[9];main(){for(;;){n=time(0);strftime(b,9,"%H:%M:%S",localtime(&n));printf("\r%s",b);}}

----

I figured out I don't need to put `#include<stdio.h>` into the file :)
#include<time.h>
main(){for(;;){time_t n=time(0);char b[9];strftime(b,9,"%H:%M:%S",localtime(&n));printf("\r%s",b);}}

----

#include<time.h>
#include<stdio.h>
main(){for(;;){time_t n=time(0);char b[9];strftime(b,9,"%H:%M:%S",localtime(&n));printf("\r%s",b);}}

It looks like (for me) you can remove time.h as well.  This removes the time_t type, so you need to make n an int instead.  This can be done by declaring it outside of main (like n;main...), which removes the need for the int.  You can also get rid of the char with the same trick: b[9];main....  They're both int type now, but it's flexible enough.

Wow, thanks a lot, I didn't know this would work. Thank you

Please stop me if you'd like to golf it yourself, but I also took out the strftime... and the b[9] and just made print into this: printf("\r%d:%d:%d",(n/3600)%60-29,(n/60)%60,n%60);  I'm not sure if the parens are needed or not.  Also you can take out a set of {} by putting commas between your statements so it's for(;;)a,b,c;

I'll just go try it, I've never golfed in C before so I don't know most of those tricks, thanks a lot :)

Could you please explain why you calculate hours that way ((n/3600)%60-29), the result is wrong for me but correct when I subtract 24

I screwed up.  Hours should be (n/3600)%24 NOT %60.  I think that gives you GMT, so then I would have to -5 to get EST.  Just using GMT might be fine though?

These parentheses are annoying. (n/60)%60, seriously?

@anatolyg yeah, you're right. Those aren't necessary

You can save 1 byte by declaring n as parameter of main, say main(n) instead of n;main()

@JayDepp, please don't suggest or make edits to others' code

Powershell, 39 bytes
for(){write-host -n(date -F h:m:s`0`r)}

Because I dislike using cls in Powershell. From briantist's post @https://codegolf.stackexchange.com/a/102450/63383

Pascal, 61 bytes
uses sysutils;begin while 1=1do write(#13,timetostr(now))end.

Free pascal has nice time routines in SysUtils unit. Ungolfed:
uses
  sysutils;
begin
  while 1=1 do
    write(#13, timetostr(now));
end.

WinDbg, 73 bytes
.do{r$t0=0;.foreach(p {.echotime}){r$t0=@$t0+1;j8==@$t0'.printf"p \r"'}}1

It continually updates a line with the current time until the user presses Ctrl+Break.
How it works:
.do                          * Start do-while loop
{
    r$t0 = 0;                * Set $t0 = 0
    .foreach(p {.echotime})  * Foreach space-delimited word in a sentence like "Debugger (not
    {                        * debuggee) time: Mon Dec  5 14:08:10.138 2016 (UTC - 8:00)"
        r$t0 = @$t0+1;       * Increment $t0
        j 8==@$t0            * If $t0 is 8 (ie- p is the current time)
        '
            .printf"p \r"    * Print p (current time) and \r so the next print overwrites
        '
    }
} 1                          * Do-while condition: 1, loop forever

Sample output (well, you get the idea):
0:000> .do{r$t0=0;.foreach(p {.echotime}){r$t0=@$t0+1;j8==@$t0'.printf"p \r"'}}1
14:10:12.329

C#, 82 bytes
()=>{for(;;)Console.Write(new string('\b',8)+DateTime.Now.ToString("HH:mm:ss"));};

Anonymous method which constantly overwrites 8 characters with new output. Can be made 1 byte shorter if modifying to accept a dummy parameter (z=>...).
Full program:
using System;

public class Program
{
    public static void Main()
    {
        Action a =
        () =>
        {
            for (;;)
                Console.Write(new string('\b', 8) + DateTime.Now.ToString("HH:mm:ss"));
        };

        a();
    }
}

Is it allowed not to import System? Some people do it, and some people don't :/

He didn't in his actual solution, just in the demo program, so yes, it is ok

C#, 65 bytes
()=>{for(;;)Console.Write("\r"+DateTime.Now.ToLongTimeString());};

Works by overwriting the same line within an endless loop

Commodore BASIC (CBM/PET, C64, C128, VIC-20, C16/+4), 64 ~62 BASIC bytes (tokens), 64 62 PETSCII characters with keyword abbreviations
?"{CLEAR}":FORI=0TO1:?"{HOME}"LEFT$(TI$,2)":"MID$(TI$,3,2)":"RIGHT$(TI$,2):I=0:NEXT

Edit I realised that this is what I would call a zero liner, or in other words, it does not require a line number to run, so I've taken this out. Once you break it though, you need to type it in again.
Changes Line numbers in Commodore BASIC take up I think at least two bytes (though I need to check), so by actual byte count is an estimation, however, removing the line number and using the LEFT$ command for the first two digits, rather than the MID$ command, has shaved off two whole characters from this.
Some notes: if you are entering this on a Commodore C64 then you will need to use keyword abbreviations (see the screen shot below). Some other Commodore 8-bits, like the C128 and VIC-20, accept more than 80 characters entered per line, but to be sure, use the keyword abbreviations anyway.
To set the time first, use TI$="112233" as HHMMSS format as 24 hours (000000 being midnight).
How it works
TI$ is a system variable which fairly accurately keeps time. 8 BIT Show and Tell explores this in some depth in this YouTube video and is well worth a watch if you are interested.
An unbroken loop is set with resetting the I variable per iteration by setting it to 0. We then use the MID$ and RIGHT$ function to print out each relevant time segment, being HH:MM:SS. A list of BASIC keywords can be found here.

I can save a few bytes by using the LEFT$ command in place of the first MID$ command, because of the way that Commodore BASIC tokenises each keyword.

Groovy, 45 characters
for(;;)print(new Date().format("\rHH:mm:ss"))

PowerShell, 30 28 24 20 bytes
Changed my computer's region to Germany based on raznagul's comment to save 4 bytes. :)
for(){date -F T;cls}

Previous version that works in all locales.
for(){date -F h:m:s;cls}

Jelly, 8 bytes
13Ọ7ŒTȮß

13Ọ        chr(13), carriage return
   7ŒT     time string, which extends the previous character
      Ȯ    print
       ß   call the whole link again

Try it online!
The carriage return doesn't work online, and I can't get the interpreter to work, so its kinda untested, but it works as expected when I use printable characters in place of the CR.

ForceLang, 123 bytes
def s set
s d datetime
s z string.char 8
s z z.repeat 16
label 1
io.write z
io.write d.toTimeString d.now()
d.wait 9
goto 1

datetime.toTimeString is backed in the reference implementation by Java's DateFormat.getTimeInstance(), which is locale-dependent, so you can set your default system locale to one that uses 24-hour time.

Java, 67 bytes
for(;;)System.out.print("\r"+java.time.LocalTime.now()+"\b\b\b\b");

We loop infinitely, grabbing the current time and outputting to screen. The quad backspace is for easy formatting, because otherwise we'd have to do something like this:
for(;;)System.out.print("\r" + java.time.LocalTime.now().truncatedTo(java.time.temporal.ChronoUnit.SECONDS));

Vim, 26 bytes
qqS<C-r>=strftime("%T")<CR><esc>@qq@q

This creates a recursive macro (e.g. an eternal loop) that deletes all the text on the current line and replaces it with the current time.

Pyth - 28 bytes
Kinda longish, because pyth  has no strftime.
#p+"\r"j\:m.[`02`dP>4.d2.d.1

tcl, 69 bytes
while 1 {puts -nonewline \r[clock format [clock seconds] -format %T]}

Try it here!

C 65 (prev 64) bytes
Guaranteed to work on Linux machine. :)
@Marco Thanks!
f(){while(1){system("date +%T");usleep(100000);system("clear");}}

SmileBASIC, 14 bytes
CLS?TIME$EXEC.

CLS clears the screen, ? TIME$ prints the current time, and EXEC 0 runs the code that's in slot 0.
It's a bit flickery, but there's nothing in the reqirements about that, so it should be fine.
Format is HH:MM:SS 24 hour time :(

x86-16 machine code, IBM PC DOS, 71 69 bytes
Binary:
00000000: b81c 35cd 2153 06ba 1901 e806 00b4 08cd  ..5.!S..........
00000010: 211f 5ab8 1c25 cd21 c3b4 2ccd 218a c5e8  !.Z..%.!..,.!...
00000020: 0800 91e8 0400 8ac6 b2ff d40a 0d30 3086  .............00.
00000030: e0cd 2986 e0cd 2984 d27c 05b0 3acd 29c3  ..)...)..|..:.).
00000040: b00d cd29 cf                             ...).

Listing:
B8 351C         MOV  AX, 0351CH             ; AL = 1CH, AH = 35H
CD 21           INT  21H                    ; get interrupt vector for 1CH into ES:BX
53              PUSH BX                     ; save old vector
06              PUSH ES                     ; save old segment
BA 011D R       MOV  DX, OFFSET GET_TIME    ; DX = interrupt vector of time proc
E8 0117 R       CALL SET_VECT               ; setup new vector
B4 08           MOV  AH, 8                  ; DOS read char from stdin without echo
CD 21           INT  21H                    ; wait for user to press the "any key"
1F              POP  DS                     ; restore old segment
5A              POP  DX                     ; restore old vector
            SET_VECT:
B8 251C         MOV  AX, 0251CH             ; AL = 1CH, AH = 25H
CD 21           INT  21H                    ; set interrupt vector from DS:DX
C3              RET                         ; return to DOS
            GET_TIME:
B4 2C           MOV  AH, 2CH                ; get DOS time
CD 21           INT  21H                    ; CH = hour CL = minute DH = second
8A C5           MOV  AL, CH                 ; display hour: AL = CH
E8 012E R       CALL OUT_TIME               ; write time
91              XCHG AX, CX                 ; display minute: AL = CL
E8 012E R       CALL OUT_TIME               ; write time
8A C6           MOV  AL, DH                 ; display second: AL = DH
B2 FF           MOV  DL, -1                 ; set DL to -1 so doesn't display ':'
            OUT_TIME:
D4 0A           AAM                         ; BCD convert: AL = AL % 10, AH = AL / 10
0D 3030         OR   AX, '00'               ; ASCII convert
86 E0           XCHG AH, AL                 ; endian convert
CD 29           INT  29H                    ; write tens
86 E0           XCHG AH, AL                 ; swap digits
CD 29           INT  29H                    ; write ones
84 D2           TEST DL, DL                 ; when DL = -1, it is seconds digit
7C 05           JL   DONE_TIME              ; if last number, write CR not ':'
B0 3A           MOV  AL, ':'                ; write ':'
CD 29           INT  29H
C3              RET                         ; return from near call
            DONE_TIME:
B0 0D           MOV  AL, 0DH                ; carriage return
CD 29           INT  29H                    ; move cursor back to beginning of line
CF              IRET                        ; return from interrupt

A standalone PC DOS executable COM program.  Uses DOS to hook the hardware timer interrupt which calls the program every 18.2ms to update the clock on the screen.  Exits when any key is pressed.
Runtime:

(A key was hit after 5 seconds, exiting the program)

Japt, 8 bytes
i@OqK¤¯8

Test it
i@OqK¤¯8
i            :Every 0 milliseconds
 @           :Run the following function
  Oq         :Replace the output with
    K        :Date object
     ¤       :Convert to time string
      ¯8     :Slice to the 8th character

05AB1E, 15 bytes
[žažbžc':ý13ç«?

Try it online. (The TIO doesn't support carriage returns, so every line is printed without overwriting the previous line. I also included a footer with a 0.1 sec sleep and which stops after 5 seconds, so the output won't be flooded with the same outputs and you won't have to wait 60 seconds for it to timeout.)
Here a gif to see it in action:

Explanation:
[                # Loop indefinitely:
 ža              #  Push the current hours
   žb            #  Push the current minutes
     žc          #  Push the current seconds
       ':ý      '#  Join the entire stack with ":" as delimiter
          13ç    #  Push 13 and convert it to a character: '\r'
             «   #  Append this carriage return to the time-string
              ?  #  Pop and output this string (without newline)

Windows Batch Scripting, 55 bytes
@echo off
:l
cls
echo %time:~0,8%
timeout 1 >nul
goto l

Output

R, 41 bytes
repeat{cat(format(Sys.time(),"%T"),"\r")}

Has one trailing space (because of cat default separator being a space).
Because of the refresh rate of the R GUI, running this in the GUI will occasionally skip some seconds, but if you save it to a file and run it on the command line it will display correctly every single seconds.
Will run forever until user interrupt.

*><> (Starfish), 22 bytes
"   ::"s@hm@donononooo

Try it here!
Ungolfed
>s":"m":"hnonon"   "ooo1S\
\                 ;?+1iod/

Explanation
d                      push \r to the stack
 "   ::"               push "   ::" to the stack
        s              push seconds to the stack
         @             move seconds back 2
          hm           push hours and minutes to the stack
            @          move minutes back 2
             n         output a number
              o        output a character

First, we build the initial stack with d"   ::"s, giving us ["\r", "   ", ":", ":", seconds], building the stack this way saves two bytes by removing 4 ", and adding two @. It's important to know what the @ instruction does here, it simply changes the end of the stack in such a way so [1,2,3,4] @ [1,4,2,3]. So we run @ giving us a stack of ["\r", "   ", seconds, ":", ":"]. Then we run hm@, which adds the hours, then the minutes to the end of the stack and executes @, giving us ["\r", "   ", seconds, ":", ":", hours, minutes] @ ["\r", "   ", seconds, ":", minutes, ":", hours]. In nononoooo, n outputs a number from the end of the stack, o outputs a byte.
Then the ><> simply loops back around to the beginning!

Excel VBA, 17 Bytes
Outputs current time to cell A1
Do:[A1]=Now:Loop

Note: The above subroutine does not exit so either holding Esc to terminate the process or adding a DoEvents call to the sub above (Sub a:Do:[A1]=Now:DoEvents:Loop) to allow for hitting the stop button is recommended

TI-Basic, 40 Bytes
(In TI-BASIC, many characters are 2 byte tokens, and colons at the beginning of a line are 0 extra bytes)
:ClrHome
:Output(1,6,":
:setTmFmt(24
:While 1
:Output(1,1,getTmSrr(0
:getTime
:Output(1,7,Ans(3
:End

I have a TI calculator (TI‑82) but it does not feature the time commands. Could you indicate the minimum hardware requirements?

Batch, 36 bytes
@set/p.=␈␈␈␈␈␈␈␈%time:~0,8%<nul
@%0

Where ␈ represents the ASCII BS character (code 8).

Racket, 71 bytes
(require srfi/19)(let l()(display(date->string(current-date)"↵~3"))(l))

Where the ↵ is actually a CR (hex 0d). Hex dump of the program for further clarification (notice byte at position hex 4d):
00000000  28 72 65 71 75 69 72 65  20 73 72 66 69 2f 31 39  |(require srfi/19|
00000010  29 28 6c 65 74 20 6c 28  29 28 64 69 73 70 6c 61  |)(let l()(displa|
00000020  79 28 64 61 74 65 2d 3e  73 74 72 69 6e 67 28 63  |y(date->string(c|
00000030  75 72 72 65 6e 74 2d 64  61 74 65 29 22 0d 7e 33  |urrent-date)".~3|
00000040  22 29 29 28 6c 29 29                              |"))(l))|
00000047

Uses SRFI/19 included with the Racket distribution. (current-date) gets the current local date & time. The date->string format ~3 is ISO-8601 hour-minute-second format. (let l () ... (l)) in an idiomatic infinite loop. (require srfi/19) loads the srfi/19 module.

C, 156 bytes
#include<stdio.h>
#include<time.h>
int main(){time_t a;struct tm *b;char c[9];for(;;){time(&a);b=localtime(&a);strftime(c,9,"%H:%M:%S",b);printf("%s\r",c);}}

Batch, 25 bytes (not including newline)
:k
@echo %time% && @goto k

Example output:

I'm afraid that this is not a valid answer: The time must remain on the first line it was outputted with no visible trailing characters. Clearing the terminal though, would be allowed as that still wouldn't have any trailing characters. - see the disallowed answers section of the prompt for more information

HP‑41C series, 9 Bytes
This program requires an HP‑41CX or an HP‑41C/CV with a time module plugged in.
Press the R/S (run/stop) key to interrupt the program.
Press the ⭠ key to return to the regular display with the current time now being the value of the X register (HH.MMSSss format).
Pressing any other key will clear the display, too, but also execute the key’s associated function.
01♦LBL⸆T           5 Bytes  global label requires 4 + (length of string) Bytes
02 CLK24           2 Bytes  select military time format
03 CLOCK           2 Bytes  show the current time refreshing every second

The default setting is showing a 12‑hour clock (using AM/PM) and a calendar date (MM/DD).
You may need to insert the CLKT command (2 Bytes) to revert to this setting (i. e. omitting the calendar date) to see the current seconds value, too.
Remember, if you are running low on batteries (indicated by the BAT annunciator and flag 49 set), the CLOCK command turns the calculator off.
The continuous clock draws about 2 mA of power.

source: Stack Exchange

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

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

sort: votes


text:
Plus and Times, Ones and Nines
Implement this recurrence relation as a function or program that inputs and outputs a non-negative integer:

F(0) = 0
F(N) = the smallest integer greater than F(N-1) such that the sum and/or product of its base-10 digits is N

N is your program's input and F(N) its output.
To be clear, the sum of the digits in a number like 913 is 9+1+3=13. The product is 9×1×3=27. For single-digit numbers, the sum and product is the same number. Numbers that contain a 0 of course have product 0.
The results through F(70) are:
N F(N)
0 0
1 1
2 2
3 3
4 4
5 5
6 6
7 7
8 8
9 9
10 19
11 29
12 34
13 49
14 59
15 69
16 79
17 89
18 92
19 199
20 225
21 317
22 499
23 599
24 614
25 799
26 899
27 913
28 1147
29 2999
30 3125
31 4999
32 5999
33 6999
34 7999
35 8999
36 9114
37 19999
38 29999
39 39999
40 41125
41 59999
42 61117
43 79999
44 89999
45 91115
46 199999
47 299999
48 311128
49 499999
50 511125
51 699999
52 799999
53 899999
54 911116
55 1999999
56 2111147
57 3999999
58 4999999
59 5999999
60 6111125
61 7999999
62 8999999
63 9111117
64 11111188
65 29999999
66 39999999
67 49999999
68 59999999
69 69999999
70 71111125

The shortest code in bytes wins. Kudos if you can show that your code takes advantage of some efficiency.

OEIS sequence

Not quite right sequence.

05AB1E, 20 12 bytes
Saved 8 bytes thanks to Osable!
µNSDOsP‚¾>å½

Uses the CP-1252 encoding. Try it online!

Is the length test required? I came up with µNSDOsP‚¾>å½. It seems to work for randomly chosen numbers.

@Osable Ahh of course, you're a genius! I don't even know why I included that.

Amazing how you can suddenly reduce a 20 bytes program by 40%...

Mathematica, 71 bytes, 68 characters
±0=0;±n_:=(For[x=±(n-1),FreeQ[{+##,1##}&@@IntegerDigits@x,n],x++];x)

For just 4 more bytes, here's a version that stores the values of ±n:
±0=0;±n_:=(For[x=±(n-1),FreeQ[{+##,1##}&@@IntegerDigits@x,n],x++];±n=x)

With the latter version, before you evaluate ±n, PlusMinus will have two down values:
In[2]:= DownValues@PlusMinus
Out[2]= {HoldPattern[±0] :> 0, HoldPattern[±n_] :> (For[x=±(n-1),FreeQ[{+##,1##}&@@IntegerDigits@x,n],x++];±n=x)}

Now if we evaluate ±20:
In[3]:= ±20
In[3]:= 225

In[4]:= DownValues@PlusMinus
Out[4]= {HoldPattern[±0] :> 0, HoldPattern[±1] :> 1, HoldPattern[±2] :> 2, HoldPattern[±3] :> 3, HoldPattern[±4] :> 4, HoldPattern[±5] :> 5, HoldPattern[±6] :> 6, HoldPattern[±7] :> 7, HoldPattern[±8] :> 8, HoldPattern[±9] :> 9, HoldPattern[±10] :> 19, HoldPattern[±11] :> 29, HoldPattern[±12] :> 34, HoldPattern[±13] :> 49, HoldPattern[±14] :> 59, HoldPattern[±15] :> 69, HoldPattern[±16] :> 79, HoldPattern[±17] :> 89, HoldPattern[±18] :> 92, HoldPattern[±19] :> 199, HoldPattern[±20] :> 225, HoldPattern[±n_] :> (For[x=±(n-1),FreeQ[{+##,1##}&@@IntegerDigits@x,n],x++];±n=x)}

This dramatically speeds up future calculations since Mathematica will no longer calculate the values between 0 and 20 recursively. The time saved is more dramatic as n increases:
In[5]:= Quit[]

In[1]:= ±0=0;±n_:=(For[x=±(n-1),FreeQ[{+##,1##}&@@IntegerDigits@x,n],x++];±n=x)

In[2]:= AbsoluteTiming[±60]
Out[2]= {23.0563, 6111125}

In[3]:= AbsoluteTiming[±60]
Out[3]= {9.89694*10^-6, 6111125}

This starts at F(N - 1) instead of F(N - 1) + 1; the recurrence must be strictly increasing.

Pyth - 18 17 bytes
One byte saved thanks to @Jakube!
Uses reduce to do the recursive thing.
uf}HsM*FBjT;hGSQZ

Test Suite.

sM*FBjT; also generates the digit sum and product and is 1 byte shorter.

@Jakube ooh nice trick

C#, 155 159 135 bytes
a=n=>{if(n<1)return 0;int i=n,s=0,p=1,N=a(n-1);for(;;){s=0;p=1;foreach(var c in++i+""){s+=c-48;p*=c-48;}if(i>N&(s==n|p==n))return i;}};

Super inefficient, takes a long time for just N>=14.  Gonna try to get a more efficient, but longer solution.
Okay, much better now, but 4 bytes longer.  Oh well, I can do N<=50 pretty quickly now.  Thank you @milk for saving 24 bytes!

-2 bytes to replace the for with for(;;) and the foreach with foreach(var c in++i+""). -22 bytes to replace int.Parse(c+"") with c-48.

Mathematica, 67 bytes
a@0=0;a@b_:=NestWhile[#+1&,a[b-1]+1,+##!=b&&1##!=b&@*IntegerDigits]

Function, named a. Takes a number as input and returns a number as output. Inspired by the previous Mathematica solution, but uses a different looping mechanism.

C, 240 bytes
int f(char n){int q[19],i=19,r=n%9,j=9,*p=q,c=n/9;while(i)q[--i]=0;if(c){if(!r){r=9;c--;}q[9]=c;if(!(n%r)){n/=r;while((j-1)*(n-1)*c){if(n%j)j--;else{c--;q[9+j]++;n/=j;}}q[10]=c;if(1==n)p+=9;}while(++i<10){while(p[i]--)r=r*10+i;}}return(r);}

Trying to exploit some math properties of the sequence.

R, 124 112 bytes
f=function(N){y=x=`if`(N-1,f(N-1),0);while(N!=prod(y)&N!=sum(y)){x=x+1;y=as.double(el(strsplit(c(x,""),"")))};x}

Fails at N=45 because R insists on writing 10.000 as 1e+05, which isnt appreciated by as.numeric(), this is fixable by using as.integer() at the cost of 12 bytes:
f=function(N){y=x=`if`(N-1,f(N-1),0);while(N!=prod(y)&N!=sum(y)){x=x+1;y=as.double(el(strsplit(c(as.integer(x),""),"")))};x}

As a statistical programming language R has annoyingly wordy ways of splitting numbers into a vector of digits. Especially because everything has to be converted back from strings to numerical values explicitly.
12 bytes saved thanks to billywob.

You can use as.double(el(strsplit(c(x,""),""))) to split an integer into a vector of its digits. However, you still run into the formatting issue but that can as in your answer be solved by as.integer()

Ooh, clever way of forcing x into a string :o

You can also use sprintf() instead to format the integer into a string with no trailing zeros directly: as.double(el(strsplit(sprintf("%1.f",x),""))) and skip the use of as.integer()

@LegionMammal978 The first thing it does in the while loop is x=x+1 and this is guaranteed to be evaluated once, because at the start y=F(N-1) which is definitely not equal to N.

@JarkoDubbeldam Whoops, misread it :P

@LegionMammal978 That's ok, it generally takes me a long time to really grasp these golfed down notations.

JavaScript (ES6) 109 107 105 91 89 Bytes

f=n=>n&&eval(`for(i=f(n-1);++i,${x="[...i+''].reduce((r,v)=>"}+r+ +v)-n&&${x}r*v)-n;);i`)

console.log(f.toString().length + 2);
console.log(f(25));
console.log(f(13));
console.log(f(8));

JavaScript (ES6), 84 86
Edit: 2 bytes saved thx @Arnauld
f=n=>eval("for(v=n&&f(n-1),p=s=n+1;s&&p-1;)[...++v+''].map(d=>(p/=d,s-=d),p=s=n);v")

Test Note above 50 it will use too much of your CPU, click 'Hide results' to stop before it's too late

f=n=>eval("for(v=n&&f(n-1),p=s=n+1;s&&p-1;)[...++v+''].map(d=>(p/=d,s-=d),p=s=n);v")

out=x=>O.textContent=x+'\n'+O.textContent

i=0
step=_=>out(i+' '+f(i),++i,setTimeout(step,i*10))

step()

I think for(v=n&&f(n-1),p=s=n+1;s&&p-1;)[...++v+''].map(d=>(p/=d,s-=d),p=s=n);v should save 2 bytes. I suspect it can be shortened some more, but I couldn't figure it out so far.

@Arnauld I expect some problem with repeated floating point division

Our only requirement is that p /= d produces an exact result when d is actually a divisor of p. Unless I'm mistaken, this is true for any d <= p <= Number.MAX_SAFE_INTEGER. We'll get floating point rounding errors when p % d != 0, but that should be safe.

@darrylyeo don't give suggestions you did not try yourself (try eval`1+1` ) (here's why http://codegolf.stackexchange.com/a/52204/21348 : read the first comment)

BASH, 107 bytes
with fold + paste + bc
for ((;n<=$1;z++)){
p(){ fold -1<<<$z|paste -sd$1|bc;}
[ `p +` = $n -o `p \*` = $n ]&&((z-->n++))
}
echo $z

Wonder, 49 bytes
f\.{0\0@(:>@(| =#1sum#0)=#1prod#0)(dp +1f -#0 1)N

Pattern matching ftw! Usage:
f\.{0\0@(:>@(| =#1sum#0)=#1prod#0)(dp +1f -#0 1)N}; f 10

More readable:
f\.{
  0\0
  @(
    find @(or = #1 sum #0) = #1 prod #0
  ) (dp + 1 (f -#0 1)) N
}

This is basically just a word-for-word implementation of the specs.

Python 2, 77 bytes
f=lambda n,k=0,r=0:-(k>n)or-~f(n,k+(k in[eval(c.join(`r`))for c in'+*']),r+1)

Try it online!

Befunge, 101 bytes
&20p>:000pv
>\1+^vp011<
| >.@>:55+%:00g+00p10g*v>10g-*
::\$_^#!:/+55p01*!`"~":<^\-g00
< |!-g02
+1< v\

Try it online! But note that it's going to get really slow once you get into the high forties. If you want to test the full range, you really need to be using a Befunge compiler.
Explanation
&20p           Read N and save for later.

>              Start of main loop; current target and test number on stack, initially 0.
:              Duplicate the test number so we can manipulate it.
000p           Initialise the sum to 0.
110p           Initialise the product to 1.

>              Start of inner loop.
:55+%:         Modulo 10 of the test number to get the first digit.
00g+00p        Add to the sum.
10g*           Multiply by the product.
:"~"`!*        If greater than 126, set to 0 to prevent overflows - it'll never match.
10p            Update the product variable.
55+/           Divide the test number by 10 to get the next digit.
:!_            If not zero, repeat the inner loop

$              Drop the zero left over from the loop.
\::00g-\10g-   Compare the sum and product with the current target.
*|             Multiply the two diffs and branch; up if no match, down if either match.
\1+^           On no match, we increment the test number and repeat the main loop.
:>20g-!|       With a match, we compare the current target with the saved N.
1+\v           If that doesn't match, increment the current target and restart main loop.
\>.@           If it does match, we've got our result; output it and exit.

PowerShell v3+, 114 bytes
param($n)$i=,0;$l=1;1..$n|%{for(;$_-notin((($b=[char[]]"$l")-join'+'|iex)),(($b-join'*'|iex))){$l++}$i+=$l};$i[$n]

Iterative solution, with no easy way to turn a number into the sum/product of its digits, so it's quite a bit longer than the JavaScript answers.
Takes input $n, sets $i to an array with just 0 (this is the collection of F(), and sets $l equal to 1 (this is the latest F). We then loop upward from 1 to $n, each iteration executing a for loop.
The for loop's conditional takes the $latest number, in a string "$l", then casts that as a char-array, and stores that array into temp variable $b. We then -join those digits together with + and pipe that to iex (short for Invoke-Expression and similar to eval). Additionally, we also do similar with *. Those two numbers are encapsulated in parens and treated as the array argument for the -notin operator against the current number $_ of the outer loop (i.e., the for loop runs so long as either + and * are different than $_). The body of the for loop just increments $l++.
Once we're out of that inner for loop, we add our $l on as a new element of $i. Once we've fully completed the range loop, we just place $i[$n] on the pipeline, and output is implicit.
NB -- Gets pretty slow to execute above about 20, simply because of the loop structure. For example, N=40 takes about two minutes on my machine, and I've not even bothered testing N>50.

Pyke, 17 bytes
t.fY'Bs]~ohR{Io(e

Try it here!
Or 13 bytes noncompetitive
first_n now puts the amount of items already found plus one in i if used.
Q.fY'Bs]iR{)e

Try it here!
Q.f        )  -  first_n(input, start=1)
   Y          -   digits(^)
    'Bs]      -   [sum(^), product(^)]
         R}   -   V in ^
        i     -    len(results)+1
            e - ^[-1]

PHP, 110 bytes
for(;$c<=$a=$argn;$c=count($r))array_product($s=str_split($n++))!=$c&&array_sum($s)!=$c?:$r[]=~-$n;echo$r[$a];

Try it online!


text:
Convert a sample to an index
We are putting balls into a fixed number a bins. These bins begin empty.
Empty bin (a=4): 0 0 0 0

And one by one we add balls to the bins.
0 0 0 1  or
0 0 1 0  or
0 1 0 0  or
1 0 0 0

We need a quick way to loop over all the possible states the bins take, without duplicates and without missing any and we don't want to enumerate all the possible bins. So instead we assign each bin-configuration an index.
We assign the index by sorting the possible configurations in a specific way:

Sort ascending by sum: so first 0 0 0 0, then the possible configurations with 1 ball added, then 2, etc.

Then sort within each sum in ascending order, from the first bin to the last:
0 0 0 2
0 0 1 1
0 0 2 0
0 1 0 1
0 1 1 0
0 2 0 0
etc

The index is then assigned ascending through this list:
0 0 0 0  -> 1
0 0 0 1  -> 2
0 0 1 0  -> 3
0 1 0 0  -> 4
1 0 0 0  -> 5
0 0 0 2  -> 6
0 0 1 1  -> 7
0 0 2 0  -> 8
0 1 0 1  -> 9
0 1 1 0  -> 10
0 2 0 0  -> 11

Rules
Create a function or program that takes a list of any size with non-negative integers and print or output its index. You can assume a to be at least 2. Shortest code wins. You may use 0-indexed output or 1-indexed, but specify which you use. NB: all examples here are 1-indexed.
Example code
Not golfed, in R:
nodetoindex <- function(node){
  a <- length(node)
  t <- sum(node)
  if(t == 0) return(1)

  index <- choose(t-1 + a, a)

  while(sum(node) != 0){
    x <- node[1]
    sumrest <- sum(node)
    if(x == 0){
      node <- node[-1]
      next
    }
    a <- length(node[-1])
    index <- index + choose(sumrest + a, a) - choose(sumrest - x + a, a)
    node <- node[-1]
  }
  return(index + 1)
}

Test cases
10 10 10 10 -> 130571
3 1 4 1 5 9 -> 424407
2 9 -> 69
0 0 0 -> 1
0 0 1 -> 2
0 0 0 0 0 0 -> 1
1 0 0 0 0 1 -> 23

How does sorting via the numerical value of the concatenation work when the counts have different numbers of digits?

@TheBikingViking hmm, hadn't thought of that, I changed the wording to reflect the example code and the test cases. Within each sum, the configurations are sorted first in the first bin, then in the second, and so forth.

Jelly, 8 bytes
S0rṗLSÞi

Try it online!
Brute-force solution. The first test case is too much for TIO, but I've verified it locally on my laptop. The second test case requires too much RAM, even for my desktop computer.
How it works
S0rṗLSÞi  Main link. Argument: A (array)

S         Compute the sum s of A.
 0r       Create the range [0, ..., s].
    L     Yield the length l of A.
   ṗ      Cartesian power; yield the array of all l-tuples over [0, ..., s], in
          lexicographical order.
     SÞ   Sort the l-tuples by their sums. The sorting mechanism is stable, so
          l-tuples with the same sum are still ordered lexicographically.
       i  Find the index of A in the generated array of tuples.

Nice. Your remark about RAM reminded me of the source of this challenge. For my thesis I needed to loop over all possible arrays for some a=8 and as high as possible balls. The idea to transform the arrays to indices and just loop over those came exactly from the limitation of RAM :P

Which is also why the example code is so wordy :P

Mathematica, 50 bytes
A port of Dennis's Jelly answer.
0~Range~Tr@#~Tuples~Length@#~SortBy~Tr~Position~#&

Unnamed function taking a list of integers as input, and returning a depth-2 list with a single integer as output; for example, the input for the last test case is {1,0,0,0,0,1} and the output is {{23}}.
A slightly ungolfed version is:
Position[SortBy[Tuples[Range[0,Tr[#]],Length[#]],Tr],#]&

Often we can save individual bytes in Mathematica by using prefix notation (function@n instead of function[n]) and infix notation (a~function~b instead of function[a,b]). This only works, however, when the resulting code happens to mesh well with Mathematica's intrinsic precedence order for applying functions. I was kind of amazed here that, with six sets of square brackets, it actually worked to remove all of them and save six bytes with the (pleasantly bracketless) submitted code.

Clojure, 152 bytes
#(loop[v[(vec(repeat(count %)0))]i 1](if-let[r((zipmap v(range))%)](+ r i)(recur(sort(set(for[v v i(range(count v))](update v i inc))))(+ i(count v)))))

Not as easy as I thought. Less golfed version:
(def f (fn[t](loop[v[(vec(repeat(count t)0))]i 1]
               (if-let[r((zipmap v(range))t)](+ r i)
                 (recur (sort-by (fn[v][(apply + v)v]) (set(for[v v i(range(count v))](update v i inc))))
                        (+ i(count v)))))))

Loops over current states v, creates a hash-map from elements of v to their rank, if the searched state is found then its rank is returned (+ the number of previously seen states). If not found then recurses with a new set of possible states.
Oh actually we don't need that custom sorting function as all states within each loop has identical sum. This isn't as slow as I expected as [3 1 4 1 5 9] took only 2.6 seconds.


text:
Help my maniacal wife decorate our Christmas tree
My wife is very, let's say, particular when it comes to putting ornaments on our Christmas tree. Let's get her some code to help her in this trying time.
Input
Given an input 2 < n < 10 the height of the tree and 0 < k < n the distinct number of ornaments.
Task
Decorate the tree starting with 1 and increment to k as we wrap the ornaments around the tree. If we reach k and we have more branches to decorate then start back at 1.
It is okay if there are not the same number of each ornament on the tree, as long as the pattern is satisfied.
The ornaments should appear above each branch ^ except for the top row.
The tree is structured by starting with one branch  then the next level has + 1 branches with a space between each, staggered from the top like:
 ^
^ ^

For a third row you would add one more branch and stagger them again such that no branch is on the same column (if you think of it like a grid).
  ^
 ^ ^
^ ^ ^

Output
Output your decorated tree.
Examples
1.
 n = 3, k = 2
  ^      //Height is 3
 ^ ^
^ ^ ^

Now we decorate each branch starting with 1 and increment to k:
  ^
 1 2
 ^ ^
1 2 1
^ ^ ^

2.
 n = 6, k = 5
     ^    //Non-Decorated
    ^ ^
   ^ ^ ^
  ^ ^ ^ ^
 ^ ^ ^ ^ ^
^ ^ ^ ^ ^ ^

     ^    //Decorated
    1 2
    ^ ^
   3 4 5
   ^ ^ ^
  1 2 3 4
  ^ ^ ^ ^
 5 1 2 3 4
 ^ ^ ^ ^ ^
5 1 2 3 4 5
^ ^ ^ ^ ^ ^

3.
n = 5, k = 1
    ^
   ^ ^
  ^ ^ ^
 ^ ^ ^ ^
^ ^ ^ ^ ^

    ^
   1 1
   ^ ^
  1 1 1
  ^ ^ ^
 1 1 1 1
 ^ ^ ^ ^
1 1 1 1 1
^ ^ ^ ^ ^

This is code-golf so the shortest code wins! Have fun and good luck!

spaces after each line acceptable ?

@MukulKumar no It should maintain the structure above.

Can we assume k less than 10? Or else, how to align the numbers?

@LuisMendo Yes assume < 10 good point

C# 226 221 Bytes
Saved 5 Bytes thanks to @Mukul Kumar and @aloisdg
Golfed:
string C(int n,int k){string o="",x;int j=1,i=1,m;for(;i<=n;i++){o+=string.Concat(Enumerable.Repeat("^ ",i)).PadLeft(n+i)+"\n";m=0;x="";if(i<n){while(m<i+1){if(j>k)j=1;x+=j+++" ";m++;}o+=x.PadLeft(n+i+1)+"\n";}}return o;}

Ungolfed:
public string C(int n, int k, WifeMode wifeMode = WifeMode.Maniacal)
{
  string o = "",x;
  int j = 1,i=1,m;

  for (; i <= n; i++)
  {
    o += string.Concat(Enumerable.Repeat("^ ", i)).PadLeft(n+i) + "\n";

    m = 0;
    x = "";

    if (i < n)
    {
      while (m < i + 1)
      {
        if (j > k) j = 1;
        x += j++ + " ";
        m++;
      }

      o += x.PadLeft(n + i + 1) + "\n";
    }
  }

  return o;
}

Testing:
Console.Write(new ChristmasTreeDecorating().C(20, 9));

                   ^
                  1 2
                  ^ ^
                 3 4 5
                 ^ ^ ^
                6 7 8 9
                ^ ^ ^ ^
               1 2 3 4 5
               ^ ^ ^ ^ ^
              6 7 8 9 1 2
              ^ ^ ^ ^ ^ ^
             3 4 5 6 7 8 9
             ^ ^ ^ ^ ^ ^ ^
            1 2 3 4 5 6 7 8
            ^ ^ ^ ^ ^ ^ ^ ^
           9 1 2 3 4 5 6 7 8
           ^ ^ ^ ^ ^ ^ ^ ^ ^
          9 1 2 3 4 5 6 7 8 9
          ^ ^ ^ ^ ^ ^ ^ ^ ^ ^
         1 2 3 4 5 6 7 8 9 1 2
         ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^
        3 4 5 6 7 8 9 1 2 3 4 5
        ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^
       6 7 8 9 1 2 3 4 5 6 7 8 9
       ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^
      1 2 3 4 5 6 7 8 9 1 2 3 4 5
      ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^
     6 7 8 9 1 2 3 4 5 6 7 8 9 1 2
     ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^
    3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9
    ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^
   1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8
   ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^
  9 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8
  ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^
 9 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9
 ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^
1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 1 2
^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^

Edit: I had a play casting int to ConsoleColor... Tis the season :)

MerryChristmas.gif

You can give i=1 in the int declaration and remove it from your for loop...

You can replace "\r\n" with "\n". It will run fine with core and mono.

Good to see a C# answer getting some love.

@jacksonecac Glad you enjoyed it. Couldn't resist once the idea came into my head :)

@MichaelMcGriff Just when I was starting to think I would never succeed at Code Golf using C#... :)

@tuskiomi Thanks :)

05AB1E, 29 27 24 bytes
Saved three bytes thanks to Adnan!
>GN„^ ×NÝNLO<+²%>ðý}\».c

>G                       For N in [1, ..., input[0]]
  N„^ ×                  Push a string of "^ " N times
       NÝ                Push [0, ..., N]
         NLO<            Compute the decoration offset, sum([1, ..., N])-1
             +           Add the offset value to each array cell
              ²%         Modulo input[1]
                >        Add 1 so that it is in range [1, k] instead of [0, k-1]
                 ðý      Join with spaces, now we have a string with the full decoration for the current layer
                   }     End for
                    \    Remove the last decoration
                     »   Join everything with newlines
                      .c Center all and implicitly display

Try it online!

I think you can replace NN>*; by NLO.

Of course! That's funny because I actually used N*(N+1)/2 intentionally to get the sum of consecutive integers starting from 1, but I completely forgot that 05AB1E had built-ins for that. Thanks!

Also, do you need the ï part now :p?

I don't think so ^^ .

JavaScript (ES6), 97 bytes
It seems like your wife really is maniacal, so this doesn't include any leading or trailing newline, nor any leading or trailing space. :-)
f=(n,k,x,s=`^
`)=>n--?(p=' '.repeat(n)+s,x?p.replace(/\^/g,_=>x++%k+1)+p:p)+f(n,k,x||k,'^ '+s):''

Demo

f=(n,k,x,s=`^
`)=>n--?(p=' '.repeat(n)+s,x?p.replace(/\^/g,_=>x++%k+1)+p:p)+f(n,k,x||k,'^ '+s):''

console.log(f(6, 5))

C++ 214 - 13 - 3 - 1 -1 - 10 = 186 bytes
golfed
#define s std::cout<<
int f(int n,int k){int N=++n,K=0,i=0,I;for(;i<n;i++,N--){for(I=N;I--;)s' ';for(I=0;I++<i&&i-1;)s' '<<(K++%k)+1;s'\n';for(I=N;I--;)s' ';for(I=0;I++<i;)s" ^";s'\n';}}

Thanks @ cyoce for saving 1 byte.
Thanks @ conor for chopping it down to 186!
Ungolfed + copy&compile
#include<iostream>
#include<conio.h>

#define s(a) std::cout<<a;

int main()
{
    int n,N,k,K=0,i,I;
    std::cin>>n>>k;
    N=++n;
    for(i=0;i<n;i++,N--)
    {
        for(I=N;I--;)

            s(' ')

        for(I=0;I<i&&i-1;I++)

            s(' '<<(K++%k)+1)

        s('\n')

        for(I=N;I;I--)

            s(' ')

        for(I=0;I<i;I++)

            s(" ^")

        s('\n')

    }
    getch();//or any func to pause the console
}

finally < 200...

Can you remove the space after #define s(a)?

@Cyoce thanks! I did not know about that!!!

186 bytes by changing the define to #define s std::cout<< and making according adjustments.

Woaa..thats nice.. never crossed my mind:p

Python 2, 133 bytes
n,k=input()
d=-1
j=' '.join
for i in range(1,n+1):s=' '*(n-i);print(['',s+j(`x%k+1`for x in range(d,d+i))+'\n'][i>1]+s+j('^'*i));d+=i

Clojure, 223 bytes
My first go at golfing with Clojure:
(let[r repeat](defn d[n k](apply str(concat(r(dec n)\ )"^\n"(flatten(for[i(range 2(inc n))m[nil true]](concat(r(- n i)\ )(butlast(interleave(if m(r\^)(rest(iterate #(inc(mod % k))(dec(/(* i(dec i))2)))))(r i\ )))"\n")))))))

When called like (println (str "\n" (d 6 5))) a newline makes it nicer on REPL:
     ^
    1 2
    ^ ^
   3 4 5
   ^ ^ ^
  1 2 3 4
  ^ ^ ^ ^
 5 1 2 3 4
 ^ ^ ^ ^ ^
5 1 2 3 4 5
^ ^ ^ ^ ^ ^

Un-golfed:
(defn tree-row [n k index mode]
  (concat
    (repeat (- n index) \ ) ; Left padding
    (butlast ; Removing trailing space
      (interleave
        ; Either printing carets or numbers...
        (if mode
          (repeat \^)
          ; Using "rest" as the iteration starts from a large value
          ; from which the modulo has not been calculated yet.
          (rest (iterate #(inc (mod % k)) (dec (/ (* index (dec index)) 2)))))
        ; ...and interleaved with spaces
        (repeat index \ )))
    "\n"))

(defn decorate [n k]
  (apply str (concat
               (repeat (dec n) \ ) "^\n"
               (flatten (for [index (range 2 (inc n)) mode [nil true]]
                          (tree-row n k index mode))))))

I had some issues with lazy sequences and nested lists but I was able to save some characters by not repeating repeat ;) and using \^ characters instead of "^" strings. I could also leave out surprisingly many spaces.

Nice first answer, welcome to the site!

Ruby 107 bytes
t=->(n,k){d=[*1..k]*n*n;o=0;(1..n).each{|b|s=' '*(n-b);b>1&&(puts(s+d[o,b].join(' '));o+=b);puts s+'^ '*b}}

Called like this
t.call(5,4)

Output:
    ^
   1 2
   ^ ^
  3 4 1
  ^ ^ ^
 2 3 4 1
 ^ ^ ^ ^
2 3 4 1 2
^ ^ ^ ^ ^

C, 170 bytes
i=0;d,j,l;t(n,k){char s[20],r[20];d=k-2;l=n;for(;i++<n;){for(j=0;j<l;++j)s[j]=r[j]=32;for(j=n-i;j<l;j+=2){s[j]=94;r[j]=(++d%k)+49;}s[l]=r[l++]=0;if(i-1)puts(r);puts(s);}}

Call with:
int main()
{
   t(5,4);
}

As a bonus, here's a 4-bit binary version:
m=0;b(n,k){char*a="000100100011010001010110011110001001";char s[20],r[20];d=k*4-2;l=n;for(;m++<n;){for(j=0;j<l;++j)s[j]=r[j]=32;for(j=n-m;j<l;j+=2){s[j]=94;r[j]=a[++d%(k*4)];}s[l]=r[l++]=0;if(m-1)puts(r);puts(s);}}


text:
Eating Skittles Like a Normal Person
Skittles are colored candy where there are 5 distinct flavors; grape, green apple, lemon, orange, and strawberry represented by (p)urple, (g)reen, (y)ellow, (o)range, and (r)ed respectively. I used to eat skittles by sorting all the different colors, then eating them in sequence. After getting a few weird looks in the office, I now pretend to eat them like a normal person. Your task is to emulate this:
Your code (full program or function) will receive an array of skittles (10x10) as input (in any reasonable format). This array will represent a pile of unsorted skittles. Your task is to "eat" them from your least favorite to favorite color. My preferred order is grape, green apple, lemon, orange, strawberry, but you are free to choose any order so long as it is consistently enforced (please list your preference in your submission so I can judge you for it). After eating each piece of candy your code will output (in the same format you take input) the remaining pile with the eaten piece replaced by a space. You will repeat until only your favorite remains. You may choose any skittle to eat (may be random or deterministic). Trailing spaces must be kept.
For example, your output sequence could look like this (using 5x5 for brevity and showing spaces as .)
start   1     2     3     4     5        n
.org. .org. .org. .org. .or.. .or..    ..r..
prgrg .rgrg .rgrg .rgrg .rgrg .r.rg    .r.r.
gggpr gggpr ggg.r ggg.r ggg.r ggg.r    ....r
oyyor oyyor oyyor oyyor oyyor oyyor    ....r
.r.p. .r.p. .r.p. .r... .r... .r...    .r...

This is code-golf, so shortest code in bytes wins
TL;DR Rules:

Submission may be full program or function
Input may be taken in any reasonable format (string, list, matrix, etc) by any reasonable method (STDIN, function arguments, etc.). However there must be some delineation between rows
Output must be produced in the same format as input by any reasonable method (STDOUT, function return, ect.). Intermediate output may or may not be delimited
First output shall be the first input
Trailing spaces must be preserved
Any color order may be used (list in your answer)
Any skittle of the current color may be eaten
Last output shall be only your favorite color and spaces
If possible, include a link to an online compiler to test your submission

so, we are supposed to eat least favorite first and leave the most favorites ?

@MukulKumar, correct, you want them to be better as you go along

Can we accept the skittles as a single 100-skittle string, no line breaks or anything?

@GabrielBenamy, No, there should be some delimiter between rows

Do intermediate outputs need to be separated by anything?

@Poke, intermediate outputs do not need to be delimited, but may be if desired

Suppose I am accepting input as a String. Since we are always receiving a 10x10 "grid" of skittles can I assume and hardcode the length of my input? In my specific case 109 is shorter than s.length

Related http://codegolf.stackexchange.com/questions/40913/eating-candy-in-the-correct-order

@Poke, yes, you may assume input is always 10x10

@wnnmaw How could you like the grape ones the least! Purple and red skittles are the best!

I considered entering this challenge, and then read "please list your preference in your submission so I can judge you for it".  I think that people are already too judgemental of my preferences!

I love this code challenge in light of the recent skittle's fame regarding The Donald http://www.nytimes.com/2016/09/21/us/politics/donald-trump-jr-faces-backlash-after-comparing-syrian-refugees-to-skittles-that-can-kill.html

Jelly, 16 14  13 bytes
Ṅ⁶ỤṪ$¦µQL>3µ¿

TryItOnline!
Most to least favourite, as for anyone serious about their O.C.D., is alphabetical!
Takes input and outputs as text (i.e. the rows are delimited by new lines).
3 bytes saved by reversing the direction and using a different method: grade up rather than finding characters from the alphabet.
How?
Ṅ⁶ỤṪ$¦µQL>3µ¿ - Main link: Skittle text
      µ    µ  - monadic chain separation
            ¿ - while
       Q      - unique items
        L     - length
         >3   - greater than 3 (until only new lines, spaces and 'g's remain)
Ṅ             -     print z and a line feed, yield z
    $         -     treat last two links as a monad
  Ụ           -         grade up (get indices of: new lines; spaces; gs; os; ps; rs; ys)
   Ṫ          -         tail (the last of those, so last y if there is one, else last r, ...)
 ⁶            -     space character
     ¦        -     apply at index (replace that index with a space)

Bash, 48, 46 bytes
UPDATE:

Saved two bytes by using raw parameters to printf;

Golfed
sed -nz "p;:a;`printf "s/%s/ /p;ta;" p g y o`"

Takes input at stdin, prints to stdout.
Eats purple, green, yellow and then orange.
An equivalent sed program would be:
p;:a;s/p/ /p;ta;s/g/ /p;ta;s/y/ /p;ta;s/o/ /p;ta

Sample output (delimiters are for clarity only)
-----
 org
prgrg
gggpr
oyyor
 r p
-----
-----
 org
 rgrg
gggpr
oyyor
 r p
-----
-----
 org
 rgrg
ggg r
oyyor
 r p
-----
-----
 org
 rgrg
ggg r
oyyor
 r
-----
-----
 or
 rgrg
ggg r
oyyor
 r
-----
-----
 or
 r rg
ggg r
oyyor
 r
-----
-----
 or
 r r
ggg r
oyyor
 r
-----
-----
 or
 r r
 gg r
oyyor
 r
-----
-----
 or
 r r
  g r
oyyor
 r
-----
-----
 or
 r r
    r
oyyor
 r
-----
-----
 or
 r r
    r
o yor
 r
-----
-----
 or
 r r
    r
o  or
 r
-----
-----
  r
 r r
    r
o  or
 r
-----
-----
  r
 r r
    r
   or
 r
-----
-----
  r
 r r
    r
    r
 r
-----

Try it online !

JavaScript (ES6), 74 75 74 bytes
Flavors are ordered as described in the challenge: grape, green apple, lemon, orange, strawberry.
Intermediate outputs are separated by newlines.
f=(s,n=3,r=s)=>(S=s.replace('oygp'[n],' '))!=s&&(r+=`
`+S)||n--?f(S,n,r):r

Test case
This test case is using the 5x5 example. Any other grid size should work as expected.

f=(s,n=3,r=s)=>(S=s.replace('oygp'[n],' '))!=s&&(r+=`
`+S)||n--?f(S,n,r):r

console.log(f(
` org
prgrg
gggpr
oyyor
 r p
`))

Python 2, 60 57 56 bytes
def f(s):print s;q=max(s);q>'g'and f(s.replace(q,' ',1))

repl.it
Recursive function that eats in reverse alphabetical order, leaving the greens for last.
Input s is a string with a row delimiter with an ordinal less than that of a 'g' (for example a new line or a comma).
The function prints its input, and then recurses if that input contains anything greater than a 'g', passing the input with the first occurrence of the maximum character replaced by a space.
(Almost a port of my Jelly answer.)

Perl, 53 46 + 2 = 48 bytes
Run with -0n
-10 bytes thanks to @Dada
Edit: Also thanks to @Dada for pointing it out, I forgot to print the input as the first output.  That's been fixed.
say;eval sprintf"say while s/%s/./;"x4,p,o,g,r

There's a little bit of trickery involved in this answer, so I'll break down what's going on.
First of all, Perl doesn't like multi-line parameters being passed.  The variable $/ is the input record separator, and whenever any input encounters the character stored in it, the interpreter terminates that input and begins a new input.  The default content is the newline character \n, which means that passing a multi-line string is not possible.  To do that, we must unset $/ from its contents.  That's where the -0 flag comes in:  setting -0 will store null in the variable $/, allowing the interpreter to read everything into the implicit variable $_ at once.
The next bit of trickery is the eval statement.  Just what exactly are we evaling?  We're evaling the result of the sprintf statement, which is broken down as follows:
The first thing that sprintf is passed is the string "say while s/%s/./;" repeated 4 times, so:
say while s/%s/./;say while s/%s/./;say while s/%s/./;say while s/%s/./;

Then, sprintf is passed four bareword characters, p,o,g,r, which are interpolated into the sprintf statement, replacing each instance of %s.  What we then get is the following string, which is passed to the eval function:
say while s/p/./;say while s/o/./;say while s/g/./;say while s/r/./;

Each while loop evaluates the expression s/[color]/./, which replaces the first instance of whatever color it is in the implicit variable $_ with a period.  If a substitution is made, it returns 1, otherwise it returns nothing.  Since s/// has side-effects, it modifies the original variable $_, whose contents are then printed via say.  Four versions of this loop are performed, replacing the purples, the oranges, the greens, and then the reds, leaving only the yellows.
The reason that the yellows are left is because y cannot be a bareword, because it's actually a function, and having a y instead of any of those letters would throw an error.  I could change this by putting quotes around it (+2 bytes), or using a capital Y and making the regex case-insensitive (+1 byte), but for code-golf, every byte counts, so I decided that I actually like lemon skittles the most.
TL;DR: Grape, Orange, Green Apple, Strawberry, Lemon

-0 flag should save you around 10 bytes

Also, I'm afraid you missed the rule First output shall be the first input

Good on you for sacrificing your own personal preference to save two bytes

C 145 - 5 - 18 - 1 = 121 bytes
#define l(a)for(a=0;a<10;a++)
i,j,k,b='a';F(char a[][11]){while(b++<'x')l(i)l(j)if(a[i][j]==b){a[i][j]=32;l(k)puts(a[k]);puts("");}}

ungolfed + pretty
#include<stdio.h>
#include<windows.h>
i,j,k;
F(char a[][11])
{
    char b='a';
    while(b++<'x')
        for(i=0;i<10;i++)
            for(j=0;j<10;j++)
                if(a[i][j]==b)
                {
                    system("cls");
                    a[i][j]=32;
                    for(k=0;k<10;k++)
                        puts(a[k]);
                    puts("");
                    Sleep(35);
                }
}
main()
{
    char a[][11]={
            "gggggggggg",
            "goooooooog",
            "goppppppog",
            "goprrrrpog",
            "gopryyrpog",
            "gopryyrpog",
            "goprrrrpog",
            "gopppppppg",
            "goooooooog",
            "gggggggggg"
    };
    for(i=0;a[i][j];)
        puts(a[i++]);
    F(a);
}

Here a[][11] means taking n-strings of length 11 where 1 char is required for termination so, technically only 10 visible chars.
order : alphabetical
this function checks for 'g' in the given input and eliminates it 1/1 then increments the variable holding 'g' until it finds a next match(probably letter 'o') and then eliminates those matched characters.
The downside is that this function is just too careful.So, if your skittels were of 26 different colors code-named from letters a-z, this function will handle that input too...

A lot more than 3 now :P

@Yodle yeah..thanks to macros you can define with #define. That cut down 19 bytes

Java 7, 139 135 130 151 138 135 bytes
void t(char[]s){int i,j=-1;for(;++j<5;)for(i=-1;++i<109;)if(j>3|s[i]=="yogp!".charAt(j)){System.out.println(s);if(j>3)return;s[i]=32;}}

Eats skittles in the order: Yellow, Orange, Green, Purple, Red
I guess this is better than 2 print statements >.>

Of course you can, your function is named skit :P -3 right there!

@Yodle oops! hahaha

If we're always receiving a 10x10 grid i could hardcode the length rather thatn using s.length

Don't we need to print it out once at the start before eating any :s

@Yodle that's why I'm eating "!" skittles first ;) ...wait i think i broke that trick

@Yodle regolfed things but still have two print statements...

HA! beat you too!

@MukulKumar nice job :] System.out.println is always a bummer in java, haha

we were equal If java ppl named that function puts instead of System.out.println...but java functions don't work that way, haha

Perl, 30 31 33 + 2 = 32 33 35 bytes
for$x(g,o,p,r){say;s/$x/ /&&redo}

Run with -n0 (2 byte penalty).
Apparently, I like to eat Skittles in alphabetical order, because the program turns out shorter that way. The program doesn't really need much explanation: -n0 reads the input implicitly (-n means "read input implicitly", -0 means "don't break input on newlines"); for$x(g..r) runs a loop with $x set from each letter from g to r in turn; say; prints the current input, after any mutations; s/$x/ / replaces one copy of $x (specifically, the first) with a space if possible; and &&redo repeats the code inside the braces (without advancing the loop counter) if the replacement was successful.
This program can easily be generalized to more flavours of Skittle without changing its length, and will work with a pile of any size.
Here's an Ideone link where you can test it. (Ideone doesn't allow you to specify command-line options, so I had to add a couple of lines at the start to set -n0 and the -M5.010 that you get for free.)

I'm not sure you are allowed to print several times the same pile of skittles several times.. (Actually I think you can't) Maybe switch to say;for$x(g..r){say while s/$x/ /} ?

Ah right. I originally had for$x(p,o,g,r) which wouldn't. say while is only one byte longer, and something that I'd considered as an alternative, so I can simply change to that.

And you need to start with a say; because the rules say First output shall be the first input

Oh, in that case I'll go back to the for$x(g,o,p,r) version which does copy the input first. (It takes some extra time searching if there are colours missing, but you wouldn't expect to have a colour missing in a pack of skittles.) For the record, the version with say; first would be 37 bytes.

Dada's original comment still stands, though--the code as it stands will print the same configuration twice in a row sometimes (once at the end of the greens and a second time at the beginning of the oranges, e.g.).

C#, 134 148 bytes
Order:  G -> O -> Y -> P -> R
I=>{var v=new string(I)+";\n";int i,j=0,c;for(;j<4;){c="goyp"[j++];for(i=0;i<I.Length;i++)if(I[i]==c){ I[i]='.';v+=new string(I)+";\n";}}return v;};

Used some similar things from @Poke's answer, currently a bit longer though since I need to convert the character array to a string ;(

HA! beat you by 3 chars!!!

Octave, 49 bytes
Eats skittles in alphabetical order, highest ascii-code first.
A=input("");do [~,p]=max(A(:));A(p)=32 until A<33

ES6 (Javascript), 72,71 bytes
EDITS:

Minus 1 byte, by using template literal with of

A non-recursive version in Javascript.
Golfed
s=>{r=s;for(c of`pogy`)while(s!=(s=s.replace(c,' ')))r+=`
`+s;return r}

Input and output are multiline strings, eats pills in the "purple=>orange=>green=>yellow" order.
Test

S=s=>{r=s;for(c of`pogy`)while(s!=(s=s.replace(c,' ')))r+=`
`+s;return r}

console.log(
S(` org
prgrg
gggpr
oyyor
 r p `)
);

Vim 57 55 bytes
Saving two bytes by removing my line delimiter.  Unfortunately it makes it a lot harder to read and check for correctness :(.
:set ws!
yGP/o
qqnr G9kyGGp@qq@q/y
@q/p
@q/g
@qdG

Unprintables:
:set ws!
yGP^O/o
^Oqq^Hnr G9kyGGp@qq@q/y
^O@q/p
^O@q/g
^O@qdG

TryItOnline
Eats in the order oypg, leaving all of the r's for the end :)

Python 3 - 141 99 75 bytes
s=input();[exec("print(s);s=s.replace(c,' ',1);"*s.count(c))for c in'orgy']

Program eats skittles in this order - Orange Red Green Yellow Purple.
Edit - Thanks to Flp.Tkc who helped to cut down 24 bytes!

Input -
ygro  goppr rppog rppog orgy

Output -
ygro  goppr rppog rppog orgy
ygr   goppr rppog rppog orgy
ygr   g ppr rppog rppog orgy
ygr   g ppr rpp g rppog orgy
ygr   g ppr rpp g rpp g orgy
ygr   g ppr rpp g rpp g  rgy
yg    g ppr rpp g rpp g  rgy
yg    g pp  rpp g rpp g  rgy
yg    g pp   pp g rpp g  rgy
yg    g pp   pp g  pp g  rgy
yg    g pp   pp g  pp g   gy
y     g pp   pp g  pp g   gy
y       pp   pp g  pp g   gy
y       pp   pp    pp g   gy
y       pp   pp    pp     gy
y       pp   pp    pp      y
        pp   pp    pp      y
        pp   pp    pp

I believe it can be further golfed as it looks very simple.

Looks like this is eating all of one color at a time whereas it should eat only one at a time

Also, you are taking input as a nest list, but producing strings, please modify your code such that both input and output are same format

@wnnmaw Changes made. I hope it is fine now :)

I know there's already a shorter solution, but staying with this algorithm you can golf it more to something like this.

I like how you specifically chose the ordering that led to orgy.

@QPaysTaxes :D. I've never eaten skittles. This is what I used to eat - Gems

MATL, 24 bytes
`tDX:t2#X>wx32w(10etun2>

Try it online! I prefer eating my skittles in reverse alphabetical order: green is my favourite colour. Explanation:
                           % Take input implicitly.
`                          % Start do ... while loop
 tD                        % Duplicate skittle pile (nom!), but give away for display
   X:                      % Put skittles in long row (like normal people do)
     t2#X>                 % Get least favourite skittle name and number in the row
          wx               % Discard the skittle name
            32w            % Put an eaten skittle on the stack (ASCII 32)
               (           % Put the eaten skittle back in the row of skittles.
                10e        % Shape the row back into a 10x10 array
                   tun     % Check the number of unique skittles
                      2>   % Loop while this number >2 (eaten skittles + favourite skittles)
                           % Implicit end of do... while loop.
                           % Display last iteration implicitly, since it's still on the stack.

Java 7, 125 bytes
Purple, Yellow, Green, Red, Orange. I'm enjoying that I get to pick my order in this solution. :D
Golfed
String s(String p){String r=p;for(String c:"pygr".split(""))for(;p.contains(c);r+="\n\n"+p)p=p.replaceFirst(c," ");return r;}

Ungolfed
String s(String p) {
    String r=p;
    for (String c : "pygo".split("")) {
        for (; p.contains(c); r += "\n\n" + p) {
            p = p.replaceFirst(c, " ");
        }
    }
    return r;
}

Try it here!
A different approach to the other Java answer by @Poke. We start by making a copy of the original string. Iterating through each color, we replace it each time it's found with a space, then append the new layout to the output string, returning after we've eaten everything but orange.
Notes
Seperation between steps is done with a double newline \n\n, but if the input grid can be taken with a trailing newline at the end, it can be shorted to just \n.

Haskell, 60 bytes
f x|(a,b:c)<-span(<maximum x)x,b>'g'=(:)<*>f$a++' ':c|1<2=[]

Input is a single string where the rows are separated with ,. Return value is a list of strings with all intermediate steps. Order is alphabetically, largest first, so green remains. Usage example:
*Main> mapM_ putStrLn $ f " org ,prgrg,gggpr,oyyor, r p "
 org ,prgrg,gggpr,o yor, r p
 org ,prgrg,gggpr,o  or, r p
 o g ,prgrg,gggpr,o  or, r p
 o g ,p grg,gggpr,o  or, r p
 o g ,p g g,gggpr,o  or, r p
 o g ,p g g,gggp ,o  or, r p
 o g ,p g g,gggp ,o  o , r p
 o g ,p g g,gggp ,o  o ,   p
 o g ,  g g,gggp ,o  o ,   p
 o g ,  g g,ggg  ,o  o ,   p
 o g ,  g g,ggg  ,o  o ,
   g ,  g g,ggg  ,o  o ,
   g ,  g g,ggg  ,   o ,
   g ,  g g,ggg  ,     ,

Simple recursion. Save the input list in for the return value, replace the largest element greater g with a space and call the function again. Base case is when there's no element left to remove.

Mathematica, 67 bytes
Most[#/.(i=0;#:>"."/;i++≤0&/@Characters@"ryop")&~FixedPointList~#]&

Eats reds, then yellows, then oranges, then purples.

Boy am I glad there isn't a built-in for this

QBasic, 125 bytes
Creative rules abuse!
DATA 71,89,82,79
?INPUT$(109)
DO
READ s
FOR r=1TO 10
FOR c=1TO 10
IF s=SCREEN(r,c)THEN SLEEP 1:LOCATE r,c:?" "
NEXT
NEXT
LOOP

This submission assumes a lot of things are okay:

Input and output are uppercase (GORPY)
Input is taken as 109 successive keypresses, which are not echoed to the screen until the last one is entered. At the end of each row except the last one, the user must enter a carriage return.
Instead of printing the Skittles pile multiple times, the program displays it on the screen with a 1-second pause before each step. (QBasic doesn't have output scrollback, so printing the pile multiple times would only give you the last 2 1/2 steps. Also, this method is a much better depiction of how your pile of Skittles evolves as you eat them.)
The program ends with an error.

I also have a 130-byte version that uses lowercase and doesn't error.
Here's a sample run in QB64, with 109 changed to 29 for a 5x5 grid:

Explanation
DATA 71,89,82,79 stores the ASCII codes of G, Y, R, and O.
?INPUT$(109) gets 109 keypresses from the user and prints them.
We then enter an infinite DO ... LOOP construct. Each time through, we READ the ASCII code of the current Skittle into s. Then we loop over rows and columns from 1 to 10. SCREEN(r,c) gets the ASCII code of the character on the screen at row r, column c. If this is equal to the current Skittle s, we SLEEP for one second and then print a space at r, c.
The main loop runs four times, removing the green, yellow, red, and orange Skittles. On the fifth iteration, READ errors because we're out of data.


text:
Gather the trash
You're looking at an avenue, and someone has left the trash out! You need to write a program to help fix the problem, by putting the trash into trashcans.
The task
The avenue is made up of a string of printable ASCII characters, e.g.:
[[](dust)[]] car ((paper)vomit) (broken(glass)) [[] (rotten) fence (dirty)

Some of the brackets here are unmatched; those are just decoys. What we care about are the matched sets of brackets.
A trash can is a string starting with [ and ending with ], and with internally matched brackets and parentheses. For example, [] and [[](dust)[]] are trash cans in the above string.
A trash bag is a string starting with ( and ending with ), and with internally matched brackets and parentheses. For example, (dust) is a trash bag in the above string.
It's possible that some of the trash bags are in trash cans already. However, at least one will have been left out, and we need to move the trash bags so that they're all inside trash cans. Specifically, for each trash bag that isn't currently inside a trash can (i.e. a substring of that trash can), we need to remove it from its current location in the string, and insert it into a location that's inside a trash can instead.
There's an additional rule here. Because we don't want to spend too much money on garbage collectors, and their route takes them along the avenue from right to left, we want to move each trash bag to the left (most important criterion, assuming we have to move it at all) and the shortest distance possible (as long as it's moved to the left). So for example, the only correct output for
[can1](bag)[can2]

is
[can1(bag)][can2]

(moving the bag just one character leftwards). Additionally, the bags need to stay in the same relative order:
[can](bag1)(bag2)

has to become
[can(bag1)(bag2)]

(i.e. you can't put (bag2) to the left of (bag1).)
Clarifications

There won't be any trash bags to the left of the leftmost trash can; it will always be possible to can all the trash by moving it to the left.
There will always be at least one bag to move. There might be more than one.
There will never be a trash can inside a trash bag (the cans are too valuable to just throw away).
If a bag is already inside a can, just leave it alone.
It's OK for the input and output to differ in trailing whitespace (including newlines).

Examples:

Input: [[](dust)[]] car ((paper)vomit) (broken(glass)) [[] (rotten) fence (dirty)
Output: [[](dust)[]((paper)vomit)(broken(glass))] car   [[(rotten)(dirty)]  fence
Input: []] (unusable) door  (filthy) car
Output : [(unusable)(filthy)]] door  car

Close voters, could you explain what you're finding unclear? The post's going to be hard to fix without an explicit guide as to what's wrong with it.

@ais523 I can't understand what the task is. Granted that might be because I'm tired but the current wording doesn't make much sense

Basically, for each substring that's inside parentheses but isn't inside brackets, move it to the left until it's also inside brackets.

Because this problem's getting repeatedly closed and reopened, I edited it with my understanding of the problem. Hopefully I haven't changed the problem in the process.

@ais523 This is fine by me. Thank you very much for all your editing.

What about trash cans that have trash in them that isn't in a trash bag already? Or is that something we don't need to worry about? For example: [unusable] instead of [(unusable)] when passing input.

@XavCo7 This is something that we don't need to worry about. We are only disturbed by items on the street, not by items inside a trash can.

JavaScript (ES6), 263 228 209 205 184 177 173 162 bytes
Any help with the code / regular expressions is greatly appreciated.
f=s=>s.match(t=/\[\[][\w()]*\[]]|\[]/g,g=/\([\w()]*\)/g,i=0,u=s.split(t).filter(e=>e)).map(e=>e.substr(0,e.length-1)+u[i].match(g).join``+`]`+u[i++].replace(g,``)).join``

An anonymous function; takes one String parameter, s, and returns the output.
/\[\[][\w()]*\[]]|\[]/g matches trash cans with nested trash bags, however I don't think it could check balanced brackets within trash bags if needed.