text:
Javascript left-pad golf
Introduction
In the wake of the left-pad npm package fallout, let's have a code golf for implementing left-pad.
The left-pad function consists of 2 default arguments and 1 additional argument, in the form string, length, (padchar). If the padchar is not given, this is standardized to a space character. Let's take an example with two arguments:
left_pad("abc", 6)

First, we observe the length of the string, which is 3. After this, we need to pad this string in the left until the length of the full string has reached the length given in the function. In this case 6. Since the padchar is not given, we need to pad this with spaces:
   abc

This is a string with 3 spaces and the initial string, resulting into a string with length 6. Here is an example with the padchar given:
left_pad("abc", 6, "-")

We just do the same as the example above, but replace the spaces with the padchar. In this case, the hyphen:
---abc

The Task
Given the string, length, and maybe the additional argument padchar, output the left-padded string. You can assume that the length number is equal or greater than the length of the string. The padchar will always consist of 1 character.
Test cases
left_pad("string", length, ("padchar")) === "left-padded string"

left_pad("foo", 5) === "  foo"
left_pad("foobar", 6) === "foobar"
left_pad("1", 2, "0") === "01"
left_pad("1", 2, "-") === "-1"

This is code-golf, so the submission with the smallest number of bytes wins!

Also, in the future, I'd recommend posting in the Sandbox to get feedback before you challenge is live, and note that restricting to a language is highly discouraged, since it limits participation.

@m0sa It would be valid, but I'd find it too straightforward to be interesting.  There's already a challenge to right-align text, which basically requires padding as a sub-task.

@m0sa There's still a few issues. Restricting the challenge to javascript is strongly discouraged -- there's no reason other languages can't participate in this. The spec should describe the desired behavior and range of possible allowed inputs without needing to follow a link. It's not clear offhand how the third parameter is being handled.

I am certain that a Javascript-relevant reference can be made for motivation, without having to say "therefore no other languages are allowed to play". If you are particularly interested in seeing the best Javascript entries you could offer a bounty for it, while still leaving the challenge open for other languages.

Either single language questions are forbidden or they aren't. If they are forbidden, close this. If they are allowed, let the OP restrict the question as they like.

@Sklivvz Single language is allowed, though I may venture to say it's the reason the downvotes are pouring in now. We should discuss though banning it in the future, since it's existence seems like a trap.

@xnor thanks, that's what I meant. As an outsider, this feels like a bad community reaction to a valid question :-)

@Sklivvz A challenge we have in the SE question-answer framework is that the SE rules are designed to separate on-topic questions from off-topic ones, but in a site whose goal is competition and entertainment, there's a large grey area of things that are not against the rules, but are generally believed to make for a less interesting challenge. Feel free to join chat and discuss more.

@xnor looks like the entertainment ship has already sailed, otherwise this would've been [tag:popularity-contest]

@Sklivvz (and m0sa) There are rare cases where language-specific challenges make sense, particularly if the challenge requires some very unique feature of a language to make sense or even be a challenge in the first place. That's the main reason those are allowed and why I'd also be opposed to disallowing them completely. That said, for any challenge that does make sense in any language, there's no good reason to restrict it to one language. Otherwise, we'd have "Sort an array in JavaScript", "Sort an array in Ruby", "Sort an array in Python"... and 300 more challenges for no benefit at all.

@MartinBüttner the challenge was intended in "replace the left-pad" npm dependency. I don't oppose other languages but they should interface with js and pass the tests?

@Sklivvz As trichoplax said, this is a fine motivation for a challenge, but it boils down to a very simple string-processing task that makes just as much sense in any other language. The challenge is not specifically hard, doable or interesting in JavaScript compared to any other language (in particular, someone might not have known about the left-pad package, and still ask this question without the language restriction, and the answers in JavaScript wouldn't have been affected at all, and neither would anyone have thought "why isn't this JS-only?").

In c# one can answer s.PadLeft(n,p);...

@Sklivvz It's common practice to disallow built-ins that exactly implement what the challenge asks if that's a concern.

Nah, my only concern is that the OP wanted (with reason) creative javascript answers, but the only way to make this work here is to allow any language, disallow built ins, ask for code golf. It ended up being a completely different, non-fun, question. Probably it was the wrong site for it.

This really shouldn't have [tag:javascript]. The JavaScript in the title is fine for the relevance, though.

@tac Why is that? As long as the challenge has the language restriction, I think the tag is fine.

@MartinBüttner It's not like anyone's going to obey the language restriction when it has no reason to exist.

@tac I think the "Not an answer" flag exists for this reason.

@Mystagogue You're gonna waste mods' time by flagging answers in the "wrong" language? There are no language rules on this site, the only reason some challenges are "restricted" to certain languages is because they wouldn't make any sense otherwise. This challenge is clearly undertakable by many languages, and there's no justification for such a restriction.

@tac All four test cases already appear to be in the question.

@Mystagogue I hadn't bothered clicking the link but I kinda assumed there were more.

@edc65 I didn't make up the test cases up by myself,  so I don't want to make them more detailed or anything.  I guess we could add bonus points to implementations that behave weird in unspecified edge cases?

@Sklivvz, m0sa: re: entertainment value, yes, it's true that part of the purpose of this site can be to have fun. That's not an excuse for posting an off-topic or otherwise prohibited form of challenge. "Fun" does not mean "anything goes;" just like all other Stack Exchange sites, we hold all posts to a high quality standard. The inclusionist argument of "we're just having fun!" wouldn't hold on any other Stack Exchange site, and we're no different in that regard.

There's even an API now - left-pad.io

@Sklivvz As an early mod here, I carry a lot of the responsibility for setting the "we discourage language-specific challenges" tone in the community. (See this thread, for example.) I still believe this question could be multi-language and still fun, IMHO. :-) (BTW, I saw your IRC messages! So feel free to drop by again and chat about this or anything else. I'd love to keep in touch!)

@m0sa JavaScript is special in that 1 + "1" is 11, not, for instance, a TypeError (Python) or compiler error (C/C++/etc). Should our answers work for f("foo", 5, 0) to give 00foo, or may we assume the first and last arguments will always be strings?

I'm not surprised this challenge showed up so soon - I was thinking of posting a similar one myself. :)

Why is there a reopen vote? As @edc65 said, it doesn't have a spec.

Here is a spec because people wanted a spec.

I was wrong, 2 lines of text give a complete spec. Voting to reopen. Note: many current answers don't fulfill this spec

@CatsAreFluffy Would you mind adding a test case with the new spec :p.

Added the new test case.

@CatsAreFluffy Shouldn't it be abaa?

@CatsAreFluffy In the original test cases, padstring can be a number. Also, the referenced npm package isn't supposed to take a string, just a single character. leftpad('a', 4, 'ab') returns something nonsensical.

@AandN a̶b ab a

@Dennis True and true. but if we're not restricting to JS, then padstring being a number makes less sense (and makes it impossible in strongly typed languages like Java)

@CatsAreFluffy I don't fully understand the last test case. I think you need to elaborate a bit more on that in the challenge spec.

@CatsAreFluffy I'm not saying it's a bad change, but the test cases would have to get amended to reflect the change. Also, I disagree with changing the spec from pad char to pad string, as it break many existing answers.

@AandN Is that better?

@Dennis Well the community will decide if the changes are good. how did I get into this mess

Specification, test cases and the linked code on GitHub all contradict each other. I'm re-closing this until everything get cleared up.

@CatsAreFluffy It's poor taste to edit a challenge and invalidate the majority of the many existing answers, especially when the challenge isn't even your own.

@CatsAreFluffy why can't the last test case also give "abaa"? no explanation of this, and breaks nearly every answer.

I disagree with replacing === with >, but the original spec didn't say anything about strings vs characters, so I guess that's OK

also, I don't know why the link to the github test repo was edited out, as it was clearly part of the problem. The first and last parameter, as specified by the tests on github, is anything the language can turn into a string; e.g. in C# this should be object...

and for reference, here's the link to the tests on github, as it was edited out https://github.com/azer/left-pad/blob/76979f0a50877c50afd817923acf6f224bba3d36/test.js

Pyth, 13 11 bytes
+*.xwd-Qlzz

Try it here.
Takes input from STDIN as the string on the first line, length on the second line, and padding char optionally on a third line.

This is suppose to be javascript only

@MMM Language restrictions in challenges are so universally disliked that I expect it to be summarily ignored. Nobody likes to be told "you can't participate."

@MMM https://en.wikipedia.org/wiki/Civil_disobedience

Stick it to the man! You go Doorknob! Don't let your dreams be dreams! JUST DO IT!

'Tis a wicked society where the moderators are the one doing civil disobedience!

@FryAmTheEggman That's longer because of the need for conditional application (see the first revision).

@FryAmTheEggman I think it pads to the nearest multiple of the input number which is not suitable for this case.

This got flagged as low-quality. Coincidence? :P

Note that this code was broken by a recent update to Pyth, but worked at the time.

JavaScript (ES6), 43 bytes
f=(s,n,p=" ",r=p)=>(r+=s+="")[n]?s:f(r,n,p)

you're missing the 3rd parameter

@m0sa Thanks, fixed.

It fails the third test, now ;-)

@Sklivvz Ugh, that's what I get for not reading the requirements properly.

Instead of p+=s, you can add 2 bytes to make it p+=[s], and it'll work.

@Aplet123 Thanks for pointing out that I'd tried (and failed, as it happens) to fix the fourth case, rather than the third. Sadly it cost me a fair number of bytes to fix them both.

If we use the new spec by @CatsAreFluffy, this is ok for 'foo',5,'.-' but curiosly fails for 'foo',6,'.-'  (or any even padding len)

@edc65 It's not that curious, it assumes that \${p}`.length == 1`

@CatsAreFluffy What's the expected result for 'foo',6,'.-'?

It's curios because I was expecting a more blatant fail (see Pyth answer). Instead it's just a char too long and just for even length.

@edc65 That doesn't help; I can't seem to run the Pyth answer at all.

Javascript ES6, 35 bytes
(s,l,c=' ')=>c.repeat(l-s.length)+s

Try it. I believe this is the shortest possible implimentation currently possible in Javascript.

This is what I was going to do, except it wasn't an anonymous function.

@Aplet123 I think by the contest's definition of what's expected this is ok. It was just asking for the function; naming it is irrelevant in this context or at least that's what I would think based on other answers.

JavaScript (ES6), 37 43 44 bytes
(a,n,c=' ')=>((c+'').repeat(n)+a).substr(-n)

Test:
> f=(a,n,c)=>((c?c:" ").repeat(n)+a).substr(-n)
< function (a,n,c)=>((c?c:" ").repeat(n)+a).substr(-n)
> f('foo', 5) === '  foo';
< true
> f('foobar', 6) === 'foobar';
< true
> f(1, 2, 0) === '01';
< true
> f(1, 2, '-') === '-1';
< true

Not sure if you want to count the function declaration, I'd inline this.

I think that generally, we don't count the function declaration unless the question specifically asks for a full program rather than a function.

slice is shorter than substr.

@Deusovi right. what I mean is that I wouldn't do console.log(f("whatever",10, "*")), but console.log(("*".repeat(10)+"whatever").substr(-10))

Python 3, 33 31 29 bytes
lambda a,b,x=" ":a.rjust(b,x)

Fairly straightforward. Thanks to @xnor for reminding me str.rjust is a thing. :P
For the same length (also thanks to xnor):
lambda a,b,x=" ":(x*b+a)[-b:]

Previous solution:
lambda a,b,x=" ":x*(b-len(a))+a

It's a bit shorter to do (x*b+a)[-b:] or a.rjust(b,x). Actually, str.rjust itself arguably works for the whole thing.

@xnor I forgot rjust was a builtin, thank you!

None of these follow the spec: f(1, 2, 0) === '01';

@ValentinLorentz I asked the OP for clarification on languages that don't coerce numbers to strings by default, and haven't gotten an answer. As this question has no formal specification, I'm going to assume the arguments are all strings.

Now there's a spec, and solution 1 is invalid (tested on Python 2.7.10)

@CatsAreFluffy Okay, well, 1) the question's closed so I see no reason to update (if it were reopened, then...), 2) why would you test a Python 3 submission in Python 2? Even if the behaviour seems the same, that's still silly.

Doesn't work in Python 3 either.

@CatsAreFluffy cool, it was your edit that invalidated almost every (or every) answer and made this less fun, so I'm not bothered

You don't need a lambda. str.rjust is a valid answer (as str.rjust is just as much of a valid function expression as a lambda)

05AB1E, 11 9 bytes
Code:
g-ð³0@×¹«

Explanation:
g          # Implicit first input, take the length.
 -         # Substract the length with the second input.
  ð³       # Push a space and if the third input exists, also the third input.
    0@     # Reposition the first element of the stack to the top (zero-indexed).
      ×    # Multiply the character with the difference in length.
       ¹«  # Concatenate the first input to the string.

