text:
Quack the Angry Duck
No one is quite certain what the emoticon >:U is intended to represent, but many scholars believe it looks like an angry duck. Let's assume that's the case.
Task
Given an integer n between 0 and 3 inclusive, print or return
quack

if n = 0,
>:U

if n = 1,
     U   U
>  : U   U
 >   U   U
>  : U   U
      UUU

if n = 2, or
                  >:U         >:U
>:U               >:U         >:U
   >:U       >:U  >:U         >:U
      >:U         >:U         >:U
         >:U      >:U         >:U
      >:U         >:U         >:U
   >:U       >:U  >:U         >:U
>:U               >:U         >:U
                     >:U>:U>:U

if n = 3.
You can assume the input will always be valid. There should be no leading space in the output, but any amount of trailing space is fine. Ducks (with the possible exception of @cobaltduck) have no tolerance for loopholes. Shortest code in bytes wins.

...huh. The [tag:number] tag seems like it should be on a lot of challenges. "using,...accepting as input... numerical values."

"scholars" :-DDD

First I was thinking "huh, what is a duck?". Luckily you have provided a link to the wikipedia page.

It looks more like an angry magpie than a duck to me, heh heh. :-P

"Ducks have no tolerance for loopholes." But you're a bird not a duck, does that mean we can use loopholes? :P

@Downgoat Nope. Also that edit was entirely unnecessary so I rolled it back.

@Downgoat s/:P/>:U/

"Ducks have no tolerance for loopholes."  That, my friend, is a dangerous stereotype.  If I didn't know your intentions, I might take offense.

@cobaltduck My apologies. Is this any better?

ROFL :-)  One of these days, my sarcastic streak is going to get me in trouble.  Apology accepted.

"...but many scholars believe it looks like an angry duck." I beg to differ... https://i.ytimg.com/vi/OmNymPocKro/hqdefault.jpg

CJam, 108 90 85 bytes
"quack"">:U":D"scT¦{$ì"{269b22bSf*D}:F~[ZYB].*s.+s5/"ÿ3nÜïS{JÐø¦yûn"F*33/z]ri=zN*

Note that some characters are unprintable. Try it online!
Background
The first two outputs are incompressible in CJam.
Compressing the last output is straightforward. After stripping all linefeeds, we can split the resulting string at occurrences of >:U, and compute the length of each resulting string of spaces.
That results in the array
[18 9 0 15 9 3 7 2 9 6 9 9 9 6 9 6 9 9 3 7 2 9 0 15 9 21 0 0 0]

which we can store efficiently by converting it from base 22 to base 269, yielding the digits
[255 12 51 110 220 239 83 123 74 208 248 166 121 251 110 17]

Since each digit is less than 256, we can store it as a single byte.
Finally, compressing the third output becomes easier if we transpose lines and columns:
 > >
  >

 : :

UUUU
    U
    U
    U
UUUU

Counting once more the spaces between non-whitespace characters, we get the array
[1 1 3 8 1 6 0 0 0 5 4 4 0 0 0 0 0]

which becomes
[115 159 99 84 166 123 36 236 6]

when transcoded from base 22 to base 269.
How it works
"quack"   e# Push the first output.

">:U":D   e# Push the second output, and save it in D.

e# Push [115 159 99 84 166 123 36 236 6] as bytes.

"scT¦{$ì"

{         e# Define a code block:
  269b22b e#   Transcode from base 269 to base 22.
  Sf*     e#   Replace each digit with a string of that many spaces.
  D       e#   Push D.
}         e#
:F~       e# Save the block in F. Execute it.
[ZYB]     e# Push [3 2 11].
.*        e# Vectorized repeat; push [">>>" "::" "UUUUUUUUUUU"].
s         e# Flatten the array of strings.
.+        e# Append the nth character to the nth string of spaces.
s5/       e# Flatten and split into chunks of length 5.

e# Push [255 12 51 110 220 239 83 123 74 208 248 166 121 251 110 17] as bytes.

"ÿ3nÜïS{JÐø¦yûn"

F         e# Execute F.
*         e# Join the resulting array of strings of spaces, separating by ">:U".
33/       e# Split into chunks of length 33.
z         e# Zip; transpose rows with columns.

]         e# Wrap the entire stack in an array.
ri        e# Read a token from STDIN and interpret it as an integer.
=         e# Retrieve the element at the corresponding index.
z         e# Zip; transpose rows with columns or map "string" to ["string"].
N*        e# Join, separating by linefeeds.

I like the extra :D between the two strings.

@Zgarb He has appeased the great duck overlord. The duck now smiles.

I went through the page thinking, "172... 162... 182... I can beat all those. Wait, 90? Oh, it's Dennis the Unbeatable..."

Java, 303 286 bytes
Saved 17 bytes thanks to @VoteToClose!
Not actually meant to be the shortest, I just thought it would be fun to try in Java.
Creates a list of string variables representing common strings, then creates an array of all the outputs, then prints the right one.
String a(int y){String n="\n",d=">:U",A=" ",B=A+A,C=B+B,D=C+C,a="U"+B+" U"+n,G=D+A,H=C+B,c=d+G+d+n,E=B+A,F=C+E;String[]z={"quack",d,C+A+a+">"+B+": "+a+" >"+E+a+">"+B+": "+a+C+B+"UUU",D+D+B+c+d+D+F+c+B+A+d+F+d+B+c+H+d+G+c+G+d+H+c+H+d+G+c+E+d+F+d+B+c+d+D+F+c+D+D+C+A+d+d+d};return z[y];}

Ungolfed:
String a(int y) {
    String n = "\n", d = ">:U", A = " ", B = A + A, C = B + B, D = C + C,
            a = "U" + B + " U" + n, G = D + A, H = C + B, c = d + G + d + n,
            E = B + A, F = C + E;
    String[] z = { "quack", d, C + A + a + ">" + B + ": " + a + " >" + E + a + ">" + B + ": " + a + C + B + "UUU", D + D + B + c + d + D + F + c + B + A + d + F + d + B + c + H + d + G + c + G + d + H + c + H + d + G + c + E + d + F + d + B + c + d + D + F + c + D + D + C + A + d + d + d };
    return z[y];
}

This is my first answer on this site, so please tell me if I have done something wrong.

It looks fine! Nice first post, and welcome to PPCG!

@AlexA. Thanks for letting me know, I fixed it.

@kittycat3141 Looks great. Nice solution and thanks for participating in my challenge! :)

It appears that D+A and C+B appear frequently enough to be golfed further into 2 new variables. I also get the slightest feeling that using an array with a for loop might help, but I haven't figured out how yet...

