27
\$\begingroup\$

Tomorrow, November 23rd, is Thanksgiving Day in the United States. To prepare, you need to cook up some ASCII turkeys. However, since you're late in planning, you need a program (or function) to help you with how many birds you need to prepare.

      .---.   _
    .'     './ )
   /   _   _/ /\
 =(_____) (__/_/==
===================

The turkeys you found are rather on the small side, so you've figured out the following ratios -- one turkey will feed:

  • four people who only like white meat and three people who only like dark meat
  • or seven people who don't care either way
  • or a combination thereof.

Meaning, there are a total of 4 servings of white meat and 3 servings of dark meat in any given turkey. Further, you can't purchase and cook a partial turkey.

For example, for 3 people who only like white meat, 6 people who only like dark meat, and 3 people who don't care, you'll need two turkeys. That gives 8 servings of white and 6 servings of dark, which is enough to satisfy everyone and have some leftover white meat:

      .---.   _         .---.   _
    .'     './ )      .'     './ )
   /   _   _/ /\     /   _   _/ /\
 =(_____) (__/_/== =(_____) (__/_/==
=====================================

For 20 people who don't care, you'll need three turkeys, and have either a little bit of white or dark leftover:

      .---.   _         .---.   _         .---.   _
    .'     './ )      .'     './ )      .'     './ )
   /   _   _/ /\     /   _   _/ /\     /   _   _/ /\
 =(_____) (__/_/== =(_____) (__/_/== =(_____) (__/_/==
=======================================================

And so on.

Rules

  • The three inputs can be in any order you choose, and in any convenient format. Please indicate in your answer how the input is taken.
  • There will never be a requirement for more than 25 turkeys (so a maximum of 175 people to feed).
  • Leading/trailing newlines or other whitespace are optional, provided that the characters line up appropriately.
  • Either a full program or a function are acceptable. If a function, you can return the output rather than printing it.
  • Output can be to the console, returned as a list of strings, returned as a single string, etc.
  • Standard loopholes are forbidden.
  • This is so all usual golfing rules apply, and the shortest code (in bytes) wins.
\$\endgroup\$
  • \$\begingroup\$ your ratios don't quite make sense to me - you seem to imply that the 7 people who don't care only get the leftovers, but seem to write that a turkey can feed 3+4+7 = 14 people (or that one turkey might only be enough to feed 3 dark meat eaters). \$\endgroup\$ – dzaima Nov 22 '17 at 17:28
  • \$\begingroup\$ @dzaima From the examples, it seems that one turkey has 4 servings of white meat and 3 of dark. So it serves (4 people who only like white meat AND 3 people who only like dark meat) OR 7 people with no preference. \$\endgroup\$ – KSmarts Nov 22 '17 at 17:34
  • \$\begingroup\$ @KSmarts that's what I'm saying in my comment too, but the text doesn't say that well \$\endgroup\$ – dzaima Nov 22 '17 at 17:36
  • 1
    \$\begingroup\$ How should the turkeys be put next to each other? It seems as that none of the current answers have that overlap that the examples do \$\endgroup\$ – dzaima Nov 22 '17 at 18:19
  • 4
    \$\begingroup\$ Do we get a bounty for a solution in Chicken? \$\endgroup\$ – Uriel Nov 22 '17 at 23:11
20
\$\begingroup\$

Befunge-93, 231 224 bytes

p&:10p3+4/:&:20p2+3/\-:v
v<0-1:+*`0:-\/7+++&g02<0
>"   _   .---.      "vg`
>"  ) /.'     '.    "v0*
>"  \/ /_   _   /   "v1+
>"==/_/__( )_____(= "v6:
v^0-1 _$"v"000g1+:>v v^<
:#,_$:^1,+55:p+1p00< >>>
_$$99+*"=":>,#:\:#->#1_@

Try it online!

The three values are read from stdin in the order: white meat, dark meat, don't care.

\$\endgroup\$
  • 16
    \$\begingroup\$ I know I'm not supposed to upvote a code golf challenge for artistically laid out code but... This just happens to look like a freakin turkey in the oven, so +1! \$\endgroup\$ – Level River St Nov 23 '17 at 0:53
  • 1
    \$\begingroup\$ I look at the question and think "There's no way golfed code can do this easily", and then I saw a friggin turkey in the oven getting cooked and solving the problem. \$\endgroup\$ – MechMK1 Nov 23 '17 at 10:28
6
\$\begingroup\$

APL (Dyalog), 120 118 104 bytes

14 bytes saved thanks to @Adám

{,/(⌈⌈/4 3 7÷⍨⍵,⍺++/⍵)/⊂'='⍪⍨' .-_''/)\=('[4 19⍴10 10⊤¯35+⎕UCS'###(##-:77-&(#F*####+,&0N&&)#,N0Z&d++#']}

Try it online!

The picky white and dark are on the right, the non picky on the left.

Too bad most of the byte count is taken by the string currently.

How?

⍵,⍺++/⍵ - creates array of whity, darky and sum of them all plus non pickys

4 3 7÷⍨ - divide by how many of them gets their wishes from one chicken

⌈/ - take the highest estimate of the three - so if we have extremely high amount of dark meat seekers, they won't be left aside

- ceiling, in case only a half-chicken is in demand

Then we create a string, enclose it with , then repeat the eclosed matrix the calculated chickens times with /, and finally concatenate all chickens with ,/.

\$\endgroup\$
  • 4
    \$\begingroup\$ +1 for calling the turkeys chickens. Because that's what they are, glorified chickens. Still delicious though. \$\endgroup\$ – J. Sallé Nov 22 '17 at 18:10
  • 2
    \$\begingroup\$ @J.Sallé Nobody calls me chicken \$\endgroup\$ – manassehkatz Nov 22 '17 at 18:14
  • \$\begingroup\$ '='⍪⍨' .-_''/)\=('[4 19⍴10 10⊤¯35+⎕UCS'###(##-:77-&(#F*####+,&0N&&)#,N0Z&d++#'] with ⎕IO←0. \$\endgroup\$ – Adám Nov 23 '17 at 0:29
4
\$\begingroup\$

Python 2, 142 bytes

lambda w,d,n:[min(e)+-min(-w/3,-d/4,-(w+d+n)/7)*e.center(18)for e in"  .---.   _"," .'     './ )","/   _   _/ /\\","=(_____) (__/_/==","="*18]

Try it online!

-16 bytes thanks to Lynn
-4 bytes thanks to Mr. Xcoder

and back to a lambda xD

\$\endgroup\$
3
\$\begingroup\$

SOGL V0.12, 65 bytes

N∫4*κ:F3*.-:h+.-¹χ∆>?F"Ωeχ&i[A⁄╔■§‼╗╝│¼ο≠≈⁹,Ρ⁴žγūž℮3zl3βΜ%G‘'³n*←

Try it Here!

Order of inputs is white, dark, and then either.

\$\endgroup\$
3
\$\begingroup\$

Python 2, 197 189 174 bytes

thanks to Erik the Outgolfer for -12 bytes
thanks to Jonathan Frech for -1 byte

a,b,c=input()
for i in range(5):print'='[i<4:]+(' '+"   =   (  /_ . _ ' _.  _- __-  )-   .  ( '__ ./_ / /_ /_ )\\/   =   ="[i::4],'='*18)[i>3]*max((6+c+a+b)/7,a+3>>2,(b+2)/3)

Try it online!

\$\endgroup\$
2
\$\begingroup\$

Charcoal, 76 bytes

”{‴∨➙×95;{;C.ÞgF⁷J*←λ|⁸KK][§X⎚¦»Z◧↘gⅉ✳⟧F⎇≧h”×=¹⁹NθNηF⊖⌈⌈⟦∕θ³∕η⁴∕⁺⁺θηN⁷⟧C¹⁸¦⁰

Try it online! Link is to verbose version of code. Explanation:

”{‴∨➙×95;{;C.ÞgF⁷J*←λ|⁸KK][§X⎚¦»Z◧↘gⅉ✳⟧F⎇≧h”

Print a 1-space-indented turkey.

×=¹⁹

Print the table.

NθNη

Input the number of dark and white meat eaters.

F⊖⌈⌈⟦∕θ³∕η⁴∕⁺⁺θηN⁷⟧

Repeat one less than the ceiling of the maximum of a) one third of the number of dark meat eaters b) one quarter of the number of white meat eaters c) one seventh of the number of diners.

C¹⁸¦⁰

Make a copy of the turkey.

\$\endgroup\$
2
\$\begingroup\$

Excel VBA, 222 219 211 198 Bytes

Anonymous VBE immediate window function that takes input from range [A1:C1] with order of white meat, dark meat, and indifferent in that order and outputs to the range [D1].

[D1]=[Int(Max((A1+3)/4,(B1+2)/5,Sum(1:1,6)/7))]:For Each s In Split("      .---.   _   1    .'     './ )  1   /   _   _/ /\  1 =(_____) (__/_/==1",1):[E1]=s:?[Rept(E1,D1)]:Next:?[Rept("=",18*D1+1)]

Initially the solution finds the correct number of turkeys and then it repeats the turkey pattern that many times. Ideally this would then be directly outputted onto the VBE immediate window as shown by the function below

[D1]=[Int(Max((A1+3)/4,(B1+2)/5,Sum(1:1,6)/7))]:For Each s In Split("      .---.   _   1    .'     './ )  1   /   _   _/ /\  1 =(_____) (__/_/==1",1):[E1]=s:?[Rept(E1,D1)]:Next:?[Rept("=",18*D1+1)]

This version does initially produce the correct response, however, it is immediately autoformatted by the compiler, as _ is the line continutation character, and is thus moved to have only one (space) character to its left, breaking the pattern.

Example shown below for clarity

[A1:C1]=Array(0,0,20):[D1].Clear
[D1]=[Int(Max((A1+3)/4,(B1+2)/5,Sum(1:1,6)/7))]:For Each s In Split("      .---.   _   1    .'     './ )  1   /   _   _/ /\  1 =(_____) (__/_/==1",1):[E1]=s:?[Rept(E1,D1)]:Next:?[Rept("=",18*D1+1)]

'' Note that the `_` to the right has moved     V
      .---.   _         .---.   _         .---. _
    .'     './ )      .'     './ )      .'     './ )  
   /   _   _/ /\     /   _   _/ /\     /   _   _/ /\  
 =(_____) (__/_/== =(_____) (__/_/== =(_____) (__/_/==
=======================================================

To correct this the last space character (, char 32) before the _ in line one of the output is replaced with a non-breaking space ( , char 160, Alt + 255)

      .---.   _         .---.   _         .---.   _   
    .'     './ )      .'     './ )      .'     './ )  
   /   _   _/ /\     /   _   _/ /\     /   _   _/ /\  
 =(_____) (__/_/== =(_____) (__/_/== =(_____) (__/_/==
=======================================================

-3 bytes for use of 1 delimited split statement

-8 bytes for use moving ='s into the split and using string addition over concatenation

-13 bytes for use of a non-breaking space to prevent autoformatting of the output

\$\endgroup\$
2
\$\begingroup\$

Kotlin, 207 198 bytes

thanks to Taylor Scott for -7 bytes

{a,b,c->val n=maxOf((a+3)/4,(b+2)/3,(6+c+a+b)/7);arrayOf("      .---.   _   ","    .'     './ )  ","   /   _   _/ /\\  "," =(_____) (__/_/==").map{println(it.repeat(n))};println("=".repeat(n*18+1))}

This does not work on TIO yet, as it requires Kotlin 1.1

Try it online!

\$\endgroup\$
1
\$\begingroup\$

JavaScript (ES6), 180 179 bytes

Outputs an array of strings.

(a,b,c)=>[...`      .---.   _   
    .'     './ )  
   /   _   _/ /\\  
 =(_____) (__/_/==`.split`
`.map(l=>l.repeat(n=Math.max((6+c+a+b)/7,a+3>>4,(b+2)/3)|0)),'='.repeat(18*n+1)]

f=

(a,b,c)=>[...`      .---.   _   
    .'     './ )  
   /   _   _/ /\\  
  =(_____) (__/_/==`.split`
`.map(l=>l.repeat(n=Math.max((6+c+a+b)/7,a+3>>4,(b+2)/3)|0)),'='.repeat(18*n+1)]

console.log(f(3, 2, 3))
console.log(f(0, 0, 20))


JavaScript (ES6), 182 181 bytes

Outputs a single string.

(a,b,c)=>`      .---.   _   
    .'     './ )  
   /   _   _/ /\\  
 =(_____) (__/_/==
${'='.repeat(18)}`.split`
`.map(l=>l.repeat(Math.max((6+c+a+b)/7,a+3>>4,(b+2)/3))).join`
`+'='

f=

(a,b,c)=>`      .---.   _   
    .'     './ )  
   /   _   _/ /\\  
 =(_____) (__/_/==
${'='.repeat(18)}`.split`
`.map(l=>l.repeat(Math.max((6+c+a+b)/7,a+3>>4,(b+2)/3))).join`
`+'='

console.log(f(3, 2, 3))
console.log(f(0, 0, 20))

-1 byte (Arnauld): a+3>>4 instead of (a+3)/4)

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.