11
\$\begingroup\$

It's lunch time, I am hungry and I came to your Sushi Bar. You are the Sushi Chef and you have to produce a full program or function to make me some sushi!

enter image description here Credits: Wikipedia

Disclaimer: The image is for illustration purposes only and do not necessarily represent the exact product.

Although you have limited ingredients (due to a truck drivers strike) it will be fine for me.

The ingredients you have (in plenty amount) are:

  • Nori seaweed (made with: \/_¯|)
  • Raw Tuna (T)
  • Raw Salmon (S)
  • Raw Avocado (A)
  • Sushi Rice (o)

With these ingredients you are able to make some nice makis for your clients.

Your minimum order is $1 for 2 makis, you only make makis in couples and only accept integer numbers as payment. You accept orders up to $50 per person (total input) because you are alone and you must satisfy all your clients.

You will need to get the client's orders from standard input in any reasonable format, for example: [1,T],[2,S],[3,A] which means that you have to output:

  • Two Tuna Makis
  • Four Salmon Makis
  • Six Avocado Makis

One maki is exactly made like this:

   _____  
  /ooooo\ 
 |ooTTToo|
 |\ooooo/|
 | ¯¯¯¯¯ |
  \_____/ 

And since you are a fine Sushi Chef, you always arrange the makis with the pieces of any given type in a square shape or at most in a rectangular shape (as close as possible to a square) with no gaps. The overall shape is also square or rectangular, as close as possible to a square given the above restriction, with no gaps.

Example input/outputs:

Input: [1,T],[2,S],[3,A]

Valid Output:
  _____    _____    _____    _____  
 /ooooo\  /ooooo\  /ooooo\  /ooooo\ 
|ooTTToo||ooTTToo||ooAAAoo||ooAAAoo|
|\ooooo/||\ooooo/||\ooooo/||\ooooo/|
| ¯¯¯¯¯ || ¯¯¯¯¯ || ¯¯¯¯¯ || ¯¯¯¯¯ |
 \_____/  \_____/  \_____/  \_____/ 
  _____    _____    _____    _____  
 /ooooo\  /ooooo\  /ooooo\  /ooooo\ 
|ooSSSoo||ooSSSoo||ooAAAoo||ooAAAoo|
|\ooooo/||\ooooo/||\ooooo/||\ooooo/|
| ¯¯¯¯¯ || ¯¯¯¯¯ || ¯¯¯¯¯ || ¯¯¯¯¯ |
 \_____/  \_____/  \_____/  \_____/ 
  _____    _____    _____    _____  
 /ooooo\  /ooooo\  /ooooo\  /ooooo\ 
|ooSSSoo||ooSSSoo||ooAAAoo||ooAAAoo|
|\ooooo/||\ooooo/||\ooooo/||\ooooo/|
| ¯¯¯¯¯ || ¯¯¯¯¯ || ¯¯¯¯¯ || ¯¯¯¯¯ |
 \_____/  \_____/  \_____/  \_____/ 

Valid Output:
  _____    _____    _____    _____  
 /ooooo\  /ooooo\  /ooooo\  /ooooo\ 
|ooAAAoo||ooAAAoo||ooSSSoo||ooSSSoo|
|\ooooo/||\ooooo/||\ooooo/||\ooooo/|
| ¯¯¯¯¯ || ¯¯¯¯¯ || ¯¯¯¯¯ || ¯¯¯¯¯ |
 \_____/  \_____/  \_____/  \_____/ 
  _____    _____    _____    _____  
 /ooooo\  /ooooo\  /ooooo\  /ooooo\ 
|ooAAAoo||ooAAAoo||ooSSSoo||ooSSSoo|
|\ooooo/||\ooooo/||\ooooo/||\ooooo/|
| ¯¯¯¯¯ || ¯¯¯¯¯ || ¯¯¯¯¯ || ¯¯¯¯¯ |
 \_____/  \_____/  \_____/  \_____/ 
  _____    _____    _____    _____  
 /ooooo\  /ooooo\  /ooooo\  /ooooo\ 
|ooAAAoo||ooAAAoo||ooTTToo||ooTTToo|
|\ooooo/||\ooooo/||\ooooo/||\ooooo/|
| ¯¯¯¯¯ || ¯¯¯¯¯ || ¯¯¯¯¯ || ¯¯¯¯¯ |
 \_____/  \_____/  \_____/  \_____/   

Not Valid Output:
  _____    _____    _____    _____  
 /ooooo\  /ooooo\  /ooooo\  /ooooo\ 