Uses CP-1252 encoding. Try it online.

All these chars fit into the Jelly codepage (0x672D188330401181FA)

JavaScript (ES5), 70 bytes
Using recursion...

function f(s,c,p,u){return(s+'').length<c?f((p==u?' ':p+'')+s,c,p):s}

My initial go was only 57 bytes:
function f(s,c,p){return s.length<c?f((p||" ")+s,c,p):s}

But only passed the first 2 tests:
> f('foo', 5) === '  foo';
true
> f('foobar', 6) === 'foobar';
true
> f(1, 2, 0) === '01';
false
> f(1, 2, '-') === '-1';
false

I still like the shorter one, because in practise, passing numbers to a string manipulation function isn't a feature I would need.

Mathematica, 13 bytes
StringPadLeft

Builtin-only answer #3 (first was Range, second was Surd)
Or less builtin: (35 bytes)
##2~StringRepeat~(#3-Length@#2)<>#&

May I quietly downvote?

...Why? Is it because this is just a builtin? The 41byte Python answer #1 (which is no longer valid) was just a wrapper for a builtin.

It's common practice to disallow built-ins that exactly implement what the challenge asks if that's a concern. (Appeal to authority: Martin)(but common sense, too)

@edc65 Related meta post. I'm pretty sure it's allowed, since built-ins are generally allowed by default. It requires creativity and knowledge on the user's part to know the relevant built-in function.

@mbomb007 allowed maybe - creative no. I did not flag this answer as invalid but mantain my downvote

See the answer two above this one-I'm assuming that's been downvoted by you two as well.

JavaScript ES7, 16 bytes
''.padStart.bind

built-ins ftw! Only works on Firefox 48 and above. Valid as this feature was added March 12.
This takes input like:
(''.padStart.bind)(arg1)(arg2,arg3)

Javascript (ES6), 55 bytes
(a,n,c=' ',s=a+'')=>(new Array(++n-s.length).join(c)+s)

Create an empty array of values and join version.
(a,n,c=' ')=>{a+=''; return new Array(++n-a.length).join(c)+a}

Is more readable but the return adds a few more characters.

Since the question is on hold I'm going to put my answer under the JS answer that's most like mine.  43 bytes  (s,n,c=' ')=>(Array(n).join(c)+s).slice(-n)

