Output visual diagram of pictureWrite a code golf problem in which Java winsGolf a Venn Diagram generatorBooks on a ShelfDetermine the Dimensions of a Rotated RectangleDraw a Houndstooth PatternDraw and label an ASCII hexagonal gridGolf me an ASCII AlphabetOutput a pretty boxASCII-Art Venn DiagramTatamibari solver

Should a narrator ever describe things based on a characters view instead of fact?

Print a physical multiplication table

When should a starting writer get his own webpage?

Is this Pascal's Matrix?

If I cast the Enlarge/Reduce spell on an arrow, what weapon could it count as?

Hackerrank All Women's Codesprint 2019: Name the Product

Isn't the word "experience" wrongly used in this context?

Why is there so much iron?

Can a university suspend a student even when he has left university?

Does convergence of polynomials imply that of its coefficients?

Do people actually use the word "kaputt" in conversation?

What is it called when someone votes for an option that's not their first choice?

How do researchers send unsolicited emails asking for feedback on their works?

Writing in a Christian voice

Why didn’t Eve recognize the little cockroach as a living organism?

How are passwords stolen from companies if they only store hashes?

Asserting that Atheism and Theism are both faith based positions

Can "few" be used as a subject? If so, what is the rule?

Fair way to split coins

What is 管理しきれず?

Air travel with refrigerated insulin

Is there any common country to visit for uk and schengen visa?

Why do I have a large white artefact on the rendered image?

Could any one tell what PN is this Chip? Thanks~



Output visual diagram of picture


Write a code golf problem in which Java winsGolf a Venn Diagram generatorBooks on a ShelfDetermine the Dimensions of a Rotated RectangleDraw a Houndstooth PatternDraw and label an ASCII hexagonal gridGolf me an ASCII AlphabetOutput a pretty boxASCII-Art Venn DiagramTatamibari solver













6












$begingroup$


Write a program that inputs the dimensions of a painting, the matting width, and the frame width for a framed portrait. The program should output a diagram using the symbol ‘X ’ for the painting, ‘+’ for the matting, and ‘# ’ for the framing. The symbols must be space-separated.



INPUT: 3 2 1 2
(Width, Height, Matte Width, Frame Width)



OUTPUT:



First 3 and 2 are painting width and height. 1 is the matte width around it. 2 is the frame width around the whole thing.



In text form:



# # # # # # # # #
# # # # # # # # #
# # + + + + + # #
# # + X X X + # #
# # + X X X + # #
# # + + + + + # #
# # # # # # # # #
# # # # # # # # #


The winning code completes the following conditions in the least possible bytes.










share|improve this question









New contributor




George Harris is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.







$endgroup$











  • $begingroup$
    Nice challenge! For future challenges you may want to use The Sandbox
    $endgroup$
    – MilkyWay90
    3 hours ago










  • $begingroup$
    Also, will the frame height be given?
    $endgroup$
    – MilkyWay90
    3 hours ago










  • $begingroup$
    MilkyWay90, the frame is a constant width around the portrait so only one value is needed.
    $endgroup$
    – George Harris
    3 hours ago










  • $begingroup$
    Thanks! Is the constant width always 2 (or is it the height of the frame)?
    $endgroup$
    – MilkyWay90
    3 hours ago











  • $begingroup$
    Well, the program should be able to handle any case, no? Typically it should be assumed any of the numbers are subject to change. Just given the four inputs, you must produce the visual output. :)
    $endgroup$
    – George Harris
    3 hours ago















6












$begingroup$


Write a program that inputs the dimensions of a painting, the matting width, and the frame width for a framed portrait. The program should output a diagram using the symbol ‘X ’ for the painting, ‘+’ for the matting, and ‘# ’ for the framing. The symbols must be space-separated.



INPUT: 3 2 1 2
(Width, Height, Matte Width, Frame Width)



OUTPUT:



First 3 and 2 are painting width and height. 1 is the matte width around it. 2 is the frame width around the whole thing.



In text form:



# # # # # # # # #
# # # # # # # # #
# # + + + + + # #
# # + X X X + # #
# # + X X X + # #
# # + + + + + # #
# # # # # # # # #
# # # # # # # # #


The winning code completes the following conditions in the least possible bytes.










share|improve this question









New contributor




George Harris is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.







$endgroup$











  • $begingroup$
    Nice challenge! For future challenges you may want to use The Sandbox
    $endgroup$
    – MilkyWay90
    3 hours ago










  • $begingroup$
    Also, will the frame height be given?
    $endgroup$
    – MilkyWay90
    3 hours ago










  • $begingroup$
    MilkyWay90, the frame is a constant width around the portrait so only one value is needed.
    $endgroup$
    – George Harris
    3 hours ago










  • $begingroup$
    Thanks! Is the constant width always 2 (or is it the height of the frame)?
    $endgroup$
    – MilkyWay90
    3 hours ago











  • $begingroup$
    Well, the program should be able to handle any case, no? Typically it should be assumed any of the numbers are subject to change. Just given the four inputs, you must produce the visual output. :)
    $endgroup$
    – George Harris
    3 hours ago













6












6








6





$begingroup$


Write a program that inputs the dimensions of a painting, the matting width, and the frame width for a framed portrait. The program should output a diagram using the symbol ‘X ’ for the painting, ‘+’ for the matting, and ‘# ’ for the framing. The symbols must be space-separated.



INPUT: 3 2 1 2
(Width, Height, Matte Width, Frame Width)



OUTPUT:



First 3 and 2 are painting width and height. 1 is the matte width around it. 2 is the frame width around the whole thing.



In text form:



# # # # # # # # #
# # # # # # # # #
# # + + + + + # #
# # + X X X + # #
# # + X X X + # #
# # + + + + + # #
# # # # # # # # #
# # # # # # # # #


The winning code completes the following conditions in the least possible bytes.










share|improve this question









New contributor




George Harris is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.







$endgroup$




Write a program that inputs the dimensions of a painting, the matting width, and the frame width for a framed portrait. The program should output a diagram using the symbol ‘X ’ for the painting, ‘+’ for the matting, and ‘# ’ for the framing. The symbols must be space-separated.



INPUT: 3 2 1 2
(Width, Height, Matte Width, Frame Width)



OUTPUT:



First 3 and 2 are painting width and height. 1 is the matte width around it. 2 is the frame width around the whole thing.



In text form:



# # # # # # # # #
# # # # # # # # #
# # + + + + + # #
# # + X X X + # #
# # + X X X + # #
# # + + + + + # #
# # # # # # # # #
# # # # # # # # #


The winning code completes the following conditions in the least possible bytes.







code-golf






share|improve this question









New contributor




George Harris is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




George Harris is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited 3 hours ago









Stephen

7,49223397




7,49223397






New contributor




George Harris is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked 3 hours ago









George HarrisGeorge Harris

311




311




New contributor




George Harris is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





George Harris is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






George Harris is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











  • $begingroup$
    Nice challenge! For future challenges you may want to use The Sandbox
    $endgroup$
    – MilkyWay90
    3 hours ago










  • $begingroup$
    Also, will the frame height be given?
    $endgroup$
    – MilkyWay90
    3 hours ago










  • $begingroup$
    MilkyWay90, the frame is a constant width around the portrait so only one value is needed.
    $endgroup$
    – George Harris
    3 hours ago










  • $begingroup$
    Thanks! Is the constant width always 2 (or is it the height of the frame)?
    $endgroup$
    – MilkyWay90
    3 hours ago











  • $begingroup$
    Well, the program should be able to handle any case, no? Typically it should be assumed any of the numbers are subject to change. Just given the four inputs, you must produce the visual output. :)
    $endgroup$
    – George Harris
    3 hours ago
















  • $begingroup$
    Nice challenge! For future challenges you may want to use The Sandbox
    $endgroup$
    – MilkyWay90
    3 hours ago










  • $begingroup$
    Also, will the frame height be given?
    $endgroup$
    – MilkyWay90
    3 hours ago










  • $begingroup$
    MilkyWay90, the frame is a constant width around the portrait so only one value is needed.
    $endgroup$
    – George Harris
    3 hours ago










  • $begingroup$
    Thanks! Is the constant width always 2 (or is it the height of the frame)?
    $endgroup$
    – MilkyWay90
    3 hours ago











  • $begingroup$
    Well, the program should be able to handle any case, no? Typically it should be assumed any of the numbers are subject to change. Just given the four inputs, you must produce the visual output. :)
    $endgroup$
    – George Harris
    3 hours ago