|ooTTToo||ooAAAoo||ooSSSoo||ooAAAoo|
|\ooooo/||\ooooo/||\ooooo/||\ooooo/|
| ¯¯¯¯¯ || ¯¯¯¯¯ || ¯¯¯¯¯ || ¯¯¯¯¯ |
 \_____/  \_____/  \_____/  \_____/ 
  _____    _____    _____    _____  
 /ooooo\  /ooooo\  /ooooo\  /ooooo\ 
|ooSSSoo||ooAAAoo||ooTTToo||ooAAAoo|
|\ooooo/||\ooooo/||\ooooo/||\ooooo/|
| ¯¯¯¯¯ || ¯¯¯¯¯ || ¯¯¯¯¯ || ¯¯¯¯¯ |
 \_____/  \_____/  \_____/  \_____/ 
  _____    _____    _____    _____  
 /ooooo\  /ooooo\  /ooooo\  /ooooo\ 
|ooSSSoo||ooSSSoo||ooAAAoo||ooAAAoo|
|\ooooo/||\ooooo/||\ooooo/||\ooooo/|
| ¯¯¯¯¯ || ¯¯¯¯¯ || ¯¯¯¯¯ || ¯¯¯¯¯ |
 \_____/  \_____/  \_____/  \_____/ 

Not Valid Output:
  _____    _____    _____    _____    _____    _____    _____    _____    _____    _____    _____    _____
 /ooooo\  /ooooo\  /ooooo\  /ooooo\  /ooooo\  /ooooo\  /ooooo\  /ooooo\  /ooooo\  /ooooo\  /ooooo\  /ooooo\
|ooTTToo||ooTTToo||ooSSSoo||ooSSSoo||ooSSSoo||ooSSSoo||ooAAAoo||ooAAAoo||ooAAAoo||ooAAAoo||ooAAAoo||ooAAAoo|
|\ooooo/||\ooooo/||\ooooo/||\ooooo/||\ooooo/||\ooooo/||\ooooo/||\ooooo/||\ooooo/||\ooooo/||\ooooo/||\ooooo/|
| ¯¯¯¯¯ || ¯¯¯¯¯ || ¯¯¯¯¯ || ¯¯¯¯¯ || ¯¯¯¯¯ || ¯¯¯¯¯ || ¯¯¯¯¯ || ¯¯¯¯¯ || ¯¯¯¯¯ || ¯¯¯¯¯ || ¯¯¯¯¯ || ¯¯¯¯¯ |
 \_____/  \_____/  \_____/  \_____/  \_____/  \_____/  \_____/  \_____/  \_____/  \_____/  \_____/  \_____/ 


Not Valid Output:
  _____    _____    _____    _____    _____    _____    _____
 /ooooo\  /ooooo\  /ooooo\  /ooooo\  /ooooo\  /ooooo\  /ooooo\
|ooTTToo||ooTTToo||ooSSSoo||ooSSSoo||ooSSSoo||ooSSSoo||ooAAAoo|
|\ooooo/||\ooooo/||\ooooo/||\ooooo/||\ooooo/||\ooooo/||\ooooo/|
| ¯¯¯¯¯ || ¯¯¯¯¯ || ¯¯¯¯¯ || ¯¯¯¯¯ || ¯¯¯¯¯ || ¯¯¯¯¯ || ¯¯¯¯¯ |
 \_____/  \_____/  \_____/  \_____/  \_____/  \_____/  \_____/ 
  _____    _____    _____    _____    _____  
 /ooooo\  /ooooo\  /ooooo\  /ooooo\  /ooooo\ 
|ooAAAoo||ooAAAoo||ooAAAoo||ooAAAoo||ooAAAoo|
|\ooooo/||\ooooo/||\ooooo/||\ooooo/||\ooooo/|
| ¯¯¯¯¯ || ¯¯¯¯¯ || ¯¯¯¯¯ || ¯¯¯¯¯ || ¯¯¯¯¯ |
 \_____/  \_____/  \_____/  \_____/  \_____/ 


Input: [1,S]

Valid Output:
  _____    _____  
 /ooooo\  /ooooo\ 
|ooSSSoo||ooSSSoo|
|\ooooo/||\ooooo/|
| ¯¯¯¯¯ || ¯¯¯¯¯ |
 \_____/  \_____/ 

Valid Output:
  _____  
 /ooooo\ 
|ooSSSoo|
|\ooooo/|
| ¯¯¯¯¯ |
 \_____/ 
  _____  
 /ooooo\ 