05AB1E, 162 159 157 bytes
Code
Dammit, way too long, but it's at least something:
">:U"VI3Qið16×7166b1ð:0Y:DUJ,Yð13×JD?X,3838b1ð:0Y:D?X,16255b1ð:0Y:D?X,16367b1ð:0Y:4F?X,}ð21×Y3×J,}¹2Qið4×" U   U"©J,">  :"®JD," >  "?®,,ð6×'U3×J,}¹iY,}"quack

Try it online!

Explanation
The first part of the code exists of ">:U"V, which sets Y to that string. After that, we just check if the input is equal to 3. That is done at the I3Qi part. If equal, we print the giant magpie:
N = 3
It first starts with ð16× which just pushes 16 space characters. After that, there is a number 7166b. This covers the ">:U             " part, with a little help from Retina :). I used this script to convert the string to a binary number. After that, we get to the 1ð:0Y: part, which replaces every 1 with a space character and every 0 with Y, which has been set to >:U. After that, we Duplicate this string, store it in X using U and Join the stack. We pop this using ,, which prints the full string with a newline. All the others after that are all based on the same principe. The if statement ends at the second }.
The full conversion can be found here.
N = 2
We now check if the input is equal to 2. This is done at the ¹2Qi part. After that, if equal, we push the space character 4 times using ð4×. After that, we push the " U   U" string and store it using © (idea blatantly stolen from Jelly :p). We again Join the stack and print this with a newline. After that, we push the ">  :" string, retrieve the " U   U" using ®, Join the stack and Duplicate this string and print these both on the same line.
Short quiz, what will this do: " >  "?®,?
After printing the above string, we get the duplicate of the second line of the face, and print this (since it's the same as the 2nd line).
The last part covered by this case is:
ð6×'U3×J,

ð6×        # Push the space character × 6
   'U3×    # Push the "U" character three times
       J,  # Join and print pop with a newline

N = 1
This one is easier to explain:
¹1QiY

¹1Qi   # Check if the input is equal to 1
    Y  # Push the magpie face
       # This is then implicitly printed

N = 0
¹0Qi"quack

¹0Qi        # Check if the input is equal to 0
    "quack  # Weird sound what magpies make
            # Implicitly printed

Explanation plz? :P

@VoteToClose Done :)

"way too long"? See my answer :-P

TIL that magpies quack. Apparently.

Vitsy, 172 171 159 bytes
Oh, geez. If I wanted something to show off the power of methods, I got it.
' 'V1+m
'kcauq'Z
'U:>'Z
58m5m6m'   > 'Z5m6m'UUU'68m
f3+bm9mamcm98m2m6bmcmam9mf6+8m3\[2m]
a'U   U'Z
' :  >'Z5m
Z2m98ma2m
\VZ
2mfbm
VVVZ2m78m2mVV7m
8m7m
68m2m9bm
Try it Online!
How this works is by calling various methods throughout itself. The explanation is below:
' 'V1+m
' 'V      Save character literal ' ' as a permanent variable.
    1+    Add one to the top item of the stack (input + 1)
      m   Go to that index of code.

'kcauq'Z
'kcauq'   Push 'quack' to the stack.
       Z  Output everything in the stack as a char.

'U:>'Z
'U:>'Z    Ouput ">:U" with the same method as the previous line.

Now on to some more... interesting lines.

58m5m6m'   > 'Z5m6m'UUU'68m
5              Push space, push 4
 8m            Call the 8th line index.
               As we will soon see, the 8th line index duplicates the space
               the number of times specified by the number just before the call
               (4 in this case)
   5m          Call the 5th line index.
               The 5th line index outputs the 'U   U' and a newline.
     6m        Call the 6th line index.
               The 6th line index outputs '>  : U   U' and a newline.
'   > 'Z       Output ' >   '.
        5m6m   Same method calls as before.
'UUU'          Push 'UUU'.
     68m       Push 6, then call the 8th line index. This gives us the correct padding.

f3+bm9mamcm98m2m6bmcmam9mf6+8m3\[2m]
f3+              Push 18.
   bm            Call the 11th line index.
                 The 11th line index calls the 8th line index (which we've already seen
                 in action) and then the 7th line index, which you can find and explanation
                 for below (it does a lot)
     9m          Call the 9th line index.
                 The 9th line index outputs '>:U               >:U         >:U' (explanation lower)
       am        Call the 10th line index.
                 ...I'm gonna stop explaining these and just tell you to go to the lines now. :P
         cm      Call the 12th line index.
9                Push space, push 9.
 8m              Call the 8th line index (explained below and before).
   2m            Call the 2nd line index.
     6           Push 6.
      bm         Call the 11th line index. We've finished up to '>:U      >:U         >:U' now.
cm               You guessed it! Call the 12th line index. (explanation below)
  am             Call the 10th line index. (explanation below)
    9m           Call the 9th line index. (explanation below)
f6+              Push space, push 19 21.
   8m            Call the 8th line index. (explanation below)
     3\[2m]      Call the 2nd line index thrice.

All of the rest of these methods are supporting methods now.

a'U   U'Z       Output 'U   U' followed by a newline.

' :  >'Z5m      Output '>  : U   U' followed by a newline.

Z2m98ma2m
Z               Output everything currently in the stack.
 2m             Call the 2nd line index.
   9            Push space, push 8.
    8m          Call the 8th line index. (explained below)
      a         Push a newline to the stack.
       2m       Call the 2nd line index.
                This handles the biggest angry duck face's faces showing the eyebrows and eyes.

\VZ
\V    Push space as many times as the top item specifies.
  Z   Output everything in the stack.

2mfbm
2m      Call the 2nd line index.
  f     Push space, push 14.
   bm   Go to the 11th line index.
        This handles the mouth and some parts of the eyebrows of the biggest duck face.

VVVZ2m78m2mVV7m
VVVZ              Output 3 spaces (and whatever was pushed before it)
    2m            Call the 2nd line index.
      7           Push space, push 6.
       8m         Call the 8th line index. (explained... above)
         2m       Call the 2nd line index.
           VV     Push 2 spaces.
             7m   Call the 7th line index.

8m7m     This is pretty damn self-explanatory if you've read this far.

68m2m9bm
6            Push space, push 5.
 8m          Call the 8th line index.
   2m        Call the 2nd line index.
     9       Push space, push 9.
      bm     Call the 11th line index.
This code is ridiculous. It's verbose form is:
toggle single quote;
 ;
toggle single quote;
save top as permanent variable;
push 1;
add top two;
goto top method;
:toggle single quote;
k;
push 12;
push 10;
flatten top two stacks;
q;
toggle single quote;
output stack as chars;
:toggle single quote;
U;
clone current stack;
go forward;
toggle single quote;
output stack as chars;
:push 5;
push 8;
goto top method;
push 5;
goto top method;
push 6;
goto top method;
toggle single quote;
 ;
 ;
 ;
