text:
"Break" a number
Origins
tl;dw (too lazy, didn't write): thought of it right before I fell asleep
Challenge
Breaking a number is defined as the following steps:

Take a number or a parseable data type as input in any allowed way.
Duplicate the first digit (64 -> 664)
Subtract 4 from the last digit (664 -> 660)
If the subtraction gets a negative last digit, move the negative sign (-) to the front of the number (73 -> 773 -> -771)
If the original number was negative, and the last digit becomes negative, remove all negative signs entirely. (-44441 -> 444443)
Output the number in any allowed way.

Here are a few test cases:
64 -> 660
73 -> -771
thisisnotanumber -> (handle the situation)
432188 -> 4432184
-83213 -> 883211 (two negative signs turn into a positive)
0 -> -4 (0 -> 00 -> 0-4 -> -04 -> -4)

Clarifications
Standard loopholes are disallowed.
By "parseable data type", I mean any data type (String, Float, etc) that can be converted into the number type your program/function uses (Integer, Number, etc).
Your answer can be a function or a program. In both cases, provide an explanation of the code.
If it is a function, give a usage of it.
Test cases (or online interpreter) would be a nice plus to your answer.
Preceding 0s (-04) aren't allowed.
Behavior should be exactly replicated from the test cases above.

Since it wasn't specified, I've assumed this is code golf and added the tag. If you intended a different winning criterion please edit to whatever you prefer.

@trichoplax i'd say falling gracefully is preferred, but hey, it's your code

The trouble with "preferred" is that it isn't defined in the scoring, so no one will do it if it is not required, as it will adversely affect their score.

@trichoplax added to question

Could you define what "fail gracefully" means in this context? Should code return a particular string or give an error message? I usually post to the sandbox first to go through this clarification process before posting to main. I can recommend it for future challenges.

@trichoplax defined

It's still unclear to me. Also, I don't think that required behavior for invalid inputs really adds something to the challenge.

Note to self: will put in sandbox first.

Are languages that don't have number types allowed to participate? (Since you require input to be either a number type or something that can be converted to a number type?)

Is -04 ok or does it have to be -4?

Batch, 105 bytes
@set/an=%1,n*=s=n^>^>31^|1
@set n=%n:~0,1%%n%
@cmd/cset/ad=n%%10,e=d-4,t=e^^^>^^^>31^^^|1,(n-d+e*t)*s*t

Alternatively the first line can be @set/as=%1^>^>31^|1,n=%1*s, also for 105 bytes. Explanation (without quoting metacharacters):
set /a n = %1               Get parameter
set /a s = n >> 31 | 1      Get sign of parameter
set /a n *= s               Get absolute value of parameter
set n=%n:~0,1%%n%           Duplicate the first digit
cmd /c                      Cause the final result to be printed
set /a d = n % 10           Get last digit
set /a e = d - 4            Calculate new last digit
set /a t = e >> 31 | 1      Get sign of new last digit
set /a e *= t               Get absolute value of new last digit
set /a (n - d + e) * s * t  Replace last digit and correct sign of result

Ruby, 88 87 + 3 (-n flag) = 90 bytes
Regex approach that reads lines from STDIN. Probably better solved with Perl if it's just regex like this?
Returns a nonsense NoMethodError if the input is not a number, which costs 14 bytes. If there's no need to worry about invalid inputs like that (the spec implied it needed handling) then the first line of the code can be removed.
-2 bytes from @Dada
+(~/^-?\d+$/)
sub(/\d/){$&*2}
sub(/.$/){$&.to_i-4}
p sub(/(-)?(.+)-/){$1?$2:?-+$2}.to_i

Nicely done. Your regex to check if the input is a number isn't quite right though, as it allows - anywhere, as well as inputs like ---. You'll probably want to use something like /^-?\d+$/ (which happens to be shorter by the way).

And indeed, the Perl solution is slightly shorter (66 bytes) : perl -pe '!/^-?\d+$/&¨s/\d/$&$&/;s/.$/$&-4/e;s/(-?)(.+)-/$1?$2:"-$2"/e;'. (which I won't post as it's your solution).

Pyth, 31 bytes
*i++hJja0QTPJa0K-eJ4T^_1x<K0<Q0

Naive implementation of the question.
Test suite.

Python, 79 78 Bytes
lambda x:"+-"[(int(x)<0)!=(int(x[-1])-4<0)]+x[1]+x[1:-1]+str(int(x[-1])-4)[-1]

anonymous lambda function, does all of the four parts, then adds them together. Expects input as a string with explicit sign e.g. "+64", output is of the same form. Throws ValueError if the string cannot be converted to an int.

C, 191 bytes
f(char*n){if(!isdigit(*n)&!isdigit(n[1]))return 0;char*m;strcpy(m+1,n);*m=m[1];if(*n==45)m[1]=m[2];int a=strlen(n);if(m[a]<52)m[a]=100-m[a],m--,*m=45;else m[a]-=4;return atoi(m[1]^45?m:m+2);}

Ungolfed with explanations:
f(char*n){
    if(!isdigit(*n)&!isdigit(n[1])) /* if first two chars aren't digits
                                     * if it was only the first one, negative numbers wouldn't pass
                                     * if it was only the second one, 0 wouldn't pass */
        return 0;        // handling
    char*m;
    strcpy(m+1,n);        // copy leaving space for doubling the number
    *m=m[1];              // double the first digit or the minus sign
    if(*n==45)            // if negative
        m[1]=m[2];        // double the first digit
    int a=strlen(n);      /* length of the nunber
                           * it doesn't let me save 2 bytes, i dunno why. */
    if(m[a]<52)           // if the last digit is less than 4
        m[a]=100-m[a],    // subtract 4
        m--,              // leave space for minus sign
        *m=45;            // put minus sign
    else
        m[a]-=4;          // subtract 4 from the last digit
    return atoi(m[1]^45?m:m+2); /* if there are two minus signs, skip them,
                                 * turn the string into an integer, and return */
}

source: Stack Exchange

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

sort: votes


text:
Teach me how to add!
Everyone knows how to add numbers by hand, right?––Well, I hope so, but for anyone who needs a quick reminder:
To add 17282 and 1342, you proceed as follows:

place the larger (value wise, not number of digits) number above the smaller number and match up the digits
17282
 1342

draw the plus sign (+) to the left of the equation on the second row. The plus sign must be flush with the left side.
 17282
+ 1342

draw a line of dashes (-) with one dash in each column of the digits of the first line
 17282
+ 1342
 -----

evaluate the expression and write the digits above each column if you need to 'carry' them
   1
 17282
+ 1342
 -----
 18624

Your output is what you get after applying step #4. You may have trailing whitespace, but there may not be any leading zeroes.
You must write a program or a function that prints or returns the output.
The input can be taken as either two separate inputs or an array with two items; the type of the inputs can be either string or integer.
This is code golf so shortest code in bytes wins!
Edit:
The largest number you could expect to receive as output/the sum is the largest integer that your system will display without exponents (thanks to Adám).
More examples:
Input:
1596, 8404
Output:
1111
 8404
+1596
 ----
10000

Input:
1776, 76
Output:
  11
 1776
+  76
 ----
 1852

Input:
123, 456
Output:
 456
+123
 ---
 579

What are the bounds on the input?

I think it should be the largest integer that you system will display in non-exponential format. CC: @dj0wns

I have edited the question to include Adám's suggestion respecting the upper bound on the input.

@dj0wns, see my edit

May we have an empty row at the start of the output if there is nothing to carry? I would argue yes, since on paper you have to have space free at the start of the process above the sum since you don't know if there will be carries or not.

@orlp, sure, optionally

Can we assume that the input will be in order of magnitude, i.e. the largest number will be input first followed by the smallest?

@Dopapp Actually, you may want to guarantee that the sum is displayable.

@R.Kap, no. See the last example.

@Niel This one is much simpler, having only two inputs.

Dyalog APL, 90 bytes
{⌽↑(⊂⌽s),⍨↓⌽(' + ',⍨' 1'⊃⍨l<⍴s),'-'⍪⍨w⍪⍨' 1'[10|(⍎¨(-l←⍴⍉w)↑s←⍕+/⍵)-(+/0 10⊤⍎)¨⊂[0]w←⍕⍪⍵]}

Takes list of two numbers as argument. Needs ⎕IO←0 which is default on many systems.
      f←{⌽↑(⊂⌽s),⍨↓⌽(' + ',⍨' 1'⊃⍨l<⍴s),'-'⍪⍨w⍪⍨' 1'[10|(⍎¨(-l←≢⍉w)↑s←⍕+/⍵)-(+/0 10⊤⍎)¨⊂[0]w←⍕⍪⍵]}
      f¨(17282 1342)(1596 8404)(1776 76)(123 456)
┌──────┬─────┬─────┬────┐
│   1  │1111 │  11 │    │
│ 17282│ 1596│ 1776│ 123│
│+ 1342│+8404│+  76│+456│
│ -----│ ----│ ----│ ---│
│ 18624│10000│ 1852│ 579│
└──────┴─────┴─────┴────┘

TryAPL online! Note that ⎕IO has been set and ⍎ has been emulated with e as ⍎ is banned from TryAPL for security reasons.
Ungolfed and explained

{ An anonymous function

w ← ⍕ ⍪⍵ w gets the textified vertical arrangement of the argument
    (the numbers to be added)
l ← ≢ ⍉w s gets the count of rows in the transposed w (i.e. the
    number of columns in w)
s ← ⍕ +/⍵ s gets the textified sum of the argument
' 1'[... index into the string " 1", so zeros give spaces, and ones
    give character 1s.

⊂[0] w enclose down, gets list of pairs of corresponding digits in
      the numbers
(+/ 0 10 ⊤ ⍎)¨ for each pair; make into digit(s), then sum
(⍎¨ (-l) ↑ s)- chop left-most digit of grand total to the width of
      the longest input, then make each character into separate number and
      subtract the column sums (if the sum does not add up to the total, the
      discrepancies are due to carrys, so this gives us each column's carry)
10| division remainder when divided by 10

] [end of indexing]
w⍪⍨ stack the input numbers below
'-'⍪⍨ stack a minus below each column
(' + ',⍨' 1'⊃⍨l<⍴s), prepend a space to the 2nd line, a
    plus to the 3nd, a space to the 4rd, and a one
    or space to the 1st – depending on if the sum is wider than
    the widest input (meaning we need a carry high over the plus )
⌽ mirror right-left (so left-justification will be to the right)
↓ make table into list of lines (so that differing line lengths are
    allowed
(⊂⌽s),⍨ append the sum
↑ combine list of lines into table (padding the right with spaces as
    needed)
⌽ mirror back to normal

} [end of function]`

Python 2.7, 201 192 161 155 167 164 182 bytes:
(Saved 2 bytes (192->190) thanks to TheBikingViking)
def Q(T,Y):O,D=sorted([T,Y]);E=len(`D`);print'%s\n %s\n+%*s\n %s\n %d'%(''.join([' ',i[0]][len(i)>1]for i in[`sum(map(int,u))`for u in zip(`D`,'%0*d'%(E,O))]),D,E,O,'-'*E,sum([T,Y]))

A named function that takes input in any order while outputting the correct answer in order of magnitude from top to bottom.
Try it Online! (Ideone)

Alternatively, if allowed to take input in order of magnitude (i.e. bigger number first, then smallest), then here is a much smaller solution which also uses a named function at 164 bytes:
def Q(T,Y):E=len(`T`);print'%s\n %d\n+%*d\n %s\n %d'%(''.join([' ',i[0]][len(i)>1]for i in[`sum(map(int,u))`for u in zip(`T`,`Y`.zfill(E))]),T,E,Y,'-'*E,sum([T,Y]))

Try this Version Online! (Ideone)

join takes any iterable, including a generator statement, so you can drop the outer pair of [, ] within the call.

@TheBikingViking Thanks! :)

You can also change E=max('T','Y',key=L) to E='max(T,Y)'. (I've used ' instead of backticks).

@TheBikingViking Yeah, I was just doing that.

Converting to a function with def(T,Y,L=len): saves a few.

Ruby, 192 191 bytes
Returns a multiline string. Input is an array with two strings.
Try it online!
->o{x,y=o.sort_by!(&:to_i).map{|e|e.reverse.chars}
a,b=o.map &:to_i
k=' '
y.zip(x).map{|z|i,j=z.map &:to_i
k=i+j+k.to_i<10?' ':1}.reverse*''+"
 %s
+%#{s=y.size}s
 %s
%#{s+1}s"%[b,a,?-*s,a+b]}

C (ansi), 392 384 Bytes
Saved 8 thanks to Value Ink (392->384)
Code:
char c[9],d[9],p[99]=" %s\n%0s\n+%0s\n %s\n%0i",*t,*b;k,r;main(a,i,m,n)char**i;{m=strlen(i[1]);n=strlen(i[2]);m==n?(strcmp(i[1],i[2])<0?t=i[2],b=i[1]:(t=i[1],b=i[2])):m<n?t=i[2],b=i[1]:(t=i[1],b=i[2]);n>m?:(n^=m,m=n^m,n=n^m);p[18]=p[5]=1+(p[10]=48+n);while(k<n)d[k]=45,a=(n-++k>=0)*(t[n-k]-48)+(m-k>=0)*(b[m-k]-48),r+=a*pow(10,k-1),c[n-k-1]=32+(a+c[n-k]%2>9)*17;printf(p,c,t,b,d,r);}

With Spacing:
char c[9],d[9], p[99] = " %s\n%0s\n+%0s\n %s\n%0i", *t,*b;
k,r;
main(a,i,m,n)char**i;{
    m=strlen(i[1]);     //get length of num 1
    n=strlen(i[2]);     //get length of num 2
                        //Set the larger number to the top pointer
    m==n?(strcmp(i[1],i[2])<0?t=i[2],b=i[1]:(t=i[1],b=i[2])):m<n?t=i[2],b=i[1]:(t=i[1],b=i[2]);
    n>m?:(n^=m,m=n^m,n=n^m); //set n to the longer length
    p[18]=p[5]=1+(p[10]=48+n); //set the buffers in the printf string

    while(k<n)     //for every number
        d[k]=45,   //add a dash
        a=(n-++k>=0)*(t[n-k]-48)+(m-k>=0)*(b[m-k]-48), //do the addition
        r+=a*pow(10.,(float)k-1), //add to result
        c[n-k-1]=32+(a+c[n-k]%2>9)*17;  //set 1 if carry or a space otherwise

    printf(p,c,t,b,d,r);    //print to stdio
}

Usage:
Compile Params:
gcc -O3 -ansi -lm -o add add.c

Input:
./add 2834 97829

Output:
  11 1
  97829
 + 2834
  -----
 100663

Notes:
Only works on numbers up to 8 in length - formatting is hard or I'm really bad at it
I feel like my approach was suboptimal

C lets you skip #include<stdio.h> like that? That's pretty cool. Intuitively, I don't think you need to cast (float)k-1 in your pow function because it should coerce to float anyways? But I'm unsure, maybe that's just C++.

@Value Ink, whether or not you can get away without includes is compiler specific behavior. In gcc I have only found one header I needed to include and that was openmp.h. You are correct on removing float, weird - I distinctly remember that not being the case

@ValueInk The header files are only needed for the prototypes of the functions. By default C compilers will assume the types of the parameters you give a function that hasn't been declared already are correct and always assume the return type is int. In the case of printf this fits perfectly, and the linker will find the function in the standard libraries with that signature after it has been compiled.

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


text:
Leo's Pokerface
Pokerface
Introduction
Leo enjoys playing poker, but his job at Tech Inc. is too demanding for him to learn how to play well. Leo, being a computer scientist, is not discouraged. He decides to take more time than it would have taken to just learn poker, and use it to write a poker bot to help him play better. But now Leo has a problem: in order to understand how to play a bit better, Leo needs to observe multiple games of multiple "people," but the "people" need different play styles to improve the quality and reality of the game.
The Challenge
Leo recalls that there is actually a website dedicated to programming challenges, and is enlisting your help! Your job is to write a program which plays "Pokerface" a modified version of 5-card poker. The program will take input as a 5-card hand in whatever format you wish, after which the program will output:

Exactly (case-sensitive) "true" "1" or "t" if the player wishes to exchange cards, any other non-empty output otherwise.
If true, list of indices of cards and/or card names the player wishes to exchange.
A single number between 0 and 3, which specifies how many additional cards the player wants.
Print out the hand the player wishes to use.

(See formatting below)
Pokerface rules

Since pokerface is a text-based adventure game, cards must be presented in a consistent way. Cards are represented by two character codes, the first character is the suit, and the second is the name of the card.

Cards:

2-9 = 2-9
10 = T
Jack = J
Queen = Q
King = K
Ace = A

Suits:

Spades = S
Clubs = C
Hearts = H
Diamond = D

So the ace of spades would be SA, the 10 of hearts is HT, the 4th of diamonds is D4, etc.

A single round of Pokerface consists of four steps:

The deck is reshuffled and a five card hand is dealt to each player.
Each player is given the chance to exchange as many cards as they want.
Each player is given the chance to gain up to three more cards.
Each player must reveal their best hand.

The best hand wins, and gains that player a point. In the event of a tie, both players get a point.
In a single game, ten rounds are played and the player with the most points wins and gains a single "win point." In the event of a tie, both players gain a win point.
Leo doesn't really have a large amount of money, so your bot can assume that this is a perfect world with no betting.

Hands

Hands are exactly 5 cards in length (initial input and final output).
Hands are ranked consistent with the rules described here.

Input / Output

Leo only knows Java, so your program must be executable via the Process API (command line), and use STDIN and STDOUT for input and output, respectively.
For each step of input and output detailed above, the input and output must each exist on one line.
There must be at least one trailing new line after the final output. (This is due to the way input is read from STDIN)
No extraneous input/output is allowed, other than trailing and leading spaces. The parser simply does not understand things like final_hand=... or draw 0.
When drawing, output is a single integer, when exchanging output is a list of integers and/or cards defined below, and when being dealt the original hand, output is a list of cards defined below.
All input/output numbers must be positive integers in base 10.
You may define the format for card input (see post format below).
True is defined as exactly "true," "1" or "t" and false is any other non-empty value.
During the exchange step:

Card indices must be output with at least one space between them (e.g. 3  4    0)
Card names must be output with at least one space between them (e.g. H4 S8)
Card names and indices may be mixed in the output (e.g. 0 H7 3 D3)
Trailing and leading spaces are allowed.
The input as a result of the player outputting the above will be formatted as specified by the bot.jlsc file, in the same order as requested

The number of cards a player wants to add to their hand can have leading and trailing spaces.
Hands must be output with at least one space between them (e.g. H4 D5  CA), trailing spaces and leading spaces are allowed.
Hands do not need to be output in proper order (e.g. H4 D4 C4 DA SA and H4 DA D4 SA C4 both represent 4, 4, 4, Ace, Ace, which is a full house).
If you wish to build a strategy by analyzing opponents hands, you may store data in a <botname>/data directory.

After competing bots have displayed their hands, they will be written to every bots data directory, in hands.txt, with each hand on a new line (separated by \n). The file will be encoded in US_ASCII.

After your bot requests new cards or exchange cards, the cards will be input depending on what format you specify in the bot.jlsc file.

Post Format

Every post must include two things:

The source code of your bot, or a link to a public facing repository.
A zip file containing:

The compiled/executable version of your bot (If the file is a .exe or other non-de-compilable file, please just include compilation instructions in your post).
A bot.jlsc file, see below (side note: the .jlsc extension is just because of a side project of mine, a configuration format. The file below matches the proper syntax, so don't worry).

The .zip file must be named the same as your bot.

If you don't have access to windows or some other zipping utility, or can't make a .zip for whatever reason, just include the text of the bot.jlsc file in your post

bot.jlsc file:
name= "Botty"
link= "example.com"
cmd= "java -jar Botty.jar"
input_hand= "${0} ${1} ${2} ${3} ${4}"
input_1= "${0}"
input_2= "${0} ${1}"
input_3= "${0} ${1} ${2}"
input_4= "${0} ${1} ${2} ${3}"

Where:

"cmd" is the windows command line command to run your bot. Note that your bot will be in directory <botname>, so adjust the command accordingly.
"name" is the name of your bot.
"link" is the link to your answer, you'll have to edit this in after posting.

"input_hand" is how you want the original dealing to be formatted (with ${#} representing cards 0-4).

"input_1" is how you want the input of one additional card to be formatted.
"input_2" is how you want the input of two additional cards to be formatted.
"input_3" is how you want the input of three additional cards to be formatted.
"input_4" is how you want the input of four additional cards to be formatted.

Specifics

These loopholes are disallowed (see 'common pitfalls')
You may not write a bot the will always output the best hand possible, every time, within the rule set. (i.e. no long-running brute-force bots, nothing should be quite as 'good' as LeoBot)
Your bot should run in ~100 ms or less (Lenient on this point, max of ~1 second)
Any output of the bot after its chosen hand will be ignored.
Standard loopholes are disallowed.
Yes, I know linux is better, but I have a windows PC, so be sure the compiled/executable version of your program can be run from the windows command line.

I already have python and java installed on my computer, but I'm willing to update to new versions and install other environments, so please specify what type of environment your program requires.

You may not write a bot which does the same thing as another bot in every case. Spam bots are allowed, but discouraged.
Your bot may only use cards it has. Cards lost through exchange or not dealt to begin with are invalid output in the final hand.
Input and output may only contain ASCII characters.

Tournaments

Tournaments will be run when I get the time (my schedule is nearly as packed as Leo's, so this my be a little infrequent. Sorry for the inconvenience.).
Bots will be pit against eachother in 4 person games, and there will be one game for each possible subset of bots (i.e. lots of games).

This process will be repeated five times.
Due to the way the tournament handler makes the groups of bots, up to three filler bots will be added to make the number of bots divisible by 4. These bots will simply return the hand they were originally dealt.

After every round and game is run, the scores of the bots will be computed based on the number games they won.

Multiple bots can share a position (ties for first won by first posted).

After a tournament finishes, the scores will be appended to the bottom of this post.

Scoring
Normal KoTH rules. The bot(s) that win the most games win the challenge.
LeoBot
Leo's bot is pretty smart. It doesn't exchange any cards, that's too hard, but it does request the maximum number of additional cards, and it determines the best possible hand it can make, and plays that hand. The main logic of leobot is below.
package com.gmail.socraticphoenix.pokerface.leobot;

import com.gmail.socraticphoenix.pokerface.lib.card.Card;
import com.gmail.socraticphoenix.pokerface.lib.card.Deck;
import com.gmail.socraticphoenix.pokerface.lib.rule.HandRegistry;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class LeoBot {

    public static void main(String[] args) {
        List<Card> hand = new ArrayList<>();

        Scanner scanner = new Scanner(System.in);
        hand.addAll(Card.parseHand(scanner.nextLine()));
        System.out.println(false);

        System.out.println(3);
        hand.addAll(Card.parseHand(scanner.nextLine()));

        List<List<Card>> possibleHands = LeoBot.getSubsets(hand, 5);
        System.out.println(Deck.toString(possibleHands.stream().sorted((a, b) -> HandRegistry.determineWinner(b, a).comparable()).findFirst().get()));
    }

    private static <T> void getSubsets(List<T> superSet, int k, int idx, List<T> current, List<List<T>> solution) {
        if (current.size() == k) {
            solution.add(new ArrayList<>(current));
            return;
        }
        if (idx == superSet.size()) return;
        T x = superSet.get(idx);
        if (!current.contains(x)) {
            current.add(x);
        }
        getSubsets(superSet, k, idx + 1, current, solution);
        current.remove(x);
        getSubsets(superSet, k, idx + 1, current, solution);
    }

    public static <T> List<List<T>> getSubsets(List<T> superSet, int k) {
        List<List<T>> res = new ArrayList<>();
        getSubsets(superSet, k, 0, new ArrayList<T>(), res);
        return res;
    }

}

Note that if LeoBot consistently wins the tournaments, and there are a good amount of entries, I'll stop including him in the running.
Important Links

Tournament bot and library
Leo's bot

Disclaimer
Leo and Tech Inc. are story elements and any resemblance to real-life companies or people is purely unintentional. (However, when Leo's 'situation' adds or subtracts conditions from the question, those are actually part of the question...)

Wait, isn't this a [tag:king-of-the-hill] question?

Cuz I forgot the tag...

Surely a dumb bot (that is shortest in bytes) is going to win this competition.

@Nathan Merrill That's probably true... if it becomes a problem I'll weight the tournament position more...

@SocraticPhoenix I'd highly recommend weighting it now or never.  It'd be really unfair to players to adjust the scoring after submission are already ranked.

Okay, adjusting now

This challenge definitely needs more detail. It is unclear how hands are scored (I assume standard poker rules, but maybe some people don't know those, or I'm wrong), what exactly a best hand is (is it all cards, some cards, a choice of the number of cards), why someone wouldn't want to receive more cards (because not drawing cards results in less chance of winning (less good hand, I think), and less info), is the deck shuffled after a round, etc.

@DestructibleWatermelon better? Just FYI, this was on sandbox for like 2-3 days... No one commented. I mean, it's all cool though

Well, I can definitely understand that. I got feedback about my challenge as it went out of the sandbox. A little bit annoying, I must say. Behind the issues I stated, you have a good challenge here. I might participate later, if I feel that I'm capable of making a bot.

Do we have to choose the best hand at the end of our turn? In other words, we are allowed to choose any hand we so desire, right?

Also, @NathanMerrill is probably still right about the dumb bot winning. After investigating cjam somwhat, a 5 byte program "f"q+ fulfils minimum requirements. If there are 10 people in competition, this probably beats all non-dumb entries (non-dumb entry probably has >75 chars, 5*10(score of dumb bot, coming last)=50<75 (score of very small smart bot (coming first))). Thusly, you should probably remove codegolf from this challenge

even if Cjam cannot be used, the point stands that dumbbots will be a reasonable strategy, and removing codegolf removes all the difficulties of balancing size VS performance

@R.Kap you can choose whatever hand you like.

@DestructibleWatermelon if I do remove code golf, people may just write longer programs that brute-force the hands... Bad for performance and bad for business. I'll try to brainstorm some other method, cuz I don't want people just writing bots that can do everything...

The challenge was kind of supposed to be balancing size and performance...

Ooh, what.abput this: players are ranked in two separate lists, one for bytes and one for tourney. The final place is determined by adding their places from each list.

After Leo's successful pokerface, comes Leo's Fortune

Could you post LeoBot as an answer? I think [tag:codegolf] shouldn't be a factor and you should ask for a maximum runtime. See other [tag:king-of-the-hill] questions and http://meta.codegolf.stackexchange.com/q/8900/32686

Killed code-golf to death....

What does exchanging do? If a bot asks to exchange all 5 cards, then asks for 3 new cards, will they be left with a 3 card hand?

No. When a bot exchanges a card at index x, it is dealt a new card to replace that card. So if a hand is HA H1 H2 H3 D9, the bot may ask to exchange 4 (fifth card, 0-indexed), and receive input like so: H4. The hand then becomes HA H1 H2 H3 H4 and the bot has a wonderful straight flush. Of course, the new card dealt is random, so it won't always help.

@ValueInk forgot to tag you. See above comment.

@SocraticPhoenix When are the results going to come out for who won?

@Magenta soo... about that. The controller code wasn't work, and then I cleared out my old projects, but I accidentally deleted the controller too... so never? Sorry...

(Python), Pairbot, not quite competing (I don't know how to make cmd commands and stuff)
Pairbot will compete as soon as someone assists with the bot.jlsc, and zip files etc.

Pairbot knows that you don't always get good hands. He knows good hands are rare. Pairbot knows pairs and other duplicates are some of the best hands. Pairbot also knows the lowest hand you can get is a seven high, so he knows if he has 6 high, that's actually a straight (pairbot doesn't know why he knows that). He also knows if his lowest card is 10, (with no pairs), that's also a straight (pairbot knows he can get royal flush this way). Pairbot checks mainly for same number dupes, but also checks for two types of straights in special cases.
card_values={"2":2, "3":3, "4":4, "5":5, "6":6, "7":7, "8":8,
             "9":9, "T":10, "J":11, "Q":12, "K":13, "A":14,}
straight=False
def card_valuing(item):
    return card_values[item[1]]

input_list=input().split()
pairs_to_keep=[]
for item in input_list:
    if sum(item[1]==card[1] for card in input_list)>1:
        pairs_to_keep+=[item]
cards_to_remove=input_list
for item in pairs_to_keep:cards_to_remove.remove(item)#we want to remove all non pairs
hand=pairs_to_keep
if pairs_to_keep==[]:
    input_list.sort(key=card_valuing, reverse=True)
    if card_values[input_list[0][1]]==6:
        straight=True
        hand=input_list
    elif card_values[input_list[-1][1]]==10:
        straight=True
        hand=input_list
    else:
        print("true\n"+" ".join(input_list[1:]))
        hand+=input_list[0]+input().split()
elif input_list!=[]:
    print("true\n"+" ".join(input_list))
    hand+=input().split()
else:print(0, end=', ')
if straight:print("0\n0\n"+" ".join(hand))
else:
    print("3")
    hand+=input().split()
    same_number_dict={} #holds the amount of each type (A, 2, 3, etc.)

    def dict_value(item):
        return int(same_number_dict[item[1]])*100+card_values[item[1]]

    for card in hand:
        same_number_dict[card[1]]=sum(card[1] == item[1] for item in hand)

    hand=list(sorted(hand, key=dict_value, reverse=True))
    final_hand =[]
    last_number=hand[0][1]
    hand_taken=0
    while hand_taken < 5:
        if last_number==hand[0][1]:
            final_hand+=[hand[0]]
            hand=hand[1:]
            hand_taken+=1
        else:
            for card in hand:
                if same_number_dict[card[1]]>5-hand_taken:
                    same_number_dict[card[1]]=5-hand_taken
            hand=list(sorted(hand, key=dict_value, reverse=True))
            last_number=hand[0][1]
    print(" ".join(final_hand))

Format for input is the same as in the example: separated by spaces

If Socratic Phoenix could assist with the file stuffs, that would be good

Clever! So the file you'll want is here, I'm going to edit the main post to make the actual .zip optional...

Also, +1 for FGITW

More like FGITLOSG (Fastest gun in the land of slow guns).

True. I'm not sure that the input/output is in the proper form. When I enter a hand, the program prints "True" and then its current hand. I believe you wan to just print "false" as the "True" indicates you want to exchange cards. Secondly, the program needs to print a single integer when drawing, or integers separated by spaces when exchanging. Not "draw 0." I'll try to clarify the main post.

[So does it count as competing now?] didn't see new messages. I will correct bot right away

@SocraticPhoenix, you are mistaken about the trading: it just trades all non-dupes but one, if there are no pairs, otherwise all non-dupes. Also, is it necessary to use card indices instead of the card name? I thought that would be ok

I fixed the draw issue, which is now a single int, but I do not understand why I cannot use card names instead of integer indices. I shouldn't expect it too difficult to implement, if that is the issue, and it is a lot more intuitive for most answers

You're probably right... I'll change it to allow exchanging via card names. However, it still looks like your printing "True" followed by the hand, where it probably should be "true", lowercase w/ no extraneous output

Okay... Your earlier comments weren't showing up. You just have some output issues. "true" must be on its own line, followed by the list of cards/indices, which must be separated by one or more spaces, not commas. Oh, and the true thing is case-sensitive

Case sensitive? It's just that python uses cap'd True.  Anyway, I will fix this now. Thank you.

If someone doesn't make another bot soon I might have to.

It looks good to me! Someone will probably answer soon. I might actually place a bounty... Still considering that. I'll run a test tournament tomorrow with PairBot and LeoBot, just to make sure everything is working right.

Plumber, Python
Plumber is all about flushes. Plumber also prioritises higher value cards (meaning he can sometimes get straight flushes, especially royal ones (should they occur).) Plumber is pretty much messed if he doesn't get a flush, except that he might be lucky enough for a straight. Plumber will get flushes about 20% of the time, if calculations by Sherlock9 are correct
hand=input().split()
suit_in_hand={"S":0,"C":0,"D":0,"H":0}
card_values={"2":2, "3":3, "4":4, "5":5, "6":6, "7":7, "8":8,
             "9":9, "T":10, "J":11, "Q":12, "K":13, "A":14,}
def value_sort(x):
    return card_values[x[1]]
def suit_sort(x):
    return suit_in_hand[x[0]]

for card in hand:
    suit_in_hand[card[0]]+=1

hand.sort(key=suit_sort, reverse=True)

print(" ".join(hand[suit_in_hand[hand[0][0]]:]))
hand=hand[:suit_in_hand[hand[0][0]]]

for new_card in input().split():
    hand+=[new_card]
    suit_in_hand[new_card[0]]+=1

print(3)

for new_card in input().split():
    hand+=[new_card]
    suit_in_hand[new_card[0]]+=1
hand.sort(key=value_sort, reverse=True)
hand.sort(key=suit_sort, reverse=True)
print(" ".join(hand[:5]))

Also takes input separated by spaces like other my two bots

Note: I've changed the output rules slightly due to a bug in my own tournament program. There must now be at least one trailing new line after your final output.

LadyGaga, Python 3

Is somewhat blind to suits
Has a dress full of bugs
And likes to play Poker Face once in a while
from math import ceil as f
M=lambda A:max(set(A),key=A.count)
K=lambda A:A.count(M(A))
O=lambda A:range(len(A))
J=lambda A:A[0]+str(U(A[1]))
X={"2":2,"3":3,"4":4,"5":5,"6":6,"7":7,"8":8,"9":9,"T":10,"J":11,"Q":12,"K":13,"A":14}
def V(A):return([A[0]]+[int(X[A[1]])])
def U(c):
 if c==10:c='T'
 if c==11:c='J'
 if c==12:c='Q'
 if c==13:c='K'
 if c==14:c='A'
 return(c)
def P(A):
 S=[];C=[];t=len(A)
 for x in A:S.append(x[0]);C.append(x[1])
 B=[0]*9;q=len(set(C));p=K(C);D=list(set(C));D.sort()
 B[2]=1/f(13**(4-p));B[6]=1/f(13**(3-p));B[8]=1/f(13**(2-p))
 if (p,q)==(2,4):B[3]=1/1100;B[7]=5/34
 if (p,q)==(3,3):B[3]=1/169;B[7]=1/169
 if (p,q)==(4,2):B[3]=1/13;B[7]=1
 if (p,q)==(2,3):B[3]=5/169;B[7]=1
 if (p,q)==(3,2):B[3]=1;B[7]=1
 for x in O(D):D[x]-=x
 j=M(D);h=K(D)-5;B[5]=13**h
 for x in O(D):
  if j+h<D[x]<j-h and D[x]!=j:B[5]*=13
 W=K(S);B[4]=(4**(W-t))*(13-W)/52
 return(B,M(S))
def E(B,h,u):
 x=0;D=[];C=[]
 while 1:
  k=list(C)
  C=[]
  while 1:
   p=list(B);del p[x]
   if len(D)==3:break
   if P(p)[0][h]>=P(B)[0][h]:C.append(B[x])
   x+=1
   if x>len(p):break
  if len(C)==0:break
  for x in O(C):
   if k==C or not((u in C[x])and(len(C)-1)):D.append(C[x]);del B[B.index(C[x])]
 return(D)
s=input()
A=s.split(' ')
b=list(map(V,A));G,u=P(b);F=[649739,72192,4164,693,508,254,46.3,20,1.4];H=[]
for x in O(F):F[x]=1-((1-(1/F[x]))**4)
for x in O(F):H.append(G[x]-F[x])
Y=H.index(max(H));p=[]
e=E(list(b),Y,u);g=list(e)
for x in O(e):e[x]=J(e[x])
print(' '.join(e)if len(e)else'')
for x in g:
 if x in b:del b[b.index(x)]
s=input()
if len(s):
 A=s.split(' ')
 b+=list(map(V,A))
print(3)
s=input()
A=s.split(' ')
b+=list(map(V,A));G,u=P(b);H=[]
for x in O(F):H.append(G[x]-F[x])
Y=H.index(max(H))
e=E(list(b),Y,u)
for x in e:
 if x in b:del b[b.index(x)]
for x in O(b):b[x]=J(b[x])
print(' '.join(b[:5]))
print()

(I/O) modeled after PlumberBot
-Edit: Extensive bugfixes thanks to Destructible Watermelon
-Edit: Due to new rules, a trailing newline after the final output

You might want to use a dictionary instead of all that complicated stuff for the card values

Anything that has been packed into an array already has been to my knowledge. Which section of code could I shorten?

def V(A):  b=[A[0]];c=A[1]  if c=='T':c=10  if c=='J':c=11  if c=='Q':c=12  if c=='K':c=13  if c=='A':c=14  return (b + [int(c)])
to
x={"2":2,"3":3,"4":4,"5":5,"6":6,"7":7,"8":8,"9":9,"T":10,"J":11,"Q":12,"K":13,"A":14,} def V(A):return(A[0] + x[A[1]])

Pairbot is only just longer than your program, and that's because it's readable

I know. Bad codegolfing habits.

How does this bot behave? It's too unreadable to tell

evaluates rough probabilities on winning based on the hand at hand, and goes through (four of a kind, flush, straight, 3 of a kind, 2 pair, pair) to find out which is more likely, and chooses that one

Also, how I/O works: First, you get a list of five cards, which are delimited how you like, default space delimited. Then you are expected to output whether you want to exchange any cards (output true or 1 if so, else 0 or false), and on a new line print the ones you wish to exchange if you do, then get input of new cards from the exchange, then print the amount of additional cards you want to draw (0 to 3), then get input if you want any cards. The bot is relaunched every round

I'm not sure whether or not to feel threatened by this bot, with its fancy risk analysis

If you saw the quality of that math that this has, you would not feel that way.

Should we move this to chat?

I would think that if you would think that

Let us continue this discussion in chat.

Note: I've changed the output rules slightly due to a bug in my own tournament program. There must now be at least one trailing new line after your final output.

LuckyBot, Python
Pairbot invited his buddy Luckybot, who sprang for the chance. Luckybot had watched a lot of fictional poker, and reckoned he'd figured out the secret to poker: luck. Everyone knows the real pros (James Bond, for example) really rely and getting good hands, not skill. Hence, he doesn't look at his cards, and tries to pack as much good luck into them as possible

lucky_number=24 #IMPORTANT

from random import randint as roll

def lucky_shuffle(i):
    return sorted(i, key=lucky_dice)

def lucky_dice(seed):
    return sum(roll(1,6)for i in range(roll(1,6)))

hand=lucky_shuffle(input().split())

throw=lucky_dice(lucky_number)%5
print("true\n"+" ".join(hand[throw:]))

hand=hand[:throw]+lucky_shuffle(input().split())

hand=lucky_shuffle(hand)
hand=lucky_shuffle(hand)
#One more for good luck
hand=lucky_shuffle(hand)
#maybe one more
hand=lucky_shuffle(hand)
#I got a good feeling about this one
hand=lucky_shuffle(hand)

hand=lucky_shuffle(hand)
#I think I'm done
hand=lucky_shuffle(hand)
#for real this time

hand=lucky_shuffle(hand)

print("3")
hand=hand+lucky_shuffle(input().split())
#All right, I got a real good feeling about this,
#let me shuffle some more luck into them cards!

def extra_super_lucky_shuffle(item):
 return lucky_shuffle(lucky_shuffle(lucky_shuffle(\
    lucky_shuffle(lucky_shuffle(lucky_shuffle(\
        lucky_shuffle(lucky_shuffle(lucky_shuffle(item)))))))))

def super_duper_extra_ultra_uber_luckyshuffle(item):
    return extra_super_lucky_shuffle(extra_super_lucky_shuffle(\
        extra_super_lucky_shuffle(extra_super_lucky_shuffle(item))))

hand=super_duper_extra_ultra_uber_luckyshuffle(super_duper_extra_ultra_uber_luckyshuffle(hand))
#cmoooooooooooooooon
print(hand[:5])


text:
Partial factorisations of a positive integer
A collection of positive integers d_1 d_2 ... d_k is a factorisation of a positive integer n if
d_1 * d_2 * ... * d_k = n

Each positive integer has a unique prime factorisation, but in general they also have factorisations in which some of the terms are composite. E.g.
12 = 6 * 2 = 4 * 3 = 3 * 2 * 2

Write a program, function, verb, or similar which takes as input a single positive integer and returns or prints a complete list of its distinct factorisations. The factorisations may be produced in any order, and their terms may be in any order, but no two should be permutations of each other. Factorisations may not include 1 with two exceptions: for input n you may give the factorisation n*1 instead of n; and for input 1 you may give the factorisation 1 instead of the empty list.
You may assume that the input will be in the range of a signed 32-bit integer. If the output is as a string, there should be a clear distinction between the delimitation of numbers within a factorisation and the delimitation of the factorisations, but it is not necessary (for example) for the factors to be joined with an *.
Your code should be capable of handling any valid input within 10 minutes on a reasonable desktop machine.
Examples
1                  [[]]
                or [[1]]
                or [[1 1]]

7                  [[7]]
                or [[7 1]]
                or [[1 7]]

12                 [[12] [6 2] [4 3] [2 3 2]]
                or variants

16                 [[2 2 2 2] [2 2 4] [2 8] [4 4] [16]]
                or variants

901800900          a list of 198091 factorisations

1338557220         a list of 246218 factorisations

Can you post the list of factorisations of 901800900 and 1338557220 somewhere where we can check them? My code is giving me 2048 and 1024 factorizations for those numbers, respectively, and I'm not sure why.

@Sherlock9, will do that when I get home. What I can do with an online generator is to give you a valid output for 5336100.

This reminds me of a ProjectEuler challenge (unfortunately I don't remember which). But there you had to count the number of factorizations instead of listing them.

Related OEIS: A001055

Haskell, 56 bytes
_!1=[[]]
i!n=[j:f|j<-[i..n],mod n j<1,f<-j!div n j]
(2!)

(2!)(1338557220::Int) prints in five minutes on my laptop, when compiled with ghc -O3.
Haskell, 62 bytes, but much faster
i!n|i*i>n=[[n]]|0<1=[i:f|mod n i<1,f<-i!div n i]++(i+1)!n
(2!)

(2!)(1338557220::Int) prints in a quarter of a second on my laptop, when compiled with ghc -O3.

How do I test this? ghc gives me Parse error: naked expression at top level and ghci gives me parse error on input `='

@PeterTaylor Replace the function (2!) with the program main = print ((2!) (1338557220::Int)), compile with ghc -O3 factor.hs, and run with ./factor.

Pyth, 29 bytes
Msam+Ldgd/Hdf!%HT>S@H2tG]]Hg2

M                                def g(G, H):
                   @H2             square root of H
                  S                1-indexed range up to floor
                 >    tG           all but first G − 1 elements
            f                      filter for elements T such that:
              %HT                    H mod T
             !                       is false (0)
   m                               map for elements d:
       gd/Hd                         g(d, H/d)
    +Ld                              prepend d to each element
  a                     ]]H        append [[H]]
 s                                 concatenate
                           g2Q   print g(2, input)