Tip: \`` for inline code blocks.`.

+= returns the value of its left operand, so the second version becomes shorter: (a,n,c=' ')=>(new Array(++n-(a+='').length).join(c)+a) But it becomes longer when you add multichar padding strings.

Julia, 4 bytes
lpad

Passes all the test cases:
julia> lpad("foo", 5)
"  foo"

julia> lpad("foobar", 6)
"foobar"

julia> lpad(1, 2, 0)
"01"

julia> lpad(1, 2, '-')
"-1"

Does it work for rect 7 cor?

Yes. lpad("rect", 7, "cor") => "correct"

Bash, 57 Bytes
Parameters: string width padchar
printf -vX %$2s;Y="${X// /${3- }}$1";echo -n "${Y:${#1}}"

Make a string of width spaces.
Convert each space character into padchar.
Write padding then string.

Python, 41 bytes
lambda a,b,x=' ':str(a).rjust(b,str(x))

Without the builtin rjust, 43 bytes:
lambda a,b,x=' ':str(x)*int(b/2%3)+str(a)

(not what one expects it to do, but it passes the test suite)

You can remove s=str and replace s with str for same byte count.

Jelly, 12 bytes
L⁴_ẋ@⁵⁵⁶<?¤³

So many variable references. Wasn't Jelly supposed to be a tacit language?
Try it online!
How it works
L⁴_ẋ@⁵⁵⁶<?¤³  Main link
              Arguments: string (³), length (⁴), padchar (⁵, defaults to 10)

L             Compute the length of ³.
 ⁴_           Subtract the length from ⁴.
          ¤   Combine the two links to the left into a niladic chain:
     ⁵          Yield ⁵.
      ⁵⁶<?      Yield ⁵ if ⁵ < ⁵, else ⁶.
              Comparing a number with itself gives 0 (falsy), but comparing a
              string / character list with itself gives [0] (truthy).
   ẋ@         Repeat the result to the right as many times as specified in the
              result to the left.
           ³  Print the previous return value and return ³.

padchar (⁵, defaults to 10) shouldn't it default to 20 or 32?

Superscript 3 to 9 are constants that are initialized to arguments (if present) or some useful default values. The conditional ? checks if it has its default value 10 and yields a space in that case.

JavaScript (ES6), 34 bytes
I used a recursive solution.
f=(s,l,c=' ')=>s[l-1]?s:f(c+s,l,c)

Powershell, 87 67  incorrect counted 54, 46 Bytes
function f($s,$l,$c=' '){$c*($l-$s.length)+$s}

Try it online!

Welcome to Code Golf. As this is a code-golf challenge, you need to make an attempt to make your code as short as possible (e.g. by removing whitespace). Also, you might want to add a link to Try it online! so others can test your code.

Nice answer! I don't think you have to call your function left_pad (looking at the other answers, most of them have called their function f)

I currently count 53 bytes (or 46 by renaming the function to one character). The TIO link is still pointing to an old version, you can do something like this to make it easier to calculate the bytecount

Thank for the tips, and thank you for pointing out the incorrect count, I think I got it right this time.

C (gcc), 91 86 bytes
Takes 2 or 3 arguments on the command line. Also uses the rare "-->" operator!
-5 bytes from ceilingcat and c--
l;main(c,v)int**v;{for(l=atoi(v++[2]);l-->strlen(*v);)putchar(c-3?*v[2]:32);puts(*v);}

Try it online!

Lua, 39 38 bytes
s,n,c=...print((c or" "):rep(n-#s)..s)

Try it online!
Thanks to c-- for saving a byte.

Japt, 5 bytes
ùVWªS

Try it
ù      # left-pad the input string with:
 V     #   second input (length)
  WªS  #   third input, or space if not specified

Or, for 1 byte:
ù

But this isn't a full program, so I don't think it counts. It can be called AùBC where A is the string, B is the length, and C is (optionally) the padding character.

Exactly what I had. If only the underlying JavaScript had default parameters then we could omit the ªS.

Pike, 67 bytes
mixed n(mixed a,int b,mixed x){return x!=""?x:" "*(b-strlen(a))+a;}

sigh. The empty string "" evaluates to true. Why!?
mixed mixed mixed mixed mixed Pike soup...

Another language with stupid truthys.

@CatsAreFluffy yeah, Pike is kinda weird, but it has nice string processing utilities.

Pyke, 12 bytes (noncompeting)
added input node, bugfix on len node, change default results on assign node after the challenge was posted.
\ =zzjl-z*j+

Explanation:
\ =z         - assign default input for `z` to be " " (Will still prompt but no input will return a space instead)
    zj       -     j = input()
      l      -    len(j)
       -     -   eval_or_not_input() - ^
        z*   -  ^*input()
          j+ - ^+j

+1 because answering in the language is helping you refine it :)

I've edited the format of your header to make it easier to read & easier for userscripts, etc to parse -- roll it back if you disagree.

Why the downvote?

@muddyfish It seems that every non-Javascript answer here is downvoted.

@AandN thats just not nice... Also why I couldn't see a pattern from the top 6 answers

JavaScript ES6, 38 bytes
(s,l,c=" ")=>(c.repeat(l)+s).slice(-l)

An alternate solution.

Arturo, 34 bytes
$=>[++repeat ??attr""" "&-size<=&]

Try it
Arturo has pad but here's a non-builtin.

Vyxal, 8 bytes
□ðJ3Ẏ÷ø↳

Try it Online!
Link is to test suite. Somehow, vyncode also gives 8 bytes.
Explained
□ðJ3Ẏ÷ø↳
□ðJ      # append a space to all input arguments
   3Ẏ     # take the first 3 items of that
     ÷    # dump everything to the stack
      ø↳  # call the built-in left pad function.

Because of the new default about taking multiple inputs as a list, 6.75 bytes

Ruby, 42 bytes
def left_pad(s,t,p=" ");p*(t-s.size)+s;end

Parameters: string, size, padchar.
Test suite below; should print all "true"s, just put everything in the same file.
puts left_pad("foo", 5) == "  foo"
puts left_pad("foobar", 6) == "foobar"
puts left_pad("1", 2, "0") == "01"
puts left_pad("1", 2, "-") == "-1"

You don't need to use that method name... and you can probably make it a lambda, too. (All the other examples do similar)

Java 8, 86 88 bytes
This is a function. The third argument is a varargs to allow the optional pad char (defaults to ' ')
String p(String s,int l,char...p){return s.length()<l?p((p.length>0?p[0]:' ')+s,l,p):s;}

Recursion!
+2 bytes (added brackets because of incompatible type error)

This TypeErrors. Can always test Ideone (Java 7, but I get the same exact error in Java 8 on my box) http://ideone.com/B7gTA5

PHP, 54 48 bytes
Uses Windows-1252 encoding.
function(&$s,$l,$p=~ß){$s=str_pad($s,$l,$p,0);};

Run like this (-d added for easthetics only):
php -r '$f = function(&$s,$l,$p=~ß){$s=str_pad($s,$l,$p,0);}; $s="foo";$f($s,5);echo"$s\n";' 2>/dev/null

Old version (without the builtin):
function(&$s,$l,$p=~ß){for(;strlen($s)<$l;)$s=$p.$s;};

Tweaks

Saved 6 bytes by using str_pad instead of a loop. Leaving the old one for reference, as builtins are frowned upon

R, 50 bytes
Late to the party again but here it goes:
function(s,n,p=" ")cat(rep(p,n-nchar(s)),s,sep="")

This simply prints the output to stdout but does not actually return the padded string (wasn't sure if this is a requirement for the challenge). If this is needed, the solution is slightly longer at 61 bytes:
function(s,n,p=" ")paste0(c(rep(p,n-nchar(s)),s),collapse="")

brainfuck, 212 bytes
,----------[++++++++++<[<]<+>>[>],----------]<[<]<<<,----------[<[-<++++++++++>]<[->+<]>>>++++++++[-<----->]<++[-<+>],----------]>>[-<<<->>>]++++[>++++++++<-]><<+>,[<->[-<<+>>]]<[->>[-<<<+>>>]<<]<<[->.<]>>>>>[.>]

Explained
,----------[      While it isn't a newline
    ++++++++++        Restore the character
    <[<]<+>>[>]       Increment the counter behind the array and return
,----------]      Read and repeat
<[<]<<<           navigate behind the length
,----------[                   While it isn't a newline
    <[-<++++++++++>]<[->+<]>>      x10 the stored number
    >++++++++[-<----->]<++             sub 39
    [-<+>]                         Copy into stored
,----------]                   Read and repeat
>>[-<<<->>>]        Subtract the counter from the target
++++[>++++++++<-]>  Prepare a space
<<+>,[<->[-<<+>>]]  If the next byte isnt eof then we copy it left two and zero the test byte
<[->>[-<<<+>>>]<<]  If the text bit is still high copy space in there instead
<<[->.<]            While the counter is positive write the pad char
>>>>>[.>]           Write the rest of the string

Arguments separated by linefeeds. If no pad char is present, a linefeed after the length must still be included.
Try it online!

Go, 110 bytes
import."strings"
func l(n int,c...string)string{q,p:=c[0]," "
if len(c)>1{p=c[1]}
return Repeat(p,n-len(q))+q}

Attempt This Online!
Uses Go's variadic arguments feature to have an optional argument. Expects at minimum 1 string passed to the function (the string to be padded); the first string after that is the padding character.
A solution were all arguments are explicit is significantly shorter:
Go, 76 bytes, no variadic arguments
import."strings"
func l(s,c string,n int)string{return Repeat(c,n-len(s))+s}

Attempt This Online!

C, 64 bytes
f(s,n,c,p){return memset(p,c,asprintf(&p,"%*s",n,s)-strlen(s));}

Try it here.

This does not comply with the specification, as it does not default to space when a character is not provided.

This code doesn't run as given. gcc will let undefined reference to function printf pass and include printf itself, but no such luck for memset, asprintf, and strlen. You need to add the #include<string.h>... etc definitions to make this valid.

@tac Hmmm...I wrote and tested my answer completely within ideone. It compiles and runs successfully on that platform, though it states that it uses gcc-5.1. I'm not sure if they're using compiler flags or what-have-you behind the scenes that I'm not aware of. I was initially using this as my justification for it not running in your environment, but now I'm not sure...

well, this is gcc 5.2.1 on Linux, so you might be able to get away with saying Ideone C, 64 bytes but if you're gonna claim it's C, make it compile. :p

I'm only a beginner at C: Why does f take four parameters, not 3? Are you requiring the address of the string, or...? either way, f should take at most 3 arguments.

I hadn't previously tested this. http://ideone.com/H2t6DR It works with three args!  However, it doesn't coerce ints to strings. http://ideone.com/i2fzRZ

@Doorknob Consider deleting this as it doesn't meet the requirements?


text:
Count the ASCII hamantaschen!
Today is Purim on which one custom is to give out triangle-shaped cookies with filling called hamantaschen (singular: hamantasch).  Another custom is to drink heavily.
I'm not the most perfect baker.... I have so many irregularly-sized hamantaschen to give out and so many friends to give them to! If I sent you a picture of my cookies, can you tell me how many I have of which size and filling?  But because it's Purim and I'm too drunk to read much code, it needs to be as small code as you can make.
Definitions
Size
A hamantasch can be any size.  The smallest hamantasch is size 1 and looks like these:
/\  --
--  \/

Sometimes, multiple hamantaschen can overlap.  The shape below counts as two hamantaschen (one size 1, one size 2):
 /\
/\ \
----

Some hamantaschen have filling.  This will be indicated by filling all whitespace inside with a character.  Note that size 1 hamantaschen cannot have filling.
We will name hamantaschen based on filling and size.  Let's use the format <filling> <size> and if unfilled, - <size> (you can use a space instead of a -, but markdown doesn't like that).
Here are a . 2, a . 4, and a - 3:
          /\
         /./\
 ----   /./  \
 \../  /./    \
  \/   --------

These are a @ 3, a . 2 and a - 4:
          /\
         / /\
  /\    / /@@\
 /..\  / /@@@@\
 ----  --------

Here's something more difficult.  See how the & 2 has less filling than you've come to expect due to the slant from the overlapping - 3?  It has a - 1, a & 2 a - 3 and a & 4:
--------
\   \/&/
 \  /\/
  \/&/
   \/

Input
You will be given a text file or single string of hamantaschen (optional trailing newline and optionally padded trailing whitespace to be even).
Limits

You can expect the string to be valid - that is, every non-whitespace character contributes to a deliciously sweet hamantasch (why waste dough?).
You can also expect it to be properly filled or not - that is, each hamantasch it will be entirely filled with a consistent ASCII character - ASCII 32 for unfilled, or anything 32..127 for filled (excluding /, \ and -).
These hamantaschen are not stacked in 3-space. All / and \ will be visible.  All - that are not blocked by / and \ will be visible.  Filling comes very last.
All hamantaschen will have at least half of their horizontal line (rounding up) visible.
Any contiguous block of filling only fills the smallest
hamantasch that surrounds it.

Output
Return a list of "names" of all the hamantaschen that can be found meeting the above criteria.  The output can be in whatever form you'd like (a string, a hash, stdout, etc).
Test cases
Test case #1
Input #1:
          /\
         / /\
  /\    / /@@\
 /..\  / /@@@@\
 ----  --------
    /\
   /**\
  /*/\*\
 /*/..\*\
 --------

Output #1:
. 2
. 2
- 4
@ 3
* 4

Test Case #2
Input #2:
  /\----
 /\/\*\/
/ /\d\/
------

Output #2:
- 3
- 2
d 2
- 1
* 2
- 1

Test #3
Input #3:
----
\/\/
/\/\  /\
---- /::\
     ----

Output #3:
- 1
- 1
- 2
- 1
- 1
- 2
: 2

Test #4
Input #4:
 /\/\
/ /\$\
-/--/\\
 --/--\
  /xxx/\
 /xxx/##\
 ---/----\
   /      \
   --------

Output #4:
$ 2
x 4
- 3
- 2
- 4
- 1
- 1
# 2

Invalid Test Case #5
Input:
/\
\/

Output:
You do not need to handle this.

How about a test case in which hamentaschen are overlapping but do not have the same horizontal line? One may even block another's horizontal line.

@proudhaskeller Ok, done.  However, and I just put this in the text, this is 2-space.  We will always see all / and \ , and - will always trump filling.

So, people eat cookies and get drunk on purim.  That sounds... Interesting. :P

@EasterlyIrk There are other important bits, too - reading the Book of Esther (and booing at the bad guys), giving to the poor - and less foundational things like dressing in costume.

@NotthatCharles oh good.   We need a little Torah with our beer. :P

Also giving gift baskets to your neighbors/the poor depending on your traditions. (Starts singing fiddler on the roof).

made relevant again!

@downrep_nation In your honor, I removed the more annoying half of the puzzle (dividing up your bags).  Now it's just about counting.

@Riker The Torah generally refers to the first 5 books of the Bible, doesn't it? Esther would not be included in that.

@mbomb007 well yeah but my point stands

@mbomb007 You're right, but "Torah" can also mean "Jewish learning" more generally.  People can refer to studying something written in 2015 as "learning Torah".

Test case three's output seems incorrect, listing two unverifiable - 2s.

@MichaelPlotke If the top-left before the first char is (line, col): (1,0), the vertices of the - 2s are: (1,0), (1,5), (3,3), and (4,1), (2,3), (4,5) - that is - one upside down and one right-side up triangle that overlap each other.

Based on an initial column of zero all your vertex columns, except (1,0), are off by +1. Still, I know what you mean, and I disagree. What indication is there that (2, 2) is the top center of a - 2 and not just the top right and left of the two upper - 1s? None that I can see. And the same logic applies to (3, 2). Unless you want to add a rule to assume maximum possible hamantaschen...

@MichaelPlotke point taken.  Does the change to Output make this clear?

'I'm too drunk to read much code' basically everyone here is too drunk to read much code, and you actually just have to go on TIO

C#, 496 452 bytes
Edit: found a bug with bounds checking... but also striped a load of bytes having been forced to understand my own code. Unrolling the local function helped a bit, and removed the C# 7 specific code. This question has been a lot of fun.
using C=System.Console;class P{static void Main(){string D="",L;int W=0,H=0,z=0,d,q,c,j,b;for(;(L=C.ReadLine())!=null;H+=W=L.Length)D+=L;var B=new int[H];for(d=W;(d=-d)>0||++z<H*H;)for(c=1,q=z%H;c<=z/H&q%W+c<W&q>=d&q<H+d&&D[q]==(d>0?92:47)&D[j=q+c]==(d<0?92:47);q-=d+1,c+=2){for(b=0;j>q;)b+=D[--j-d]==45?2:0;for(char h='-',e;c==z/H&b>c;C.WriteLine(h+" "+c/2))for(b=c++;b>1;j=q+=d+1,b-=2)for(;j<q+b;)B[j]=h=B[j]<1&h==45&(e=D[j++])!=47&e!=92&e>32?e:h;}}}

Try it Online
Complete program, expects space-padded input to standard in, outputs to standard out. The output is one entry per line, with trailing line feed. Cookies are outputted in increasing size order, upper-left most first. It took me a good while to understand the rules, but I think it passes all the examples provided.
It works by repeatedly searching the entire grid for valid Hamantaschen, incrementing the 'allowed' size. For each cell, it checks up and down, following the \ and / on either side as far as it can. If it notices that the next row has lots of -, and the current size is the 'allowed' size, then it determines the filling and prints out the entry.
The filling is found by exploring the entire space of the cookie, looking for an 'unused' cell. When an unused cell is found, it is marked as used (since we increase the allowed size, we know we are the smallest cookie that contains it), and we record the filling.
Formatted and commented code:
using C=System.Console;

class P
{
    static void Main()
    {
        //   32
        // - 45
        // / 47
        // \ 92
        // range 32..127 (no mod for you)

        string D="", // the whole map
            L; // initally each line of the map, later each line of output

        int W=0, // width
            H=0, // length (width * height)
            z=0, // search tracker
            d, // check direction (this is backwards (1 byte saving!))
            q, // check tracker
            c, // counter (truely, this is the distance from the right to the left)
            //M, // c max (now inlined as z/H)
            j, // horiontal tracker
            b; // - count, and reverse counter

        // read map and width
        for(;(L=C.ReadLine())!=null; // read a line, while we can
                H+=W=L.Length) // record the width, and increment height
            D+=L; // add the line to the map

        var B=new int[H]; // whether this filling has been used already (0 -> false, >0 -> true)

        for(d=W; // init direction
            (d=-d)>0|| // swap direction, else increment z (this allows us to run the check for the same z twice with opposite direction)
            ++z<H*H; // for all M, for all q (z<H -> M=z/H=0 -> no valid cookies, so we can safetly skip them)
            )
            for(//M=z/H, // c allow (now inlined)
                c=1, // reset counter
                q=z%H; // note position
                c<=z/H& // counter check
                // no need for a left check: if we run off the left end, then the right check will necessarily fail
                q%W+c<W& // right check
                q>=d& // high check
                q<H+d&& // low check (short-circuit lookups)
                D[q]==(d>0?92:47)&D[j=q+c]==(d<0?92:47); // /\ or \/ check, and set j=q+c
                    q-=d+1, // move left tracker
                    c+=2) // increase counter (move right tracker)
            {
                // count the number of '-' into b
                for(b=0; // zero b
                    j>q; // for each element in the row below
                        ) // empty
                    b+=D[--j-d]==45?2:0; // add 2 to b if we tap a '-'

                // j = q

                // check valid before looking up cHaracter (so we don't mark unused stuff as taken)
                // if we are at the current max count, and we have enough -, then we are valid and should be commited
                for( // this runs either one or zero times, we only have a for here (rather than an if) so we can ditch a pair of braces
                    char h='-', // default filling
                         e; // filling we are considering
                    c==z/H&b>c;
                        C.WriteLine(h+" "+c/2)) // print filling and count
                    // continuously compute character
                    for(b=c++; // count b backwards, starting from c (add 1 to c so we can /2 in print)
                        b>1;j=q+=d+1,b-=2) // count q backwards toward z%H (where q came from), and b backwards toward 1 (for each row)
                        for(;j<q+b;) // for each cell in row
                            B[j]= // mark cell as taken (h,e > 0)
                            h= // record filling
                                B[j]<1& // check cell not already used
                                h==45& // '-'
                                (e=D[j++])!=47& // '/'
                                e!=92& // '\'
                                e>32 // ' '
                                ?e:h; // take first filling we can
                    // c runs out after this (exists both loops), so no need to action
            }
    }
}

Outputs for the 4 test cases:
testcase #1
. 2
. 2
@ 3
- 4
* 4

testcase #2
- 1
- 1
- 2
d 2
* 2
- 3

testcase #3
- 1
- 1
- 1
- 1
- 2
- 2
: 2

testcase #4
- 1
- 1
- 2
$ 2
# 2
- 3
x 4
- 4

I'm amazed at how compact this is in C#!  Well done!

The only valid answer!  I have something that's nearly functional, but has a few errors (but I wouldn't set myself as winner anyway)

source: Stack Exchange

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

sort: votes


text:
Draw an ASCII art phone keypad
Draw the following in the fewest bytes possible:
-------------------------
|       |  ABC  |  DEF  |
|   1   |   2   |   3   |
-------------------------
|  GHI  |  JKL  |  MNO  |
|   4   |   5   |   6   |
-------------------------
| PQRS  |  TUV  | WXYZ  |
|   7   |   8   |   9   |
-------------------------
|       |       |       |
|   *   |   0   |   #   |
-------------------------

Why the too-broad close-vote?

Erm... hardcoding output alert!

This output seems very well-chosen for a fixed-output challenge. There's geometric structure, the numbers are ordered, the letters are alphabetized and chunks -- lots of possible tradeoffs for hardcoding versus generating. I think the length is high enough that hardcoding will lose out, but we'll see.

An old-style phone without Q or Z would be easier to generate.

I'm not a code golfer myself (more interested challenge ideas) but would certain languages benefit from removing P and W from an alphabet array and then adding them in manually? Since they are the only two out of place.

pb, 240 bytes
<[8]^w[Y!14]{w[X!24]{>[8]b[124]^b[124]v}vw[X!-8]{b[45]<}vv}>[12]^[12]b[49]>[12]w[T!8]{<[4]b[T+50]^<w[X%8!6]{b[65+T*3+X%8%3]>}>[10]vw[B!124]{<[24]vvv}t[T+1]}<[4]b[42]>[8]b[48]>[8]b[35]^[4]>w[B!0]{b[B+2]<}b[87]w[X!2]{<[5]w[B!0]{b[B+1]<}}b[80]

(This program will prompt for input in the current version of pbi, because it goes to Y=-1 and the B variable tries to update itself. Even if you do enter input, nothing will break. It's annoying but it's better than the old version that prompted for input no matter what.)
pb is a language all about treating the terminal as a 2D canvas. To output, you have to move the "brush" (a point represented by the current values of the X and Y variables) to where you want that character to go and put it there. It's cumbersome for things like printing out a word but for art it's often convenient.
This program doesn't actually draw exactly what the question specifies. (Wait, don't downvote me yet! Let me explain!)
Drawing boxes with loops is pretty easy, but there's a catch. If you repeat the following shape:
--------
|
|

You do get boxes, but the right and bottom ones will be open. You can manually draw the extra sides, but that costs bytes. To get around this, my program actually draws this, with the open edges on the left and top:
        |       |       |       |
        |       |       |       |
 --------------------------------
        |       |  ABC  |  DEF  |
        |   1   |   2   |   3   |
 --------------------------------
        |  GHI  |  JKL  |  MNO  |
        |   4   |   5   |   6   |
 --------------------------------
        | PQRS  |  TUV  | WXYZ  |
        |   7   |   8   |   9   |
 --------------------------------
        |       |       |       |
        |   *   |   0   |   #   |
 --------------------------------

But monorail! That's not what the spec says! You can't just draw something else because it's easier and you feel like it! Also, while I have your attention, you are very smart and cute.

Shh, shh, it's okay. pb allows you to "write" to a point on the canvas with one or more negative values in its coordinates. The value is stored while the program runs, but only points where X and Y are both >= 0 are actually written to the screen. This program positions the brush so that areas that are tinted in this image have a negative X or Y:

Although extra lines are "drawn", they're never printed.
After looping through and creating the grid, this program fills in the top nine boxes. The first is hardcoded, a 1 is written and the program moves on. The other eight are generated programmatically. Ignoring code for moving to the next box, noticing when the row is empty, etc (assume the brush always starts on the bottom row of the box and in the middle column), this is what is run eight times:
b[T+50]
^<w[X%8!6]{b[65+T*3+X%8%3]>}
t[T+1]

Even knowing that b is the command to write a character, ^v<> move the brush and w[a!b]{} runs the code in curly braces until a != b, this is hard to follow. The first important thing to note is that you can't define variables in pb. There are six in every program and you have to learn to live with them. Second, T is the only variable that you can actually use the way you're used to using variables; assigning a value and then reading it later. Every other variable either can't be set and just tells you something about the point in the canvas you're on or can only be set indirectly and with side effects (^v<> change X and Y, which also changes the brush location. c sets P to (P+1)%8, which also changes the output colour). Keeping a counter for what number needs to be written and which letters is simply impossible. Instead, this code only keeps track of the number and figures out the letters based on it. Here's how:
b[T+50]                       # We start printing at box 2 with T==0, 0+50=='2'
^<                            # Go up and to the left of the number
w[X%8!6]{                     # Take the X coordinate mod 8 so it's like we're in
                              # the leftmost box. Until hitting the sixth cell:
    b[                          # Write this character:
      65                          # 'A'
      + T * 3                     # Number of current box - 2 (letters start at
                                  # 2) * 3 (3 letters per box)
      + X % 8 % 3                 # X % 8 makes every box behave like it's on the
                                  # left, % 3 puts 0 at the point where the first
                                  # letter goes, then 1, then 2. This is how each
                                  # letter is made different in a box.
    ]
    >                           # Move to the right
}
t[T+1]                        # Box is done, increase counter

This is imperfect, as only 3 letters are put into boxes 7 and 9. So, after filling the bottom row (simple hardcoding), each letter in box 9 is increased by 2 and the W is placed manually. Similarly, every letter in boxes 7 and 8 are increased by 1 and the P is placed manually.
Ungolfed:
<[8]^                         # Go to (-8, -1)
w[Y!14]{                      # While the brush is not on Y=14:
    w[X!24]{                      # While the brush is not on X=24:
        >[8]                          # Go right 8
        b[124]^b[124]v                # Draw a pipe at the current location and above it
    }
    vw[X!-8]{b[45]<}              # Go down and draw hyphens all the way until X=-8
    vv                            # Go down by 2 to start drawing next row
}
>[12]^[12]b[49]               # Write a 1 in the first box
>[12]                          # Go to the bottom pipe on the right of box 2
w[T!8]{                       # While T is not 8:
    <[4]                          # Go to center cell of the box
    b[T+50]                       # Write the number that belongs there
    ^<w[X%8!6]{b[65+T*3+X%8%3]>}  # Write the letters
    >[10]v                        # Go to the next box
    w[B!124]{                     # If the next box isn't there:
        <[24]vvv                      # Go down a row
    }
    t[T+1]                        # Increase counter
}
<[4]b[42]>[8]b[48]>[8]b[35]   # Put the asterisk, 0 and hash in their boxes
^[4]>w[B!0]{b[B+2]<}          # Increase all letters in the 9th box by 2
b[87]                         # Put a W in the 9th box
w[X!2]{<[5]w[B!0]{b[B+1]<}}   # Increase all letters in the 7th/8th box by 1
b[80]                         # Put a P in the 7th box

Brainfuck, 565 characters (212 bytes)
 1 +++++[>+++++>>>>+++++++++>>>>+++++++++++++<<<<<<<<<-]    //initialize
 2 >[->>+++++>>>>+++++<<<<<<]                               //initialize
 3 >>>++++++++[-<<<++++++>++++>>>>>>++++<<<<]               //initialize
 4 ++++++++++<->>>>-<<                                      //initialize
 5
 6 //print first block (123)
 7 >+++++[-<.....>]<<.>>>.>.......<.<++[->>..>.+.+.+<..<.<]<<.<.>>>+++[-<<<<...<+.>...>.>>>]<<.
 8 //print second block (456)
 9 >>+++++[-<.....>]<<.>>>.<+++[->>..>.+.+.+<..<.<]<<.<.>>>+++[-<<<<...<+.>...>.>>>]<<.
10 //print third block (789)
11 >>+++++[-<.....>]<<.>>>.>.>.+.+.+.+<..<.>..>.+.+.+<..<.>.>.+.+.+.+<..<.<<<.<.>>>+++[-<<<<...<+.>...>.>>>]<<.
12 //print fourth block (*0#)
13 >>+++++[-<.....>]<<.>>>.<+++[->>.......<.<]<<.<.<...<---------------.>...>.<...<++++++.>...>.<...<-------------.>...>.>>><<.
14 //print last block (the remaining dashes)
15 >>+++++[-<.....>]

Plain code:
+++++[>+++++>>>>+++++++++>>>>+++++++++++++<<<<<<<<<-]>[->>+++++>>>>+++++<<<<<<]>>>++++++++[-<<<++++++>++++>>>>>>++++<<<<]++++++++++<->>>>-<<>+++++[-<.....>]<<.>>>.>.......<.<++[->>..>.+.+.+<..<.<]<<.<.>>>+++[-<<<<...<+.>...>.>>>]<<.>>+++++[-<.....>]<<.>>>.<+++[->>..>.+.+.+<..<.<]<<.<.>>>+++[-<<<<...<+.>...>.>>>]<<.>>+++++[-<.....>]<<.>>>.>.>.+.+.+.+<..<.>..>.+.+.+<..<.>.>.+.+.+.+<..<.<<<.<.>>>+++[-<<<<...<+.>...>.>>>]<<.>>+++++[-<.....>]<<.>>>.<+++[->>.......<.<]<<.<.<...<---------------.>...>.<...<++++++.>...>.<...<-------------.>...>.>>><<.>>+++++[-<.....>]

Bubblegum, 103 bytes
Hexdump:
00000000: d3d5 c501 b86a 1420 0048 3b3a 3983 6917  .....j. .H;:9.i.
00000010: 5737 200d 9631 84c8 2818 4169 6310 cd85  W7 ..1..(.Aic...
00000020: cb30 b069 ee1e 9e60 b55e de3e 60da d7cf  .0.i...`.^.>`...
00000030: 1f66 9a09 d414 5328 6d46 d0b4 80c0 a060  .f....S(mF.....`
00000040: b0da 90d0 3010 1d1e 1119 0533 cd1c 6a8a  ....0......3..j.
00000050: 0594 b624 ec36 984f 5169 b08c 1654 c400  ...$.6.OQi...T..
00000060: 4a2b e337 0d00 04                        J+.7...

