Backhanded Compliments

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











up vote
4
down vote

favorite
1












This challenge is created in celebration of my first esoteric language, Backhand!



Backhand is a one dimensional language with a non-linear pointer flow. The pointer moves three steps at a time, only executing every third instruction.



The program 1 1 + O @ will add 1+1 and output 2 before terminating. The intermediate instructions are skipped, so 1<>1()+O@ is exactly the same program.



When the pointer is about to step off the end of the tape, it instead reverses direction and steps the other way, so 1.@1.O+. is the same program. Note that it only counts the end instruction once. This allows us to compress most linear programs down, such as 1O+1@



Your challenge here is to write a program or function that take a string, and output the instructions that would be executed if the program was interpreted like Backhand (you don't need to handle any actual Backhand instructions). You are to only output until the pointer lands on the last character of the string (at which point the execution would normally go backwards).



But wait, that's not all! When your program itself is interpreted in this fashion, the resulting code should output one of the below:



  • (Mostly) works

  • Turing complete


  • 'Recreational' (quotes can be either ' or ", but not both)

  • Perfectly okay

  • Only a few bugs

For example, if your source code is code 2 backhand, then the program ce cankb od2ahd should output one of these phrases.



Test cases:



"1 1 + O @" -> "11+O@"
"1O+1@" -> "11+O@"
"HoreWll dlo!" -> "Hello World!"
"abcdefghijklmnopqrstuvwxyz" -> "adgjmpsvyxurolifcbehknqtwz"
"0123456789" -> "0369" (not "0369630369")
"@" -> "@"
"io" -> "io" (Cat program in Backhand)
"!?O" -> "!?O" (Outputs random bits forever in Backhand)
"---!---!" -> "-!-----!"


And a reference program written in, of course, Backhand (this might be a bit buggy).



Rules.




  • Standard Loopholes are forbidden

  • The input of the first program will contain only printable ASCII and newlines (that is, bytes 0x20-0x7E as well as 0x0A)

  • You can choose whether your second program is converted from your first by bytes or by UTF-8 characters.

  • Second program:

    • Case does not matter, so your output could be pErFectLy OKay if you want.

    • Any amount of trailing/leading whitespace (newline, tabs, spaces) are also okay.

    • The second program should be the same language as the first, though not necessarily the same format (program/function)

    • I'm happy to include suggestions from the comments on extra phrases (as long as they're not too short)


  • As this is code-golf, your aim is to get the shortest answer for your language!

  • In two weeks, I'll award a 200 bounty to the shortest Backhand answer.









share|improve this question























  • Sandbox (deleted)
    – Jo King
    7 hours ago






  • 1




    Suggested testcase: "---!---!" (or any string where the last character appears more than once)
    – TFeld
    6 hours ago










  • When your program itself is interpreted in this fashion - interpreted by what?
    – ngm
    6 hours ago






  • 4




    So let's say I write an R program (because that's pretty much all I do around here.) My R program has to transform the Backhanded code into the sequence of Backhanded instructions. In addition, my R program when input into into itself has to become another R program that outputs on of those strings when run (in the case of R, interpreted by an R interpreter). Is this correct?
    – ngm
    5 hours ago







  • 1




    @ngm Yes. -----
    – user202729
    5 hours ago














up vote
4
down vote

favorite
1












This challenge is created in celebration of my first esoteric language, Backhand!



Backhand is a one dimensional language with a non-linear pointer flow. The pointer moves three steps at a time, only executing every third instruction.



The program 1 1 + O @ will add 1+1 and output 2 before terminating. The intermediate instructions are skipped, so 1<>1()+O@ is exactly the same program.



When the pointer is about to step off the end of the tape, it instead reverses direction and steps the other way, so 1.@1.O+. is the same program. Note that it only counts the end instruction once. This allows us to compress most linear programs down, such as 1O+1@