|ooSSSoo|
|\ooooo/|
| ¯¯¯¯¯ |
 \_____/ 


Input: [1,A],[1,T],[1,S]

Valid Output:
  _____    _____    _____  
 /ooooo\  /ooooo\  /ooooo\ 
|ooAAAoo||ooTTToo||ooSSSoo|
|\ooooo/||\ooooo/||\ooooo/|
| ¯¯¯¯¯ || ¯¯¯¯¯ || ¯¯¯¯¯ |
 \_____/  \_____/  \_____/ 
  _____    _____    _____  
 /ooooo\  /ooooo\  /ooooo\ 
|ooAAAoo||ooTTToo||ooSSSoo|
|\ooooo/||\ooooo/||\ooooo/|
| ¯¯¯¯¯ || ¯¯¯¯¯ || ¯¯¯¯¯ |
 \_____/  \_____/  \_____/ 

Valid Output:
  _____    _____    _____  
 /ooooo\  /ooooo\  /ooooo\ 
|ooTTToo||ooTTToo||ooAAAoo|
|\ooooo/||\ooooo/||\ooooo/|
| ¯¯¯¯¯ || ¯¯¯¯¯ || ¯¯¯¯¯ |
 \_____/  \_____/  \_____/ 
  _____    _____    _____  
 /ooooo\  /ooooo\  /ooooo\ 
|ooSSSoo||ooSSSoo||ooAAAoo|
|\ooooo/||\ooooo/||\ooooo/|
| ¯¯¯¯¯ || ¯¯¯¯¯ || ¯¯¯¯¯ |
 \_____/  \_____/  \_____/ 

Input: [1,T],[1,A],[2,S]

Valid Output:
  _____    _____    _____    _____  
 /ooooo\  /ooooo\  /ooooo\  /ooooo\ 
|ooTTToo||ooTTToo||ooAAAoo||ooAAAoo|
|\ooooo/||\ooooo/||\ooooo/||\ooooo/|
| ¯¯¯¯¯ || ¯¯¯¯¯ || ¯¯¯¯¯ || ¯¯¯¯¯ |
 \_____/  \_____/  \_____/  \_____/ 
  _____    _____    _____    _____  
 /ooooo\  /ooooo\  /ooooo\  /ooooo\ 
|ooSSSoo||ooSSSoo||ooSSSoo||ooSSSoo|
|\ooooo/||\ooooo/||\ooooo/||\ooooo/|
| ¯¯¯¯¯ || ¯¯¯¯¯ || ¯¯¯¯¯ || ¯¯¯¯¯ |
 \_____/  \_____/  \_____/  \_____/ 

Valid Output:
  _____    _____    _____    _____  
 /ooooo\  /ooooo\  /ooooo\  /ooooo\ 
|ooTTToo||ooTTToo||ooSSSoo||ooSSSoo|
|\ooooo/||\ooooo/||\ooooo/||\ooooo/|
| ¯¯¯¯¯ || ¯¯¯¯¯ || ¯¯¯¯¯ || ¯¯¯¯¯ |
 \_____/  \_____/  \_____/  \_____/ 
  _____    _____    _____    _____  
 /ooooo\  /ooooo\  /ooooo\  /ooooo\ 
|ooAAAoo||ooAAAoo||ooSSSoo||ooSSSoo|
|\ooooo/||\ooooo/||\ooooo/||\ooooo/|
| ¯¯¯¯¯ || ¯¯¯¯¯ || ¯¯¯¯¯ || ¯¯¯¯¯ |
 \_____/  \_____/  \_____/  \_____/     

Valid Output:
  _____    _____  
 /ooooo\  /ooooo\ 
|ooAAAoo||ooAAAoo|
|\ooooo/||\ooooo/|
| ¯¯¯¯¯ || ¯¯¯¯¯ |
 \_____/  \_____/ 
  _____    _____  
 /ooooo\  /ooooo\ 
|ooSSSoo||ooSSSoo|
|\ooooo/||\ooooo/|
| ¯¯¯¯¯ || ¯¯¯¯¯ |
 \_____/  \_____/ 
  _____    _____  
 /ooooo\  /ooooo\ 
|ooSSSoo||ooSSSoo|
|\ooooo/||\ooooo/|
| ¯¯¯¯¯ || ¯¯¯¯¯ |
 \_____/  \_____/ 
  _____    _____  
 /ooooo\  /ooooo\ 
|ooTTToo||ooTTToo|
|\ooooo/||\ooooo/|
| ¯¯¯¯¯ || ¯¯¯¯¯ |
 \_____/  \_____/   


