Chop up my ascii art

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
1
down vote

favorite












So, let's say I've got some ascii art



 ___
,"---".
: ;
`-.-'
| |
| |
| |
_.-_/-._
_ / | | _
/ / `---'
/ `-----------'
/,-""-. ,-""-.
( i-..-i i-..-i )
|`| |-------| |'|
`-..-' ,=. `-..-'/
`--------|=|-------'
| |

) ) hjw
/ /
( (


(Source)



But I want to focus on the cable of this joystick, because I actually want a picture of a garden path, leading up to a door.



 ,=. 
-|=|-
| |

) )
/ /
( (


I could copy out line after line, I could use a text editor with block selection mode, or... I could write some code!



So, my code needs 5 arguments:



  • A piece of ascii art, a newline separated string.

  • The X axis of the top-left corner (1-indexed, from left hand column, positive integer)

  • The Y axis of the top-left corner (1-indexed, from top row, positive integer)

  • Width of the resultant image (positive integer)

  • Height of the resultant image (positive integer)

Test Cases



Ascii image:



 ___
,"---".
: ;
`-.-'
| |
| |
| |
_.-_/-._
_ / | | _
/ / `---'
/ `-----------'
/,-""-. ,-""-.
( i-..-i i-..-i )
|`| |-------| |'|
`-..-' ,=. `-..-'/
`--------|=|-------'
| |

) ) hjw
/ /
( (


Garden path



  • X: 10

  • Y: 16

  • Width: 5

  • Height: 7

Result:



 ,=. 
-|=|-
| |

) )
/ /
( (


DB icon



  • X: 2

  • Y: 12

  • Width: 6

  • Height: 4

Output:



,-""-.
i-..-i
| |
`-..-'


Alien Elder



  • X: 9

  • Y: 1

  • Width: 7

  • Height: 10