go forward;
 ;
toggle single quote;
output stack as chars;
push 5;
goto top method;
push 6;
goto top method;
toggle single quote;
U;
U;
U;
toggle single quote;
push 6;
push 8;
goto top method;
:push 15;
push 3;
add top two;
push 11;
goto top method;
push 9;
goto top method;
push 10;
goto top method;
push 12;
goto top method;
push 9;
push 8;
goto top method;
push 2;
goto top method;
push 6;
push 11;
goto top method;
push 12;
goto top method;
push 10;
goto top method;
push 9;
goto top method;
push 15;
push 6;
add top two;
push 8;
goto top method;
push 3;
repeat next instruction set top times;
begin recursive area;
push 2;
goto top method;
end recursive area;
:push 10;
toggle single quote;
U;
 ;
 ;
 ;
U;
toggle single quote;
output stack as chars;
:toggle single quote;
 ;
clone current stack;
 ;
 ;
go forward;
toggle single quote;
output stack as chars;
push 5;
goto top method;
:output stack as chars;
push 2;
goto top method;
push 9;
push 8;
goto top method;
push 10;
push 2;
goto top method;
:repeat next instruction set top times;
save top as permanent variable;
output stack as chars;
:push 2;
goto top method;
push 15;
push 11;
goto top method;
:save top as permanent variable;
save top as permanent variable;
save top as permanent variable;
output stack as chars;
push 2;
goto top method;
push 7;
push 8;
goto top method;
push 2;
goto top method;
save top as permanent variable;
save top as permanent variable;
push 7;
goto top method;
:push 8;
goto top method;
push 7;
goto top method;
:push 6;
push 8;
goto top method;
push 2;
goto top method;
push 9;
push 11;
goto top method;

JavaScript (ES6), 163 bytes

var solution =

n=>["quack",d=">:U",`5U3U
>2:1U3U
1>3U3U
>2:1U3U
6UUU`,`99090
096090
30702090
609090
906090
609090
30702090
096090
993000`][n].replace(/\d/g,c=>+c?" ".repeat(c):d)
<input type="number" oninput="R.textContent=solution(+this.value)">

Explanation
Uses my go-to compression with JavaScript: run-length encoding. The digits 1 to 9 map to that many spaces, 0 maps to the angry duck face, and any other character stays the same.

Very impressive for a non-golfing language, but the rows right above and below the center for n = 3 seem to be missing.

@ETHproductions Oops, not sure what happened there. Fixed now.

Japt, 116 105 102 99 96 bytes
["quack""c)`+«öÂ[@=^Gñ`1]o2"mc r'4#¿+R "4z>2:z >2z>2:z6UUU"rz" U3U
" '1]®r'1">:U" r"%d"_SpZ}ÃgU

Contains an unprintable. Test it online!
How it works
The first two strings are not compressed at all. The third is compressed simply by replacing each runs of spaces with its length, then " U3U" with "z". The last one is more complex:

Replace each run of 2-9 spaces with its length.
Replace >:U with 1.
Replace 191\n with 4. (4 isn't used anywhere else in the string.)
Map each valid byte code (10-255, or 0A-FF) to the character with that char code.

The resulting string is only 21 19 bytes long, but the decompression takes up another 31 29.
After decompressing the strings, we simply take the item at position U, the input. (The array is arranged [0,3,2,1] because there's a bug which makes it count from the end of the array instead of the beginning.)
[                      // Create an array of the following:
  "quack"              //  "quack".

  "c)`+«öÂ[@=^Gñ`1]o2" //  Take this string (contains an unprintable).
                       //  Map each char to its char code.
                       //  This produces "994196431712461949164619431712419649931112".
  r'4#¿+R              //  Replace each "4" with the char code of "¿" (191) + a newline.

  "4z>2:z >2z>2:z6UUU" //  Take this string.
  rz" U3U\n"           //  Replace each "z" with " U3U\n".

  '1                   //  "1".
]
®              Ã       // Map each item by this function:
r'1">:U"               //  Replace each "1" with ">:U".
r"%d"_SpZ}             //  Replace each remaining digit Z with Z spaces.

gU                     // Get the item at index -U, wrapping.
                       // (This should just be U, but there's a bug which negates it.)

MATL, 283 182 bytes
101 bytes saved thanks to @Adnan!
This uses decimal numbers to encode indices 0...3 to the four characters for cases 2 and 3. The decimal numbers could perhaps be compressed using base-64 encoding, but quack!
For the case 3 a very nice trick suggested by @Adnan is used: define binary sequences to encode each row, where 0 and 1 correspond to space and >:U respectively.
~?'quack'}G1=?'>:U'}G2=?' :>U'12336 8466480h2109488h8466480h4032h4YA47-)}268697600 67174401h16795656h67174464h67174912h67174464h16795656h67174401h14680064h"@BP48+]Xh49'>:U'YX48 32YXc

Try it online!

How about for the last case, using this, replacing the 1 with spaces and the 0 with the >:U string. I don't know if that would help.

@Adnan That's a good idea!

@Adnan 101 bytes saved :-O

That is amazing! Very nice answer! :)

JavaScript ES6, 232 223 203 188 bytes
Saved 29 44 bytes thanks to ETHproductions!
n=>[`quack`,r=`>:U`,`     U   U
>  : U   U
 >   U   U
>  : U   U
      UUU`,`00022
10022
0100 1  12
00122
20012
00122
0100 1  12
10022
0000211`.replace(/\d/g,N=>[g=`   `,r,g+g+g+r][N])][n]

Test it out!

A=n=>[`quack`,r=`>:U`,`     U   U
>  : U   U
 >   U   U
>  : U   U
      UUU`,`0000002
1000002
0100 1  2
0010002
0001002
0010002
0100 1  2
1000002
0000000111`.replace(/\d/g,N=>[g=`   `,r,r+g+g+g+r][N])][n]

(a.onchange=a.onkeydown=a.onkeyup=function(){
 o.innerHTML = A(+a.value);
})();
*{font-family:"Consolas",monospace;font-size:20px;white-space:pre-wrap}input{left:50%;width:150px;position:absolute;text-align:center;margin-left:-75px;}#o{margin:15px;border:1px solid #00ACDC;padding:15px;}
<input id=a type=number value=0 min=0 max=3>

surely it can be atob'd... if not, could the 1 and 0s be made into a trinary number?

@Downgoat btoaing and trinary both are longer.

Old answer, but you could save like 15 bytes by changing r+g+g+g+r to g+g+g+r and adjusting the string accordingly.

