# Mama Say Mama Sa Mama Coosa [duplicate]

## Mama Say Mama Sa Mama Coosa

I'm sure all of you have heard of Michael Jackson and some of you have listened to MJ's song "Wanna be starting something". The line "Mama Say Mama Sa Mama Coosa" is repeated throughout the song.

## Specification

In this line, the word "Mama"occurs three times, "Say", "Sa", "Coosa" occurs once. The task is the following: Given the input number of occurrences of the words "Mama", "Say", "Sa", "Coosa", output the number of times MJ can sing "Mama Say Mama Sa Mama Coosa", like in a complete sentence.

## Input

Input is a single line with four positive integers denoting the number of times he says the words "Mama", "Say", "Sa","Coosa" respectively .

## Output

Output the number of times MJ can sing "Mama Say Mama Sa Mama Coosa"

Shortest code wins.

## Testcases

Testcase 1
Input -->  3 1 1 1
Output-->  1

Testcase 2
Input -->  6 1 1 1
Output-->  1

Testcase 3
Input -->  1000 3 2 3
Output-->  2

Testcase 4
Input -->  7 3 4 3
Output-->  2

• I am a bit confused by the specification. It would be nice to include exactly what is being calculated. – Wheat Wizard Feb 12 '17 at 16:16
• Any constraints about the number? Like are they necessary all strictly positive? – Dada Feb 12 '17 at 16:17
• Just a note. 1 minute in the sandbox isn't enough time for any feedback. – fəˈnɛtɪk Feb 12 '17 at 16:20
• So, you want the minimum of four numbers where the first is divided by three first? – John Dvorak Feb 12 '17 at 16:22
• There are already answers so don't delete the question. Next time you should wait for feedback in the sandbox before posting – fəˈnɛtɪk Feb 12 '17 at 16:23

# Jelly, 5 bytes

Ḣ:3«Ṃ


Try it online!

### How it works

Ḣ:3«Ṃ  Main link. Argument: [a, b, c, d]

Ḣ      Head; pop and yield a.
:3    Perform integer division by 3,
Ṃ  Yield the minimum of [b, c, d].
«   Take the minimum of a and the result to the right.

• Giving you a +1 for :3 – Okx Feb 12 '17 at 19:46
• @Okx Another 5 byte solution, :1¦3Ṃ, and one can bastardise that one into the 6 byte :-3¦3Ṃ – Jonathan Allan Feb 13 '17 at 9:41

# Python 2, 23 bytes

lambda a,*x:min(a/3,*x)


Try it online!

• What does the asterisk before the x do? – user41805 Feb 12 '17 at 16:21
• Create a function with a variable number of arguments. The first argument becomes a, all remaining ones are stored in the tuple x. – Dennis Feb 12 '17 at 16:22
• The second time the *x is used it unpacks an array (x) into arguments for min. – Wheat Wizard Feb 12 '17 at 18:00

# MATL, 9 8 bytes

1 byte saved thanks to @Luis

I7Bh/kX<


Try it at MATL Online

Explanation

        % Implicitly grab input as an array
I       % Push the literal 3 to the stack
7B      % Push 7 and convert to binary ([1, 1, 1]) and push it to the stack
h       % Horizontally concatenate the two to create the array [3 1 1 1]
/       % Perform element-wise division
k       % Round all values towards minus infinity
X<      % Compute the minimum of the resulting array
% Implicitly display the result


# Perl 6, 19 bytes

{min $^a div 3,|@_}  Try it online! ### How it works { } # A lambda.$^a             # First argument.
div 3       # Integer division by 3.
@_   # All regaining arguments as a list.
,      |     # Slipped into the outer list.
min                 # Smallest number in the list.


The $^a and @_ are in-place parameter declarations for the surrounding block lambda. One is a positional parameter, and the other to a slurpy parameter that takes all remaining positional arguments. # MATLAB / Octave, 26 bytes @(a)min(fix(a./[3 1 1 1]))  Creates an anonymous function named ans which you can then pass the input array as: ans([3 1 1 1]) Online Demo # Cubix, 24 bytes O;@sI3,>I?;^>..^.-!..;;?  Try it here  O ; @ s I 3 , > I ? ; ^ > . . ^ . - ! . . ; ; ?  I Read number from the input 3, Push 3 onto the stack and integer divide > Redirect to the right I? Read number from input and test if 0 (end of input), ; remove from stack. ^ redirect to top face, O@ Output TOS and quit if positive, - subtract from TOS ? Test. For 0 and positive ; remove TOS, for negative ;s remove TOS and swap top items on the stack. This keeps the lowest number at the top. Follow arrows back to the 2nd I and repeat until done. # Mathematica, 18 bytes ⌊#/3⌋~Min~##2&  Pure function taking four integer arguments and returning an integer. Computes the floor of the first argument divided by 3, then finds the minimum of that number and the remaining arguments ##2. ## Batch, 71 bytes @set/am=%1/3 @for %%n in (%*)do @set/a"n=%%n-m,m-=(n>>31)*n @echo %m%  Unrolling the loop would have been 7 bytes longer. # JavaScript (ES6), 30 bytes a=>Math.min(a/3,...a)|0  ## Usage f=a=>Math.min(a/3,...a)|0 f([2,1,1,1])  ### Output 0  ## Explanation This function takes an array as argument, and then feeds all its elements to Math.min as well as the first element devided by three. Since a/3 is smaller than a (because a is guaranteed to be positive), we don't have to remove it from the main array. Math.min returns the minimum value, which is then floored and returned. • You will be given 4 numbers as input and not 3 – user41805 Feb 12 '17 at 18:21 • Oops, cost me 2B to fix – Luke Feb 12 '17 at 18:23 • If you take the arguments as a single array parameter then you can save 4 bytes. – Neil Feb 12 '17 at 19:33 # C#, 62 bytes ## Golfed int i(int a,int b,int c,int d){return new[]{a/3,b,c,d}.Min();}  Pretty self-explanatory I think. # PowerShell, 44 bytes $a,$b=$args;[int]($a/3),$b|measure -mi|% Mi*


Try it online!

# R, 26 bytes

As an unnamed function that takes a vector of numbers as the parameter.

function(x)min(x,x%/%3)


Return the min of the parameter and the first item integer divided by 3. So for an input of 7,8,9,10, it will return the min of 7,8,9,10,2. This was shorter than dividing the complete vector by c(3,1,1,1)