Your challenge here is to write a program or function that take a string, and output the instructions that would be executed if the program was interpreted like Backhand (you don't need to handle any actual Backhand instructions). You are to only output until the pointer lands on the last character of the string (at which point the execution would normally go backwards).



But wait, that's not all! When your program itself is interpreted in this fashion, the resulting code should output one of the below:



  • (Mostly) works

  • Turing complete


  • 'Recreational' (quotes can be either ' or ", but not both)

  • Perfectly okay

  • Only a few bugs

For example, if your source code is code 2 backhand, then the program ce cankb od2ahd should output one of these phrases.



Test cases:



"1 1 + O @" -> "11+O@"
"1O+1@" -> "11+O@"
"HoreWll dlo!" -> "Hello World!"
"abcdefghijklmnopqrstuvwxyz" -> "adgjmpsvyxurolifcbehknqtwz"
"0123456789" -> "0369" (not "0369630369")
"@" -> "@"
"io" -> "io" (Cat program in Backhand)
"!?O" -> "!?O" (Outputs random bits forever in Backhand)
"---!---!" -> "-!-----!"


And a reference program written in, of course, Backhand (this might be a bit buggy).



Rules.




  • Standard Loopholes are forbidden

  • The input of the first program will contain only printable ASCII and newlines (that is, bytes 0x20-0x7E as well as 0x0A)

  • You can choose whether your second program is converted from your first by bytes or by UTF-8 characters.

  • Second program:

    • Case does not matter, so your output could be pErFectLy OKay if you want.

    • Any amount of trailing/leading whitespace (newline, tabs, spaces) are also okay.

    • The second program should be the same language as the first, though not necessarily the same format (program/function)

    • I'm happy to include suggestions from the comments on extra phrases (as long as they're not too short)


  • As this is code-golf, your aim is to get the shortest answer for your language!

  • In two weeks, I'll award a 200 bounty to the shortest Backhand answer.









share|improve this question























  • Sandbox (deleted)
    – Jo King
    7 hours ago






  • 1




    Suggested testcase: "---!---!" (or any string where the last character appears more than once)
    – TFeld
    6 hours ago










  • When your program itself is interpreted in this fashion - interpreted by what?
    – ngm
    6 hours ago






  • 4




    So let's say I write an R program (because that's pretty much all I do around here.) My R program has to transform the Backhanded code into the sequence of Backhanded instructions. In addition, my R program when input into into itself has to become another R program that outputs on of those strings when run (in the case of R, interpreted by an R interpreter). Is this correct?
    – ngm
    5 hours ago







  • 1




    @ngm Yes. -----
    – user202729
    5 hours ago












up vote
4
down vote

favorite
1









up vote
4
down vote

favorite
1






1





This challenge is created in celebration of my first esoteric language, Backhand!



Backhand is a one dimensional language with a non-linear pointer flow. The pointer moves three steps at a time, only executing every third instruction.



The program 1 1 + O @ will add 1+1 and output 2 before terminating. The intermediate instructions are skipped, so 1<>1()+O@ is exactly the same program.



When the pointer is about to step off the end of the tape, it instead reverses direction and steps the other way, so 1.@1.O+. is the same program. Note that it only counts the end instruction once. This allows us to compress most linear programs down, such as 1O+1@