Cinnamon Gum, 76 bytes
0000000: 6c33 502b 2c4d 4cce b636 54b3 b30a b536  l3P+,ML..6T....6
0000010: 5253 0081 5010 e6b2 5350 b082 3215 ecb0  RS..P...SP..2...
0000020: 8a42 1487 865a 1bab 2960 00a0 79c8 6c2e  .B...Z..)`..y.l.
0000030: 2026 a002 4221 0430 55c0 5938 cd40 9720   &..B!.0U.Y8.@.
0000040: 6c06 6177 90e9 17ac 4102 4100            l.aw....A.A.

Non-competing since Cinnamon Gum was created after this challenge.
Try it online.
Explanation
The first byte l specifies the mode: in this case it tells Cinnamon Gum to enter lookup table mode. Cinnamon Gum then decompresses the rest of the string (which has been compressed with zopfli --deflate) into this:
0&quack;1&>:U;2&     U   U
>  : U   U
 >   U   U
>  : U   U
      UUU;3&                  >:U         >:U
>:U               >:U         >:U
   >:U       >:U  >:U         >:U
      >:U         >:U         >:U
         >:U      >:U         >:U
      >:U         >:U         >:U
   >:U       >:U  >:U         >:U
>:U               >:U         >:U
                     >:U>:U>:U

It then splits by ;, puts each key-value pair (with & as delimiter) in a dictionary, and outputs dictionary[input].

Brainfuck 802 bytes
I know its not very optimal to make this challenges in bf... but its very fun :)
Code:
,>-[<->-----]<+++>>+[--[<]>>+<-]>++[-<++<+>>]>-[<+>+++++++++]>-[<+>---]++++++++++<<+<<+<<[-[-[[-]>>..................>.>.>.<<<.........>.>.>.>.<<<.>.>.<<<...............>.>.>.<<<.........>.>.>.>.<<<<...>.>.>.<<<.......>.>.>.<<<..>.>.>.<<<.........>.>.>.>.<<<<......>.>.>.<<<.........>.>.>.<<<.........>.>.>.>.<<<<.........>.>.>.<<<......>.>.>.<<<.........>.>.>.>.<<<<......>.>.>.<<<.........>.>.>.<<<.........>.>.>.>.<<<<...>.>.>.<<<.......>.>.>.<<<..>.>.>.<<<.........>.>.>.>.<<<.>.>.<<<...............>.>.>.<<<.........>.>.>.>.<<<<.....................>.>.>.<<.>.>.<<.>.>.>>>+<]>-[>.....>>>.<<<...>>>.>.<<<.<..>>.<<.>>>.<<<...>>>.>.<<<<.>.<...>>>.<<<...>>>.>.<<<.<..>>.<<.>>>.<<<...>>>.>.<<<<......>>>...>>>-+]<>+<]>-[ >>.>.>.<<<< +]<>+<]>-[>[>]-[+>+++++[<]>+]>.++++.>+[-[---<]>>-]<-.++.++++++++.>-+]

Try it yourself
"Beautiful version":
READ NUMBER
,>-[<->-----]<+++
WRITE LETTERS FROM SPACE TO LINE JUMP
>>+[--[<]>>+<-]>++[-<++<+>>]
>-[<+>+++++++++]
>-[<+>---]
++++++++++
<<+<<+<<
START A SWITCH CASE
[-
   [-
      [[-]
CASE 3
         >>..................>.>.>.<<<.........>.>.>.>.
         <<<.>.>.<<<...............>.>.>.<<<.........>.>.>.>.
         <<<<...>.>.>.<<<.......>.>.>.<<<..>.>.>.<<<.........>.>.>.>.
         <<<<......>.>.>.<<<.........>.>.>.<<<.........>.>.>.>.
         <<<<.........>.>.>.<<<......>.>.>.<<<.........>.>.>.>.
         <<<<......>.>.>.<<<.........>.>.>.<<<.........>.>.>.>.
         <<<<...>.>.>.<<<.......>.>.>.<<<..>.>.>.<<<.........>.>.>.>.
         <<<.>.>.<<<...............>.>.>.<<<.........>.>.>.>.
         <<<<.....................>.>.>.<<.>.>.<<.>.>.>>
      >+<]>-[
CASE 2
         >.....>>>.<<<...>>>.>.
         <<<.<..>>.<<.>>>.<<<...>>>.>.
         <<<<.>.<...>>>.<<<...>>>.>.
         <<<.<..>>.<<.>>>.<<<...>>>.>.
         <<<<......>>>...>>>-
      +]<
CASE 1
   >+<]>-[ >>.>.>.<<<< +]<
>+<]>-[
CASE 0 (CREATE NEW LETTERS)
   >[>]-[+>+++++[<]>+]>.++++.>+[-[---<]>>-]<-.++.++++++++.>-
+]

GML, 265 bytes
A port of @kittycat3141's excellent answer, with the suggestion to golf it further with two new variables (which I named G and H) by @VoteToClose. I also managed to shorten it further with GML's relatively loose syntax.
d=">:U"A=" "B=A+A;C=B+B;D=C+C;G=D+A;H=C+B;a="U"+B+" U"+"#"c=d+G+d+"#"E=B+A;F=C+E;x[0]="quack"x[1]=d;x[2]=C+A+a+">"+B+": "+a+" >"+E+a+">"+B+": "+a+H+"UUU"x[3]=D+D+B+c+d+D+F+c+B+A+d+F+d+B+c+H+d+G+c+G+d+H+c+H+d+G+c+E+d+F+d+B+c+d+D+F+c+D+D+C+A+d+d+d;return x[argument0]

JavaScript (ES6),  151  150 bytes
n=>(g=s=>(l=s.split(--k),k?g(l.join(l.pop())):l[n]))(`quack030285 >256UUU06273646371631
63436766133162328 3>:U47236 3831
5U2U
>8: U2U
622711
8  `,k=9)

Try it online!

///, 130 bytes
/0/quack//e/UrU
//d/m
//m/br1//b/rr//r/   //1/>:U//2/r  e>  : e >re>  : ebUUU//3/bbb1d1bmdr1b 1  1db1mdmb1db1mdr1b 1  1d1bmdbbm11/

Try it online!


text:
Reimplement the wc coreutil
This challenge is similar to this old
one, but with some unclear
parts of the spec hammered out and less strict I/O requirements.

Given an input of a string consisting of only printable ASCII and newlines,
output its various metrics (byte, word, line count).
The metrics that you must output are as follows:

Byte count. Since the input string stays within ASCII, this is also the
character count.
Word count. This is wc's definition of a "word:" any sequence of
non-whitespace. For example, abc,def"ghi" is one "word."
Line count. This is self-explanatory. The input will always contain a
trailing newline, which means line count is synonymous with "newline
count." There will never be more than a single trailing newline.

The output must exactly replicate the default wc output (except for the file
name):
llama@llama:~$ cat /dev/urandom | tr -cd 'A-Za-z \n' | head -90 > example.txt
llama@llama:~$ wc example.txt
  90  165 5501 example.txt

Note that the line count comes first, then word count, and finally byte count.
Furthermore, each count must be left-padded with spaces such that they are all
the same width. In the above example, 5501 is the "longest" number with 4
digits, so 165 is padded with one space and 90 with two. Finally, the
numbers must all be joined into a single string with a space between each
number.
Since this is code-golf, the shortest code in bytes will win.
(Oh, and by the way... you can't use the wc command in your answer. In case that wasn't obvious already.)
Test cases (\n represents a newline; you may optionally require an extra
trailing newline as well):
"a b c d\n" -> "1 4 8"
"a b c d e f\n" -> " 1  6 12"
"  a b c d e f  \n" -> " 1  6 16"
"a\nb\nc\nd\n" -> "4 4 8"
"a\n\n\nb\nc\nd\n" -> " 6  4 10"
"abc123{}[]()...\n" -> " 1  1 16
"\n" -> "1 0 1"
"   \n" -> "1 0 4"
"\n\n\n\n\n" -> "5 0 5"
"\n\n\na\nb\n" -> "5 2 7"

I'm gonna VTC the old one as a dupe of this one because this one is a much better challenge.

Should the empty input be supported ?

I don't think so, he said all inputs end with \n.

Perl, 49 bytes
Added +3 for -an0
Input on STDIN or 1 or more filenames as arguments.
Run as perl -an0 wc.pl
wc.pl:
/\z/g;pos=~//;printf"%@+d %@+d $`
",y/
//,~~@F