Try it online
Runs in twenty seconds for 1338557220 on my laptop.

@PeterTaylor The usual way: pyth factor.pyth (or pyth -c 'Msam+Ldgd/Hdf!%HT>S@H2tG]]Hg2'), providing 16 on stdin. Make sure you are using a current version of Pyth; implicit Q was added in March. I can’t imagine how you might be getting division by zero, though.

Arrrrgh. I was using " instead of ', and bash was expanding the !% to something else.

Python, 252 313 312 311 145 141 137 135 103 84 83 bytes
This is largely based on Anders Kaseorg's Pyth answer. Any golfing suggestions welcome. Try it online!
Edit: 19 bytes golfed thanks to Dennis. Fixed a typo in the code and added a TIO link.
g=lambda n,m=2:[[n]]+[j+[d]for d in range(m,int(n**.5)+1)if n%d<1for j in g(n/d,d)]

Ungolfed:
def g(n, m=2):
    a = [[n]]
    s = int(n**.5) + 1
    for d in range(m, s):
        if n%d == 0:
            for j in g(n/d, d):
                a.append([d]+j)
    return a

**.5 gets rid of the import.

JavaScript (ES6), 83 bytes
f=(n,a=[],m=2,i=m)=>{for(;i*i<=n;i++)n%i<1&&f(n/i,[...a,i],i);console.log(...a,n)}