$begingroup$
Nice challenge! For future challenges you may want to use The Sandbox
$endgroup$
– MilkyWay90
3 hours ago




$begingroup$
Nice challenge! For future challenges you may want to use The Sandbox
$endgroup$
– MilkyWay90
3 hours ago












$begingroup$
Also, will the frame height be given?
$endgroup$
– MilkyWay90
3 hours ago




$begingroup$
Also, will the frame height be given?
$endgroup$
– MilkyWay90
3 hours ago












$begingroup$
MilkyWay90, the frame is a constant width around the portrait so only one value is needed.
$endgroup$
– George Harris
3 hours ago




$begingroup$
MilkyWay90, the frame is a constant width around the portrait so only one value is needed.
$endgroup$
– George Harris
3 hours ago












$begingroup$
Thanks! Is the constant width always 2 (or is it the height of the frame)?
$endgroup$
– MilkyWay90
3 hours ago





$begingroup$
Thanks! Is the constant width always 2 (or is it the height of the frame)?
$endgroup$
– MilkyWay90
3 hours ago













$begingroup$
Well, the program should be able to handle any case, no? Typically it should be assumed any of the numbers are subject to change. Just given the four inputs, you must produce the visual output. :)
$endgroup$
– George Harris
3 hours ago




$begingroup$
Well, the program should be able to handle any case, no? Typically it should be assumed any of the numbers are subject to change. Just given the four inputs, you must produce the visual output. :)
$endgroup$
– George Harris
3 hours ago










7 Answers
7






active

oldest

votes


















1












$begingroup$

JavaScript (ES6),  118  113 bytes





(w,h,M,F)=>(g=(c,n)=>'01210'.replace(/./g,i=>c(+i).repeat([F,M,n][i])))(y=>g(x=>'###+X#++'[y+x*5&7]+' ',w)+`
`,h)


Try it online!



Commented



(w, h, M, F) => ( // given the 4 input variables
g = ( // g = helper function taking:
c, // c = callback function returning a string to repeat
n // n = number of times the painting part must be repeated
) => //
'01210' // string describing the picture structure, with:
.replace( // 0 = frame, 1 = matte, 2 = painting
/./g, // for each character in the above string:
i => // i = identifier of the current area
c(+i) // invoke the callback function
.repeat // and repeat it ...
([F, M, n][i]) // ... either F, M or n times
) // end of replace()
)( // outer call to g:
y => // callback function taking y:
g( // inner call to g:
x => // callback function taking x:
'###+X#++' // figure out which character to use
[y + x * 5 & 7] // by applying a small hash function to (x, y)
+ ' ', // append a space
w // repeat the painting part w times
) // end of inner call
+ 'n', // append a line feed
h // repeat the painting part h times
) // end of outer call





share|improve this answer