Explanation:
-n0      slurps the whole input into $_ and says we will do our own printing
-a       tells perl to split the input on whitespace into array @F
/\z/g    Matches the absolute end of the input. g modifier so the position
         is remembered in pos which will now contain the input length
pos=~//  An empy regex repeats the last succesful match, so /\z/ again.
         After that $` will contain the the number of input characters and
         the array @+ will contain the length of this number
printf   All preparation is complete, we can go print the result
"%@+d"   will become e.g. %6d if the number of characters is a number of
         length 6, so lines and words will get printed right aligned
         in a field of length 6.
$`       $` we can directly interpolate since it won't contain a %
y/\n//   Count the number of newlines in $_
~~@F     The array of words @F in scalar context gives the number of words

Pyth, 21 bytes
jdm.[;l`lQ`ld[@bQcQ)Q

Test suite
Pyth has some very nice built-ins here. We start by making a list ([) of the newlines in the string (@bQ), the words in the string (cQ)) and the string itself (Q). Then, we pad (.[) the length of each string (ld) with spaces (; in this context) out to the length of the number of characters (l`lQ). Finally, join on spaces (jd).

Python 2, 100 77 bytes
This solution is a Python function that accepts a multi-line string and prints the required counts to stdout. Note that I use a format string to build a format string (which requires a %% to escape the first format placeholder).
Edit: Saved 23 bytes due to print optimisations by Dennis.
def d(b):c=len(b);a='%%%us'%len(`c`);print a%b.count('\n'),a%len(b.split()),c

Before the minifier, it looks like this:
def wc(text) :
    size = len(text);
    numfmt = '%%%us' % len(`size`);
    print numfmt % text.count('\n'), numfmt % len(text.split()), size

Seriously, 39 bytes
"
 "╩╜l;$l╝@╜sl'
╜ck`#╛#"{:>%d}"%f`M' j

Try it online!
Explanation (newlines are replaced with \n):
"\n "╩╜l;$l╝@╜sl'\n╜ck`#╛#"{:>%d}"%f`M' j
"\n "                                      push a string containing a newline and a space
     ╩                                     push input to register 0 (we'll call it s)
      ╜l;                                  push two copies of len(s) (byte count)
         $l╝                               push len(str(len(s))) to register 1
                                            (this will serve as the field width in the output)
            @╜sl                           push word count by getting the length of the list formed by
                                            splitting s on spaces and newlines
                '\n╜c                      count newlines in input
                     k                     push stack to list
                      `#╛#"{:>%d}"%f`M     map:
                       #                     listify
                        ╛#                   push reg 1 (field width), listify
                          "{:>%d}"           push that string
                                  %          do old-style string formatting for field width
                                   f         do new-style string formatting to pad the field appropriately
                                      ' j  join on spaces

I cannot fidn any documentation for this language, can you provide a link?

@JohnEye, https://github.com/Mego/Seriously

POSIX awk, 79 75 67 65 bytes
{w+=NF;c+=length+1}END{d=length(c)"d %";printf"%"d d"d\n",NR,w,c}

Edit: saved 4 bytes since POSIX allows a bare length, saved 7 bytes by discounting the invocation part, and saved two bytes thanks to Doorknob's tip for adding d % to d.
This was originally for GNU awk, but best I can tell, it uses only POSIX awk functionality.
Better formatted:
gawk '{
  w += NF
  c += length($0) + 1  # length($0) misses the newline
}
END {
  d = length(c) # GNU awk's length returns the length of string representation of number
  printf "%"d"d %"d"d %d\n", NR, w, c
}'

@Doorknob OK, thanks for that. Guess you saw the chat conversation? Also, that question should graduate from [tag:faq-proposed] to [tag:faq].

Oh, I didn't see you in chat; your answer just popped up in my inbox :P I was the one who added [faq-proposed] to that question, so maybe I'll check in the mod room before upgrading it to [faq].

Setting d to length(c)"d %" should allow you to change the printf to "%"d d"d\n", which saves two bytes.

@Doorknob indeed, thanks! Guess it's not the exotic, but the mundane that saves bytes.

CJam, 31 26 bytes
q_)/_S*S%@_]:,:s),f{Se[}S*

Try it online!
How it works
q_                         e# Read all input from STDIN and push two copies.
  )                        e# Pop the last character (linefeed) of the second copy.
   /                       e# Split the remaining string at linefeeds.
    _                      e# Push a copy.
     S*                    e# Join the copy, separating by spaces.
       S%                  e# Split at runs of spaces.
         @_                e# Rotate the original input on top and push a copy.
           ]               e# Wrap all four items in an array.
            :,             e# Get the length of each item.
              :s           e# Cast the lengths (integers) to strings.
                )          e# Pop the last length (byte count).
                 ,         e# Get the number of digits.
                  f{Se[}   e# Left-pad all three length with spaces to that length.
                        S* e# Join, separating by spaces.

AppleScript, 253 bytes
This assumes that AppleScript's text item delimiters are set to space (if I need to count the stuff to force that assumption, I'll add it).
set w to(display dialog""default answer"")'s text returned
set x to b(w)
set y to w's text item's number
set z to w's paragraph's number
a(x,z)&z&a(x,y)&y&" "&x
on a(x,n)
set o to" "
repeat b(x)-b(n)
set o to o&" "
end
o
end
on b(n)
count(n as text)
end