Only borrowed @AndersKaseorg's square root trick because it ended up saving me bytes overall. Prints 1 for an input of 1, otherwise doesn't print 1s.

Ruby 1.9+, 87 89 87 bytes
This answer is based on Anders Kaseorg's Pyth answer. This code only works for versions after Ruby 1.9, as stabby lambdas -> were only introduced in 1.9. Any golfing suggestions are welcome.
g=->n,m=2{(m..Math.sqrt(n)).select{|i|n%i<1}.flat_map{|d|g[n/d,d].map{|j|[d]+j}}+[[n]]}

Ungolfed:
def g(n, m=2)
  a = [[n]]
  s = (m..Math.sqrt(n))
  t = s.select{|i|n%i<1}
  t.each do |d|
    g[n/d,d].each do |j|
      a.push([d]+j)
    end
  end
  return a
end

Does this require a particular version of Ruby? With 1.8.7 I get a complaint about g[n/d,d]: wrong number of arguments (0 for 1)

Apparently stabby lambdas -> were introduced in Ruby 1.9. I'll edit the answer to show the version number required.

Ok, thanks. I'm still curious about g[n/d,d]. g(n/d,d) is more backwards-compatible.

Ah, the f[n] is required to call stabby lambdas and Ruby lambdas in general. f(n) and f n calls require def and end. More info here and here