Your challenge here is to write a program or function that take a string, and output the instructions that would be executed if the program was interpreted like Backhand (you don't need to handle any actual Backhand instructions). You are to only output until the pointer lands on the last character of the string (at which point the execution would normally go backwards).



But wait, that's not all! When your program itself is interpreted in this fashion, the resulting code should output one of the below:



  • (Mostly) works

  • Turing complete


  • 'Recreational' (quotes can be either ' or ", but not both)

  • Perfectly okay

  • Only a few bugs

For example, if your source code is code 2 backhand, then the program ce cankb od2ahd should output one of these phrases.



Test cases:



"1 1 + O @" -> "11+O@"
"1O+1@" -> "11+O@"
"HoreWll dlo!" -> "Hello World!"
"abcdefghijklmnopqrstuvwxyz" -> "adgjmpsvyxurolifcbehknqtwz"
"0123456789" -> "0369" (not "0369630369")
"@" -> "@"
"io" -> "io" (Cat program in Backhand)
"!?O" -> "!?O" (Outputs random bits forever in Backhand)
"---!---!" -> "-!-----!"


And a reference program written in, of course, Backhand (this might be a bit buggy).



Rules.




  • Standard Loopholes are forbidden

  • The input of the first program will contain only printable ASCII and newlines (that is, bytes 0x20-0x7E as well as 0x0A)

  • You can choose whether your second program is converted from your first by bytes or by UTF-8 characters.

  • Second program:

    • Case does not matter, so your output could be pErFectLy OKay if you want.

    • Any amount of trailing/leading whitespace (newline, tabs, spaces) are also okay.

    • The second program should be the same language as the first, though not necessarily the same format (program/function)

    • I'm happy to include suggestions from the comments on extra phrases (as long as they're not too short)


  • As this is code-golf, your aim is to get the shortest answer for your language!

  • In two weeks, I'll award a 200 bounty to the shortest Backhand answer.









share|improve this question















This challenge is created in celebration of my first esoteric language, Backhand!



Backhand is a one dimensional language with a non-linear pointer flow. The pointer moves three steps at a time, only executing every third instruction.



The program 1 1 + O @ will add 1+1 and output 2 before terminating. The intermediate instructions are skipped, so 1<>1()+O@ is exactly the same program.



When the pointer is about to step off the end of the tape, it instead reverses direction and steps the other way, so 1.@1.O+. is the same program. Note that it only counts the end instruction once. This allows us to compress most linear programs down, such as 1O+1@



Your challenge here is to write a program or function that take a string, and output the instructions that would be executed if the program was interpreted like Backhand (you don't need to handle any actual Backhand instructions). You are to only output until the pointer lands on the last character of the string (at which point the execution would normally go backwards).



But wait, that's not all! When your program itself is interpreted in this fashion, the resulting code should output one of the below:



  • (Mostly) works

  • Turing complete


  • 'Recreational' (quotes can be either ' or ", but not both)

  • Perfectly okay

  • Only a few bugs

For example, if your source code is code 2 backhand, then the program ce cankb od2ahd should output one of these phrases.



Test cases:



"1 1 + O @" -> "11+O@"
"1O+1@" -> "11+O@"
"HoreWll dlo!" -> "Hello World!"
"abcdefghijklmnopqrstuvwxyz" -> "adgjmpsvyxurolifcbehknqtwz"
"0123456789" -> "0369" (not "0369630369")
"@" -> "@"
"io" -> "io" (Cat program in Backhand)
"!?O" -> "!?O" (Outputs random bits forever in Backhand)
"---!---!" -> "-!-----!"


And a reference program written in, of course, Backhand (this might be a bit buggy).



Rules.




  • Standard Loopholes are forbidden

  • The input of the first program will contain only printable ASCII and newlines (that is, bytes 0x20-0x7E as well as 0x0A)

  • You can choose whether your second program is converted from your first by bytes or by UTF-8 characters.

  • Second program:

    • Case does not matter, so your output could be pErFectLy OKay if you want.

    • Any amount of trailing/leading whitespace (newline, tabs, spaces) are also okay.

    • The second program should be the same language as the first, though not necessarily the same format (program/function)

    • I'm happy to include suggestions from the comments on extra phrases (as long as they're not too short)


  • As this is code-golf, your aim is to get the shortest answer for your language!

  • In two weeks, I'll award a 200 bounty to the shortest Backhand answer.






code-golf source-layout






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 8 mins ago

























asked 8 hours ago









Jo King

16.6k24190




16.6k24190











  • Sandbox (deleted)
    – Jo King
    7 hours ago






  • 1




    Suggested testcase: "---!---!" (or any string where the last character appears more than once)
    – TFeld
    6 hours ago










  • When your program itself is interpreted in this fashion - interpreted by what?
    – ngm
    6 hours ago






  • 4




    So let's say I write an R program (because that's pretty much all I do around here.) My R program has to transform the Backhanded code into the sequence of Backhanded instructions. In addition, my R program when input into into itself has to become another R program that outputs on of those strings when run (in the case of R, interpreted by an R interpreter). Is this correct?
    – ngm
    5 hours ago







  • 1




    @ngm Yes. -----
    – user202729
    5 hours ago
















  • Sandbox (deleted)
    – Jo King
    7 hours ago






  • 1




    Suggested testcase: "---!---!" (or any string where the last character appears more than once)
    – TFeld
    6 hours ago










  • When your program itself is interpreted in this fashion - interpreted by what?
    – ngm
    6 hours ago






  • 4




    So let's say I write an R program (because that's pretty much all I do around here.) My R program has to transform the Backhanded code into the sequence of Backhanded instructions. In addition, my R program when input into into itself has to become another R program that outputs on of those strings when run (in the case of R, interpreted by an R interpreter). Is this correct?
    – ngm
    5 hours ago







  • 1




    @ngm Yes. -----
    – user202729
    5 hours ago















Sandbox (deleted)
– Jo King
7 hours ago




Sandbox (deleted)
– Jo King
7 hours ago




1




1




Suggested testcase: "---!---!" (or any string where the last character appears more than once)
– TFeld
6 hours ago




Suggested testcase: "---!---!" (or any string where the last character appears more than once)
– TFeld
6 hours ago












When your program itself is interpreted in this fashion - interpreted by what?
– ngm
6 hours ago




When your program itself is interpreted in this fashion - interpreted by what?
– ngm
6 hours ago




4




4




So let's say I write an R program (because that's pretty much all I do around here.) My R program has to transform the Backhanded code into the sequence of Backhanded instructions. In addition, my R program when input into into itself has to become another R program that outputs on of those strings when run (in the case of R, interpreted by an R interpreter). Is this correct?
– ngm
5 hours ago





So let's say I write an R program (because that's pretty much all I do around here.) My R program has to transform the Backhanded code into the sequence of Backhanded instructions. In addition, my R program when input into into itself has to become another R program that outputs on of those strings when run (in the case of R, interpreted by an R interpreter). Is this correct?
– ngm
5 hours ago





1




1




@ngm Yes. -----
– user202729
5 hours ago




@ngm Yes. -----
– user202729
5 hours ago










5 Answers
5






active

oldest

votes

















up vote
2
down vote














Python 2, 163 bytes






# p r i n t ' P e r f e c t l y o k a y ' #
s=list(enumerate(input()))
S=(s+s[-2:0:-1]+s)[::3]
print''.join(zip(*S[:S.index(s[-1])+1])[1])


Try it online!