Boring and practical.

"Boring and practical" like a phone keypad :)

Python 2, 147 bytes
print(("|%s"*3+"|\n")*2).join(["-"*25+"\n"]*5)%tuple(x.center(7)for x in" ABC DEF 1 2 3 GHI JKL MNO 4 5 6 PQRS TUV WXYZ 7 8 9    * 0 #".split(' '))

A quick draft of a basic strategy. Uses string formatting to insert the labels, which are hardcoded in a long string.

C,160 bytes
j,k,l,m,n=65;main(i){for(i=325;i--;i%25||puts(""))l=i-139,putchar((k=i/25%3)?(j=i%25%8)?k-2?j-4?32:"123456789*0#"[m++]:j/3-1&&l*l!=64||i%290<75?32:n++:'|':45);}

It makes sense to take avantage of the fact that the letters are in sequence. This code runs through the 325 characters of the keypad, and prints either a space or the next letter as needed.
Ungolfed
i,    //main loop variable
j,    //x position within key
k,    //y position within key
l,    //distance from character 139 (the space immediately left of T)
m,    //symbol counter
n='A';//letter counter

main(){
  for(i=325;i--;i%25||puts(""))             //loop through 325 characters. puts() adds a newline at the end of each line of 25
    l=i-139,                                //calculate l. if it is 8, we need to print P or W
    putchar((k=i/25%3)?                     //if row not divisible by 3
      (j=i%25%8)?                             //if position on row not a |
         k-2?                                   //if row mod 3 = 1
           j-4?' ':"123456789*0#"[m++]            //print a space or a character from the string (increment m for next time)
         :                                      //else row mod 3 must = 2
           j/3-1&&l*l!=64||i%290<75?' ':n++       //print a space or a letter according to formula (increment n to the next letter)
      :'|'                                    //else print |
    :
    '-')                                    //else print -
;}

// j/3-1 returns a 0 when in any of the three columns where letters are generally found
// l*l!=64 returns a 0 at the correct place fo P and W
// i%290<75 returns a 1 for keys 1,*,0,#, supressing the printing of letters/symbols

Java, 296 bytes
Golfed:
class a{static void main(String[]a){System.out.println("-\n|&|  ABC  |  DEF  |\n|$1$|$2$|$3$|\n-\n|  GHI  |  JKL  |  MNO  |\n|$4$|$5$|$6$|\n-\n| PQRS  |  TUV  | WXYZ  |\n|$7$|$8$|$9$|\n-\n|&|&|&|\n|$*$|$0$|$#$|\n-".replace("&","       ").replace("$","   ").replace("-","--------------------"));}}

Ungolfed:
public class AsciiPhoneKeypad{
    public static void main(String []args){
        // - for twenty-five dashes
        // $ for three spaces
        // & for seven spaces
        System.out.println("-\n|&|  ABC  |  DEF  |\n|$1$|$2$|$3$|\n-\n|  GHI  |  JKL  |  MNO  |\n|$4$|$5$|$6$|\n-\n| PQRS  |  TUV  | WXYZ  |\n|$7$|$8$|$9$|\n-\n|&|&|&|\n|$*$|$0$|$#$|\n-"
        .replace("&","       ").replace("$","   ").replace("-","--------------------"));
     }
}

283 bytes (does have a single trailing new-line, but this is allowed by default), without is still 289 bytes, though.

JavaScript (ES6), 184 182 bytes

f=
_=>`-
! |  ABC  |  DEF  |
!1!2!3|
-
|  GHI  |  JKL  |  MNO  |
!4!5!6|
-
| PQRS  |  TUV  | WXYZ  |
!7!8!9|
-
! ! ! |
!*!0!#|
-`.replace(/-|!./g,s=>s<`-`?`|   ${s[1]}   `:s.repeat(25))
;document.write('<pre>'+f());

The rows of dashes are obviously compressible and the digits were too but I couldn't do anything with the letters. Edit: Saved 1 of 2 bytes thanks to @Shaggy.

Save a byte with: replace(/-|!./g,s=>s=="-"?s.repeat(25):"|   ${s[1]}   ") - replacing quotation marks with backticks. I tried a few things to pad out the letter groups but the best I could do was 194 bytes.

@Shaggy Thanks, and I managed to shave another byte off that too!

Lua, 209 bytes
Golfed:
a=("-\n|&|  ABC  |  DEF  |\n123|\n-\n|  GHI  |  JKL  |  MNO  |\n456|\n-\n| PQRS  |  TUV  | WXYZ  |\n789|\n-\n|&|&|&|\n*0#|\n-"):gsub("&","       "):gsub("([0-9*#])","|   %1   "):gsub("-",("-"):rep(25))print(a)

Ungolfed:
-- "&" for seven spaces
-- "1" -> "|   1   "
-- "-" -> twenty-five dashes