J, 52 bytes
[:~.q:<@/:~@(*//.)"$~#@q:_&(;@]<@(,~"{~0,#\@~.)"1)}:

Not as efficient as it could be since some factorizations may be repeated and a final pass has to be done after sorting each factorization and then de-duplicating.
Try it online! (But try to keep the input values small).
On my desktop, the timings are
   f =: [:~.q:<@/:~@(*//.)"$~#@q:_&(;@]<@(,~"{~0,#\@~.)"1)}:
   timex 'r =: f 1338557220'
3.14172
   # r
246218
   timex 'r =: f 901800900'
16.3849
   # r
198091

Explanation
This method relies on generating all set partitions for the prime factors of the input integer n. The performance is best when n is square-free, otherwise duplicate factorizations will be created.
[:~.q:<@/:~@(*//.)"$~#@q:_&(;@]<@(,~"{~0,#\@~.)"1)}:  Input: integer n
                                                  }:  Curtail, forms an empty array
                       q:                             Prime factorization
                     #@                               Length, C = count prime factors
                         _&(                     )    Repeat that many times on x = []
                                 (            )"1       For each row
                                            ~.            Unique
                                         #\@              Enumerate starting at 1
                                       0,                 Prepend 0
                                  ,~"{~                   Append each of those to a
                                                          copy of the row
                               <@                         Box it
                            ;&]                         Set x as the raze of those boxes
                                                      These are now the restricted growth
                                                      strings of order C
    q:                                                Prime factorization
            (    )"$~                                 For each RGS
               /.                                       Partition it
             */                                         Get the product of each block
        /:~@                                            Sort it
      <@                                                Box it
[:~.                                                  Deduplicate


text:
Coin Change Problem Enumeration Using N Coins And Each Denomination
The coin change problem is very well documented. Given an infinite supply of coins of denominations x_1 to x_m you need to find the number of combinations which add up to y. For example, given x = {1,2,3} and y = 4 we have four combinations:

{1,1,1,1}
{1,1,2}
{1,3}
{2,2}

Introduction
There are several variations of the coin change problem. In this variation  we have two additional restrictions:

Every denomination must be used at least once.
Exactly a fixed number of coins must be used in total.

For example, given x = {1,2,3}, y = 36 and n = 15 where n is the total number of coins that must be used, we get four combinations:

{1,2,2,2,2,2,2,2,3,3,3,3,3,3,3} (1 ones, 7 twos, 7 threes)
{1,1,2,2,2,2,2,3,3,3,3,3,3,3,3} (2 ones, 5 twos, 8 threes)
{1,1,1,2,2,2,3,3,3,3,3,3,3,3,3} (3 ones, 3 twos, 9 threes)
{1,1,1,1,2,3,3,3,3,3,3,3,3,3,3} (4 ones, 1 twos, 10 threes)

Challenge
The challenge is to write a function enumerate in the language of your choice which enumerates all the combinations as described above given:

The list of denominations. For example {1,5,10,25}. You may use either lists or arrays.
A non-negative integer y that denotes the sum of every combination.
A non-negative integer n that denotes the total number of coins.

The order of the arguments doesn't matter. Pointfree functions are allowed.
The output of the enumerate function must be a list of combinations. Each combination must be unique and it must be a list of n integers which add up to y. Every denomination must appear at least once in each combination and no combination must be missing. The ordering of the integers and the combinations doesn't matter. You may use either lists or arrays for the output.
Keep in mind the following edge cases:

If both y and n are zero and the list of denominations is empty then the output is a list of one combination, the empty combination (i.e. {{}}).
Otherwise, if y is zero, n is zero or the list of denominations is empty then the output is a list of zero combinations (i.e. {}).
More generally, if y is less than the sum of the denominations or n is less than the number of denominations then the output is a list of zero combinations.

Scoring will be based on the size of the entire program in bytes. Note that this includes the enumerate function, helper functions, import statements, etc. It does not include test cases.

Pretty sure I've seen this challenge somewhere...

I hope this question isn't a duplicate. I couldn't find the same question on Code Golf. Hence, I posted it.

@PeterTaylor If y is less than the sum of the denominations then at some point in your recursive solution you'll reach the base case where the list of denominations is empty. Hence, the answer will be {} (i.e. no solution found). If n is less than the number of denominations then you'll eventually reach the base case where n = 0 but y != 0. Hence, the answer will again be {}.

@PeterTaylor Indeed. I might have assumed too much about the implementation details. Would you know how to fix that?

Can we assume that the list of denominations is sorted?

I suggest you remove the "Accepted" flag until you get a working answer. And in general it's sensible to wait a couple of days before accepting.

@MartinEnder No. You may only assume that you have a list of denominations.

05AB1E, 20 bytes
g-¹sã€{Ùvy¹«DO³Qiˆ}¯

Input is in the order: list of values, nr of coins, sum to reach.
Explanation in short

Get all permutations of the coin list of length: final length - length of unique coin list
Add the list of unique coins to these lists.
If the sum equals the sought after sum, save the list
Output all saved lists

Try it online
The online compiler can't handle large number of coins.

MATL, 22 bytes
Z^!S!Xu!tsi=Z)"1G@m?@!

Input order is: array of denominations, number of coins taken (n), desired sum (y).
Each combination is displayed on a different line. Empty output is displayed as an empty string (so nothing).
Try it online!
The code runs out of memory in the online compiler for the example in the challenge, but works offline with a standard, reasonably modern computer:
>> matl
 > Z^!S!Xu!tsi=Z)"1G@m?@!
 >
> [1 2 3]
> 15
> 36
1 1 1 1 2 3 3 3 3 3 3 3 3 3 3
1 1 1 2 2 2 3 3 3 3 3 3 3 3 3
1 1 2 2 2 2 2 3 3 3 3 3 3 3 3
1 2 2 2 2 2 2 2 3 3 3 3 3 3 3

Explanation
Z^      % Implicitly input array of denomminations and number of coins n. Compute
        % Cartesian power. This gives 2D array with each "combination"
        % on a different row
!S!     % Sort each row
Xu      % Deduplicate rows
!       % Transpose: rows become columns. Call this array A
ts      % Push a copy, compute sum of each column
i       % Input y (desired sum)
=       % Logical array that contains true if the "combination" has the desired sum
Z)      % Keep only those columns in array A
"       % For each column
  1G    %   Push array of denominations again
  @     %   Push current column
  m     %   Is each denomination present in the column?
  ?     %   If so
    @!  %     Push current column again. Transpose into a row
        %   End if
        % End for
        % Implicitly display stack contents

Python 3, 120 106 bytes
from itertools import*
lambda d,t,l:[i+d for i in combinations_with_replacement(d,l-len(d))if sum(i+d)==t]

An anonymous function that takes input of a tuple of denominations of the form (x_1, x_2, x_3 ... , x_k), a target value, and a number of coins via argument, and returns a list of tuples of the form [(solution_1), (solution_2), (solution_3), ... (solution_k)].
How it works
Itertools's combinations_with_replacement function is used to generate all l-len(d) combinations, with replacement, of the denominations. By appending d to each of these combinations, it is guaranteed that each denomination appears at least once, and that the new combination has length l. If the elements of a combination sum to t, the combination is added to the return list as a tuple.
Try it on Ideone

An alternative method for 108 bytes
from itertools import*
lambda d,t,l:set(tuple(sorted(i+d))for i in product(d,repeat=l-len(d))if sum(i+d)==t)

An anonymous function that takes input of a tuple of denominations of the form (x_1, x_2, x_3 ... , x_k), a target value, and a number of coins via argument, and returns a set of tuples of the form {(solution_1), (solution_2), (solution_3), ... (solution_k)}.
How it works (other version)
This uses the product function from itertools to generate all l-len(d) arrangements of the denominations. By appending d to each of these combinations, it is guaranteed that each denomination appears at least once, and that the new combination has length l. If the elements of a combination sum to t, the combination is sorted, converted from a list to a tuple, and added to the return tuples. Finally, calling set removes any duplicates.
Try it on Ideone (other version)

JavaScript (ES6), 135 bytes
g=(a,n,y,r)=>n>0?y>0&&a.map((x,i)=>g(a.slice(i),n-1,y-x,[...r,x])):n|y||console.log(r)
(a,n,y)=>g(a,n-a.length,a.reduce((y,x)=>y-x,y),a)