Skip to main content
add new test cases for duplicate chars in meal
Source Link
Surculose Sputum
  • 8.4k
  • 1
  • 13
  • 40

Python 2, 95 71 7070 55 bytes

lambda li,sm:min(sum(si.count(c)for s in l)/sm.count(c)for c in sm if" "<c)

Try it online!Try it online!

Input: A list of strings as ingredientsIngredients li as a comma-separated string, and a string as the meal sm as a string.
Output: Max number of meals that can be made.

How: Divides the frequency of each character in the ingredient by its corresponding character in the meal, then taketakes the minimum.

Python 2, 95 71 70 bytes

lambda l,s:min(sum(s.count(c)for s in l)/s.count(c)for c in s if" "<c)

Try it online!

Input: A list of strings as ingredients l, and a string as the meal s.
Output: Max number of meals that can be made.

How: Divides the frequency of each character in the ingredient by its corresponding character in the meal, then take the minimum.

Python 2, 95 71 70 55 bytes

lambda i,m:min(i.count(c)/m.count(c)for c in m if" "<c)

Try it online!

Input: Ingredients i as a comma-separated string, and a meal m as a string.
Output: Max number of meals that can be made.

How: Divides the frequency of each character in the ingredient by its corresponding character in the meal, then takes the minimum.

Added 2 more test cases
Source Link
RGS
  • 14.1k
  • 1
  • 57
  • 116

Python 2, 95 71 70 bytes

lambda l,s:min(sum(s.count(c)for s in l)/s.count(c)for c in s if" "<c)

Try it online!Try it online!

Input: A list of strings as ingredients l, and a string as the meal s.
Output: Max number of meals that can be made.

How: Divides the frequency of each character in the ingredient by its corresponding character in the meal, then take the minimum.

Python 2, 95 71 70 bytes

lambda l,s:min(sum(s.count(c)for s in l)/s.count(c)for c in s if" "<c)

Try it online!

Input: A list of strings as ingredients l, and a string as the meal s.
Output: Max number of meals that can be made.

How: Divides the frequency of each character in the ingredient by its corresponding character in the meal, then take the minimum.

Python 2, 95 71 70 bytes

lambda l,s:min(sum(s.count(c)for s in l)/s.count(c)for c in s if" "<c)

Try it online!

Input: A list of strings as ingredients l, and a string as the meal s.
Output: Max number of meals that can be made.

How: Divides the frequency of each character in the ingredient by its corresponding character in the meal, then take the minimum.

-1 byte, add explanation
Source Link
Surculose Sputum
  • 8.4k
  • 1
  • 13
  • 40

Python 3Python 2, 95 7171 70 bytes

lambda l,s:min(sum(xs.count(c)for xs in l)//s.count(c)for c in s if" "<c)

Try it online!Try it online!

Input: A list of strings as ingredients l, and a string as the meal s.
Output: Max number of meals that can be made.

How: Divides the frequency of each character in the ingredient by its corresponding character in the meal, then take the minimum.

Python 3, 95 71 bytes

lambda l,s:min(sum(x.count(c)for x in l)//s.count(c)for c in s if" "<c)

Try it online!

Python 2, 95 71 70 bytes

lambda l,s:min(sum(s.count(c)for s in l)/s.count(c)for c in s if" "<c)

Try it online!

Input: A list of strings as ingredients l, and a string as the meal s.
Output: Max number of meals that can be made.

How: Divides the frequency of each character in the ingredient by its corresponding character in the meal, then take the minimum.

-24 bytes
Source Link
Surculose Sputum
  • 8.4k
  • 1
  • 13
  • 40
Loading
Source Link
Surculose Sputum
  • 8.4k
  • 1
  • 13
  • 40
Loading