$endgroup$




















    0












    $begingroup$


    Charcoal, 48 bytes



    NθNηNζNεUO⁺θ⊗⁺ζε⁺η⊗⁺ζε#Mε↘UO⁺θ⊗ζ⁺η⊗ζ+Mζ↘UOθηXUE¹


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



    NθNηNζNε


    Input the four values.



    UO⁺θ⊗⁺ζε⁺η⊗⁺ζε#


    Draw the framing.



    Mε↘UO⁺θ⊗ζ⁺η⊗ζ+


    Move to and draw the matting.



    Mζ↘UOθηX


    Move to and draw the painting.



    UE¹


    Double-space the output horizontally.



    Alternative solution, also 48 bytes:



    NθNηNζNεUO⁺θ⁺ζε⁺η⁺ζε#UO⁺θζ⁺ηζ+UOθηX‖OO←θ‖OO↑ηUE¹


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



    NθNηNζNε


    Input the four values.



    UO⁺θ⁺ζε⁺η⁺ζε#


    Draw the framing, but not to the left or above the painting.



    UO⁺θζ⁺ηζ+


    Draw the matting, but not to the left or above the painting.



    UOθηX


    Draw the painting.



    ‖OO←θ‖OO↑ηUE¹


    Reflect and double-space the output horizontally.






    share|improve this answer









    $endgroup$




















      0












      $begingroup$


      Python 3.8 (pre-release), 116 115 bytes





      lambda a,b,c,d,e='#',f='+':"n".join((g:=[e*(a+2*c+2*d)]*d+[(h:=e*d)+f*(a+c*2)+h]*c)+[h+f*c+'X'*a+f*c+h]*b+g[::-1])


      Try it online!



      First attempt at golfing, will be improved soon.
      a is width, b is height, c is matte width, and d is frame width.



      -1 bytes using the := operator to define h as e * d



      EXPLANATION:



      lambda a,b,c,d,e='#',f='+': Define a lambda which takes in arguments a, b, c, and d (The width of the painting, the height of the painting, the padding of the matte, and the padding of the frame width, respectively). It also defines variables e and f as '#' and '+', respectively.
      "n".join( Turn the list into a string, where each element is separated by newlines
      (g:= Define g as (while still evaling the lists)...
      [e*(a+2*c+2*d)]*d+ Form the top rows (the ones filled with hashtags)
      [(h:=e*d)+f*(a+c*2)+h]*c Form the middle-top rows (uses := to golf this section)
      )+
      [h+f*c+'X'*a+f*c+h]*b+ Form the middle row
      g[::-1] Uses g to golf the code (forms the entire middle-bottom-to-bottom)
      )





      share|improve this answer











      $endgroup$












      • $begingroup$
        Removing the e assignment saves you two bytes, the f assignment isn't saving you anything
        $endgroup$
        – Jo King
        9 mins ago


















      0












      $begingroup$

      Javascript, 158 bytes



      (w,h,m,f)=>(q="repeat",(z=("#"[q](w+2*(m+f)))+`
      `)[q](f))+(x=((e="#"[q](f))+(r="+"[q](m))+(t="+"[q](w))+r+e+`
      `)[q](m))+(e+r+"X"[q](w)+r+e+`
      `)[q](h)+x+z)


      Can probably be trimmed down a little bit






      f=

      (w,h,m,f)=>(q="repeat",(z=("# "[q](w+2*(m+f))+`
      `)[q](f))+(x=((e="# "[q](f))+(r="+ "[q](m))+(t="+ "[q](w))+r+e+`
      `)[q](m))+(e+r+"X "[q](w)+r+e+`
      `)[q](h)+x+z)

      console.log(f(3,2,1,2))








      share|improve this answer









      $endgroup$




















        0












        $begingroup$


        Wolfram Language (Mathematica), 152 bytes



        (t=(p=Table)["# ",(x=2#4+2#3)+#2,x+#];p[t[[i,j]]="+ ",j,z=#4+1,#4+2#3+#,i,z,x-#4+#2];p[t[[i,j]]="X ",j,#3+z,#3+#4+#,i,#3+z,#3+#4+#2];""<>#&/@t)&


        Try it online!






        share|improve this answer











        $endgroup$




















          0












          $begingroup$


          Perl 6, 115 bytes





          ->a,b,c,d$_=['#'xx$!*2+a]xx($!=c+d)*2+b;.[d..^*-d;d..^a+$!+c]='+'xx*;.[$!..^*-$!;$!..^a+$!]='X'xx*;.join("
          ")


          Try it online!



          Roughly golfed anonymous codeblock utilising Perl 6's multi-dimensional list assignment. For example, @a[1;2] = 'X'; will assign 'X' to the element with index 2 from the list with index 1, and @a[1,2,3;3,4,5]='X'xx 9; will replace all the elements with indexes 3,4,5 of the lists with indexes 1,2,3 with 'X'.



          Explanation:



          First, we initialise the list as a a+2*(c+d) by b+2*(c+d) rectangle of #s.



          $_=['#'xx$!*2+a]xx($!=c+d)*2+a;
          State:
          # # # # # # # # #
          # # # # # # # # #
          # # # # # # # # #
          # # # # # # # # #
          # # # # # # # # #
          # # # # # # # # #
          # # # # # # # # #
          # # # # # # # # #


          Then we assign the inner rectangle of +s



          .[d..^*-d;d..^a+$!+c]='+'xx*;
          State:
          # # # # # # # # #
          # # # # # # # # #
          # # + + + + + # #
          # # + + + + + # #
          # # + + + + + # #
          # # + + + + + # #
          # # # # # # # # #
          # # # # # # # # #


          Finally, the innermost rectangle of Xs.



          .[$!..^*-$!;$!..^a+$!]='X'xx*;
          # # # # # # # # #
          # # # # # # # # #
          # # + + + + + # #
          # # + X X X + # #
          # # + X X X + # #
          # # + + + + + # #
          # # # # # # # # #
          # # # # # # # # #





          share|improve this answer









          $endgroup$




















            0












            $begingroup$


            Python 2, 98 bytes





            w,h,a,b=input()
            a*='+'
            b*='#'
            for c in b+a+h*'X'+a+b:print' '.join(min(c,d)for d in b+a+w*'X'+a+b)


            Try it online!



            Prints a space-separated grid, strictly following the spec. I'm amused that *= is used to convert a and b from numbers to strings.



            Python 3 can save some bytes by avoiding ' '.join, maybe more by using f-strings and assignment expressions.



            Python 3, 95 bytes





            def f(w,h,a,b):
            a*='+';b*='#'
            for c in b+a+h*'X'+a+b:print(*[min(c,d)for d in b+a+w*'X'+a+b])


            Try it online!





            share









            $endgroup$












              Your Answer





              StackExchange.ifUsing("editor", function ()
              return StackExchange.using("mathjaxEditing", function ()
              StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix)
              StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["\$", "\$"]]);
              );
              );
              , "mathjax-editing");

              StackExchange.ifUsing("editor", function ()
              StackExchange.using("externalEditor", function ()
              StackExchange.using("snippets", function ()
              StackExchange.snippets.init();
              );
              );
              , "code-snippets");

              StackExchange.ready(function()
              var channelOptions =
              tags: "".split(" "),
              id: "200"
              ;
              initTagRenderer("".split(" "), "".split(" "), channelOptions);

              StackExchange.using("externalEditor", function()
              // Have to fire editor after snippets, if snippets enabled
              if (StackExchange.settings.snippets.snippetsEnabled)
              StackExchange.using("snippets", function()
              createEditor();
              );

              else
              createEditor();

              );

              function createEditor()
              StackExchange.prepareEditor(
              heartbeatType: 'answer',
              autoActivateHeartbeat: false,
              convertImagesToLinks: false,
              noModals: true,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: null,
              bindNavPrevention: true,
              postfix: "",
              imageUploader:
              brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
              contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
              allowUrls: true
              ,
              onDemand: true,
              discardSelector: ".discard-answer"
              ,immediatelyShowMarkdownHelp:true
              );



              );






              George Harris is a new contributor. Be nice, and check out our Code of Conduct.









              draft saved

              draft discarded


















              StackExchange.ready(
              function ()
              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f181763%2foutput-visual-diagram-of-picture%23new-answer', 'question_page');

              );

              Post as a guest















              Required, but never shown

























              7 Answers
              7






              active

              oldest

              votes








              7 Answers
              7






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              1












              $begingroup$

              JavaScript (ES6),  118  113 bytes





              (w,h,M,F)=>(g=(c,n)=>'01210'.replace(/./g,i=>c(+i).repeat([F,M,n][i])))(y=>g(x=>'###+X#++'[y+x*5&7]+' ',w)+`
              `,h)


              Try it online!



              Commented



              (w, h, M, F) => ( // given the 4 input variables
              g = ( // g = helper function taking:
              c, // c = callback function returning a string to repeat
              n // n = number of times the painting part must be repeated
              ) => //
              '01210' // string describing the picture structure, with:
              .replace( // 0 = frame, 1 = matte, 2 = painting
              /./g, // for each character in the above string:
              i => // i = identifier of the current area
              c(+i) // invoke the callback function
              .repeat // and repeat it ...
              ([F, M, n][i]) // ... either F, M or n times
              ) // end of replace()
              )( // outer call to g:
              y => // callback function taking y:
              g( // inner call to g:
              x => // callback function taking x:
              '###+X#++' // figure out which character to use
              [y + x * 5 & 7] // by applying a small hash function to (x, y)
              + ' ', // append a space
              w // repeat the painting part w times
              ) // end of inner call
              + 'n', // append a line feed
              h // repeat the painting part h times
              ) // end of outer call





              share|improve this answer











              $endgroup$

















                1












                $begingroup$

                JavaScript (ES6),  118  113 bytes





                (w,h,M,F)=>(g=(c,n)=>'01210'.replace(/./g,i=>c(+i).repeat([F,M,n][i])))(y=>g(x=>'###+X#++'[y+x*5&7]+' ',w)+`
                `,h)


                Try it online!



                Commented



                (w, h, M, F) => ( // given the 4 input variables
                g = ( // g = helper function taking:
                c, // c = callback function returning a string to repeat
                n // n = number of times the painting part must be repeated
                ) => //
                '01210' // string describing the picture structure, with:
                .replace( // 0 = frame, 1 = matte, 2 = painting
                /./g, // for each character in the above string:
                i => // i = identifier of the current area
                c(+i) // invoke the callback function
                .repeat // and repeat it ...
                ([F, M, n][i]) // ... either F, M or n times
                ) // end of replace()
                )( // outer call to g:
                y => // callback function taking y:
                g( // inner call to g:
                x => // callback function taking x:
                '###+X#++' // figure out which character to use
                [y + x * 5 & 7] // by applying a small hash function to (x, y)
                + ' ', // append a space
                w // repeat the painting part w times
                ) // end of inner call
                + 'n', // append a line feed
                h // repeat the painting part h times
                ) // end of outer call





                share|improve this answer











                $endgroup$















                  1












                  1








                  1





                  $begingroup$

                  JavaScript (ES6),  118  113 bytes





                  (w,h,M,F)=>(g=(c,n)=>'01210'.replace(/./g,i=>c(+i).repeat([F,M,n][i])))(y=>g(x=>'###+X#++'[y+x*5&7]+' ',w)+`
                  `,h)


                  Try it online!



                  Commented



                  (w, h, M, F) => ( // given the 4 input variables
                  g = ( // g = helper function taking:
                  c, // c = callback function returning a string to repeat
                  n // n = number of times the painting part must be repeated
                  ) => //
                  '01210' // string describing the picture structure, with:
                  .replace( // 0 = frame, 1 = matte, 2 = painting
                  /./g, // for each character in the above string:
                  i => // i = identifier of the current area
                  c(+i) // invoke the callback function
                  .repeat // and repeat it ...
                  ([F, M, n][i]) // ... either F, M or n times
                  ) // end of replace()
                  )( // outer call to g:
                  y => // callback function taking y:
                  g( // inner call to g:
                  x => // callback function taking x:
                  '###+X#++' // figure out which character to use
                  [y + x * 5 & 7] // by applying a small hash function to (x, y)
                  + ' ', // append a space
                  w // repeat the painting part w times
                  ) // end of inner call
                  + 'n', // append a line feed
                  h // repeat the painting part h times
                  ) // end of outer call





                  share|improve this answer











                  $endgroup$



                  JavaScript (ES6),  118  113 bytes





                  (w,h,M,F)=>(g=(c,n)=>'01210'.replace(/./g,i=>c(+i).repeat([F,M,n][i])))(y=>g(x=>'###+X#++'[y+x*5&7]+' ',w)+`
                  `,h)


                  Try it online!



                  Commented



                  (w, h, M, F) => ( // given the 4 input variables
                  g = ( // g = helper function taking:
                  c, // c = callback function returning a string to repeat
                  n // n = number of times the painting part must be repeated
                  ) => //
                  '01210' // string describing the picture structure, with:
                  .replace( // 0 = frame, 1 = matte, 2 = painting
                  /./g, // for each character in the above string:
                  i => // i = identifier of the current area
                  c(+i) // invoke the callback function
                  .repeat // and repeat it ...
                  ([F, M, n][i]) // ... either F, M or n times
                  ) // end of replace()
                  )( // outer call to g:
                  y => // callback function taking y:
                  g( // inner call to g:
                  x => // callback function taking x:
                  '###+X#++' // figure out which character to use
                  [y + x * 5 & 7] // by applying a small hash function to (x, y)
                  + ' ', // append a space
                  w // repeat the painting part w times
                  ) // end of inner call
                  + 'n', // append a line feed
                  h // repeat the painting part h times
                  ) // end of outer call






                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited 23 mins ago

























                  answered 1 hour ago









                  ArnauldArnauld

                  79k795328




                  79k795328





















                      0












                      $begingroup$


                      Charcoal, 48 bytes



                      NθNηNζNεUO⁺θ⊗⁺ζε⁺η⊗⁺ζε#Mε↘UO⁺θ⊗ζ⁺η⊗ζ+Mζ↘UOθηXUE¹


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



                      NθNηNζNε


                      Input the four values.



                      UO⁺θ⊗⁺ζε⁺η⊗⁺ζε#


                      Draw the framing.



                      Mε↘UO⁺θ⊗ζ⁺η⊗ζ+


                      Move to and draw the matting.



                      Mζ↘UOθηX


                      Move to and draw the painting.



                      UE¹


                      Double-space the output horizontally.



                      Alternative solution, also 48 bytes:



                      NθNηNζNεUO⁺θ⁺ζε⁺η⁺ζε#UO⁺θζ⁺ηζ+UOθηX‖OO←θ‖OO↑ηUE¹


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



                      NθNηNζNε


                      Input the four values.



                      UO⁺θ⁺ζε⁺η⁺ζε#


                      Draw the framing, but not to the left or above the painting.



                      UO⁺θζ⁺ηζ+


                      Draw the matting, but not to the left or above the painting.



                      UOθηX


                      Draw the painting.



                      ‖OO←θ‖OO↑ηUE¹


                      Reflect and double-space the output horizontally.






                      share|improve this answer









                      $endgroup$

















                        0












                        $begingroup$


                        Charcoal, 48 bytes



                        NθNηNζNεUO⁺θ⊗⁺ζε⁺η⊗⁺ζε#Mε↘UO⁺θ⊗ζ⁺η⊗ζ+Mζ↘UOθηXUE¹


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



                        NθNηNζNε


                        Input the four values.



                        UO⁺θ⊗⁺ζε⁺η⊗⁺ζε#


                        Draw the framing.



                        Mε↘UO⁺θ⊗ζ⁺η⊗ζ+


                        Move to and draw the matting.



                        Mζ↘UOθηX


                        Move to and draw the painting.



                        UE¹


                        Double-space the output horizontally.



                        Alternative solution, also 48 bytes:



                        NθNηNζNεUO⁺θ⁺ζε⁺η⁺ζε#UO⁺θζ⁺ηζ+UOθηX‖OO←θ‖OO↑ηUE¹


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



                        NθNηNζNε


                        Input the four values.



                        UO⁺θ⁺ζε⁺η⁺ζε#


                        Draw the framing, but not to the left or above the painting.



                        UO⁺θζ⁺ηζ+


                        Draw the matting, but not to the left or above the painting.



                        UOθηX


                        Draw the painting.



                        ‖OO←θ‖OO↑ηUE¹


                        Reflect and double-space the output horizontally.






                        share|improve this answer









                        $endgroup$















                          0












                          0








                          0





                          $begingroup$


                          Charcoal, 48 bytes



                          NθNηNζNεUO⁺θ⊗⁺ζε⁺η⊗⁺ζε#Mε↘UO⁺θ⊗ζ⁺η⊗ζ+Mζ↘UOθηXUE¹


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



                          NθNηNζNε


                          Input the four values.



                          UO⁺θ⊗⁺ζε⁺η⊗⁺ζε#


                          Draw the framing.



                          Mε↘UO⁺θ⊗ζ⁺η⊗ζ+


                          Move to and draw the matting.



                          Mζ↘UOθηX


                          Move to and draw the painting.



                          UE¹


                          Double-space the output horizontally.



                          Alternative solution, also 48 bytes:



                          NθNηNζNεUO⁺θ⁺ζε⁺η⁺ζε#UO⁺θζ⁺ηζ+UOθηX‖OO←θ‖OO↑ηUE¹


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



                          NθNηNζNε


                          Input the four values.



                          UO⁺θ⁺ζε⁺η⁺ζε#


                          Draw the framing, but not to the left or above the painting.



                          UO⁺θζ⁺ηζ+


                          Draw the matting, but not to the left or above the painting.



                          UOθηX


                          Draw the painting.



                          ‖OO←θ‖OO↑ηUE¹


                          Reflect and double-space the output horizontally.






                          share|improve this answer









                          $endgroup$




                          Charcoal, 48 bytes



                          NθNηNζNεUO⁺θ⊗⁺ζε⁺η⊗⁺ζε#Mε↘UO⁺θ⊗ζ⁺η⊗ζ+Mζ↘UOθηXUE¹


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



                          NθNηNζNε


                          Input the four values.



                          UO⁺θ⊗⁺ζε⁺η⊗⁺ζε#


                          Draw the framing.



                          Mε↘UO⁺θ⊗ζ⁺η⊗ζ+


                          Move to and draw the matting.



                          Mζ↘UOθηX


                          Move to and draw the painting.



                          UE¹


                          Double-space the output horizontally.



                          Alternative solution, also 48 bytes:



                          NθNηNζNεUO⁺θ⁺ζε⁺η⁺ζε#UO⁺θζ⁺ηζ+UOθηX‖OO←θ‖OO↑ηUE¹


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



                          NθNηNζNε


                          Input the four values.



                          UO⁺θ⁺ζε⁺η⁺ζε#


                          Draw the framing, but not to the left or above the painting.



                          UO⁺θζ⁺ηζ+


                          Draw the matting, but not to the left or above the painting.



                          UOθηX


                          Draw the painting.



                          ‖OO←θ‖OO↑ηUE¹


                          Reflect and double-space the output horizontally.







                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered 2 hours ago









                          NeilNeil

                          81.7k745178




                          81.7k745178





















                              0












                              $begingroup$


                              Python 3.8 (pre-release), 116 115 bytes





                              lambda a,b,c,d,e='#',f='+':"n".join((g:=[e*(a+2*c+2*d)]*d+[(h:=e*d)+f*(a+c*2)+h]*c)+[h+f*c+'X'*a+f*c+h]*b+g[::-1])


                              Try it online!



                              First attempt at golfing, will be improved soon.
                              a is width, b is height, c is matte width, and d is frame width.



                              -1 bytes using the := operator to define h as e * d



                              EXPLANATION:



                              lambda a,b,c,d,e='#',f='+': Define a lambda which takes in arguments a, b, c, and d (The width of the painting, the height of the painting, the padding of the matte, and the padding of the frame width, respectively). It also defines variables e and f as '#' and '+', respectively.
                              "n".join( Turn the list into a string, where each element is separated by newlines
                              (g:= Define g as (while still evaling the lists)...
                              [e*(a+2*c+2*d)]*d+ Form the top rows (the ones filled with hashtags)
                              [(h:=e*d)+f*(a+c*2)+h]*c Form the middle-top rows (uses := to golf this section)
                              )+
                              [h+f*c+'X'*a+f*c+h]*b+ Form the middle row
                              g[::-1] Uses g to golf the code (forms the entire middle-bottom-to-bottom)
                              )





                              share|improve this answer











                              $endgroup$












                              • $begingroup$
                                Removing the e assignment saves you two bytes, the f assignment isn't saving you anything
                                $endgroup$
                                – Jo King
                                9 mins ago















                              0












                              $begingroup$


                              Python 3.8 (pre-release), 116 115 bytes





                              lambda a,b,c,d,e='#',f='+':"n".join((g:=[e*(a+2*c+2*d)]*d+[(h:=e*d)+f*(a+c*2)+h]*c)+[h+f*c+'X'*a+f*c+h]*b+g[::-1])


                              Try it online!



                              First attempt at golfing, will be improved soon.
                              a is width, b is height, c is matte width, and d is frame width.



                              -1 bytes using the := operator to define h as e * d



                              EXPLANATION:



                              lambda a,b,c,d,e='#',f='+': Define a lambda which takes in arguments a, b, c, and d (The width of the painting, the height of the painting, the padding of the matte, and the padding of the frame width, respectively). It also defines variables e and f as '#' and '+', respectively.
                              "n".join( Turn the list into a string, where each element is separated by newlines
                              (g:= Define g as (while still evaling the lists)...
                              [e*(a+2*c+2*d)]*d+ Form the top rows (the ones filled with hashtags)
                              [(h:=e*d)+f*(a+c*2)+h]*c Form the middle-top rows (uses := to golf this section)
                              )+
                              [h+f*c+'X'*a+f*c+h]*b+ Form the middle row
                              g[::-1] Uses g to golf the code (forms the entire middle-bottom-to-bottom)
                              )





                              share|improve this answer











                              $endgroup$












                              • $begingroup$
                                Removing the e assignment saves you two bytes, the f assignment isn't saving you anything
                                $endgroup$
                                – Jo King
                                9 mins ago













                              0












                              0








                              0





                              $begingroup$


                              Python 3.8 (pre-release), 116 115 bytes





                              lambda a,b,c,d,e='#',f='+':"n".join((g:=[e*(a+2*c+2*d)]*d+[(h:=e*d)+f*(a+c*2)+h]*c)+[h+f*c+'X'*a+f*c+h]*b+g[::-1])


                              Try it online!



                              First attempt at golfing, will be improved soon.
                              a is width, b is height, c is matte width, and d is frame width.



                              -1 bytes using the := operator to define h as e * d



                              EXPLANATION:



                              lambda a,b,c,d,e='#',f='+': Define a lambda which takes in arguments a, b, c, and d (The width of the painting, the height of the painting, the padding of the matte, and the padding of the frame width, respectively). It also defines variables e and f as '#' and '+', respectively.
                              "n".join( Turn the list into a string, where each element is separated by newlines
                              (g:= Define g as (while still evaling the lists)...
                              [e*(a+2*c+2*d)]*d+ Form the top rows (the ones filled with hashtags)
                              [(h:=e*d)+f*(a+c*2)+h]*c Form the middle-top rows (uses := to golf this section)
                              )+
                              [h+f*c+'X'*a+f*c+h]*b+ Form the middle row
                              g[::-1] Uses g to golf the code (forms the entire middle-bottom-to-bottom)
                              )





                              share|improve this answer











                              $endgroup$




                              Python 3.8 (pre-release), 116 115 bytes





                              lambda a,b,c,d,e='#',f='+':"n".join((g:=[e*(a+2*c+2*d)]*d+[(h:=e*d)+f*(a+c*2)+h]*c)+[h+f*c+'X'*a+f*c+h]*b+g[::-1])


                              Try it online!



                              First attempt at golfing, will be improved soon.
                              a is width, b is height, c is matte width, and d is frame width.



                              -1 bytes using the := operator to define h as e * d



                              EXPLANATION:



                              lambda a,b,c,d,e='#',f='+': Define a lambda which takes in arguments a, b, c, and d (The width of the painting, the height of the painting, the padding of the matte, and the padding of the frame width, respectively). It also defines variables e and f as '#' and '+', respectively.
                              "n".join( Turn the list into a string, where each element is separated by newlines
                              (g:= Define g as (while still evaling the lists)...
                              [e*(a+2*c+2*d)]*d+ Form the top rows (the ones filled with hashtags)
                              [(h:=e*d)+f*(a+c*2)+h]*c Form the middle-top rows (uses := to golf this section)
                              )+
                              [h+f*c+'X'*a+f*c+h]*b+ Form the middle row
                              g[::-1] Uses g to golf the code (forms the entire middle-bottom-to-bottom)
                              )






                              share|improve this answer














                              share|improve this answer



                              share|improve this answer








                              edited 2 hours ago

























                              answered 2 hours ago









                              MilkyWay90MilkyWay90

                              523212




                              523212











                              • $begingroup$
                                Removing the e assignment saves you two bytes, the f assignment isn't saving you anything
                                $endgroup$
                                – Jo King
                                9 mins ago
















                              • $begingroup$
                                Removing the e assignment saves you two bytes, the f assignment isn't saving you anything
                                $endgroup$
                                – Jo King
                                9 mins ago















                              $begingroup$
                              Removing the e assignment saves you two bytes, the f assignment isn't saving you anything
                              $endgroup$
                              – Jo King
                              9 mins ago




                              $begingroup$
                              Removing the e assignment saves you two bytes, the f assignment isn't saving you anything
                              $endgroup$
                              – Jo King
                              9 mins ago











                              0












                              $begingroup$

                              Javascript, 158 bytes



                              (w,h,m,f)=>(q="repeat",(z=("#"[q](w+2*(m+f)))+`
                              `)[q](f))+(x=((e="#"[q](f))+(r="+"[q](m))+(t="+"[q](w))+r+e+`
                              `)[q](m))+(e+r+"X"[q](w)+r+e+`
                              `)[q](h)+x+z)


                              Can probably be trimmed down a little bit






                              f=

                              (w,h,m,f)=>(q="repeat",(z=("# "[q](w+2*(m+f))+`
                              `)[q](f))+(x=((e="# "[q](f))+(r="+ "[q](m))+(t="+ "[q](w))+r+e+`
                              `)[q](m))+(e+r+"X "[q](w)+r+e+`
                              `)[q](h)+x+z)

                              console.log(f(3,2,1,2))








                              share|improve this answer









                              $endgroup$

















                                0












                                $begingroup$

                                Javascript, 158 bytes



                                (w,h,m,f)=>(q="repeat",(z=("#"[q](w+2*(m+f)))+`
                                `)[q](f))+(x=((e="#"[q](f))+(r="+"[q](m))+(t="+"[q](w))+r+e+`
                                `)[q](m))+(e+r+"X"[q](w)+r+e+`
                                `)[q](h)+x+z)


                                Can probably be trimmed down a little bit






                                f=

                                (w,h,m,f)=>(q="repeat",(z=("# "[q](w+2*(m+f))+`
                                `)[q](f))+(x=((e="# "[q](f))+(r="+ "[q](m))+(t="+ "[q](w))+r+e+`
                                `)[q](m))+(e+r+"X "[q](w)+r+e+`
                                `)[q](h)+x+z)

                                console.log(f(3,2,1,2))








                                share|improve this answer









                                $endgroup$















                                  0












                                  0








                                  0





                                  $begingroup$

                                  Javascript, 158 bytes



                                  (w,h,m,f)=>(q="repeat",(z=("#"[q](w+2*(m+f)))+`
                                  `)[q](f))+(x=((e="#"[q](f))+(r="+"[q](m))+(t="+"[q](w))+r+e+`
                                  `)[q](m))+(e+r+"X"[q](w)+r+e+`
                                  `)[q](h)+x+z)


                                  Can probably be trimmed down a little bit






                                  f=

                                  (w,h,m,f)=>(q="repeat",(z=("# "[q](w+2*(m+f))+`
                                  `)[q](f))+(x=((e="# "[q](f))+(r="+ "[q](m))+(t="+ "[q](w))+r+e+`
                                  `)[q](m))+(e+r+"X "[q](w)+r+e+`
                                  `)[q](h)+x+z)

                                  console.log(f(3,2,1,2))








                                  share|improve this answer









                                  $endgroup$



                                  Javascript, 158 bytes



                                  (w,h,m,f)=>(q="repeat",(z=("#"[q](w+2*(m+f)))+`
                                  `)[q](f))+(x=((e="#"[q](f))+(r="+"[q](m))+(t="+"[q](w))+r+e+`
                                  `)[q](m))+(e+r+"X"[q](w)+r+e+`
                                  `)[q](h)+x+z)


                                  Can probably be trimmed down a little bit






                                  f=

                                  (w,h,m,f)=>(q="repeat",(z=("# "[q](w+2*(m+f))+`
                                  `)[q](f))+(x=((e="# "[q](f))+(r="+ "[q](m))+(t="+ "[q](w))+r+e+`
                                  `)[q](m))+(e+r+"X "[q](w)+r+e+`
                                  `)[q](h)+x+z)

                                  console.log(f(3,2,1,2))








                                  f=

                                  (w,h,m,f)=>(q="repeat",(z=("# "[q](w+2*(m+f))+`
                                  `)[q](f))+(x=((e="# "[q](f))+(r="+ "[q](m))+(t="+ "[q](w))+r+e+`
                                  `)[q](m))+(e+r+"X "[q](w)+r+e+`
                                  `)[q](h)+x+z)

                                  console.log(f(3,2,1,2))





                                  f=

                                  (w,h,m,f)=>(q="repeat",(z=("# "[q](w+2*(m+f))+`
                                  `)[q](f))+(x=((e="# "[q](f))+(r="+ "[q](m))+(t="+ "[q](w))+r+e+`
                                  `)[q](m))+(e+r+"X "[q](w)+r+e+`
                                  `)[q](h)+x+z)

                                  console.log(f(3,2,1,2))






                                  share|improve this answer












                                  share|improve this answer



                                  share|improve this answer










                                  answered 1 hour ago









                                  zeveezevee

                                  57029




                                  57029





















                                      0












                                      $begingroup$


                                      Wolfram Language (Mathematica), 152 bytes



                                      (t=(p=Table)["# ",(x=2#4+2#3)+#2,x+#];p[t[[i,j]]="+ ",j,z=#4+1,#4+2#3+#,i,z,x-#4+#2];p[t[[i,j]]="X ",j,#3+z,#3+#4+#,i,#3+z,#3+#4+#2];""<>#&/@t)&


                                      Try it online!






                                      share|improve this answer











                                      $endgroup$

















                                        0












                                        $begingroup$


                                        Wolfram Language (Mathematica), 152 bytes



                                        (t=(p=Table)["# ",(x=2#4+2#3)+#2,x+#];p[t[[i,j]]="+ ",j,z=#4+1,#4+2#3+#,i,z,x-#4+#2];p[t[[i,j]]="X ",j,#3+z,#3+#4+#,i,#3+z,#3+#4+#2];""<>#&/@t)&


                                        Try it online!






                                        share|improve this answer











                                        $endgroup$















                                          0












                                          0








                                          0





                                          $begingroup$


                                          Wolfram Language (Mathematica), 152 bytes



                                          (t=(p=Table)["# ",(x=2#4+2#3)+#2,x+#];p[t[[i,j]]="+ ",j,z=#4+1,#4+2#3+#,i,z,x-#4+#2];p[t[[i,j]]="X ",j,#3+z,#3+#4+#,i,#3+z,#3+#4+#2];""<>#&/@t)&


                                          Try it online!






                                          share|improve this answer











                                          $endgroup$




                                          Wolfram Language (Mathematica), 152 bytes



                                          (t=(p=Table)["# ",(x=2#4+2#3)+#2,x+#];p[t[[i,j]]="+ ",j,z=#4+1,#4+2#3+#,i,z,x-#4+#2];p[t[[i,j]]="X ",j,#3+z,#3+#4+#,i,#3+z,#3+#4+#2];""<>#&/@t)&


                                          Try it online!







                                          share|improve this answer














                                          share|improve this answer



                                          share|improve this answer








                                          edited 59 mins ago

























                                          answered 1 hour ago









                                          J42161217J42161217

                                          13.3k21251




                                          13.3k21251





















                                              0












                                              $begingroup$


                                              Perl 6, 115 bytes





                                              ->a,b,c,d$_=['#'xx$!*2+a]xx($!=c+d)*2+b;.[d..^*-d;d..^a+$!+c]='+'xx*;.[$!..^*-$!;$!..^a+$!]='X'xx*;.join("
                                              ")


                                              Try it online!



                                              Roughly golfed anonymous codeblock utilising Perl 6's multi-dimensional list assignment. For example, @a[1;2] = 'X'; will assign 'X' to the element with index 2 from the list with index 1, and @a[1,2,3;3,4,5]='X'xx 9; will replace all the elements with indexes 3,4,5 of the lists with indexes 1,2,3 with 'X'.



                                              Explanation:



                                              First, we initialise the list as a a+2*(c+d) by b+2*(c+d) rectangle of #s.



                                              $_=['#'xx$!*2+a]xx($!=c+d)*2+a;
                                              State:
                                              # # # # # # # # #
                                              # # # # # # # # #
                                              # # # # # # # # #
                                              # # # # # # # # #
                                              # # # # # # # # #
                                              # # # # # # # # #
                                              # # # # # # # # #
                                              # # # # # # # # #


                                              Then we assign the inner rectangle of +s



                                              .[d..^*-d;d..^a+$!+c]='+'xx*;
                                              State:
                                              # # # # # # # # #
                                              # # # # # # # # #
                                              # # + + + + + # #
                                              # # + + + + + # #
                                              # # + + + + + # #
                                              # # + + + + + # #
                                              # # # # # # # # #
                                              # # # # # # # # #


                                              Finally, the innermost rectangle of Xs.



                                              .[$!..^*-$!;$!..^a+$!]='X'xx*;
                                              # # # # # # # # #
                                              # # # # # # # # #
                                              # # + + + + + # #
                                              # # + X X X + # #
                                              # # + X X X + # #
                                              # # + + + + + # #
                                              # # # # # # # # #
                                              # # # # # # # # #





                                              share|improve this answer









                                              $endgroup$

















                                                0












                                                $begingroup$


                                                Perl 6, 115 bytes





                                                ->a,b,c,d$_=['#'xx$!*2+a]xx($!=c+d)*2+b;.[d..^*-d;d..^a+$!+c]='+'xx*;.[$!..^*-$!;$!..^a+$!]='X'xx*;.join("
                                                ")


                                                Try it online!



                                                Roughly golfed anonymous codeblock utilising Perl 6's multi-dimensional list assignment. For example, @a[1;2] = 'X'; will assign 'X' to the element with index 2 from the list with index 1, and @a[1,2,3;3,4,5]='X'xx 9; will replace all the elements with indexes 3,4,5 of the lists with indexes 1,2,3 with 'X'.



                                                Explanation:



                                                First, we initialise the list as a a+2*(c+d) by b+2*(c+d) rectangle of #s.



                                                $_=['#'xx$!*2+a]xx($!=c+d)*2+a;
                                                State:
                                                # # # # # # # # #
                                                # # # # # # # # #
                                                # # # # # # # # #
                                                # # # # # # # # #
                                                # # # # # # # # #
                                                # # # # # # # # #
                                                # # # # # # # # #
                                                # # # # # # # # #


                                                Then we assign the inner rectangle of +s



                                                .[d..^*-d;d..^a+$!+c]='+'xx*;
                                                State:
                                                # # # # # # # # #
                                                # # # # # # # # #
                                                # # + + + + + # #
                                                # # + + + + + # #
                                                # # + + + + + # #
                                                # # + + + + + # #
                                                # # # # # # # # #
                                                # # # # # # # # #


                                                Finally, the innermost rectangle of Xs.



                                                .[$!..^*-$!;$!..^a+$!]='X'xx*;
                                                # # # # # # # # #
                                                # # # # # # # # #
                                                # # + + + + + # #
                                                # # + X X X + # #
                                                # # + X X X + # #
                                                # # + + + + + # #
                                                # # # # # # # # #
                                                # # # # # # # # #





                                                share|improve this answer









                                                $endgroup$















                                                  0












                                                  0








                                                  0





                                                  $begingroup$


                                                  Perl 6, 115 bytes





                                                  ->a,b,c,d$_=['#'xx$!*2+a]xx($!=c+d)*2+b;.[d..^*-d;d..^a+$!+c]='+'xx*;.[$!..^*-$!;$!..^a+$!]='X'xx*;.join("
                                                  ")


                                                  Try it online!



                                                  Roughly golfed anonymous codeblock utilising Perl 6's multi-dimensional list assignment. For example, @a[1;2] = 'X'; will assign 'X' to the element with index 2 from the list with index 1, and @a[1,2,3;3,4,5]='X'xx 9; will replace all the elements with indexes 3,4,5 of the lists with indexes 1,2,3 with 'X'.



                                                  Explanation:



                                                  First, we initialise the list as a a+2*(c+d) by b+2*(c+d) rectangle of #s.



                                                  $_=['#'xx$!*2+a]xx($!=c+d)*2+a;
                                                  State:
                                                  # # # # # # # # #
                                                  # # # # # # # # #
                                                  # # # # # # # # #
                                                  # # # # # # # # #
                                                  # # # # # # # # #
                                                  # # # # # # # # #
                                                  # # # # # # # # #
                                                  # # # # # # # # #


                                                  Then we assign the inner rectangle of +s



                                                  .[d..^*-d;d..^a+$!+c]='+'xx*;
                                                  State:
                                                  # # # # # # # # #
                                                  # # # # # # # # #
                                                  # # + + + + + # #
                                                  # # + + + + + # #
                                                  # # + + + + + # #
                                                  # # + + + + + # #
                                                  # # # # # # # # #
                                                  # # # # # # # # #


                                                  Finally, the innermost rectangle of Xs.



                                                  .[$!..^*-$!;$!..^a+$!]='X'xx*;
                                                  # # # # # # # # #
                                                  # # # # # # # # #
                                                  # # + + + + + # #
                                                  # # + X X X + # #
                                                  # # + X X X + # #
                                                  # # + + + + + # #
                                                  # # # # # # # # #
                                                  # # # # # # # # #





                                                  share|improve this answer









                                                  $endgroup$




                                                  Perl 6, 115 bytes





                                                  ->a,b,c,d$_=['#'xx$!*2+a]xx($!=c+d)*2+b;.[d..^*-d;d..^a+$!+c]='+'xx*;.[$!..^*-$!;$!..^a+$!]='X'xx*;.join("
                                                  ")


                                                  Try it online!



                                                  Roughly golfed anonymous codeblock utilising Perl 6's multi-dimensional list assignment. For example, @a[1;2] = 'X'; will assign 'X' to the element with index 2 from the list with index 1, and @a[1,2,3;3,4,5]='X'xx 9; will replace all the elements with indexes 3,4,5 of the lists with indexes 1,2,3 with 'X'.



                                                  Explanation:



                                                  First, we initialise the list as a a+2*(c+d) by b+2*(c+d) rectangle of #s.



                                                  $_=['#'xx$!*2+a]xx($!=c+d)*2+a;
                                                  State:
                                                  # # # # # # # # #
                                                  # # # # # # # # #
                                                  # # # # # # # # #
                                                  # # # # # # # # #
                                                  # # # # # # # # #
                                                  # # # # # # # # #
                                                  # # # # # # # # #
                                                  # # # # # # # # #


                                                  Then we assign the inner rectangle of +s



                                                  .[d..^*-d;d..^a+$!+c]='+'xx*;
                                                  State:
                                                  # # # # # # # # #
                                                  # # # # # # # # #
                                                  # # + + + + + # #
                                                  # # + + + + + # #
                                                  # # + + + + + # #
                                                  # # + + + + + # #
                                                  # # # # # # # # #
                                                  # # # # # # # # #


                                                  Finally, the innermost rectangle of Xs.



                                                  .[$!..^*-$!;$!..^a+$!]='X'xx*;
                                                  # # # # # # # # #
                                                  # # # # # # # # #
                                                  # # + + + + + # #
                                                  # # + X X X + # #
                                                  # # + X X X + # #
                                                  # # + + + + + # #
                                                  # # # # # # # # #
                                                  # # # # # # # # #






                                                  share|improve this answer












                                                  share|improve this answer



                                                  share|improve this answer










                                                  answered 13 mins ago









                                                  Jo KingJo King

                                                  25k359128




                                                  25k359128





















                                                      0












                                                      $begingroup$


                                                      Python 2, 98 bytes





                                                      w,h,a,b=input()
                                                      a*='+'
                                                      b*='#'
                                                      for c in b+a+h*'X'+a+b:print' '.join(min(c,d)for d in b+a+w*'X'+a+b)


                                                      Try it online!



                                                      Prints a space-separated grid, strictly following the spec. I'm amused that *= is used to convert a and b from numbers to strings.



                                                      Python 3 can save some bytes by avoiding ' '.join, maybe more by using f-strings and assignment expressions.



                                                      Python 3, 95 bytes





                                                      def f(w,h,a,b):
                                                      a*='+';b*='#'
                                                      for c in b+a+h*'X'+a+b:print(*[min(c,d)for d in b+a+w*'X'+a+b])


                                                      Try it online!





                                                      share









                                                      $endgroup$

















                                                        0












                                                        $begingroup$


                                                        Python 2, 98 bytes





                                                        w,h,a,b=input()
                                                        a*='+'
                                                        b*='#'
                                                        for c in b+a+h*'X'+a+b:print' '.join(min(c,d)for d in b+a+w*'X'+a+b)


                                                        Try it online!



                                                        Prints a space-separated grid, strictly following the spec. I'm amused that *= is used to convert a and b from numbers to strings.



                                                        Python 3 can save some bytes by avoiding ' '.join, maybe more by using f-strings and assignment expressions.



                                                        Python 3, 95 bytes





                                                        def f(w,h,a,b):
                                                        a*='+';b*='#'
                                                        for c in b+a+h*'X'+a+b:print(*[min(c,d)for d in b+a+w*'X'+a+b])


                                                        Try it online!





                                                        share









                                                        $endgroup$















                                                          0












                                                          0








                                                          0





                                                          $begingroup$


                                                          Python 2, 98 bytes





                                                          w,h,a,b=input()
                                                          a*='+'
                                                          b*='#'
                                                          for c in b+a+h*'X'+a+b:print' '.join(min(c,d)for d in b+a+w*'X'+a+b)


                                                          Try it online!



                                                          Prints a space-separated grid, strictly following the spec. I'm amused that *= is used to convert a and b from numbers to strings.



                                                          Python 3 can save some bytes by avoiding ' '.join, maybe more by using f-strings and assignment expressions.



                                                          Python 3, 95 bytes





                                                          def f(w,h,a,b):
                                                          a*='+';b*='#'
                                                          for c in b+a+h*'X'+a+b:print(*[min(c,d)for d in b+a+w*'X'+a+b])


                                                          Try it online!





                                                          share









                                                          $endgroup$




                                                          Python 2, 98 bytes





                                                          w,h,a,b=input()
                                                          a*='+'
                                                          b*='#'
                                                          for c in b+a+h*'X'+a+b:print' '.join(min(c,d)for d in b+a+w*'X'+a+b)


                                                          Try it online!



                                                          Prints a space-separated grid, strictly following the spec. I'm amused that *= is used to convert a and b from numbers to strings.



                                                          Python 3 can save some bytes by avoiding ' '.join, maybe more by using f-strings and assignment expressions.



                                                          Python 3, 95 bytes





                                                          def f(w,h,a,b):
                                                          a*='+';b*='#'
                                                          for c in b+a+h*'X'+a+b:print(*[min(c,d)for d in b+a+w*'X'+a+b])


                                                          Try it online!






                                                          share











                                                          share


                                                          share










                                                          answered 2 mins ago









                                                          xnorxnor

                                                          92.4k18188447




                                                          92.4k18188447




















                                                              George Harris is a new contributor. Be nice, and check out our Code of Conduct.









                                                              draft saved

                                                              draft discarded


















                                                              George Harris is a new contributor. Be nice, and check out our Code of Conduct.












                                                              George Harris is a new contributor. Be nice, and check out our Code of Conduct.











                                                              George Harris is a new contributor. Be nice, and check out our Code of Conduct.














                                                              If this is an answer to a challenge…



                                                              • …Be sure to follow the challenge specification. However, please refrain from exploiting obvious loopholes. Answers abusing any of the standard loopholes are considered invalid. If you think a specification is unclear or underspecified, comment on the question instead.


                                                              • …Try to optimize your score. For instance, answers to code-golf challenges should attempt to be as short as possible. You can always include a readable version of the code in addition to the competitive one.
                                                                Explanations of your answer make it more interesting to read and are very much encouraged.


                                                              • …Include a short header which indicates the language(s) of your code and its score, as defined by the challenge.


                                                              More generally…



                                                              • …Please make sure to answer the question and provide sufficient detail.


                                                              • …Avoid asking for help, clarification or responding to other answers (use comments instead).




                                                              draft saved


                                                              draft discarded














                                                              StackExchange.ready(
                                                              function ()
                                                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f181763%2foutput-visual-diagram-of-picture%23new-answer', 'question_page');

                                                              );

                                                              Post as a guest















                                                              Required, but never shown





















































                                                              Required, but never shown














                                                              Required, but never shown












                                                              Required, but never shown







                                                              Required, but never shown

































                                                              Required, but never shown














                                                              Required, but never shown












                                                              Required, but never shown







                                                              Required, but never shown







                                                              Popular posts from this blog

                                                              Which organization defines CJK Unified Ideographs? The Next CEO of Stack OverflowCharacters which have several different shapesHow useful are the kanji in reading Chinese?Can Chinese readers scan large amounts of text faster/more accurately than their alphabet-using counterparts?丼: why is “well” also “bowl of food”?What Does Unicode 8.0 Mean For Chinese?How are blanks indicated for placeholders in Chinese (like ???)Is there a dictionary of standard character variants?How to display CJK Extension F?How is it decided as to which character is used on the tech terminology?How does 子 come to mean 'midnight'?

                                                              When We Were Young (canção de Adele) Índice Antecedentes e lançamento | Faixas e formatos | Performances e covers | Desempenho nas tabelas musicais | Créditos | Histórico de lançamento | Referências Menu de navegação«Best albums of 2015»«Adele - When We Were Young (Radio Date: 22-01-2016)»«When We Were Young - Single by Adele»«Adele: Inside Her Private Life and Triumphant Return»«adele interview: world exclusive first interview in three years»«Tobias Jesso Jr: since Adele tweeted his song, he's even bigger than his dad»«Adele interviews Tobias Jesso Jr: 'I think that a couple of the ideas we had could be rap songs'»«Adele on Her Return: 'I Was So Frightened That No One Cared'»«Tobias Jesso Jr. on working with Adele: 'I was as nervous as shit'»«How Ariel Rechtshaid Pushed Adele To Her Limit»«Adele Previews 'When We Were Young' on '60 Minutes' Teaser, Tops Trending 140»«Adele Performs New '25' Ballad, "When We Were Young" Live: Watch»«Which '25' Song Should Be Adele's Next Single?»«Adele's 'When We Were Young' Confirmed As Second Single From '25'»«Adele's new single artwork for 'When We Were Young' is perfectly adorable»«Adele at the BBC review: honest, funny and spectacular – Celebrity News News»«'Saturday Night Live': Adele Sings 'Hello' and 'When We Were Young'»«'Adele: Live in New York City' NBC Special – Set List Revealed!»«Adele Closes Out the 2016 Brit Awards With 'When We Were Young'»«What Is The Adele Live Tour Set List? There's No Way She'd Leave Out These 8 Songs»«See Demi Lovato's Soaring Cover of Adele's 'When We Were Young'»«'The Voice': 5 Best Moments From Week 1 Blind Auditions»«Adele – When We Were Young (Media Control Charts)»«Adele – When We Were Young (Entertainment Monitoring Africa)»«Adele – When We Were Young (ARIA Charts)»«Adele – When We Were Young (Ö3 Austria Top 40)»«Adele – When We Were Young (Ultratop 50)»«Adele – When We Were Young (Ultratop 40)»«Adele – When We Were Young (Canadian Hot 100)»«Adele – When We Were Young (Tracklisten)»«Adele – When We Were Young (The Official Charts Company)»«Adele – Hello (IFPI Slovenská Republika)»«Adele – When We Were Young (Productores de Música de España)»«Adele – When We Were Young (Billboard Hot 100)»«Adele – When We Were Young (Pop Songs)»«Adele – When We Were Young (Adult Pop Songs)»«Adele – When We Were Young (Hot Adult Contemporary Charts)»«Adele – When We Were Young (Hot Dance Club Songs)»«Adele – When We Were Young (Rock Airplay)»«Adele – When We Were Young (IFPI Finlândia)»«Adele – When We Were Young (Syndicat National de l'Éditon Phonographique)»«Adele – When We Were Young (Magyar Hanglemezkiadók Szövetsége)»«Adele – When We Were Young (Irish Recorded Music Association)»«Adele – When We Were Young (Mexico Airplay)»«Adele – When We Were Young (VG-lista)»«Adele – When We Were Young (NZ Top 40 Singles)»«Adele – When We Were Young (MegaCharts)»«Adele – When We Were Young (Związek Producentów Audio Video)»«Adele – When We Were Young (Portugal Digital Songs)»«Adele – When We Were Young (UK Indie Singles Chart)»«Adele – When We Were Young (UK Singles Chart)»«Adele – When We Were Young (Sverigetopplistan)»«Adele – When We Were Young (Schweizer Hitparade)»«Adele – When We Were Young (Portugal Digital Songs)»«Music Canada – Gold/Platinum – When We Were Young»«NZ Top 40 Singles Chart»«Certified Awards»e

                                                              Shenzhen Football Club Índice Elenco atual | Títulos | Referências Ligações externas | Menu de navegaçãoGooglenotíciaslivrosacadêmicoeditar«"Elenco"»Site oficialexpandindo-oeee