share|improve this answer



























    up vote
    2
    down vote














    Python 2, 130 bytes





    p='r'#i n t ' P e r f e c t l y o k a y ' # 
    s=input();S=s+s[-2:0:-1]+s
    print S[:len(~-len(s)%3and S or s):3]


    Try it online!






    share|improve this answer



























      up vote
      2
      down vote














      R, 187 bytes





       # c a t ( ' P e r f e c t l y o k a y ' ) #
      g=function(x,n=nchar(x),i=c(1:n,(n-1):1,2:n),j=seq(1,3*n-2,3),k=i[j][1:which(i[j]==n)[1]])cat(substring(x,k,k),sep='')


      Try it online!



      The single space at the end is needed so that the n never gets printed when the program is applied to itself.



      Explanation



      Part 1:



      Ungolfed:



       # c a t ( ' P e r f e c t l y o k a y ' ) #
      g <- function(x)
      n <- nchar(x) # number of characters in string
      i <- c(1:n, (n - 1):1, 2:n) # index: 1 to n, n-1 back to 1, 2 to n
      j <- seq(1, 3 * n - 2, 3) # every third element of i
      k <- i[j][1:which(i[j] == n)[1]] # the elements of i at indices j, up to the first appearance of n
      cat(substring(x, k, k), sep = "") # extract from x the characters at indices k, and paste them together



      Part 2:



      The function produces this when it acts on the entire program:



      cat('Perfectly okay')#=ni(ncr)=1,-:2)=q,n,,i]:i(j=assi(k)e' 





      share|improve this answer





























        up vote
        1
        down vote














        05AB1E, 41 bytes



        “€€Ã€€Ð€€µ€€Ý€€“/g i që¬?3U[ûDXè?XIg<Ö#X3+U


        Can without a doubt be golfed..



        Try it online. (PS: Switch the language from 05AB1E (legacy) to 05AB1E for test cases 0123456789 and @. The legacy version is much faster, but it shows incorrect results for number inputs with leading zeros or single-char inputs.)



        The 'backhanded' program will become:



        “Ãеݓ q?[XX<XU


        Which will output perfectly okay in full lowercase.



        Try it online.



        Explanation base program:





        “€€Ã€€Ð€€µ€€Ý€€“ # Push the string "the pointed who the ethernet been the"
        / # And remove it from the stack again
        g # Push the length of the (implicit) input
        i # If the length is exactly 1:
        q # Stop the program (and output the input implicitly)
        ë # Else:
        ¬? # Take the input implicitly again, and output its head
        3U # Push and pop 3, and store it in variable `X`
        [ # Start an infinite loop
        û # Palindromize the string at the top of the stack
        # i.e. "1O+1@" becomes "1O+1@1+O1" the first iteration,
        # and "1O+1@1+O1O+1@1+O1" the next iteration, etc.
        D # Duplicate the palindromized string
        Xè # Index variable `X` in the string
        ? # Output the character
        X # Check if variable `X`
        Ö # is divisible by
        Ig< # The length of the input - 1
        # # And if it is: stop the infinite loop
        X3+ # Then increase `X` by 3
        U # And pop and store it as the new `X`


        Explanation 'backhanded' program:



        “Ãеݓ # Push the string "perfectly okay"
        q # Exit the program (and implicitly output the top of the stack)
        ?[XX<XU # No-ops


        See this 05AB1E tip of mine (section How to use the dictionary?) to understand why “€€Ã€€Ð€€µ€€Ý€€“ is the pointed who the ethernet been the and “Ãеݓ is perfectly okay.






        share|improve this answer





























          up vote
          1
          down vote













          JavaScript (ES6), 130 bytes



          Early attempt. Not very satisfying.



          f =/*> " P e r f e c t l y o k a*/y=>""+/**/(g=p=>(c=y[p])?m++%3?g(p+d):y[p+1]?c+g(p+d):c:g(p-d-d,d=-d))(m=0,d=1)


          Try it online!



          When the code is processed by itself, the following characters are isolated:



          f =/*> " P e r f e c t l y o k a*/y=>""+/**/…
          ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^


          which gives:



          f=>"Perfectly okay"//…





          share|improve this answer






















            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%2f173187%2fbackhanded-compliments%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, 163 bytes






            # p r i n t ' P e r f e c t l y o k a y ' #
            s=list(enumerate(input()))
            S=(s+s[-2:0:-1]+s)[::3]
            print''.join(zip(*S[:S.index(s[-1])+1])[1])


            Try it online!






            share|improve this answer
























              up vote
              2
              down vote














              Python 2, 163 bytes






              # p r i n t ' P e r f e c t l y o k a y ' #
              s=list(enumerate(input()))
              S=(s+s[-2:0:-1]+s)[::3]
              print''.join(zip(*S[:S.index(s[-1])+1])[1])


              Try it online!






              share|improve this answer






















                up vote
                2
                down vote










                up vote
                2
                down vote










                Python 2, 163 bytes






                # p r i n t ' P e r f e c t l y o k a y ' #
                s=list(enumerate(input()))
                S=(s+s[-2:0:-1]+s)[::3]
                print''.join(zip(*S[:S.index(s[-1])+1])[1])


                Try it online!






                share|improve this answer













                Python 2, 163 bytes






                # p r i n t ' P e r f e c t l y o k a y ' #
                s=list(enumerate(input()))
                S=(s+s[-2:0:-1]+s)[::3]
                print''.join(zip(*S[:S.index(s[-1])+1])[1])


                Try it online!







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered 6 hours ago









                TFeld

                12k2833




                12k2833




















                    up vote
                    2
                    down vote














                    Python 2, 130 bytes





                    p='r'#i n t ' P e r f e c t l y o k a y ' # 
                    s=input();S=s+s[-2:0:-1]+s
                    print S[:len(~-len(s)%3and S or s):3]


                    Try it online!






                    share|improve this answer
























                      up vote
                      2
                      down vote














                      Python 2, 130 bytes





                      p='r'#i n t ' P e r f e c t l y o k a y ' # 
                      s=input();S=s+s[-2:0:-1]+s
                      print S[:len(~-len(s)%3and S or s):3]


                      Try it online!






                      share|improve this answer






















                        up vote
                        2
                        down vote










                        up vote
                        2
                        down vote










                        Python 2, 130 bytes





                        p='r'#i n t ' P e r f e c t l y o k a y ' # 
                        s=input();S=s+s[-2:0:-1]+s
                        print S[:len(~-len(s)%3and S or s):3]


                        Try it online!






                        share|improve this answer













                        Python 2, 130 bytes





                        p='r'#i n t ' P e r f e c t l y o k a y ' # 
                        s=input();S=s+s[-2:0:-1]+s
                        print S[:len(~-len(s)%3and S or s):3]


                        Try it online!







                        share|improve this answer












                        share|improve this answer



                        share|improve this answer










                        answered 5 hours ago









                        user202729

                        13k12549




                        13k12549




















                            up vote
                            2
                            down vote














                            R, 187 bytes





                             # c a t ( ' P e r f e c t l y o k a y ' ) #
                            g=function(x,n=nchar(x),i=c(1:n,(n-1):1,2:n),j=seq(1,3*n-2,3),k=i[j][1:which(i[j]==n)[1]])cat(substring(x,k,k),sep='')


                            Try it online!



                            The single space at the end is needed so that the n never gets printed when the program is applied to itself.



                            Explanation



                            Part 1:



                            Ungolfed:



                             # c a t ( ' P e r f e c t l y o k a y ' ) #
                            g <- function(x)
                            n <- nchar(x) # number of characters in string
                            i <- c(1:n, (n - 1):1, 2:n) # index: 1 to n, n-1 back to 1, 2 to n
                            j <- seq(1, 3 * n - 2, 3) # every third element of i
                            k <- i[j][1:which(i[j] == n)[1]] # the elements of i at indices j, up to the first appearance of n
                            cat(substring(x, k, k), sep = "") # extract from x the characters at indices k, and paste them together



                            Part 2:



                            The function produces this when it acts on the entire program:



                            cat('Perfectly okay')#=ni(ncr)=1,-:2)=q,n,,i]:i(j=assi(k)e' 





                            share|improve this answer


























                              up vote
                              2
                              down vote














                              R, 187 bytes





                               # c a t ( ' P e r f e c t l y o k a y ' ) #
                              g=function(x,n=nchar(x),i=c(1:n,(n-1):1,2:n),j=seq(1,3*n-2,3),k=i[j][1:which(i[j]==n)[1]])cat(substring(x,k,k),sep='')


                              Try it online!



                              The single space at the end is needed so that the n never gets printed when the program is applied to itself.



                              Explanation



                              Part 1:



                              Ungolfed:



                               # c a t ( ' P e r f e c t l y o k a y ' ) #
                              g <- function(x)
                              n <- nchar(x) # number of characters in string
                              i <- c(1:n, (n - 1):1, 2:n) # index: 1 to n, n-1 back to 1, 2 to n
                              j <- seq(1, 3 * n - 2, 3) # every third element of i
                              k <- i[j][1:which(i[j] == n)[1]] # the elements of i at indices j, up to the first appearance of n
                              cat(substring(x, k, k), sep = "") # extract from x the characters at indices k, and paste them together



                              Part 2:



                              The function produces this when it acts on the entire program:



                              cat('Perfectly okay')#=ni(ncr)=1,-:2)=q,n,,i]:i(j=assi(k)e' 





                              share|improve this answer
























                                up vote
                                2
                                down vote










                                up vote
                                2
                                down vote










                                R, 187 bytes





                                 # c a t ( ' P e r f e c t l y o k a y ' ) #
                                g=function(x,n=nchar(x),i=c(1:n,(n-1):1,2:n),j=seq(1,3*n-2,3),k=i[j][1:which(i[j]==n)[1]])cat(substring(x,k,k),sep='')


                                Try it online!



                                The single space at the end is needed so that the n never gets printed when the program is applied to itself.



                                Explanation



                                Part 1:



                                Ungolfed:



                                 # c a t ( ' P e r f e c t l y o k a y ' ) #
                                g <- function(x)
                                n <- nchar(x) # number of characters in string
                                i <- c(1:n, (n - 1):1, 2:n) # index: 1 to n, n-1 back to 1, 2 to n
                                j <- seq(1, 3 * n - 2, 3) # every third element of i
                                k <- i[j][1:which(i[j] == n)[1]] # the elements of i at indices j, up to the first appearance of n
                                cat(substring(x, k, k), sep = "") # extract from x the characters at indices k, and paste them together



                                Part 2:



                                The function produces this when it acts on the entire program:



                                cat('Perfectly okay')#=ni(ncr)=1,-:2)=q,n,,i]:i(j=assi(k)e' 





                                share|improve this answer















                                R, 187 bytes





                                 # c a t ( ' P e r f e c t l y o k a y ' ) #
                                g=function(x,n=nchar(x),i=c(1:n,(n-1):1,2:n),j=seq(1,3*n-2,3),k=i[j][1:which(i[j]==n)[1]])cat(substring(x,k,k),sep='')


                                Try it online!



                                The single space at the end is needed so that the n never gets printed when the program is applied to itself.



                                Explanation



                                Part 1:



                                Ungolfed:



                                 # c a t ( ' P e r f e c t l y o k a y ' ) #
                                g <- function(x)
                                n <- nchar(x) # number of characters in string
                                i <- c(1:n, (n - 1):1, 2:n) # index: 1 to n, n-1 back to 1, 2 to n
                                j <- seq(1, 3 * n - 2, 3) # every third element of i
                                k <- i[j][1:which(i[j] == n)[1]] # the elements of i at indices j, up to the first appearance of n
                                cat(substring(x, k, k), sep = "") # extract from x the characters at indices k, and paste them together



                                Part 2:



                                The function produces this when it acts on the entire program:



                                cat('Perfectly okay')#=ni(ncr)=1,-:2)=q,n,,i]:i(j=assi(k)e' 






                                share|improve this answer














                                share|improve this answer



                                share|improve this answer








                                edited 2 hours ago

























                                answered 2 hours ago









                                ngm

                                2,44920




                                2,44920




















                                    up vote
                                    1
                                    down vote














                                    05AB1E, 41 bytes



                                    “€€Ã€€Ð€€µ€€Ý€€“/g i që¬?3U[ûDXè?XIg<Ö#X3+U


                                    Can without a doubt be golfed..



                                    Try it online. (PS: Switch the language from 05AB1E (legacy) to 05AB1E for test cases 0123456789 and @. The legacy version is much faster, but it shows incorrect results for number inputs with leading zeros or single-char inputs.)



                                    The 'backhanded' program will become:



                                    “Ãеݓ q?[XX<XU


                                    Which will output perfectly okay in full lowercase.



                                    Try it online.



                                    Explanation base program:





                                    “€€Ã€€Ð€€µ€€Ý€€“ # Push the string "the pointed who the ethernet been the"
                                    / # And remove it from the stack again
                                    g # Push the length of the (implicit) input
                                    i # If the length is exactly 1:
                                    q # Stop the program (and output the input implicitly)
                                    ë # Else:
                                    ¬? # Take the input implicitly again, and output its head
                                    3U # Push and pop 3, and store it in variable `X`
                                    [ # Start an infinite loop
                                    û # Palindromize the string at the top of the stack
                                    # i.e. "1O+1@" becomes "1O+1@1+O1" the first iteration,
                                    # and "1O+1@1+O1O+1@1+O1" the next iteration, etc.
                                    D # Duplicate the palindromized string
                                    Xè # Index variable `X` in the string
                                    ? # Output the character
                                    X # Check if variable `X`
                                    Ö # is divisible by
                                    Ig< # The length of the input - 1
                                    # # And if it is: stop the infinite loop
                                    X3+ # Then increase `X` by 3
                                    U # And pop and store it as the new `X`


                                    Explanation 'backhanded' program:



                                    “Ãеݓ # Push the string "perfectly okay"
                                    q # Exit the program (and implicitly output the top of the stack)
                                    ?[XX<XU # No-ops


                                    See this 05AB1E tip of mine (section How to use the dictionary?) to understand why “€€Ã€€Ð€€µ€€Ý€€“ is the pointed who the ethernet been the and “Ãеݓ is perfectly okay.






                                    share|improve this answer


























                                      up vote
                                      1
                                      down vote














                                      05AB1E, 41 bytes



                                      “€€Ã€€Ð€€µ€€Ý€€“/g i që¬?3U[ûDXè?XIg<Ö#X3+U


                                      Can without a doubt be golfed..



                                      Try it online. (PS: Switch the language from 05AB1E (legacy) to 05AB1E for test cases 0123456789 and @. The legacy version is much faster, but it shows incorrect results for number inputs with leading zeros or single-char inputs.)



                                      The 'backhanded' program will become:



                                      “Ãеݓ q?[XX<XU


                                      Which will output perfectly okay in full lowercase.



                                      Try it online.



                                      Explanation base program:





                                      “€€Ã€€Ð€€µ€€Ý€€“ # Push the string "the pointed who the ethernet been the"
                                      / # And remove it from the stack again
                                      g # Push the length of the (implicit) input
                                      i # If the length is exactly 1:
                                      q # Stop the program (and output the input implicitly)
                                      ë # Else:
                                      ¬? # Take the input implicitly again, and output its head
                                      3U # Push and pop 3, and store it in variable `X`
                                      [ # Start an infinite loop
                                      û # Palindromize the string at the top of the stack
                                      # i.e. "1O+1@" becomes "1O+1@1+O1" the first iteration,
                                      # and "1O+1@1+O1O+1@1+O1" the next iteration, etc.
                                      D # Duplicate the palindromized string
                                      Xè # Index variable `X` in the string
                                      ? # Output the character
                                      X # Check if variable `X`
                                      Ö # is divisible by
                                      Ig< # The length of the input - 1
                                      # # And if it is: stop the infinite loop
                                      X3+ # Then increase `X` by 3
                                      U # And pop and store it as the new `X`


                                      Explanation 'backhanded' program:



                                      “Ãеݓ # Push the string "perfectly okay"
                                      q # Exit the program (and implicitly output the top of the stack)
                                      ?[XX<XU # No-ops


                                      See this 05AB1E tip of mine (section How to use the dictionary?) to understand why “€€Ã€€Ð€€µ€€Ý€€“ is the pointed who the ethernet been the and “Ãеݓ is perfectly okay.






                                      share|improve this answer
























                                        up vote
                                        1
                                        down vote










                                        up vote
                                        1
                                        down vote










                                        05AB1E, 41 bytes



                                        “€€Ã€€Ð€€µ€€Ý€€“/g i që¬?3U[ûDXè?XIg<Ö#X3+U


                                        Can without a doubt be golfed..



                                        Try it online. (PS: Switch the language from 05AB1E (legacy) to 05AB1E for test cases 0123456789 and @. The legacy version is much faster, but it shows incorrect results for number inputs with leading zeros or single-char inputs.)



                                        The 'backhanded' program will become:



                                        “Ãеݓ q?[XX<XU


                                        Which will output perfectly okay in full lowercase.



                                        Try it online.



                                        Explanation base program:





                                        “€€Ã€€Ð€€µ€€Ý€€“ # Push the string "the pointed who the ethernet been the"
                                        / # And remove it from the stack again
                                        g # Push the length of the (implicit) input
                                        i # If the length is exactly 1:
                                        q # Stop the program (and output the input implicitly)
                                        ë # Else:
                                        ¬? # Take the input implicitly again, and output its head
                                        3U # Push and pop 3, and store it in variable `X`
                                        [ # Start an infinite loop
                                        û # Palindromize the string at the top of the stack
                                        # i.e. "1O+1@" becomes "1O+1@1+O1" the first iteration,
                                        # and "1O+1@1+O1O+1@1+O1" the next iteration, etc.
                                        D # Duplicate the palindromized string
                                        Xè # Index variable `X` in the string
                                        ? # Output the character
                                        X # Check if variable `X`
                                        Ö # is divisible by
                                        Ig< # The length of the input - 1
                                        # # And if it is: stop the infinite loop
                                        X3+ # Then increase `X` by 3
                                        U # And pop and store it as the new `X`


                                        Explanation 'backhanded' program:



                                        “Ãеݓ # Push the string "perfectly okay"
                                        q # Exit the program (and implicitly output the top of the stack)
                                        ?[XX<XU # No-ops


                                        See this 05AB1E tip of mine (section How to use the dictionary?) to understand why “€€Ã€€Ð€€µ€€Ý€€“ is the pointed who the ethernet been the and “Ãеݓ is perfectly okay.






                                        share|improve this answer















                                        05AB1E, 41 bytes



                                        “€€Ã€€Ð€€µ€€Ý€€“/g i që¬?3U[ûDXè?XIg<Ö#X3+U


                                        Can without a doubt be golfed..



                                        Try it online. (PS: Switch the language from 05AB1E (legacy) to 05AB1E for test cases 0123456789 and @. The legacy version is much faster, but it shows incorrect results for number inputs with leading zeros or single-char inputs.)



                                        The 'backhanded' program will become:



                                        “Ãеݓ q?[XX<XU


                                        Which will output perfectly okay in full lowercase.



                                        Try it online.



                                        Explanation base program:





                                        “€€Ã€€Ð€€µ€€Ý€€“ # Push the string "the pointed who the ethernet been the"
                                        / # And remove it from the stack again
                                        g # Push the length of the (implicit) input
                                        i # If the length is exactly 1:
                                        q # Stop the program (and output the input implicitly)
                                        ë # Else:
                                        ¬? # Take the input implicitly again, and output its head
                                        3U # Push and pop 3, and store it in variable `X`
                                        [ # Start an infinite loop
                                        û # Palindromize the string at the top of the stack
                                        # i.e. "1O+1@" becomes "1O+1@1+O1" the first iteration,
                                        # and "1O+1@1+O1O+1@1+O1" the next iteration, etc.
                                        D # Duplicate the palindromized string
                                        Xè # Index variable `X` in the string
                                        ? # Output the character
                                        X # Check if variable `X`
                                        Ö # is divisible by
                                        Ig< # The length of the input - 1
                                        # # And if it is: stop the infinite loop
                                        X3+ # Then increase `X` by 3
                                        U # And pop and store it as the new `X`


                                        Explanation 'backhanded' program:



                                        “Ãеݓ # Push the string "perfectly okay"
                                        q # Exit the program (and implicitly output the top of the stack)
                                        ?[XX<XU # No-ops


                                        See this 05AB1E tip of mine (section How to use the dictionary?) to understand why “€€Ã€€Ð€€µ€€Ý€€“ is the pointed who the ethernet been the and “Ãеݓ is perfectly okay.







                                        share|improve this answer














                                        share|improve this answer



                                        share|improve this answer








                                        edited 4 hours ago

























                                        answered 4 hours ago









                                        Kevin Cruijssen

                                        30.9k553168




                                        30.9k553168




















                                            up vote
                                            1
                                            down vote













                                            JavaScript (ES6), 130 bytes



                                            Early attempt. Not very satisfying.



                                            f =/*> " P e r f e c t l y o k a*/y=>""+/**/(g=p=>(c=y[p])?m++%3?g(p+d):y[p+1]?c+g(p+d):c:g(p-d-d,d=-d))(m=0,d=1)


                                            Try it online!



                                            When the code is processed by itself, the following characters are isolated:



                                            f =/*> " P e r f e c t l y o k a*/y=>""+/**/…
                                            ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^


                                            which gives:



                                            f=>"Perfectly okay"//…





                                            share|improve this answer


























                                              up vote
                                              1
                                              down vote













                                              JavaScript (ES6), 130 bytes



                                              Early attempt. Not very satisfying.



                                              f =/*> " P e r f e c t l y o k a*/y=>""+/**/(g=p=>(c=y[p])?m++%3?g(p+d):y[p+1]?c+g(p+d):c:g(p-d-d,d=-d))(m=0,d=1)


                                              Try it online!



                                              When the code is processed by itself, the following characters are isolated:



                                              f =/*> " P e r f e c t l y o k a*/y=>""+/**/…
                                              ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^


                                              which gives:



                                              f=>"Perfectly okay"//…





                                              share|improve this answer
























                                                up vote
                                                1
                                                down vote










                                                up vote
                                                1
                                                down vote









                                                JavaScript (ES6), 130 bytes



                                                Early attempt. Not very satisfying.



                                                f =/*> " P e r f e c t l y o k a*/y=>""+/**/(g=p=>(c=y[p])?m++%3?g(p+d):y[p+1]?c+g(p+d):c:g(p-d-d,d=-d))(m=0,d=1)


                                                Try it online!



                                                When the code is processed by itself, the following characters are isolated:



                                                f =/*> " P e r f e c t l y o k a*/y=>""+/**/…
                                                ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^


                                                which gives:



                                                f=>"Perfectly okay"//…





                                                share|improve this answer














                                                JavaScript (ES6), 130 bytes



                                                Early attempt. Not very satisfying.



                                                f =/*> " P e r f e c t l y o k a*/y=>""+/**/(g=p=>(c=y[p])?m++%3?g(p+d):y[p+1]?c+g(p+d):c:g(p-d-d,d=-d))(m=0,d=1)


                                                Try it online!



                                                When the code is processed by itself, the following characters are isolated:



                                                f =/*> " P e r f e c t l y o k a*/y=>""+/**/…
                                                ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^


                                                which gives:



                                                f=>"Perfectly okay"//…






                                                share|improve this answer














                                                share|improve this answer



                                                share|improve this answer








                                                edited 26 mins ago

























                                                answered 2 hours ago









                                                Arnauld

                                                65.6k583277




                                                65.6k583277



























                                                     

                                                    draft saved


                                                    draft discarded















































                                                     


                                                    draft saved


                                                    draft discarded














                                                    StackExchange.ready(
                                                    function ()
                                                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f173187%2fbackhanded-compliments%23new-answer', 'question_page');

                                                    );

                                                    Post as a guest













































































                                                    Comments

                                                    Popular posts from this blog

                                                    What does second last employer means? [closed]

                                                    Installing NextGIS Connect into QGIS 3?

                                                    One-line joke