Input: [1,T],[1,S],[7,A]

Valid Output:
  _____    _____    _____    _____    _____    _____    _____    _____    _____  
 /ooooo\  /ooooo\  /ooooo\  /ooooo\  /ooooo\  /ooooo\  /ooooo\  /ooooo\  /ooooo\ 
|ooSSSoo||ooSSSoo||ooAAAoo||ooAAAoo||ooAAAoo||ooAAAoo||ooAAAoo||ooAAAoo||ooAAAoo|
|\ooooo/||\ooooo/||\ooooo/||\ooooo/||\ooooo/||\ooooo/||\ooooo/||\ooooo/||\ooooo/|
| ¯¯¯¯¯ || ¯¯¯¯¯ || ¯¯¯¯¯ || ¯¯¯¯¯ || ¯¯¯¯¯ || ¯¯¯¯¯ || ¯¯¯¯¯ || ¯¯¯¯¯ || ¯¯¯¯¯ |
 \_____/  \_____/  \_____/  \_____/  \_____/  \_____/  \_____/  \_____/  \_____/ 
  _____    _____    _____    _____    _____    _____    _____    _____    _____  
 /ooooo\  /ooooo\  /ooooo\  /ooooo\  /ooooo\  /ooooo\  /ooooo\  /ooooo\  /ooooo\ 
|ooTTToo||ooTTToo||ooAAAoo||ooAAAoo||ooAAAoo||ooAAAoo||ooAAAoo||ooAAAoo||ooAAAoo|
|\ooooo/||\ooooo/||\ooooo/||\ooooo/||\ooooo/||\ooooo/||\ooooo/||\ooooo/||\ooooo/|
| ¯¯¯¯¯ || ¯¯¯¯¯ || ¯¯¯¯¯ || ¯¯¯¯¯ || ¯¯¯¯¯ || ¯¯¯¯¯ || ¯¯¯¯¯ || ¯¯¯¯¯ || ¯¯¯¯¯ |
 \_____/  \_____/  \_____/  \_____/  \_____/  \_____/  \_____/  \_____/  \_____/    

 Valid Output:
  _____    _____     
 /ooooo\  /ooooo\    
|ooAAAoo||ooAAAoo|   
|\ooooo/||\ooooo/|   
| ¯¯¯¯¯ || ¯¯¯¯¯ |   
 \_____/  \_____/    
  _____    _____     
 /ooooo\  /ooooo\    
|ooAAAoo||ooAAAoo|   
|\ooooo/||\ooooo/|   
| ¯¯¯¯¯ || ¯¯¯¯¯ |   
 \_____/  \_____/    
  _____    _____     
 /ooooo\  /ooooo\    
|ooAAAoo||ooAAAoo|   
|\ooooo/||\ooooo/|   
| ¯¯¯¯¯ || ¯¯¯¯¯ |   
 \_____/  \_____/    
  _____    _____     
 /ooooo\  /ooooo\    
|ooAAAoo||ooAAAoo|   
|\ooooo/||\ooooo/|   
| ¯¯¯¯¯ || ¯¯¯¯¯ |   
 \_____/  \_____/    
  _____    _____     
 /ooooo\  /ooooo\    
|ooAAAoo||ooAAAoo|   
|\ooooo/||\ooooo/|   
| ¯¯¯¯¯ || ¯¯¯¯¯ |   
 \_____/  \_____/    
  _____    _____     
 /ooooo\  /ooooo\    
|ooAAAoo||ooAAAoo|   
|\ooooo/||\ooooo/|   
| ¯¯¯¯¯ || ¯¯¯¯¯ |   
 \_____/  \_____/    
  _____    _____     
 /ooooo\  /ooooo\    
|ooAAAoo||ooAAAoo|   
|\ooooo/||\ooooo/|   
| ¯¯¯¯¯ || ¯¯¯¯¯ |   
 \_____/  \_____/        
  _____    _____     
 /ooooo\  /ooooo\    
|ooSSSoo||ooSSSoo|   
|\ooooo/||\ooooo/|   
| ¯¯¯¯¯ || ¯¯¯¯¯ |   
 \_____/  \_____/    
  _____    _____       
 /ooooo\  /ooooo\  
|ooTTToo||ooTTToo|
|\ooooo/||\ooooo/|
| ¯¯¯¯¯ || ¯¯¯¯¯ |
 \_____/  \_____/   

Rules:

\$\endgroup\$
11
  • 3
    \$\begingroup\$ "You are the Sushi Man": I believe that assuming the reader is male is a manifestation of unconscious gender bias, that contributes to women and nonbinary people feeling unwelcome in tech contexts. \$\endgroup\$ Jan 13, 2017 at 17:41
  • 2
    \$\begingroup\$ @GregMartin thanks for your comment. You are right. I changed the title and the text to avoid any gender specification. \$\endgroup\$
    – Mario
    Jan 13, 2017 at 17:51
  • \$\begingroup\$ Awesome, I like the changes! \$\endgroup\$ Jan 13, 2017 at 20:02
  • \$\begingroup\$ In the first test case [1,T],[2,S],[3,A], is it valid or invalid to arrange them so that the top row is TTSA, the scond row is SSSA, and the bottom row is AAAA? It's not clear whether this satisfies "all the similar types close to each other"; they are certainly touching. \$\endgroup\$ Jan 13, 2017 at 20:05
  • \$\begingroup\$ @GregMartin no it is not valid as you proposed, you must arrange each individual group into squares or rectangles, in your case the S and A are not. It could be SSSS, TAAA, TAAA for example. \$\endgroup\$
    – Mario
    Jan 14, 2017 at 8:06

1 Answer 1

2
\$\begingroup\$

Python 3, 314 313 bytes

l=["  _____  "," /ooooo\ ","|oo%s%s%soo|","|\ooooo/|","| ¯¯¯¯¯ |"," \_____/ "];T=('T',)*3;S=('S',)*3;A=('A',)*3;i=eval('['+input()+']');x=sum(map(lambda x:x[0],i));m=[]
for f in i:m+=[f[1]]*f[0]
for p in 1,0:
    for j in l:
        for k in range(x):print((j%m[k]if '%s' in j else j),end='')
        print()

My attempt at this challenge. It's hard!

Sample Output:

[1,T],[1,S],[7,A]
  _____    _____    _____    _____    _____    _____    _____    _____    _____  
 /ooooo\  /ooooo\  /ooooo\  /ooooo\  /ooooo\  /ooooo\  /ooooo\  /ooooo\  /ooooo\ 
|ooTTToo||ooSSSoo||ooAAAoo||ooAAAoo||ooAAAoo||ooAAAoo||ooAAAoo||ooAAAoo||ooAAAoo|
|\ooooo/||\ooooo/||\ooooo/||\ooooo/||\ooooo/||\ooooo/||\ooooo/||\ooooo/||\ooooo/|
| ¯¯¯¯¯ || ¯¯¯¯¯ || ¯¯¯¯¯ || ¯¯¯¯¯ || ¯¯¯¯¯ || ¯¯¯¯¯ || ¯¯¯¯¯ || ¯¯¯¯¯ || ¯¯¯¯¯ |
 \_____/  \_____/  \_____/  \_____/  \_____/  \_____/  \_____/  \_____/  \_____/ 
  _____    _____    _____    _____    _____    _____    _____    _____    _____  
 /ooooo\  /ooooo\  /ooooo\  /ooooo\  /ooooo\  /ooooo\  /ooooo\  /ooooo\  /ooooo\ 
|ooTTToo||ooSSSoo||ooAAAoo||ooAAAoo||ooAAAoo||ooAAAoo||ooAAAoo||ooAAAoo||ooAAAoo|
|\ooooo/||\ooooo/||\ooooo/||\ooooo/||\ooooo/||\ooooo/||\ooooo/||\ooooo/||\ooooo/|
| ¯¯¯¯¯ || ¯¯¯¯¯ || ¯¯¯¯¯ || ¯¯¯¯¯ || ¯¯¯¯¯ || ¯¯¯¯¯ || ¯¯¯¯¯ || ¯¯¯¯¯ || ¯¯¯¯¯ |
 \_____/  \_____/  \_____/  \_____/  \_____/  \_____/  \_____/  \_____/  \_____/ 
\$\endgroup\$
3
  • \$\begingroup\$ Instead of using tabs you could use spaces for level one indentation and tabs for level two indentation. This will save you 2 bytes overall. \$\endgroup\$
    – Wheat Wizard
    Jan 22, 2017 at 5:13
  • \$\begingroup\$ The space in '%s' in is also unnecessary. \$\endgroup\$
    – Wheat Wizard
    Jan 22, 2017 at 5:14
  • \$\begingroup\$ you don't need the space after if. Python2 would save you one indentation and also the prints ad input. maps are longer than comprehensions if you have to use lambdas. \$\endgroup\$
    – Maltysen
    Jan 22, 2017 at 7:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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