a="-\n|&|  ABC  |  DEF  |\n123|\n-\n|  GHI  |  JKL  |  MNO  |\n456|\n-\n| PQRS  |  TUV  | WXYZ  |\n789|\n-\n|&|&|&|\n*0#|\n-"

a = a:gsub("&","       ")

a = a:gsub("([0-9*#])","|   %1   ")

a = a:gsub("-",("-"):rep(25))

print(a)

Python 2, 168 bytes
A straightforward method using no built-in compression:
for i in range(13):print['-'*25,'|'+'|'.join(["123456789*0#"," ABC DEF GHI JKL MNO PQRS TUV WXYZ   ".split(' ')][i%3%2][i/3%4*3+m].center(7)for m in[0,1,2])+'|'][i%3>0]

CJam, 128 bytes
'-25*N+:A" ABC DEF GHI JKL MNO PQRS TUV WXYZ   "S/3/{['|\{_,5\-S*\"  |"}%N]:+:+}%"123456789*0#"1/3/{['|\{S3*_@@'|}%N]:+:+}%.+A*A

Try it online.

Perl, 142+1 = 143 bytes
$ perl -MCompress::Zlib x.pl
$ cat x.pl
print uncompress(<DATA>)
__DATA__
x<9c><d3><d5><c5>^A<b8>j^T ^@H;:9<83>i^WW7 ^M<96>1<84><c8>(^XAic<10><cb>0<b0>i<ee>^^<9e>`<b5>^<de>>`<da><d7><cf>^_f<9a> <d4>^TS(mFд<80> `<b0>ڐ<d0>0^P^]^^^Q^Y^E3<cd>^\j<8a>^E<94><b6>$<ec>6<98>OQi<b0><8c>^VT<c4>^@J+<e3>7^M^@^D:@k

Unprintable characters, so uuencoded version is below.
$ cat x.pl.uue
begin 664 x.pl
M<')I;G1?=6YC;VUP<F5S<R@\1$%403XI"E]?1$%405]?"GB<T]7%`;AJ%"``
M2#LZ.8-I%U<W(`V6,83(*!A!:6,0S87+,+!I[AZ>8+5>WCY@VM?/'V::"=04
M4RAM1M"T@,"@8+#:D-`P$!T>$1D%,\T<:HH%E+8D[#:83U%IL(P65,0`2BOC
(-PT`!#I`:PH`
`
end
$

Wait, shouldn't -M... be counted as well?

///, 154 characters
/%/=====//=/-----//?/ ! //!/}  //{/ }//}/  |//(/|   /%
(  !ABC!DEF}
(1?2?3{
%
|  GHI!JKL!MNO}
(4?5?6{
%
| PQRS!TUV} WXYZ}
(7?8?9{
%
(  !   !   }
(*?0?#{
%

GML (Game Maker Language) 8.0, 269 bytes
a='-------------------------'b='   |   'c='  |#|   'draw_text(0,0,a+"#|       |  ABC  |  DEF"+c+"1"+b+"2"+b+"3   |#"+a+"#|  GHI  |  JKL  |  MNO"+c+"4"+b+"5"+b+"6   |#"+a+"#| PQRS  |  TUV  | WXYZ"+c+"7"+b+"8"+b+"9   |#"+a+"#|    "+b+" "+b+"  "+c+"*"+b+"0"+b+"\#   |#"+a)

In Game Maker, # is the newline character and it can be escaped by \#

Python 3.5 - 240 bytes:
k=' ABC DEF 1 2 3 GHI JKL MNO 4 5 6 PQRS TUV WXYZ 7 8 9    * 0 #'.split(' ')
for _ in range(8):
 print('\n',end='')
 if _%2==0:print("-"*27+'\n',end='')
 [print('|{}|'.format(g.center(7)),end='')for g in k[:3:1]];del k[:3:1]
print('\n'+"-"*27)

Prints just what the OP wants, although it may be a bit long.

Python 2, 200
r=str.replace;print r(r(r(r(r("""-.|  ABC`DEF`
,1=,2=,3 `-|  GHI`JKL`MNO`
,4=,5=,6 `-| PQRS`TUV`WXYZ |
,7=,8=,9 `-...|
,*=,0=,# `-""","-","\n"+"-"*25+"\n"),".",",= "),",","|="),"`","  |  "),"=","   ")

Simple replacing strategy.

Python 2, 134 bytes
This source contains non-printable characters, so it is presented as a hexdump that can be decoded with xxd -r.
00000000: efbb bf70 7269 6e74 2778 01d3 c505 b86a  ...print'x.....j
00000010: 1420 5c30 483b 3a39 8369 1757 3720 5c72  . \0H;:9.i.W7 \r
00000020: 9631 84c8 2818 4169 6310 cd85 d734 770f  .1..(.Aic....4w.
00000030: 4fb0 5a2f 6f1f 30ed ebe7 0f33 cd04 6a8a  O.Z/o.0....3..j.
00000040: 2994 3623 685a 4060 5030 586d 4868 1888  ).6#hZ@`P0XmHh..
00000050: 0e8f 888c 8299 660e 35c5 024a 5b12 345c  ......f.5..J[.4\
00000060: 7202 3068 b08c 1654 c45c 304a 2be3 375c  r.0h...T.\0J+.7\
00000070: 725c 3004 3a40 6b27 2e64 6563 6f64 6528  r\0.:@k'.decode(
00000080: 277a 6970 2729                           'zip')

05AB1E, 91 bytes
•O«ò•3B7ô'-7×.ø'|ìε3×}'|«D¦Ð)˜»A3ô5£ðý"pqrs tuvwxyz"‚J5úR12úRv0y.;}1ð:2'A:9LJ"*0#"«v'Ay.;}u

Try it online!

J, 105 103 bytes
9!:7'|'9}11#'-'
echo'PW'(7 2;7 18)}":_3;/\(12{.'',8 3$65{26-.&'PW'\a.),:&(5|.7{.])"1' ',.'123456789*0#'

Try it online!

all_licenses: 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/


text:
Random array without repetition
I was answering one challenge here and this task was part of the challenge. I've got a 73 bytes solution in javascript. But I think it is too much for a simple thing.
Challenge
Given as input two integers:

N the length of the expected array
R the interval's range starting in one: 1..R, not 0..R-1

Output in each run of your program/function one different array of length N with values between 1..R in such a way no one value occurs more than once.
You must use R-value in your code.
Restrictions
You can assume: 2 <= N <= R.
I really would like to see a javascript solution shorter than mine 73 bytes.
But of course, it is open to all languages!
If your language can not return an array, you can print all the numbers ;)

Another thing: I do not think that you want them to be different with every run, but just uniformly random? (Otherwise it would not work for R=N=1) Then I recommend allowing the ranges 0..R as an alternative as this comes more natural to many languages.

I'd recommending including that each permutation be equally likely (assuming perfect randomness), else I can do shuffle(0..N)

I posted my answer of non-uniform random quality before you made your rule change.

You say a uniformly random solution, but new Date yields non-uniform values. Further, I believe you can golf it to new Date%r+1 ;)

Does the output array need to be integers?  Seems obvious, but I don't see it explicitly stated

Dyalog APL, 1 byte
?

Just a builtin. Try it here.

With an answer like this, I had to scroll back up to see if you were the OP

@lbstr Now that you mention it, my identicon is quite similar to OP's.

JavaScript (ES6), 68 66 bytes
n=>r=>G=(s=new Set)=>s.size<n?G(s.add(Math.random()*r+1|0)):[...s]

Called as F(N)(R)(), where F is the function assignment, and N/R are the values.
You asked for shorter than 73 bytes in Js ;)
EDIT: The answer by @C5H8NNaO4 works within the fact that the rules don't specify the values must be uniform across 1..R. Given that, here's a version works in 63 bytes (called as F(R)(N)):
r=>G=(n,s=[])=>n--?G((s[n]=n+1,n),s):s.sort(a=>new Date/a%1-.5)

Man, this is impressive !! +1

@WashingtonGuedes Thanks =) Just shaved off another 2 bytes.

Octave, 22 19 9 bytes
@randperm

randperm(r,n) does exactly what is requested. Note that this does not work  (at least not in oldder versions) in Matlab.

@(n,r)randperm(r,n)

randperm with two inputs does work in recent Matlab versions. There's also randsample, but it takes more bytes, unless you can get rid of the @(...) (I think that's allowed)

Oh I can use @randperm=)

MATL, 2 bytes
Zr

Inputs are: first R, then N.
Try it online!
Explanation
The function Zr takes two inputs (implicitly in this case) and does a random sampling without replacement. The first input, R, specifies that the population is [1,2,...,R]; and the second input, N, indicates the number of samples to take from the population.

TI-84 BASIC OS 4.0, 12 bytes
Prompt N,R:randIntNoRep(1,R,N

The TI-84+ CSE (2013) and the CE (2015) are essentially the same limited BASIC dialect as the TI-84+, but there are a few new features. One of them is randIntNoRep's third argument.

Frankly, it's kind of silly that they didn't include that feature from the beginning.

I immediately thought TI-Basic when I saw this challenge :)

Pyth, 6 bytes
<.SSQE

Try it here!
Range comes on the first line and the length on the second.
Explanation

<.SSQE    # Q = range, E = length

   SQ     # generate the range 1...Q
 .S       # shuffle the list
<    E    # take the first E elements

Non-competing 5-byte version
The lastest addition to Pyth adds implicit Qs at the end of the program if needed. We can use this here by reversing the input format, so the length comes first and then the range.
<.SSE

Try it here!
Here E is the range, which we turn into a 1-based list with S, shuffle it with .S and take the first Q elements with <. < expects an integer which is implicitly added with a Q.

J, 4 3 bytes
One byte saved thanks to Zgarb! (Crossed out four is still a regular four :D)
1+?

call like N (1+?) R, e.g., 3 (1+?) 10. This uses the "Roll" operator, and does exactly what is described, except under 0...n-1. If we were allowed to do this, then the answer would be 1 byte,
?

Don't break the link chain, man!

@tac Ah, gotcah

Reng v.2.1, 140 103 98 97 bytes
This should work in earlier versions, too.
v      v      $/$'l#y0#z>(:)):(ez+#z zt>a$;!
>i#ci#x>cu1+lxetv    j21\!q   yy#-1y($/^
>n?~v
^oW <

You can try it here! Input is maximum length, such as 10 3.
I am so proud of this, you don't even know. If someone beats me with a Java answer, that will make my day. If I beat a Java answer, consider my day made as well.
I will explain it more later, once I recover. Generally, though:
v         v      $/$r$
>i#bbi1+#x>:u1+lxet

This generates the random numbers. The other part checks if there are duplicates, and, if there are, the process is repeated. Else, the results are printed, with spaces joining the results.
Here are some examples:

CJam, 8 bytes
{,:)mr<}

Try it here!
This is an unnamed block which expect the range on top of the stack and the length at the bottom and leaves a list on the stack.
Explanation

,   e# 0-based range
:)  e# inkrement each element of the list so its 1-based
mr  e# shuffle the list
<   e# take the first n elements

This is one happy program :)

@CᴏɴᴏʀO'Bʀɪᴇɴ I would be happier if CJam had a builtin for 1-based ranges, so I wouldn't need this damm smileyface :P

Bash + coreutils, 16
I think this is self-explanatory:
seq $2|shuf -n$1

Input N and R as command-line parameters.
Or as @rici points out, for the same score:
shuf -n$1 -i1-$2

Ideone.

or shuf -n$1 -i1-$2 (same length, though).

@rici very nice. very clean :)

Ruby, 27 23 bytes
Anonymous function, reasonably short and sweet.
-4 bytes from @manatwork
->n,r{[*1..r].sample n}

->n,r{[*1..r].sample n} Please use code block markup instead of inline code markup, so scripts like Code Golf UserScript Enhancement Pack can insert the code size beside it.

All right, it's fixed now.