Julia, 112 81 bytes
f(s,n=endof,l="$(n(s))",g=r->lpad(n(split(s,r))-1,n(l)))=g(r"\n")" "g(r"\S+")" "l

This is a function that accepts a string and returns a string.
We save the following as function arguments:

n = endof function, which gets the last index of an indexable collection (in this case is the length of the string)
l = "$(n(s)), the length of the input converted to a string using interpolation
A lambda function g that accepts a regular expression and returns the length - 1 of the input split on that regex, left padded with spaces to match the length of l.

We get the number of lines using g(r"\n") and the number of words using g(r"\S+"), then we join those together with l delimited by spaces.
Saved 31 bytes thanks to Dennis!

MATL, 38 bytes
'\n'32cZtttnGnw-wPZvPYbnqbnvvV!3Z"vX:!

You can try it online!
This shouldn't be so long though...
Explanation, for the calculation,
'\n'32cZt  %// Takes implicit input and replaces any \n with a space
tt         %// Duplicate that string twice
nGnw-w     %// Length of the string with \n's minus length with spaces to give number of \n's
PZvPYbnq   %// Take string with spaces, flip it, remove leading spaces, flip it again,
           %// split on spaces, find length and decrement for number of words
bn         %// get length of string with spaces, the number of characters

The last part does the output formatting
vvV!       %// concatenate the 3 numbers to a column vector, convert to string and transpose
3Z"v       %// make string '   ' and concatenate on the bottom of previous string
X:!        %// linearise and transpose to get correct output (impicitly printed)

Nicely done! Maybe remove the "debug" flag in the Try it online link?

Ahh whoops! Thanks for the heads up!

I think you can replace !3Z"vX:! by Z{Zc (cellstr followed by strjoin)

Jelly, 14 bytes
»⁶Ḳ¹ƇLṭċ⁷$;LWG

Try it online!
-1 thanks to Dennis.

JavaScript (ES6), 115 bytes
s=>[/\n\/g,/\S+/g,/[^]/g].map(r=>l=(s.match(r)||[]).length).map(n=>(' '.repeat(99)+n).slice(-`${l}`.length)).join` `

Does not require any input. Formatting was painful. If there was an upper limit on the amount of padding I could reduce (' '.repeat(99)+n) to something shorter e.g. `    ${n}`.

I think you can replace /[^]/g with /./g to save two bytes

@PatrickRoberts No, that skips newlines, so my count would be off.

Ah, never noticed that before.

PowerShell, 140 bytes
param($a)$c="$((($l=($a-split"`n").Count-1),($w=($a-split"\S+").Count-1),($b=$a.length)|sort)[-1])".Length;
"{0,$c} {1,$c} {2,$c}"-f$l,$w,$b

(newline left in for clarity :D)
The first line takes input $a, and then the next part is all one statement. We're setting $c equal to some-string's .length. This will form our requisite padding. Inside the string is an immediate code block $(...), so that code will be executed before evaluated into the string.
In the code block, we're sending three items through the |sort command, and then taking the biggest one (...)[-1]. This is where we're ensuring to get the columns to the correct width. The three items are $l the line count, where we -split on newlines, the $w word count, where we -split on whitespace, and $b the length.
The second line is our output using the -f operator (which is a pseudo-shorthand for String.Format()). It's another way of inserting expanded variables into strings. Here, we're saying that we want all of the output to be padded to the left so that each column is $c wide. The padding is done via spaces. The 0, 1, and 2 correspond to the $l, $w, and $b that are arguments to the format operator, so the line count, word count, and byte count are padded and output appropriately.
Note that this either requires the string to have already-expanded newlines (e.g., doing a Get-Content on a text file or something, and then either piping or saving that to a variable, then calling this code on that input), or use the PowerShell-styled escape characters with backticks (meaning  `n instead of \n).
Example
PS C:\Tools\Scripts\golfing> .\reimplement-wc.ps1 "This line`nis broken`ninto three lines.`n"
 3  7 38

C, 180 178 bytes
#include <stdio.h>
#include <ctype.h>
main(b,w,l,c,d){d=' ';b=w=l=0;while((c=fgetc(stdin))!=EOF){if(!isspace(c)&&isspace(d))w++;b++;d=c;if(c==10)l++;}printf("%d %d %d\n",l,w,b);}

111 bytes

Pip -s, 25 bytes
sX##a-#_._M[nNa`\S+`Na#a]

Takes the multiline string as a command-line argument. Try it online!
Thanks to Dennis's CJam answer for making me realize that the longest number is always the character count.
Explanation
                           s is space; n is newline; a is 1st cmdline arg (implicit)
           [            ]  Construct a list of three elements:
            nNa             Number of newlines in a
               `\S+`Na      Regex search: number of runs of non-whitespace characters in a
                      #a    Length of a (i.e. number of characters in a)
          M                To each element of that list, map this function:
   #a                       Number of characters in a
  #                         Length of that number
     -#_                    Subtract length of each element
sX                          Construct a string of that many spaces
        ._                  Prepend it to the element
                           The resulting list is autoprinted, space-separated (-s flag)