(Formatting issues prevent me from displaying the result here. It's the joystick itself.)



Signature



  • X: 16

  • Y: 19

  • Width: 3


  • Height: 1



    hjw



Rules



  • Output can be given by any convenient method.

  • Either a full program or a function are acceptable.


  • Standard loopholes are forbidden.

  • This is code-golf so all usual golfing rules apply, and the shortest code (in bytes) wins.









share|improve this question

















  • 3




    Can we take X and Y as 0-indexed?
    – TFeld
    1 hour ago






  • 3




    Also, in testcase 1, Y should bew 15, and in TC 2, X should be 3
    – TFeld
    57 mins ago










  • Can we assume the input is padded to a rectangle with spaces?
    – DLosc
    50 mins ago










  • Can you add a test case where the original art doesn't use both single and double quotes, please? Also, I see no good reason to enforce 1-indexing here.
    – Shaggy
    22 mins ago














up vote
1
down vote

favorite












So, let's say I've got some ascii art



 ___
,"---".
: ;
`-.-'
| |
| |
| |
_.-_/-._
_ / | | _
/ / `---'
/ `-----------'
/,-""-. ,-""-.
( i-..-i i-..-i )
|`| |-------| |'|
`-..-' ,=. `-..-'/
`--------|=|-------'
| |

) ) hjw
/ /
( (


(Source)



But I want to focus on the cable of this joystick, because I actually want a picture of a garden path, leading up to a door.



 ,=. 
-|=|-
| |

) )
/ /
( (


I could copy out line after line, I could use a text editor with block selection mode, or... I could write some code!



So, my code needs 5 arguments:



  • A piece of ascii art, a newline separated string.

  • The X axis of the top-left corner (1-indexed, from left hand column, positive integer)

  • The Y axis of the top-left corner (1-indexed, from top row, positive integer)

  • Width of the resultant image (positive integer)

  • Height of the resultant image (positive integer)

Test Cases



Ascii image:



 ___
,"---".
: ;
`-.-'
| |
| |
| |
_.-_/-._
_ / | | _
/ / `---'
/ `-----------'
/,-""-. ,-""-.
( i-..-i i-..-i )
|`| |-------| |'|
`-..-' ,=. `-..-'/
`--------|=|-------'
| |

) ) hjw
/ /
( (


Garden path



  • X: 10

  • Y: 16

  • Width: 5

  • Height: 7

Result:



 ,=. 
-|=|-
| |

) )
/ /
( (


DB icon



  • X: 2

  • Y: 12

  • Width: 6

  • Height: 4

Output:



,-""-.
i-..-i
| |
`-..-'


Alien Elder



  • X: 9

  • Y: 1

  • Width: 7

  • Height: 10

(Formatting issues prevent me from displaying the result here. It's the joystick itself.)



Signature



  • X: 16

  • Y: 19

  • Width: 3


  • Height: 1



    hjw



Rules



  • Output can be given by any convenient method.

  • Either a full program or a function are acceptable.


  • Standard loopholes are forbidden.

  • This is code-golf so all usual golfing rules apply, and the shortest code (in bytes) wins.









share|improve this question

















  • 3




    Can we take X and Y as 0-indexed?
    – TFeld
    1 hour ago






  • 3




    Also, in testcase 1, Y should bew 15, and in TC 2, X should be 3
    – TFeld
    57 mins ago










  • Can we assume the input is padded to a rectangle with spaces?
    – DLosc
    50 mins ago










  • Can you add a test case where the original art doesn't use both single and double quotes, please? Also, I see no good reason to enforce 1-indexing here.
    – Shaggy
    22 mins ago












up vote
1
down vote

favorite









up vote
1
down vote

favorite











So, let's say I've got some ascii art



 ___
,"---".
: ;
`-.-'
| |
| |
| |
_.-_/-._
_ / | | _
/ / `---'
/ `-----------'
/,-""-. ,-""-.
( i-..-i i-..-i )
|`| |-------| |'|
`-..-' ,=. `-..-'/
`--------|=|-------'
| |

) ) hjw
/ /
( (


(Source)



But I want to focus on the cable of this joystick, because I actually want a picture of a garden path, leading up to a door.



 ,=. 
-|=|-
| |

) )
/ /
( (


I could copy out line after line, I could use a text editor with block selection mode, or... I could write some code!



So, my code needs 5 arguments:



  • A piece of ascii art, a newline separated string.

  • The X axis of the top-left corner (1-indexed, from left hand column, positive integer)

  • The Y axis of the top-left corner (1-indexed, from top row, positive integer)

  • Width of the resultant image (positive integer)

  • Height of the resultant image (positive integer)

Test Cases



Ascii image:



 ___
,"---".
: ;
`-.-'
| |
| |
| |
_.-_/-._
_ / | | _
/ / `---'
/ `-----------'
/,-""-. ,-""-.
( i-..-i i-..-i )
|`| |-------| |'|
`-..-' ,=. `-..-'/
`--------|=|-------'
| |

) ) hjw
/ /
( (


Garden path



  • X: 10

  • Y: 16

  • Width: 5

  • Height: 7

Result:



 ,=. 
-|=|-
| |

) )
/ /
( (


DB icon



  • X: 2

  • Y: 12

  • Width: 6

  • Height: 4

Output:



,-""-.
i-..-i
| |
`-..-'


Alien Elder



  • X: 9

  • Y: 1

  • Width: 7

  • Height: 10

(Formatting issues prevent me from displaying the result here. It's the joystick itself.)



Signature



  • X: 16

  • Y: 19

  • Width: 3


  • Height: 1



    hjw



Rules



  • Output can be given by any convenient method.

  • Either a full program or a function are acceptable.


  • Standard loopholes are forbidden.

  • This is code-golf so all usual golfing rules apply, and the shortest code (in bytes) wins.









share|improve this question













So, let's say I've got some ascii art



 ___
,"---".
: ;
`-.-'
| |
| |
| |
_.-_/-._
_ / | | _
/ / `---'
/ `-----------'
/,-""-. ,-""-.
( i-..-i i-..-i )
|`| |-------| |'|
`-..-' ,=. `-..-'/
`--------|=|-------'
| |

) ) hjw
/ /
( (


(Source)



But I want to focus on the cable of this joystick, because I actually want a picture of a garden path, leading up to a door.



 ,=. 
-|=|-
| |

) )
/ /
( (


I could copy out line after line, I could use a text editor with block selection mode, or... I could write some code!



So, my code needs 5 arguments:



  • A piece of ascii art, a newline separated string.

  • The X axis of the top-left corner (1-indexed, from left hand column, positive integer)

  • The Y axis of the top-left corner (1-indexed, from top row, positive integer)

  • Width of the resultant image (positive integer)

  • Height of the resultant image (positive integer)

Test Cases



Ascii image:



 ___
,"---".
: ;
`-.-'
| |
| |
| |
_.-_/-._
_ / | | _
/ / `---'
/ `-----------'
/,-""-. ,-""-.
( i-..-i i-..-i )
|`| |-------| |'|
`-..-' ,=. `-..-'/
`--------|=|-------'
| |

) ) hjw
/ /
( (


Garden path



  • X: 10

  • Y: 16

  • Width: 5

  • Height: 7

Result:



 ,=. 
-|=|-
| |

) )
/ /
( (


DB icon



  • X: 2

  • Y: 12

  • Width: 6

  • Height: 4

Output:



,-""-.
i-..-i
| |
`-..-'


Alien Elder



  • X: 9

  • Y: 1

  • Width: 7

  • Height: 10

(Formatting issues prevent me from displaying the result here. It's the joystick itself.)



Signature



  • X: 16

  • Y: 19

  • Width: 3


  • Height: 1



    hjw



Rules



  • Output can be given by any convenient method.

  • Either a full program or a function are acceptable.


  • Standard loopholes are forbidden.

  • This is code-golf so all usual golfing rules apply, and the shortest code (in bytes) wins.






code-golf ascii-art






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked 1 hour ago









AJFaraday

3,06842751




3,06842751







  • 3




    Can we take X and Y as 0-indexed?
    – TFeld
    1 hour ago






  • 3




    Also, in testcase 1, Y should bew 15, and in TC 2, X should be 3
    – TFeld
    57 mins ago










  • Can we assume the input is padded to a rectangle with spaces?
    – DLosc
    50 mins ago










  • Can you add a test case where the original art doesn't use both single and double quotes, please? Also, I see no good reason to enforce 1-indexing here.
    – Shaggy
    22 mins ago












  • 3




    Can we take X and Y as 0-indexed?
    – TFeld
    1 hour ago






  • 3




    Also, in testcase 1, Y should bew 15, and in TC 2, X should be 3
    – TFeld
    57 mins ago










  • Can we assume the input is padded to a rectangle with spaces?
    – DLosc
    50 mins ago










  • Can you add a test case where the original art doesn't use both single and double quotes, please? Also, I see no good reason to enforce 1-indexing here.
    – Shaggy
    22 mins ago







3




3




Can we take X and Y as 0-indexed?
– TFeld
1 hour ago




Can we take X and Y as 0-indexed?
– TFeld
1 hour ago




3




3




Also, in testcase 1, Y should bew 15, and in TC 2, X should be 3
– TFeld
57 mins ago




Also, in testcase 1, Y should bew 15, and in TC 2, X should be 3
– TFeld
57 mins ago












Can we assume the input is padded to a rectangle with spaces?
– DLosc
50 mins ago




Can we assume the input is padded to a rectangle with spaces?
– DLosc
50 mins ago












Can you add a test case where the original art doesn't use both single and double quotes, please? Also, I see no good reason to enforce 1-indexing here.
– Shaggy
22 mins ago




Can you add a test case where the original art doesn't use both single and double quotes, please? Also, I see no good reason to enforce 1-indexing here.
– Shaggy
22 mins ago










5 Answers
5






active

oldest

votes

















up vote
2
down vote














Python 2, 64 62 bytes





lambda I,x,y,w,h:[l[x-1:][:w]for l in I.split('n')[y-1:][:h]]


Try it online!




If X and Y can be 0-indexed:




Python 2, 56 bytes





lambda I,x,y,w,h:[l[x:x+w]for l in I.split('n')[y:y+h]]


Try it online!






share|improve this answer



























    up vote
    1
    down vote














    Pip -n, 21 bytes



    _@>--b@<dM(a^n--c+,e)


    Try it online!



    Or, if 0-indexing is allowed...



    Pip -n, 17 bytes:



    _@>b@<dM(a^nc+,e)


    Try it online!



    Explanation



    Takes all five arguments as command-line args.



     a-e are the 5 cmdline args; n is newline
    a^n Split a on newlines
    ,e Range(e)
    c+ Add c to each element
    ( ) Use the resulting range(c,c+e) to slice into the list of lines
    M To each line, map this function:
    _ The line
    @>b Slice, keeping indices b and greater
    @<d Slice, keeping indices less than d
    Print, joining on newlines (-n flag)



    The above solutions also assume the input is a perfect rectangle--i.e., the lines are all the same length. Otherwise, 2 extra bytes are needed (use -l instead of -n):



    (Z(a^nZDsb+,d)c+,e) 0-indexed, 19 bytes
    (Z(a^nZDs--b+,d)--c+,e) 1-indexed, 23 bytes





    share|improve this answer



























      up vote
      1
      down vote














      05AB1E, 21 19 bytes



      UV¶¡εXG¦}Y£}sG¦}s£»


      Try it online!



      Or if 0-indexing is allowed:




      05AB1E, 18 bytes



      UV¶¡εX.$Y£}sF¦}s£»


      Try it online!






      share|improve this answer





























        up vote
        0
        down vote














        Japt -R, 13 bytes



        Can save 1 byte if we can use 0-indexing.



        ·sYÉV+Y ®tXÉW


        Try it




        Explanation



         :Implicit input of string U and integers V=Height, W=Width, X & Y
        · :Split U on newlines
        s :Slice
        YÉ : From index Y-1
        V+Y : To index V+Y
        ® :Map
        t : Substring
        XÉ : From index X-1
        W : To length W




        share



























          up vote
          0
          down vote














          JavaScript (Node.js), 70 bytes





          (a,x,y,w,h)=>a.split`
          `.map(q=>q.substr(x-1,w)).slice(--y,y+h).join`
          `


          Try it online!



          The ASCII art given is annoying tbh





          share




















            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',
            convertImagesToLinks: false,
            noModals: false,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













             

            draft saved


            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f174748%2fchop-up-my-ascii-art%23new-answer', 'question_page');

            );

            Post as a guest






























            5 Answers
            5






            active

            oldest

            votes








            5 Answers
            5






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            2
            down vote














            Python 2, 64 62 bytes





            lambda I,x,y,w,h:[l[x-1:][:w]for l in I.split('n')[y-1:][:h]]


            Try it online!




            If X and Y can be 0-indexed:




            Python 2, 56 bytes





            lambda I,x,y,w,h:[l[x:x+w]for l in I.split('n')[y:y+h]]


            Try it online!






            share|improve this answer
























              up vote
              2
              down vote














              Python 2, 64 62 bytes





              lambda I,x,y,w,h:[l[x-1:][:w]for l in I.split('n')[y-1:][:h]]


              Try it online!




              If X and Y can be 0-indexed:




              Python 2, 56 bytes





              lambda I,x,y,w,h:[l[x:x+w]for l in I.split('n')[y:y+h]]


              Try it online!






              share|improve this answer






















                up vote
                2
                down vote










                up vote
                2
                down vote










                Python 2, 64 62 bytes





                lambda I,x,y,w,h:[l[x-1:][:w]for l in I.split('n')[y-1:][:h]]


                Try it online!




                If X and Y can be 0-indexed:




                Python 2, 56 bytes





                lambda I,x,y,w,h:[l[x:x+w]for l in I.split('n')[y:y+h]]


                Try it online!






                share|improve this answer













                Python 2, 64 62 bytes





                lambda I,x,y,w,h:[l[x-1:][:w]for l in I.split('n')[y-1:][:h]]


                Try it online!




                If X and Y can be 0-indexed:




                Python 2, 56 bytes





                lambda I,x,y,w,h:[l[x:x+w]for l in I.split('n')[y:y+h]]


                Try it online!







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered 56 mins ago









                TFeld

                12.7k2836




                12.7k2836




















                    up vote
                    1
                    down vote














                    Pip -n, 21 bytes



                    _@>--b@<dM(a^n--c+,e)


                    Try it online!



                    Or, if 0-indexing is allowed...



                    Pip -n, 17 bytes:



                    _@>b@<dM(a^nc+,e)


                    Try it online!



                    Explanation



                    Takes all five arguments as command-line args.



                     a-e are the 5 cmdline args; n is newline
                    a^n Split a on newlines
                    ,e Range(e)
                    c+ Add c to each element
                    ( ) Use the resulting range(c,c+e) to slice into the list of lines
                    M To each line, map this function:
                    _ The line
                    @>b Slice, keeping indices b and greater
                    @<d Slice, keeping indices less than d
                    Print, joining on newlines (-n flag)



                    The above solutions also assume the input is a perfect rectangle--i.e., the lines are all the same length. Otherwise, 2 extra bytes are needed (use -l instead of -n):



                    (Z(a^nZDsb+,d)c+,e) 0-indexed, 19 bytes
                    (Z(a^nZDs--b+,d)--c+,e) 1-indexed, 23 bytes





                    share|improve this answer
























                      up vote
                      1
                      down vote














                      Pip -n, 21 bytes



                      _@>--b@<dM(a^n--c+,e)


                      Try it online!



                      Or, if 0-indexing is allowed...



                      Pip -n, 17 bytes:



                      _@>b@<dM(a^nc+,e)


                      Try it online!



                      Explanation



                      Takes all five arguments as command-line args.



                       a-e are the 5 cmdline args; n is newline
                      a^n Split a on newlines
                      ,e Range(e)
                      c+ Add c to each element
                      ( ) Use the resulting range(c,c+e) to slice into the list of lines
                      M To each line, map this function:
                      _ The line
                      @>b Slice, keeping indices b and greater
                      @<d Slice, keeping indices less than d
                      Print, joining on newlines (-n flag)



                      The above solutions also assume the input is a perfect rectangle--i.e., the lines are all the same length. Otherwise, 2 extra bytes are needed (use -l instead of -n):



                      (Z(a^nZDsb+,d)c+,e) 0-indexed, 19 bytes
                      (Z(a^nZDs--b+,d)--c+,e) 1-indexed, 23 bytes





                      share|improve this answer






















                        up vote
                        1
                        down vote










                        up vote
                        1
                        down vote










                        Pip -n, 21 bytes



                        _@>--b@<dM(a^n--c+,e)


                        Try it online!



                        Or, if 0-indexing is allowed...



                        Pip -n, 17 bytes:



                        _@>b@<dM(a^nc+,e)


                        Try it online!



                        Explanation



                        Takes all five arguments as command-line args.



                         a-e are the 5 cmdline args; n is newline
                        a^n Split a on newlines
                        ,e Range(e)
                        c+ Add c to each element
                        ( ) Use the resulting range(c,c+e) to slice into the list of lines
                        M To each line, map this function:
                        _ The line
                        @>b Slice, keeping indices b and greater
                        @<d Slice, keeping indices less than d
                        Print, joining on newlines (-n flag)



                        The above solutions also assume the input is a perfect rectangle--i.e., the lines are all the same length. Otherwise, 2 extra bytes are needed (use -l instead of -n):



                        (Z(a^nZDsb+,d)c+,e) 0-indexed, 19 bytes
                        (Z(a^nZDs--b+,d)--c+,e) 1-indexed, 23 bytes





                        share|improve this answer













                        Pip -n, 21 bytes



                        _@>--b@<dM(a^n--c+,e)


                        Try it online!



                        Or, if 0-indexing is allowed...



                        Pip -n, 17 bytes:



                        _@>b@<dM(a^nc+,e)


                        Try it online!



                        Explanation



                        Takes all five arguments as command-line args.



                         a-e are the 5 cmdline args; n is newline
                        a^n Split a on newlines
                        ,e Range(e)
                        c+ Add c to each element
                        ( ) Use the resulting range(c,c+e) to slice into the list of lines
                        M To each line, map this function:
                        _ The line
                        @>b Slice, keeping indices b and greater
                        @<d Slice, keeping indices less than d
                        Print, joining on newlines (-n flag)



                        The above solutions also assume the input is a perfect rectangle--i.e., the lines are all the same length. Otherwise, 2 extra bytes are needed (use -l instead of -n):



                        (Z(a^nZDsb+,d)c+,e) 0-indexed, 19 bytes
                        (Z(a^nZDs--b+,d)--c+,e) 1-indexed, 23 bytes






                        share|improve this answer












                        share|improve this answer



                        share|improve this answer










                        answered 29 mins ago









                        DLosc

                        18.6k33588




                        18.6k33588




















                            up vote
                            1
                            down vote














                            05AB1E, 21 19 bytes



                            UV¶¡εXG¦}Y£}sG¦}s£»


                            Try it online!



                            Or if 0-indexing is allowed:




                            05AB1E, 18 bytes



                            UV¶¡εX.$Y£}sF¦}s£»


                            Try it online!






                            share|improve this answer


























                              up vote
                              1
                              down vote














                              05AB1E, 21 19 bytes



                              UV¶¡εXG¦}Y£}sG¦}s£»


                              Try it online!



                              Or if 0-indexing is allowed:




                              05AB1E, 18 bytes



                              UV¶¡εX.$Y£}sF¦}s£»


                              Try it online!






                              share|improve this answer
























                                up vote
                                1
                                down vote










                                up vote
                                1
                                down vote










                                05AB1E, 21 19 bytes



                                UV¶¡εXG¦}Y£}sG¦}s£»


                                Try it online!



                                Or if 0-indexing is allowed:




                                05AB1E, 18 bytes



                                UV¶¡εX.$Y£}sF¦}s£»


                                Try it online!






                                share|improve this answer















                                05AB1E, 21 19 bytes



                                UV¶¡εXG¦}Y£}sG¦}s£»


                                Try it online!



                                Or if 0-indexing is allowed:




                                05AB1E, 18 bytes



                                UV¶¡εX.$Y£}sF¦}s£»


                                Try it online!







                                share|improve this answer














                                share|improve this answer



                                share|improve this answer








                                edited 22 mins ago

























                                answered 47 mins ago









                                Emigna

                                44k431133




                                44k431133




















                                    up vote
                                    0
                                    down vote














                                    Japt -R, 13 bytes



                                    Can save 1 byte if we can use 0-indexing.



                                    ·sYÉV+Y ®tXÉW


                                    Try it




                                    Explanation



                                     :Implicit input of string U and integers V=Height, W=Width, X & Y
                                    · :Split U on newlines
                                    s :Slice
                                    YÉ : From index Y-1
                                    V+Y : To index V+Y
                                    ® :Map
                                    t : Substring
                                    XÉ : From index X-1
                                    W : To length W




                                    share
























                                      up vote
                                      0
                                      down vote














                                      Japt -R, 13 bytes



                                      Can save 1 byte if we can use 0-indexing.



                                      ·sYÉV+Y ®tXÉW


                                      Try it




                                      Explanation



                                       :Implicit input of string U and integers V=Height, W=Width, X & Y
                                      · :Split U on newlines
                                      s :Slice
                                      YÉ : From index Y-1
                                      V+Y : To index V+Y
                                      ® :Map
                                      t : Substring
                                      XÉ : From index X-1
                                      W : To length W




                                      share






















                                        up vote
                                        0
                                        down vote










                                        up vote
                                        0
                                        down vote










                                        Japt -R, 13 bytes



                                        Can save 1 byte if we can use 0-indexing.



                                        ·sYÉV+Y ®tXÉW


                                        Try it




                                        Explanation



                                         :Implicit input of string U and integers V=Height, W=Width, X & Y
                                        · :Split U on newlines
                                        s :Slice
                                        YÉ : From index Y-1
                                        V+Y : To index V+Y
                                        ® :Map
                                        t : Substring
                                        XÉ : From index X-1
                                        W : To length W




                                        share













                                        Japt -R, 13 bytes



                                        Can save 1 byte if we can use 0-indexing.



                                        ·sYÉV+Y ®tXÉW


                                        Try it




                                        Explanation



                                         :Implicit input of string U and integers V=Height, W=Width, X & Y
                                        · :Split U on newlines
                                        s :Slice
                                        YÉ : From index Y-1
                                        V+Y : To index V+Y
                                        ® :Map
                                        t : Substring
                                        XÉ : From index X-1
                                        W : To length W





                                        share











                                        share


                                        share










                                        answered 6 mins ago









                                        Shaggy

                                        17.4k21663




                                        17.4k21663




















                                            up vote
                                            0
                                            down vote














                                            JavaScript (Node.js), 70 bytes





                                            (a,x,y,w,h)=>a.split`
                                            `.map(q=>q.substr(x-1,w)).slice(--y,y+h).join`
                                            `


                                            Try it online!



                                            The ASCII art given is annoying tbh





                                            share
























                                              up vote
                                              0
                                              down vote














                                              JavaScript (Node.js), 70 bytes





                                              (a,x,y,w,h)=>a.split`
                                              `.map(q=>q.substr(x-1,w)).slice(--y,y+h).join`
                                              `


                                              Try it online!



                                              The ASCII art given is annoying tbh





                                              share






















                                                up vote
                                                0
                                                down vote










                                                up vote
                                                0
                                                down vote










                                                JavaScript (Node.js), 70 bytes





                                                (a,x,y,w,h)=>a.split`
                                                `.map(q=>q.substr(x-1,w)).slice(--y,y+h).join`
                                                `


                                                Try it online!



                                                The ASCII art given is annoying tbh





                                                share













                                                JavaScript (Node.js), 70 bytes





                                                (a,x,y,w,h)=>a.split`
                                                `.map(q=>q.substr(x-1,w)).slice(--y,y+h).join`
                                                `


                                                Try it online!



                                                The ASCII art given is annoying tbh






                                                share











                                                share


                                                share










                                                answered 10 secs ago









                                                Shieru Asakoto

                                                2,060313




                                                2,060313



























                                                     

                                                    draft saved


                                                    draft discarded















































                                                     


                                                    draft saved


                                                    draft discarded














                                                    StackExchange.ready(
                                                    function ()
                                                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f174748%2fchop-up-my-ascii-art%23new-answer', 'question_page');

                                                    );

                                                    Post as a guest













































































                                                    Comments

                                                    Popular posts from this blog

                                                    What does second last employer means? [closed]

                                                    List of Gilmore Girls characters

                                                    One-line joke