Common Lisp, 90
52 for the expression only
(use-package :alexandria)(lambda(R N)(coerce(subseq(shuffle(iota R :start 1))0 N)'vector))

Ungolfed
;; Well known library
(use-package :alexandria)

(lambda(R N)
  (coerce                   ; make a vector from a list
    (subseq                 ; take the sublist from 0 to N
      (shuffle              ; shuffle a list
        (iota R :start 1))  ; build a list from 1 to R
    0 N)
    'vector))

Like other answers, if I don't count use-package and lambda, the remaining expression is (coerce(subseq(shuffle(iota R :start 1))0 N)'vector), for 52 bytes.

, 10 chars / 13 bytes
Ѩŝ⩤⁽1í)ą-î

Try it here (Firefox only).
Explanation
           // implicit: î=input1, í=input2
  ⩤⁽1í)    // Inclusive range from 1 to í
Ѩŝ         // Shuffle resulting range
       ą-î // Get last îth items

PowerShell v2+, 30 bytes
param($n,$r)1..$r|Random -c $n

Takes input $n and $r, constructs a range 1..$r, pipes that to Get-Random with a -Count of $n, which will select $n unique elements from the range. Output is left on the pipeline as an implicit array.

Seriously, 5 bytes
,,R╨J

Try it online!
Explanation:
,,R╨J
,,R    push N, range(1, R+1)
   ╨   push a list containing all N-length permutations of range(1, R+1)
    J  select a random element from the list

Python 3.5 - 54 53 bytes:
from random import*;lambda a,c:sample(range(1,c+1),a)

This uses the random module's sample() function to return an array with length "a" consisting of random, unique elements in the range 1 => c.

Clojure, 38 bytes
#(take %1(shuffle(map inc(range %2))))

An anonymous function taking N first and R second.

Perl 6, 32 bytes
{(^$^a).permutations.pick[^$^b]}

D, 29 bytes (expression only)
Assuming that std.random and std.range have been imported and that n and r are defined as variables, the program can be solved in the single expression:
iota(1,r).randomCover.take(n)

ES6, 72
r=>n=>[...Array(-~r).keys()].sort(a=>new Date/a%1-.5).filter(a=>a&&n-->0)

Like in @Mwr247's answer, you can call it with F(R)(N), F being the function expression

Mathcad, 67 "bytes"
creates a column vector of consecutive integers in range 1..R, joins it to a column vector of length R of (uniform) random numbers, sorts the resulting Rx2 matrix on the random number column, and then extracts the first n numbers from the randomized column of integers.

Is there a place we can test this?

You can download trial versions of Mathcad 15 and Mathcad Prime 3.1 (the successor to Mathcad 15).  Both trials run for 30 days, after which M15 stops working, but Prime 3.1 still runs, albeit with reduced functionality (eg, no programming - so the above won't work ... but the for loop can be rewritten to use range variables to create v outside of the augment statement)

Trial versions are at: Matcad 15 - http://www.ptc.com/engineering-math-software/mathcad/free-trial ; Mathcad Prime 3.1 - http://www.ptc.com/engineering-math-software/mathcad/free-download

And how do you count these bytes?

By looking at it from a user input perspective and equating one Mathcad input operation (keyboard usually, mouse-click on toolbar if no kbd shortcut) to a character and interpreting this as a byte.  csort = 5 bytes as it's typed char-by-char as are other variable/function names.  The for operator is a special construct that occupies 11 characters (including 3 blank "placeholders" and 3 spaces) but is entered by ctl-shft-#, hence = 1 byte (similar to tokens in some languages).  Typing ' (quote)creates balanced parentheses (usually) so counts as 1 byte.   Indexing v = 3 bytes (type v[k).

Python, 56 (the obvious way)
lambda N,R:__import__('random').sample(range(1,R+1),k=N)

from random import*;lambda N,R:sample(range(1,R+1),k=N) is shorter by a byte

Huh, I did consider from random import*, must've screwed up the counting.

TI-84 BASIC, 21 bytes
Prompt R,N:randIntNoRep(1,R→A:N→dim(ʟA:ʟA

One can no longer use Ans as input as per a recent meta post.

@CᴏɴᴏʀO'Bʀɪᴇɴ ...why not?

That was the consensus on meta. Vote on it if you disagree.

Perl 5, 51 43 bytes
sub{@a=1..pop;map{splice@a,rand@a,1}1..pop}

Pretty straightforward anonymous sub that generates an array from 1 to R and then splices N random elements from it to return. Call with ->(N, R).


text:
X+Y=Z - but in which base?
The  Challenge
Given 3 numbers X, Y and Z in base B, find a Base in which the addition of X and Y yields Z. The inputs x = 20, Y = 12 and Z = 32 could yield 5 because 20 + 12 = 32 in base 5.

You may assume that there will always be a base in which the addition is correct (there are cases where no base exists, thanks to @MasonWheeler and @Not that Charles for some examples of that).
The lowest possible base is 1. You may use 1s or 0s as the digits in unary, but you may not mix those.

I/O

The digits of the input numbers will be non-negative integers.
You may assume that the input numbers contain leading zeros, so the have a specific (or all the same) length.
You may take the numbers in the most convenient format, as long as it's not preprocessed. This includes the overall format of the three input numbers and the format of the digits of each of those numbers. Please make it clear which format you use.
If there are multiple possible bases, you can output all or just one of them.
You may assume that the base and the input numbers will be within the numerical limits of your language.

Rules

Function or full program allowed.
Default rules for input/output.
Standard loopholes apply.
This is code-golf, so lowest byte-count wins. Tiebreaker is earlier submission.

Test cases
Input format here is a list of integers to represent each number. The three lists are separated by commas.
Note that there are sometimes multiple bases possible. Only one (random) solution is outputted here.

[12, 103],[4, 101],[16, 204] -> 349
[4, 21, 25],[5, 1, 20],[9, 23, 17] -> 28
[16, 11],[25, 94],[41, 105] -> 147
[2, 140],[21, 183],[24, 100] -> 223
[8, 157],[1, 28],[9, 185] -> 227
[2, 158],[88],[3, 12] -> 234
[8, 199],[1, 34],[9, 233] -> 408
[3, 247],[7, 438],[11, 221] -> 464
[3, 122],[3, 2],[6, 124] -> 480
[6, 328],[3, 31],[9, 359] -> 465
[2, 1, 0, 0, 0, 0],[1, 2, 0, 0, 1, 0, 1, 0],[1, 2, 2, 1, 1, 0, 1, 0] -> 3
[16, 105],[16, 120],[33, 84] -> 141
[15, 60],[9, 30],[24, 90] -> 268
[2, 0],[1, 2],[3, 2] -> 5
[1, 3, 3, 7],[1, 2, 3],[1, 4, 6, 0] -> 10
[0],[1, 12, 8],[1, 12, 8] -> 16
[1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1],[1, 0, 0, 1, 0, 1, 1, 1, 0, 0, 1],[1, 0, 0, 1, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0] -> 2
[1],[1],[1,1] -> 1

You can generate additional test cases with this Pyth program. Enter a base on the first line and the decimal values for X and Y on the following two lines.
Also you can use this Pyth program to create multiple test cases at once by using random values. Just enter the desired amount of test cases in the input.
Happy Coding!

Very similar: Determine the Base where a Given Equation is True

Jelly, 16 11 7 bytes
_/N,‘FṀ

This approach is heavily based on @beaker's Octave answer.
Input format is Z, Y, X, with little-endian digit order, using the digit 0 for unary.
Try it online! or run all test cases.
How it works
Rather than incrementally testing potential bases, this solves the polynomial that corresponds to the array P := X + Y - Z. This returns either the largest coefficient of P ≠ 0 – which has to be a root, since there is at least one valid base – or the highest digit of X, Y and Z, incremented by 1.
_/N,‘FṀ  Main link. Argument: [Z, Y, X]

_/       Reduce by subtraction; yield Z - X - Y.
         This works since Z must have at least as many digits as X and Y.
  N      Negate to yield X + Y - Z.
    ‘    Yield [Z, Y, X], with all digits increments by 1.
   ,     Pair the results to the left and to the right.
     F   Flatten the resulting, nested list.
      Ṁ  Compute the maximum.

Pyth, 13 bytes
f!-FiRTQheSsQ

Expects Z, followed by X and Y.
Test suite
Essentially, we test every possible base, starting at one more than the largest digit. The test is that we convert each number to the base in question, then fold subtraction over the numbers, and logically negate the result.

So this one takes unattractive as zeroes?

@QPaysTaxes I'm guessing you meant unary, and yes.

@Mego I meant unary, autocorrect meant whatever it wanted to mean.

Octave, 67 75 38 32 bytes
Because "loop over ALL the things" is too much work.
@(x,y,z)max([m=max(x+y-z) z])+~m

Requires 0 padding to make the input arrays the same size, e.g.:
[2, 158],[88],[3, 12]
becomes
[2, 158],[0, 88],[3, 12]

Since 0 is used for padding, 1 is used as the token for unary.
(Thanks to @DenkerAffe for clarification in the question.)
Sample run on ideone.

Short Explanation:
Take a case involving no carries:
   [ 8, 199]
 + [ 1,  34]
 -------------
     9, 233
 - [ 9, 233]
 -------------
     0,   0 --- no carries

In this case there are no restrictions on base as long as it's greater than any "digit". Simply take the max element of z (as z >= x,y) and add 1 (or any positive integer).
In the case of a carry-out (with no carry-in), we've exceeded the base in one of the columns and the difference between x+y and z is the base:
   [ 2, 140]
 + [21, 183]
--------------
    23, 323
 - [24, 100]
 -------------
    -1  223
     ^   ^------ base
     |---------- carry in

If the second column's sum also exceeded the base, requiring a carry-out as well as the carry-in, its value would be base+(-1). We will have had a column somewhere to the right with a carry-out and no carry-in that has the correct (greater) base value.

Haskell, 90 73 bytes
f l=[b|b<-[1..],all(<b)$id=<<l,[x,y,z]<-[foldl((+).(b*))0<$>l],x+y==z]!!0

Usage example: f [[3, 247],[7, 438],[11, 221]] -> 464.
Simply try all bases b (where b is greater than the maximum of the digits). Pick the first one where x+y==z.
Edit: @xnor saved many bytes by primarily getting rid of the import Data.Digits.

If unDigits b does what I think, it should be shorter to implement as foldl(\x y->b*x+y)0 or equivalently foldl((+).(b*))0.

It's shorter to take the maximum after flattening: b<-[1+(maximum$id=<<l)..].

Or, the test for maximum as b<-[1..],all(<b)$id=<<l.

Does this work for input where base 1 is the only solution? I can't execute this with the online compilers I found, so I can't test myself.

@DenkerAffe: shouldn't the digits d of a base b number be 0 <= d < b, so for base 1 the only possible digit is 0?  f [[0],[0],[0,0]] evaluates to 1.

Yea, thats fine. Just wanted to check, since I  couldn't test it.

MATL, 20 bytes
`GY:@XJZQ2:"wJZQ-]]J

Input is in the format (note outer curly braces):
{[4, 21, 25],[5, 1, 20],[9, 23, 17]}

This works in current version (15.0.0).
Try it online!
Explanation
`        % do...while index
  G      %   push input. First time pushed nothing but asks for input implicitly
  Y:     %   unpack the cell array, pushing the three numeric arrays
  @      %   loop index: candidate base
  XJ     %   copy into clipboard J
  ZQ     %   evaluate polynomial: interpret third array in that base
  2:"    %   for loop: do this twice (subtract the other numbers from the third)
    w    %     swap, to process another array
    J    %     push base
    ZQ   %     evaluate polynomial: interpret array in that base
    -    %     subtract
  ]      %   end for loop. A result 0 indicates a solution has been found
]        % end do....while loop. Exit if top of stack is 0
J        % push found base. Implicitly display

MATL, 13 12 bytes
--X>t~1G+hX>

Translation of my Octave answer into MATL. (My first MATL answer!)

Input order is Z, X, Y (or Z, Y, X if you prefer, I'm easy)
Input arrays are zero-padded to equal lengths
Takes unattractives as 1

Try it online!
Explanation
--X>t~1G+hX>

--            % M = Z - X - Y
  X>          % P = max(M)
    t~        % Duplicate and negate
      1G      % Push 1st argument (Z)
        +     % ~P + Z
         h    % Concatenate [P (~P + Z)]
          X>  % Return max

unary is very unattractive by AutoCorrect these days

APL (Dyalog Unicode), 28 27 bytes (SBCS)
Saved 1 byte thanks to @Adám
{⍺←1+⌈/∊⍵⋄0=-/⍺⊥⍵:⍺⋄⍵∇⍨⍺+1}

Try it online!
Takes a matrix with columns x z y, with all of them padded with zeroes to have the same number of digits.
Explanation:
{
⍺←1+⌈/∊⍵                 ⍝ First base
      ∊⍵                ⍝ Flatten the input into a single vector of digits
     ⌈/                  ⍝ Maximum digit (reduce with max)
  1+                    ⍝Add one to that to get the lowest possible base

0=-/⍺⊥⍵                ⍝If this base works
 :⍺                     ⍝Return it
    ⍺⊥⍵                ⍝Convert to base ⍺
  -/                    ⍝Reduce with subtraction (x - (z - y)) = x + y - z
0=                      ⍝Check if it's 0 (the equation works)

⍵∇⍨⍺+1                  ⍝Otherwise, call itself (∇) with the next base
}
```

Take the input as a matrix instead of a vector of vectors to save a byte

@Adám Thanks. I have to go now, but I"ll update my answer when I have time

05AB1E (legacy), 6 bytes
ζÆ(I>M

Port of @Dennis's Jelly answer, so make sure to upvote him as well! The I/O is also in the same format, except with the input wrapped inside a list instead of three loose inputs: \$[Z,Y,X]\$, with little-endian digit order, using the digit \$0\$ for unary.
Try it online or verify all test cases.
The new 05AB1E version would require an additional leading 0 to overwrite the default space-filler of ζ. In the legacy 05AB1E version built in Python, the spaces are counted as 0 when we reduce by subtracting with Æ, though. Which would have given an error in the new version, which is built in Elixir.
Explanation:
        #  i.e. input = [[12,3],[88],[158,2]]
ζ       # Zip/transpose the (implicit) input-matrix, swapping rows/columns,
        # using a space filler by default if the rows doesn't have matching lengths
        #  STACK: [[12,88,158],[3," ",2]]
 Æ      # Reduce each inner-most list by subtracting, counting the spaces as 0
        #  STACK: [-234,1]
  (     # Negate each
        #  STACK: [234,-1]
   I>   # Push the input again, and increase each value by 1
        #  STACK: [234,-1],[[13,4],[89],[159,3]]
     M  # Push the largest value on the stack, which also looks inside (nested) lists
        #  STACK: [234,-1],[[13,4],[89],[159,3]],234
        # (after which this top value is output implicitly as result)


text:
Commutation of 27 functions
Introduction
Let's define a ternary function as a function from the three-element set S = {0,1,2} to itself: it associates to each element of S another element of S.
One example of a ternary function f is
f(0) = 0; f(1) = 2; f(2) = 0

There are exactly 27 different ternary functions, and we represent them with integers from 0 to 26: a function f is encoded as f(0) + 3*f(1) + 9*f(2).
The example function above is encoded as the number 6.
We can apply two ternary functions f and g in sequence, and if f(g(k)) == g(f(k)) holds for all k in S, then the functions commute.
Your task is to verify whether this is the case.
Input
Your inputs are two integers in the inclusive range from 0 to 26.
They represent two ternary functions f and g.
Input must be taken in decimal, binary or unary (string of 1s) format.
Output
Your output is a truthy value if f and g commute, and a falsey value if they don't.
You may not assume that the inputs are ordered.
Examples
Consider the inputs 5 and 16.
They encode the ternary functions
f(0) = 2; f(1) = 1; f(2) = 0
g(0) = 1; g(1) = 2; g(2) = 1

We have f(g(1)) == f(2) == 0 and g(f(1)) == g(1) == 2, so f and g don't commute and the correct output is falsey.
On the other hand, the inputs 3 and 10 encode the ternary functions
f(0) = 0; f(1) = 1; f(2) = 0
g(0) = 1; g(1) = 0; g(2) = 1

and it can be verified that f(g(k)) == g(f(k)) holds for all k in S.
Then the correct output is truthy.
Here is the 27×27 table of all possible inputs, with + marking a truthy output and - a falsey output:
+ - - + - - + - - + - - + - - + - - + - - + - - + - -
- + - - - - - - - - - - + - - - - - - - - + - - - - -
- - + - - - - - - - - - - - - - - - - - - + - - + - -
+ - - + - - - - - - + - - + - - - - + - - + - - - - -
- - - - + - - - - - - - - + - - - - - - - + - - - - -
- - - - - + - - - - - - - + - - - - - - - + - - - - -
+ - - - - - + - - - - - - - - - - - - - - + - - - - -
- - - - - - - + - - - + - - - - - - - - - + - - - - -
- - - - - - - - + - - - - - - - - - + - - + - - - - -
+ - - - - - - - - + - - - - - - - - - - - + - - - - -
- - - + - - - - - - + - - - - - - - - - - + - - - - -
- - - - - - - + - - - + - - - - - - - - - + - - - - -
+ + - - - - - - - - - - + + - - - - - - - + + - - - -
- - - + + + - - - - - - + + + - - - - - - + + + - - -
- - - - - - - - - - - - - + + - - - - - - + - - - - -
+ - - - - - - - - - - - - - - + - - - - - + - - - - -
- - - - - - - - - - - - - - - - + - - - - + - + - - -
- - - - - - - - - - - - - - - - - + - - - + + - - - -
+ - - + - - - - + - - - - - - - - - + - - + - - - - +
- - - - - - - - - - - - - - - - - - - + - + - - - - +
- - - - - - - - - - - - - - - - - - - - + + - - - - +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
- - - - - - - - - - - - + + - - - + - - - + + - - - +
- - - - - - - - - - - - - + - - + - - - - + - + + - +
+ - + - - - - - - - - - - - - - - - - - - + - + + - +
- - - - - - - - - - - - - - - - - - - - - + - - - + +
- - - - - - - - - - - - - - - - - - + + + + + + + + +

Rules and scoring
You can write a full program or a function.
The lowest byte count wins, and standard loopholes are disallowed.

Can the input be an array with the two numbers?

@DonMuesli That's allowed as per consensus on Meta.

Jelly, 17 14 13 bytes
+13ḃ3Um0ị2/⁼/

Try it online! or verify all 27×27 cases.
How it works
+13ḃ3Um0ị2/⁼/  Main link. Argument: [f, g] (encoded as integers)

+13            Add 13 ([1, 1, 1] in base 3) to f and g.
   ḃ3          Convert f + 13 and g + 13 to bijective base 3.
               Bijective base 3 uses the digits 1 to 3 instead of 0 to 2.
               This yields [[f(2)+1, f(1)+1, f(0)+1], [g(2)+1, g(1)+1, g(0)+1]].
               The increments account for 1-based indexing.
     U         Reverse each digit array.
               This yields [[f(0)+1, f(1)+1, f(2)+1], [g(0)+1, g(1)+1, g(2)+1]].
      m0       Concatenate the list with a reversed copy of itself.
        ị2/    Split the result into pairs, and reduce each one by indexing.
               This computes g○f and f○g.
          ⁼/   Reduce by match; return 1 iff g○f = f○g.

I've copied your idea of verifying all test cases and displaying the matrix :-)

MATL, 19 18 bytes
I:PII$YAZ{Y:)1Mw)=

Truthy is an array with all ones. Falsy is an array containing at least one zero.
Try it online! or verify all cases (takes a few seconds).
       % implicitly input an array of two numbers
I:P    % push [3 2 1]
I      % push 3
I$     % specify that the next function takes 3 inputs
YA     % convert input to base 3 with alphabet [3 2 1] and 3 digits. Gives 2x3 array
Z{     % convert into cell of two cells, one with each row
Y:     % split cell array. We have two arrays on the stack, one per function
)      % index operation to compute f ∘ g. Function composition is indexing
1M     % push the two arrays again
w      % swap the two arrays
)      % index operation to compute g ∘ f
=      % test for equality element-wise
       % implicitly display

I think usually only the empty list is considered falsy.

@Timtech That depends on the language. In MATL, arrays that contains zeroes are falsy.

Okay, just checking...

@Timtech Sure! Here it is in more detail: An expression is true when its result is nonempty and contains only nonzero elements (logical or real numeric)

Python 2, 61 bytes
lambda m,n:all(n/3**(m/i%3)%3==m/3**(n/i%3)%3for i in[1,3,9])

Given an input i, we can implement the function represented by n by doing n/3**i%3 to extract the ith ternary digit of n. The function checks that the same result is gotten for each of 0,1,2 when applying the functions in either order. Actually, since the first step is doing 3**, this tests with [1,3,9] instead.
The code reuse looks wasteful, but I didn't see a better way. Compare:
q=lambda x,i:x/3**i%3;lambda m,n:all(q(m,q(n,i))==q(n,q(m,i))for i in[0,1,2])

JavaScript (ES7), 68 bytes
(a,b)=>![0,1,2].some(n=>t(a,t(b,n))-t(b,t(a,n)),t=(a,n)=>a/3**n%3|0)

Unfortunately base 3 conversion was too expensive:
(a,b)=>[0,1,2].every(n=>a[b[n]]==b[a[n]],g=a=>(27+a).toString(3).slice(1),a=g(a),b=g(b))

Mathematica, 77 bytes
Reverse[#][[#2+{1,1,1}]]==Reverse[#2][[#+{1,1,1}]]&@@IntegerDigits[{##},3,3]&

Mathematica's One-based indexing strikes again!

Shorter to assign {1,1,1} to a variable and use that.


text:
Simple predictive keyboard CG
In honor of recent news of Google developing a keyboard for iPhone...
Your input (for simplicity, all input is case sensitive):

Location of standard dictionary file. File format is 1 valid word per line; in alphabetical order. Example file:
apple
banana
citrus
domino
durian
orange
tuna
zabc

Location of personal dictionary file (initially, may be empty or non-existant). Format is 1 word per line, comma separated by count of times that word was used. Example file:
Stackoverflow,15
StackExchange,11
Meta,13
TFGITW,2
VTC,10

A stream of words on standard input (for simplicity, newline separated), in the following format on each line: "Typed_word,intended_word".

You need to emulate a predictive keyboard, as follows. For every line in the stream of words:

Process the typed word character by character
After 3rd character, generate the 5 most-used words that start with the currently-seen substring
"5" is a hard-coded constant, but my example below uses "2" for simplicity. "most-used" are picked as first words when words are sorted in the order of counting; alphabetic order within same counts.
The rules for most-used words are: the word from the standard dictionary is assumed to have the used count of 20 (that's a hard-coded constant, but my example below uses "2" for simplicity). The word from personal dictionary has a used count of whatever number the dictionary file has.
If one of 5 words matches intended word, print the success: "MATCH:$substring,$intended_word" and stop
If typed word is finished and matches intended_word, print it: "FULLWORD:$typed_word,$intended_word" and stop
If typed word is finished, but none of teh matches or the word match intended_word, print ERROR message including both typed and intended word: "MISMATCH:$typed_word,$intended_word"
Add the intended word to the personal dictionary if missing from it; or increment its usage count in personal dictionary if already present

Answers should be genuine working code - no gotchas/loopholes, no edge cases like super-small input.
SAMPLE RUN
(I'm going to change the constants to 2 guesses (instead of 5) and main dictionary words weigh as 2 user-usages instead of 20)
Standard Dictionary:
abacus
abacii
abandon
abandoned
abandonment

User dictionary
EMPTY
INPUT
abanana,abanana
abanana,abanana
abanana,abanana
abandonmint,abandonment
cat,cad

OUTPUT
FULLWORD:abanana,abanana #after this, add "abanana,1" to custom dictionary
MATCH:abana,abanana
   # NOTE: your code should have matched "abandon,abandoned" till seeing "abana"
   # change custom dict count for abanana to 2
MATCH:aban,abanana #By now, aban matches "abanana,abandon"
MATCH:abandonm,abandonment
MISMATCH:cat,cad # Add cad to custom dictionary

NOTE: someone asked to be able to live with no files. I'm fine with that, the simplest spec seems to be to pass all 3 inputs on STDIN, separated by empty line between the inputs.

Yep, that helps a lot, thanks. Re: IO - Instead of specifying where this stuff should live / be sent to you can rely on our community defaults to take care of stuff we consider fair. So you could say something like "a list of words containing only upper and lower case ascii letters" and "a dictionary of words containing only upper and lower case ascii letters and a numerical weight".

Just something to clarify: words in the standard dictionary will never be added to the custom dictionary? And the two initial dictionaries are guaranteed to be mutually exclusive?

@FryAmTheEggman - yes. And if it simplifies the code, sure let's make them mutually exclusive, since the natural start state is empty custom dictionary and program logic only adds missing words to custom.

Can we take the standard dictionary from stdin or function argument? Would make solutions easier to test as there's no files involved.

@CatsAreFluffy - I suppose, if you can figure out how to separate dictionaries from data stream. I'd expect that to make the code longer but I'm fine with the idea.

Maybe an empty line between dictionary and input?

Python 3.9, 350 bytes
import sys
[s,p,x]=sys.stdin.read().split("\n\n")
p,x=[[l.split(',')for l in d.split("\n")]for d in[p,x]]
s={k:20 for k in s.split("\n")}
p={k:int(v)for k,v in p}
for t,i in x:b=s|p;b={k:b[k]for k in b if k[:4]==t[:4]};b=sorted(b,key=b.get);p[i]=p.get(i,0)+1;print((f"MATCH:{t[:4]},"if i in b[:5]else f"FULLWORD:{t},"if t==i else f"MISMATCH:{t},")+i)

Try it online! (Uses {**a,**b} instead of a|b to merge dictionaries)
The I/O formats are restrictive, but this still makes for a simple and fun challenge.
import sys
#s is the standard dictionary, p is the personal dictionary, and x is the input
#They are separated by a blank line
[s,p,x]=sys.stdin.read().split("\n\n")
#Turn both p and x into lists (separated by \n) of 2-element lists (separated by commas)
p,x=[[l.split(',')for l in d.split("\n")]for d in[p,x]]
#Split s on \n to get list of words, then map to 20, the default no. of occurrences
s={k:20 for k in s.split("\n")}
#Turn p into a dictionary, and make the values ints
p={k:int(v)for k,v in p}
#Iterate over each typed word t and intended word i in the input
for t,i in x:
  #Merge the personal and standard dictionaries and store in b
  b=s|p
  #Filter the words who start with the first 4 characters of t (typed word)
  b={k:b[k]for k in b if k[:4]==t[:4]}
  #b now contains words from the dictionary, sorted by number of occurrences
  b=sorted(b,key=b.get)
  #Increment number of occurrences of i in personal dictionary, or set to 1 if it doesn't exist yet
  p[i]=p.get(i,0)+1
  #Print the corresponding message
  print((f"MATCH:{t[:4]},"if i in b[:5]else f"FULLWORD:{t},"if t==i else f"MISMATCH:{t},")+i)


text:
Expand roots into a polynomial
Challenge
Given the roots of a polynomial separated by spaces as input, output the expanded form of the polynomial.
For example, the input
1 2

represents this equation:
(x-1)(x-2)

And should output:
x^2-3x+2

The exact format of output is not important, it can be:
1x^2+-3x^1+2x^0

or:
0 0 0
1x^3+0x^2+0x^1+0

or:
3 14 15 92
1x^4+-124x^3+3241x^2+-27954x^1+57960

Scoring/Rules

eval and likes are disallowed.
You may use any version of Python or any other language.

What about built-ins like numpy.poly?

@Dennis numpy is not built-in i think!

Python + NumPy answers are generally accepted, but that's beside the point. Can I use a function that turns roots into polynomial coefficients? I'm asking since you banned eval, and that's considerably more powerful than eval.

@Dennis That pretty much the whole think! But go ahead! Since the same function is built-in in most languages.

can we assume the roots are integers? can we assume they are nonnegative integers?

Jelly, 15 bytes
Æṛ‘Ė’Uj€“x^”j”+

This uses Æṛ to construct the coefficients of a monic polynomial with given roots. Try it online!
How it works
Æṛ‘Ė’Uj€“x^”j”+  Main link. Argument: A (list of roots)

Æṛ               Yield the coefficients of a monic polynomial with roots A.
  ‘              Increment each root by 1.
   Ė             Enumerate the roots, yielding
                 [[1, coeff. of x^0 + 1], ... [n + 1, coeff. of x^n + 1]].
    ’            Decrement all involved integers, yielding
                 [[0, coeff. of x^0], ... [n, coeff. of x^n]].
     U           Upend to yield [[coeff. of x^0, 0], ... [coeff. of x^n, n]].
      j€“x^”     Join each pair, separating by 'x^'.
            j”+  Join the pairs, separating by '+'.

Alternate version, 24 bytes
1WW;ð0;_×µ/‘Ė’Uj€“x^”j”+

This uses no polynomial-related built-ins. Try it online!
How it works
1WW;ð0;_×µ/‘Ė’Uj€“x^”j”+  Main link. Argument: A (list of roots)

1WW                       Yield [[1]].
   ;                      Concatenate with A.
    ð    µ/               Reduce [[1]] + A by the following, dyadic chain:
     0;                     Prepend a zero to the left argument (initially [1]).
                            This multiplies the left argument by "x".
        ×                   Take the product of both, unaltered arguments.
                            This multiplies the left argument by "r", where r is
                            the root specified in the right argument.
      _                     Subtract.
                            This computes the left argument multiplied by "x-r".
           ‘Ė’Uj€“x^”j”+  As before.

MATL, 29 bytes
ljU"1@_hX+]tn:Pqv'+%gx^%g'wYD

Input is an array with the roots.
EDITS:

(May 20, 2016): the X+ function has been removed, as Y+ includes its functionality. So in the above code replace X+ by Y+.
(September 29, 2017): due to changes in the YD function, w in the above code should be removed.

The following link includes those changes.
Try it online!
Explanation
This applies repeated convolution with terms of the form [1, -r] where r is a root.
l          % push number 1
jU         % take input string. Convert to number array
"          % for each root r
  1        %   push number 1
  @_       %   push -r
  h        %   concatenate horizontally
  X+       %   convolve. This gradually builds array of coefficients
]          % end for each
tn:Pq      % produce array [n-1,n-2,...,0], where n is the number of roots
v          % concatenate vertically with array of coefficients
'+%gx^%g'  % format string, sprintf-style
w          % swap
YD         % sprintf. Implicitly display

Ruby, 155 bytes
Anonymous function, input is an array of the roots.
Prints from lowest power first, so calling f[[1,2]] (assuming you assigned the function to f) returns the string "2x^0+-3x^1+1x^2".
->x{j=-1
x.map{|r|[-r,1]}.reduce{|a,b|q=a.map{|c|b=[0]+b
b.map{|e|e*c}[1..-1]}
q.pop.zip(*q).map{|e|(e-[p]).reduce(:+)}}.map{|e|"#{e}x^#{j+=1}"}.join('+')}

Python 3, 453 bytes (Spaces removed and more) -> 392 bytes
import functools
import operator
print([('+'.join(["x^"+str(len(R))]+[str(q)+"x^"+str(r)if r>0else"{0:g}".format(q)for r,q in enumerate([sum(functools.reduce(operator.mul,(-int(R[n])for n,m in enumerate(j)if int(m)==1),1)for j in[(len(R)-len(bin(i)[2:]))*'0'+bin(i)[2:]for i in range(1,2**len(R))]if sum(1-int(k) for k in j)==p)for p in range(len(R))]) ][::-1]))for R in[input().split()]][0])

Check This link, Will help understand the reason behind those two imports.

You could get rid of a lot of extra whitespace

@proudhaskeller You're right! I changed the rules kinda forgot to change my own answer.

from operator import*, from functools import* save a few bytes

import functools,operator

Haskell, 99
l%r=zipWith(-)(0:l)$map(r*)l++[0]
f e='0':do(c,i)<-zip(foldl(%)[1]e)[0..];'+':show c++"x^"++show i

prints the lower powers first, with an additional 0+ at the start. for example:
>f [1,1]
"0+1x^0+-2x^1+1x^2"

The function computes the coefficients by progressively adding more roots, like convolutions, but without the builtin.
Then we use the list monad to implicitly concat all of the different monomials.

Sage, 38 bytes
lambda N:prod(x-t for t in N).expand()

Try it online
This defines an unnamed lambda that takes an iterable of roots as input and computes the product (x-x_n) for x_n in roots, then expands it.

Mathematica, 26 bytes
Expand@Product[x-k,{k,#}]&

Mathematica has powerful polynomial builtins.
Usage
  f = Expand@Product[x-k,{k,#}]&
  f@{3, 14, 15, 92}
x^4 - 124 x^3 + 3241 x^2 - 27954 x + 57960

JavaScript (ES6), 96 bytes
a=>a.map(x=>r.map((n,i)=>(r[i]-=x*a,a=n),++j,r.push(a=0)),r=[j=1])&&r.map(n=>n+`x^`+--j).join`+`


text:
Shortest class to implement Perl hash-of-hashes
At some point, I bumped into an SO question asking how to implement Perl's trivial hash-of-hashes data structure in Java.
For those who don't know Perl, the hash value can be a scalar or another hash, or technically speaking hash reference. Arbitrary depth. Additional feature offered by Perl is autovivification - assigning an element 4 layers deep will automatically create correct hashes with proper keys 4 levels deep, without Java's need to assign hash object on level 1, then hash object on level 2 (being added to the first hash as a value) etc...
So, Perl code to assign a value to N-level hash at a known depth is
my $myHash; # initialization isn't required due to autovivification
$myHash->{$key1}->{$key2}->{$key3}->{$key4} = $value;

And to retrieve it
my $value = $myHash->{$key1}->{$key2}->{$key3}->{$key4};

The more generic code to assign a hash by arbitrary set of keys can be implemented by 5-10 line subroutine done properly; or 2-3 lines golf hack with eval.
Not being anywhere near a Java expert, my SO answer was ~30 lines of code that implemented a fixed-depth 3 level hash of hash of hashes.
Your mission, should you choose to accept it, is to produce the smallest code in a strongly typed language which implements Perl equivalent data structure which is a hashmap of hashmaps of ...; of arbitrary and non-uniform depth (basically, a tree); with hasmap keys being of String type; and leaf-level values String or Integer. The code should support 100% of what the Perl hash-of-hashes code does, including:

Retrieving a value based on a list of keys
Assigning a value based on a list of keys

As part of this, you should be able to replace a scalar leaf level node with an internal hashmap node, if your list of keys leads to that.
E.g. set("val1","k1","k2");set("val2","k1","k2","k3") basically erases "val1" from existence after second call as it's replaced by a 3rd level hashmap.

The code should be resilient, e.g. no null exceptions etc... even for the bad input (simply return NULL)
You can use any strongly typed language other than Java, though I would personally prefer Java answers due to how/why this question originated.
Caveat: using some 3rd party library that implements equivalent of Perl hashes is NOT acceptable. 100% of the code must be using only the native core capabilities of the language.

Come to think of it, this would also be possible in Python and other weakly or dynamically typed languages that have a concept of classes. Would those be allowed as well?

@AlexA. - no, sorry. As I noted in my comment (now deleted), doing it in a  language without strong typing (especially Perl-influenced ones like Python or Ruby) is too easy and basically defeats the purpose of the challenge.

Ah right, sorry.

Out of interest (since I wouldn't have used a strongly typed language) what's the result of get("k1", "k2") after the two set operations in the question?

You should add some test cases for people to ensure that their code works.

"strongly typed" is not a term with a unanimous definition; I consider some dynamic languages to be strongly typed, for example. I suppose you want to say statically typed, but maybe you should give an explicit list of allowed languages.

@Neil - an instance of the class, containing the subtree under "k2" node.

@coredump - statically typed is probably a better choice.

C#, 215 bytes
class A:System.Collections.Generic.Dictionary<string,object>{public void B(string a,object b){if(ContainsKey(a))this[a]=b;else Add(a,b);}public dynamic C(string a){if(!ContainsKey(a))Add(a,new A());return this[a];}}

The class is named A. Use hash.B("key", "val"); to set a value, and hash.C("key"); to get a value. Nested keys can be achieved through, e.g., hash.C("k1").C("k2").C("k3").B("k4", "value");.

What is "dynamic" used for? I don't know C# enough to understand why it is required.

@coredump It's (from a quick look) used here as a 'generic type' that isn't known until its resolved in the runtime. We don't know what the function return type is, so let's return an unknown type :D

@TuukkaX I just used it so that it could be easily chained without having to cast objects back to As.

@LegionMammal978 Oh. I see. Thanks for clarifying!

Scala, 231 214 199 193 bytes
Immutability always wins! (turns out the long package name of collection.mutable.Map wasn't worth the hassle...)
class A{var a=Map[String,Any]()
def g(s:String*):Any={val y=s(0);if(s.size>1)g(y).asInstanceOf[A].g(s.drop(1):_*)else if(a.contains(y))a(y)else{a+=y->new A;a(y)}}
def s(s:String,v:Any)=a+=s->v}

Only thing that's problematic is the need to cast back to A... but having another method entirely that'd return a.type is actually longer (and with cannot be used).
Example:
val a = new A()
a.g("hey").asInstanceOf[A].s("foo", "bar")
a.g("hey").asInstanceOf[A].s("int", 3)
println(a.g("hey").asInstanceOf[A].g("foo"))
println(a.g("hey", "foo"))
println(a.g("hey", "int"))
a.s("hey", 42)
println(a.g("hey"))

Output:
bar
bar
3
42

Go, 136 bytes
type S=string
type A struct{m map[S]any}
func(a*A)g(k S)any{if _,o:=a.m[k];!o{a.m[k]=N()};return a.m[k]}
func(a*A)s(k S,v any){a.m[k]=v}

Attempt This Online!
Challenge specification does not specify constructors; this implementation does not include them. An implementation with a constructor is below:
Go, with constructor, 174 bytes
type S=string
type A struct{m map[S]any}
func N()*A{return&A{make(map[S]any)}}
func(a*A)g(k S)any{if _,o:=a.m[k];!o{a.m[k]=N()};return a.m[k]}
func(a*A)s(k S,v any){a.m[k]=v}

Attempt This Online!


text:
Convert a base-10 number into a number of any other base
You have to take a base-10 number (e.g. 735) and another number for the base to convert to, and convert the base-10 number into the equivalent number in the other base.
Rules:

You aren't allowed to use any conversion functions built into your language

This is code-golf, the shortest answer in bytes wins!

How do you propose dealing with bases above, say, 62? Do we just follow the ASCII chart for symbol progression? Could use some more clarification.

The number will be the same, only expressed in another base. Can you give a few examples including output?