Here's a 29-byte solution with flags -rs that takes input from stdin:
[#g`\S+`NST:gY#g+1]MsX#y-#_._

Try it online!

Powershell, 123 115 bytes
switch -r($args|% t*y){'\s'{$a=0}'\S'{$w+=!$a;$a=1}'(?s).'{$b++}'
'{$l++}}$c="$b".Length
"{0,$c} {1,$c} $b"-f$l,+$w

Test script:
$f = {

switch -r($args|% t*y){    # evaluate all matched cases
    '\s'   {$a=0}          # any whitespace (newline not included)
    '\S'   {$w+=!$a;$a=1}  # any not-whitespace (newline not included)
    '(?s).'{$b++}          # any char (newline included!)
    '`n'   {$l++}          # new line char
}
$c="$b".Length
"{0,$c} {1,$c} $b"-f$l,+$w

}

@(
    , ("a b c d`n", "1 4 8")
    , ("a b c d e f`n", " 1  6 12")
    , ("  a b c d e f  `n", " 1  6 16")
    , ("a`nb`nc`nd`n", "4 4 8")
    , ("a`n`n`nb`nc`nd`n", " 6  4 10")
    , ("abc123{}[]()...`n", " 1  1 16")
    , ("`n", "1 0 1")
    , ("   `n", "1 0 4")
    , ("`n`n`n`n`n", "5 0 5")
    , ("`n`n`na`nb`n", "5 2 7")
) | % {
    $s,$e = $_
    $r = &$f $s
    "$($e-eq$r): $r"
}

Output:
True: 1 4 8
True:  1  6 12
True:  1  6 16
True: 4 4 8
True:  6  4 10
True:  1  1 16
True: 1 0 1
True: 1 0 4
True: 5 0 5
True: 5 2 7

Explanation:

$args|% t*y splits arument strings into chars
switch -r($args|% t*y) evaluate all matched cases

'\s' case for any whitespace
'\S' case for any non-whitespace
'(?s).' case for any char (newline included)
'\n' case for newline char (newline represent itself)

$c="$b".Length calculate a length of bytes number. $b is always max($l,$w,$b) by design
"{0,$c} {1,$c} $b"-f$l,+$w format numbers with same length. The variable $w converts to int. It need for strings without words. Other variables formats 'as is' because 'The input will always contain a trailing newline' and $l and $b cannot be 0.

104 bytes by using splatting, removing the quotes around '\s' and '\S', and replacing .Length with |% Le*

Pascal, 248 bytes
This complete program requires a processor supporting “Extended Pascal” as defined by ISO standard 10206.

The variable input possesses the built-in data type text.
As such any newline character (sometimes it’s CR, sometimes LF, sometimes CR+LF, or something else) is automagically converted into a single space character (' ').
In order to distinguish from a space character as payload of a line, and a space character that resulted from this conversion, you will need to query the function EOLn.
A text variable is conceptually similar to a file of char.
This program in fact counts characters, i. e. actually behaves like wc ‑m.
However, since the task states that characters strictly draw from the ASCII character set, there is no difference.

program c(input,output);var l,w,c,z:integer value 0;p:char;begin p:=' ';while not EOF do begin c:=c+1;l:=l+ord(EOLn);w:=w+card([p]*[' ','   ']-[input^]);p:=input^;get(input)end;z:=trunc(ln(card([0..l,0..w,0..c]))/ln(10))+2;writeLn(l:z-1,w:z,c:z)end.

Ungolfed and annotated version:
{ By listing a `program` parameter of the spelling `input`,
  there’s an implicit `reset(input)` which implies a `get(input)`. }
program wordCount(input, output);
    var
        { `line`, `word` and `character` are singular, because they kind
          of enumerate these units as if input was a zero-based `array`. }
        line, word, character, width: integer value 0;
        previousCharacter: char;
    begin
        { This program counts “word beginnings” as words. This is the
          _change_ from “space character” _to_ “non-space character”. }
        previousCharacter := ' ';

        while not EOF(input) do
        begin
            character := character + 1;
            { As per POSIX specification a line is payload _plus_ one newline. }
            line := line + ord(EOLn(input));
            { The second character literal is an HT (horizontal tabulator). }
            word := word + card([previousCharacter] * [' ', '   '] - [input^]);

            { Prepare `previousCharacter` for _next_ iteration. }
            previousCharacter := input^;
            { Advance “reading cursor”. }
            get(input);
        end;

        { To produce POSIX-compliant output write:

            writeLn(line:1, ' ', word:1, ' ', character:1);

          As per task specification we will determine a common width though.
          We use ⌊ln(N) / ln(10)⌋ + 1 as the base formula, where N needs to be
          the largest number from `line`, `word` and `character`. This can be
          found by the expression |[0, line] ∪ [0, word] ∪ [0, character] ∩ ℤ|.
          We add another +1 for the space _between_ numbers. }
        width := trunc(ln(card([0..line, 0..word, 0..character])) / ln(10)) + 2;
        writeLn(line:width-1, word:width, character:width);
    end.

Ruby, 108 bytes
f=->s{a=[s.count($/),s.split(/\S+/).size-1,s.size].map(&:to_s)
a.map{|b|" "*(a.map(&:size).max-b.size)+b}*" "}

Perl, 71 62 61 bytes
includes +1 for -n
$;=length($b+=y///c);$w+=split$"}{printf"%$;d %$;d $b",$.,$w

Commented:
while (<>) {                         # implicit because of -n
    $; = length(                     # printf formatting: width
       $b += y///c                   # count characters
    );
    $w += split $"                   # count words
}{                                   # explicit: end while, begin END block
    printf "%$;d %$;d $b", $., $w    #  $. = $INPUT_LINE_NUMBER
}                                    # implicit because of -n

Save another byte, again thanks to @TonHospel.
Save 9 bytes thanks to @TonHospel showing me a few tricks of the trade!

A few tricks of the trade: Use y///c as a shorter length of $_. split$" in scalar context gives the number of words in $_. By using a punctuation variable like $; instead of $W you can put a d just after the interpolation in the format string. Then you can drop the d in $W and drop the parenthesis. And -p gains nothing over -n, just let the printf do the printing (add a newline to taste)

Awesome, I appreciate it!

A calculation chain like $a=foo;$b=bar$a can usually be written as $b=bar($a=foo), saving one byte. Applicable here to $; and $b. You don't care if $; is recalculated every time

Thanks! I overlooked that because there are two blocks...

Lua, 74 66 bytes
Golfed:
t=arg[1]_,l=t:gsub('\n','')_,w=t:gsub('%S+','')print(l,w,t:len())

Ungolfed:
text = arg[1]
_,lines = text:gsub('\n','')
_,words = text:gsub('%S+','')
print(lines, words, text:len())

Receives input through command line arguments.
We rename the first argument (arg[1]) to save bytes. string.gsub returns the number of replacements as well as the modified string, so we're using that to count first '\n' (newlines), then '%S+' (instances of one or more non-whitespace characters, as many as possible, i.e. words). We can use anything we want for the replacement string, so we use the empty string ('') to save bytes. Then we just use string.len to find the length of the string, i.e. the number of bytes. Then, finally, we print it all.

I don't see any left padding of the lines and words values though

Retina, 65
^((\S+)|(¶)|.)*
$#3 $#2 $.0
+`(\b(.)+ )(?!.*\b(?<-2>.)+$)
a$1
a
<space>

Try it Online!
The first stage is the actual wc program, the rest of it is for padding. The a placeholder thing is probably unnecessary, and some of the groups can probably be simplified a bit.

Haskell, 140 bytes
import Text.Printf
w h=let{l=length;s=show.l;c=s h;m=s.words$h;n=s.lines$h;f=maximum$map l[c, m, n];p=printf"%*s"f}in p n++' ':p m++' ':p c

The ungolfed version is hereunder, with expanded variable and function names:
import Text.Printf

wc str =
  let charcount = show.length $ str
      wordcount = show.length.words $ str
      linecount = show.length.lines $ str
      fieldwidth = maximum $ map length [charcount, wordcount, linecount]
      printer = printf "%*s" fieldwidth
  in printer linecount ++ (' ' : printer wordcount ++ (' ' : printer charcount))

This is a function that accepts a string and returns a string. It just uses the Prelude functions words (resp. lines) to get the number of words (resp. lines) given that they seem to use the same definition as wc, then gets the longest value (as a string) amongst the counts and use the printf format taking the width amongst its arguments for formatting.

05AB1E, 24 23 bytes
¨¶¡¹…
    S¡õK¹)€g§Zg>jJ¦

j is currently bugged, so could have been 21 bytes without the § and J..
Try it online or verify all test cases.
Explanation:
¨          # Remove the trailing newline of the (implicit) input
 ¶¡        # And split it on newlines
¹…
    S¡     # Take the first input again, and split it on [" \n\t"]
      õK   # Then remove all empty string items
¹          # And take the first input again as is
)          # Wrap all three value of the stack to a single list
 €g        # Take the length of each of the items
   §       # Cast the integers to strings (should have been implicit, but `j` is bugged)
    Z      # Take the max (always the last / amount of bytes) (without popping the list)
     g>    # Take the length + 1 of this max
       j   # Append leading spaces so all items or of this length
        J  # Join them together (should have been done by the `j` already, but it's bugged)
         ¦ # Remove the leading space (and output implicitly to STDOUT)

Ruby -p0, 79 bytes
Includes a trailing space in the output.
a=[/
/,/\S+/,/./m].map{$_.scan(_1).size}
$_="%#{a.map{_1.to_s.size}.max}d "*3%a

Attempt This Online!
Ruby -p0, 84 bytes
No trailing space.
a=[/
/,/\S+/,/./m].map{$_.scan(_1).size}
$_=["%#{a.map{_1.to_s.size}.max}d"]*3*" "%a

Attempt This Online!

source: Stack Exchange

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

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

sort: votes


text:
Find if a number contains a digit without ever using using its string representation
The Challenge:
Find if a number contains a digit. The number and the digit are to be taken as input. Output must be a boolean value. But you are not allowed to use the string representation of the number at any time. Now don't count upon a char* either. You must devise a mathematical way to do it.
Rules:
• You can't use a string/char[] representation of the number. Same goes for the digit.
• It must be a complete program.
• Input can be in any form.
• Output must be a boolean value.
This is code-golf, so shortest code wins!.
Test Cases:
Input: 51, 5
Output : True
------------------------
Input: 123456789, 0
Output : False
------------------------
Input: 1111, 1
Output : True

Disclaimer: I don't understand much Pyth/CJam/Japt and similar languages. Thus I hope everyone will be honest enough not to break the rules. Never mind, the community is always there to help me :)

Uh, isn't this just repeatedly mod then divide the number by 10? Unless you mean to include floating point, which isn't really clear from your test cases.

05AB1E converts numbers to strings implicitly if needed. Is this also prohibited?

Also is built-in base conversion (from an integer to a list of digits) allowed?

@MartinBüttner no.

Recommended reading.

@MartinBüttner yep indeed. but completing the challenge without the restriction is so easy that... it's just..... you know what I mean..

What about divmod?

@Dennis what does that do? if it doesn't complete the job directly, then it's fine.

Do none of you understand "a complete program"?. That's there to maintain some uniformity.

divmod(123, 10) returns (12, 3).

@Dennis No problem. Go ahead.

@FarhanAnam of course it's not interesting without the restriction, but that doesn't mean the restriction fixes that problem.

Some languages read all input as strings, regardless of whether the input is numeric. Are such languages then banned outright?

Perl 6, 27 bytes
{$^a.polymod(10 xx*)∋$^b}

Usage:
# make it an infix op, because I can
my &infix:<contains> = {$^a.polymod(10 xx*)∋$^b}

say 51 contains 5; # True
say 123456789 contains 0; # False
say 1111 contains 1; # True

# you can use infix ops as oddly named subs as well
say infix:<contains> 1230, 0; # True

say map {$^a.polymod(10 xx*)∋$^b}, 10,0, 12,3, 12,2;
# (True False True)

# proof it isn't doing anything string related
'hi' contains 'h';
# Method 'polymod' not found for invocant of class 'Str'

# Since it uses a Set operator the second argument has to be an Int
# not a Str
say 123 contains '1'; # False
# not a Rat
say 123 contains 1.0; # False
# not a Num
say 123 contains 1e0; # False
# but an Int
say 123 contains 1; # True

Explanation:
polymod is similar to divmod from other languages, except it takes the number and a list of divisors. Here I give it an endless list of 10s so that it splits it up into a list of digits.
Then I see if the resulting list contains the second argument by using the 'contains as member' ( ∋ / (cont) ) Set operator.

Haskell, 42 bytes
Called like number!digitToFind:
n!d|n<d=1>2|mod n 10==d=1<2|1<2=div n 10!d

MATL, 15 14 bytes
t`10H#\t]xN$hm

Try it online!
t                   % take 1st input (number) implicitly. Duplicate
 `      ]           % do...while loop
  10                % push number 10, to be used as divisor
    H#\             % divmod. Pushes remainder and then quotient
       t            % duplicate quotient. Used as loop condition: exit if zero
         x          % delete last quotient (which is zero)
          N$h       % concatenate all partial results in an array
             =      % take 2nd input (digit) implicitly.
              m     % ismember function. True if digit is in array

PHP, 66 65 62 47 bytes
in_array($d,array_map('intval',str_split($n)));

$n is the number to be searched
$d is the digit to search for
This code converts the number into array[number], then scans the array for a matching digit.  Returns true if any digit matches.
Alternatively, if number->string->array[string]->array[number] is not valid (even though no operations use it as a string), there's this at 62 bytes, for any $n > 0:
function f($n,$d){return$n&&($d==$n%10||f(($n-$n%10)/10,$d));}

Python 3, 59
It uses the same approach as every other approach.
def f(x,s):
 while x:
  x,r=divmod(x,10)
  if r==s:return 1

Befunge-93, 38 bytes
&&00pv >0.@.1<
%*25:<_^#:/_ ^#\*25-g00

Arguments are taken in the form MainNum Digit.  It's the same algorithm that everyone else is doing (check if mod 10 is equal to the digit; if not, div 10 until it equals 0), since that's pretty much the optimal way to do this one.

JavaScript (ES6), 30 bytes
d=>g=n=>n%10==d||n>9&&g(n/10|0)

Examples:
f=d=>g=n=>n%10==d||n>9&&g(n/10|0)
f(0)(0) -> true
f(0)(10) -> true
f(0)(12) -> false
f(1)(12) -> true
f(2)(12) -> true
f(3)(12) -> false

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