Skip to main content
added 1 character in body
Source Link
Dennis
  • 210.6k
  • 41
  • 370
  • 825
  • The string containing all digits "0123456789" can be written as

      A,s
    
  • The uppercase ASCII letters (A-Z) can be pushed as

      '[,65>
    

    which generates the string of all characters up to Z, then discards the first 65 (up to @).

  • All ASCII letters (A-Za-z) can be pushed as

      '[,65>_el+
    

    which works as above, then creates a copy, converts to lowercase and appends.

    But there's a shorter way to do it!

    Then often overlooked ^ operator (symmetric differences for lists) allows to create the same ranges while saving three bytes:

      '[,_el^
    

    '[, creates the range of all ASCII characters up to zZ, _el creates a lowercase copy and ^ keepkeeps only characters of both strings that appear in one but not both.

    Since all letters in the first string are uppercase, all in the second are lowercase and all non-letter characters are in both strings, the result in the string of letters.

  • The RFC 1642 Base64 alphabet (A-Za-z0-9+/) can be pushed using the above technique and appending the non-letters:

      '[,_el^A,s+"+/"+
    

    An equally short way of pushing this string makes use solely of symmetric differences:

      "+,/0:[a{A0":,:^
    

    How can we find the string at the beginning?

    All used character ranges (A-Z, a-z, 0-9, +, /) can be pushed as the symmetric difference of to range that start at the null byte, namely 'A,'[,^, 'a,'{,^, '0,':,^, '+,',,^ and '/,'0,^.

    Therefore, executing :,:^ on "A[a{):+,/0" will push the desired characters, but not in the right order.

    How do we find the right order? Brute force to the rescue! The program

      '[,_el^A,s+"+/"+:T;"0:A[a{+,/0"e!{:,:^T=}=
    

    iterates over all possible permutations of the string, applies :,:^ and compares the result to the desired output (permalink).

  • The radix-64 alphabet used, e.g, by crypt (.-9A-Za-z) can be generated using the above method:

      ".:A[a{":,:^
    

    This is the shortest method I know.

    Since all characters in the desired output are in ASCII order, iterating over permutations isn't needed.

  • Not all concatenated character ranges can be pushed in the desired order using :,:^.

    For example, the range 0-9A-Za-z;-? cannot be pushed by executing :,:^ on any permutation of "0:A[a{;@".

    However, we can find a rotated variation of the desired string that can, by using the code

      A,'[,_el^'@,59>]s2*:T;"0:A[a{;@"e!{:,:^T\#:I)}=Ip
    

    which will print ([permalink][base65]) the following:

      10
      0:@[a{A;
    

    This means that

      "0:@[a{A;":,:^Am>
    

    has the same effect as

      A,'[,_el^'@,59>]s
    

    which can only be used with an empty stack without prepending a [.

  • The string containing all digits "0123456789" can be written as

      A,s
    
  • The uppercase ASCII letters (A-Z) can be pushed as

      '[,65>
    

    which generates the string of all characters up to Z, then discards the first 65 (up to @).

  • All ASCII letters (A-Za-z) can be pushed as

      '[,65>_el+
    

    which works as above, then creates a copy, converts to lowercase and appends.

    But there's a shorter way to do it!

    Then often overlooked ^ operator (symmetric differences for lists) allows to create the same ranges while saving three bytes:

      '[,_el^
    

    '[, creates the range of all ASCII characters up to z, _el creates a lowercase copy and ^ keep only characters of both strings that appear in one but not both.

    Since all letters in the first string are uppercase, all in the second are lowercase and all non-letter characters are in both strings, the result in the string of letters.

  • The RFC 1642 Base64 alphabet (A-Za-z0-9+/) can be pushed using the above technique and appending the non-letters:

      '[,_el^A,s+"+/"+
    

    An equally short way of pushing this string makes use solely of symmetric differences:

      "+,/0:[a{A0":,:^
    

    How can we find the string at the beginning?

    All used character ranges (A-Z, a-z, 0-9, +, /) can be pushed as the symmetric difference of to range that start at the null byte, namely 'A,'[,^, 'a,'{,^, '0,':,^, '+,',,^ and '/,'0,^.

    Therefore, executing :,:^ on "A[a{):+,/0" will push the desired characters, but not in the right order.

    How do we find the right order? Brute force to the rescue! The program

      '[,_el^A,s+"+/"+:T;"0:A[a{+,/0"e!{:,:^T=}=
    

    iterates over all possible permutations of the string, applies :,:^ and compares the result to the desired output (permalink).

  • The radix-64 alphabet used, e.g, by crypt (.-9A-Za-z) can be generated using the above method:

      ".:A[a{":,:^
    

    This is the shortest method I know.

    Since all characters in the desired output are in ASCII order, iterating over permutations isn't needed.

  • Not all concatenated character ranges can be pushed in the desired order using :,:^.

    For example, the range 0-9A-Za-z;-? cannot be pushed by executing :,:^ on any permutation of "0:A[a{;@".

    However, we can find a rotated variation of the desired string that can, by using the code

      A,'[,_el^'@,59>]s2*:T;"0:A[a{;@"e!{:,:^T\#:I)}=Ip
    

    which will print ([permalink][base65]) the following:

      10
      0:@[a{A;
    

    This means that

      "0:@[a{A;":,:^Am>
    

    has the same effect as

      A,'[,_el^'@,59>]s
    

    which can only be used with an empty stack without prepending a [.

  • The string containing all digits "0123456789" can be written as

      A,s
    
  • The uppercase ASCII letters (A-Z) can be pushed as

      '[,65>
    

    which generates the string of all characters up to Z, then discards the first 65 (up to @).

  • All ASCII letters (A-Za-z) can be pushed as

      '[,65>_el+
    

    which works as above, then creates a copy, converts to lowercase and appends.

    But there's a shorter way to do it!

    Then often overlooked ^ operator (symmetric differences for lists) allows to create the same ranges while saving three bytes:

      '[,_el^
    

    '[, creates the range of all ASCII characters up to Z, _el creates a lowercase copy and ^ keeps only characters of both strings that appear in one but not both.

    Since all letters in the first string are uppercase, all in the second are lowercase and all non-letter characters are in both strings, the result in the string of letters.

  • The RFC 1642 Base64 alphabet (A-Za-z0-9+/) can be pushed using the above technique and appending the non-letters:

      '[,_el^A,s+"+/"+
    

    An equally short way of pushing this string makes use solely of symmetric differences:

      "+,/0:[a{A0":,:^
    

    How can we find the string at the beginning?

    All used character ranges (A-Z, a-z, 0-9, +, /) can be pushed as the symmetric difference of to range that start at the null byte, namely 'A,'[,^, 'a,'{,^, '0,':,^, '+,',,^ and '/,'0,^.

    Therefore, executing :,:^ on "A[a{):+,/0" will push the desired characters, but not in the right order.

    How do we find the right order? Brute force to the rescue! The program

      '[,_el^A,s+"+/"+:T;"0:A[a{+,/0"e!{:,:^T=}=
    

    iterates over all possible permutations of the string, applies :,:^ and compares the result to the desired output (permalink).

  • The radix-64 alphabet used, e.g, by crypt (.-9A-Za-z) can be generated using the above method:

      ".:A[a{":,:^
    

    This is the shortest method I know.

    Since all characters in the desired output are in ASCII order, iterating over permutations isn't needed.

  • Not all concatenated character ranges can be pushed in the desired order using :,:^.

    For example, the range 0-9A-Za-z;-? cannot be pushed by executing :,:^ on any permutation of "0:A[a{;@".

    However, we can find a rotated variation of the desired string that can, by using the code

      A,'[,_el^'@,59>]s2*:T;"0:A[a{;@"e!{:,:^T\#:I)}=Ip
    

    which will print ([permalink][base65]) the following:

      10
      0:@[a{A;
    

    This means that

      "0:@[a{A;":,:^Am>
    

    has the same effect as

      A,'[,_el^'@,59>]s
    

    which can only be used with an empty stack without prepending a [.

added 87 characters in body
Source Link
Martin Ender
  • 197.2k
  • 67
  • 447
  • 975
  • The string containing all digits "0123456789" can be written as

      A,s
    
  • The uppercase ASCII letters (A-Z) can be pushed as

      '[,65>
    

    which generates the string of all characters up to Z, then discards the first 65 (up to @).

  • All ASCII letters (A-Za-z) can be pushed as

      '[,65>_el+
    

    which works as above, then creates a copy, converts to lowercase and appends.

    But there's a shorter way to do it!

    Then often overlooked ^ operator (symmetric differences for lists) allows to create the same ranges while saving three bytes:

      '[,_el^
    

    '[, creates the range of all ASCII characters up to z, _el creates a lowercase copy and ^ keep only characters of both strings that appear in one but not both.

    Since all letters in the first string are uppercase, all in the second are lowercase and all non-letter characters are in both strings, the result in the string of letters.

  • The RFC 1642 Base64 alphabet (A-Za-z0-9+/) can be pushed using the above technique and appending the non-letters:

      '[,_el^A,s+"+/"+
    

    An equally short way of pushing this string makes use solely of symmetric differences:

      "+,/0:[a{A0":,:^
    

    How can we find the string at the beginning?

    All used character ranges (A-Z, a-z, 0-9, +, /) can be pushed as the symmetric difference of to range that start at the null byte, namely 'A,'[,^, 'a,'{,^, '0,':,^, '+,',,^ and '/,'0,^.

    Therefore, executing :,:^ on "A[a{):+,/0" will push the desired characters, but not in the right order.

    How do we find the right order? Brute force to the rescue! The program

      '[,_el^A,s+"+/"+:T;"0:A[a{+,/0"e!{:,:^T=}=
    

    iterates over all possible permutations of the string, applies :,:^ and compares the result to the desired output (permalink).

  • The radix-64 alphabet used, e.g, by crypt (.-9A-Za-z) can be generated using the above method:

      ".:A[a{":,:^
    

    This is the shortest method I know.

    Since all characters in the desired output are in ASCII order, iterating over permutations isn't needed.

  • Not all concatenated character ranges can be pushed in the desired order using :,:^.

    For example, the range 0-9A-Za-z;-? cannot be pushed by executing :,:^ on any permutation of "0:A[a{;@".

    However, we can find a rotated variation of the desired string that can, by using the code

      A,'[,_el^'@,59>]s2*:T;"0:A[a{;@"e!{:,:^T\#:I)}=Ip
    

    which will print ([permalink][base65]) the following:

      10
      0:@[a{A;
    

    This means that

      "0:@[a{A;":,:^Am>
    

    has the same effect as

      A,'[,_el^'@,59>]s
    

    which can only be used with an empty stack without prepending a [.

  • The uppercase ASCII letters (A-Z) can be pushed as

      '[,65>
    

    which generates the string of all characters up to Z, then discards the first 65 (up to @).

  • All ASCII letters (A-Za-z) can be pushed as

      '[,65>_el+
    

    which works as above, then creates a copy, converts to lowercase and appends.

    But there's a shorter way to do it!

    Then often overlooked ^ operator (symmetric differences for lists) allows to create the same ranges while saving three bytes:

      '[,_el^
    

    '[, creates the range of all ASCII characters up to z, _el creates a lowercase copy and ^ keep only characters of both strings that appear in one but not both.

    Since all letters in the first string are uppercase, all in the second are lowercase and all non-letter characters are in both strings, the result in the string of letters.

  • The RFC 1642 Base64 alphabet (A-Za-z0-9+/) can be pushed using the above technique and appending the non-letters:

      '[,_el^A,s+"+/"+
    

    An equally short way of pushing this string makes use solely of symmetric differences:

      "+,/0:[a{A0":,:^
    

    How can we find the string at the beginning?

    All used character ranges (A-Z, a-z, 0-9, +, /) can be pushed as the symmetric difference of to range that start at the null byte, namely 'A,'[,^, 'a,'{,^, '0,':,^, '+,',,^ and '/,'0,^.

    Therefore, executing :,:^ on "A[a{):+,/0" will push the desired characters, but not in the right order.

    How do we find the right order? Brute force to the rescue! The program

      '[,_el^A,s+"+/"+:T;"0:A[a{+,/0"e!{:,:^T=}=
    

    iterates over all possible permutations of the string, applies :,:^ and compares the result to the desired output (permalink).

  • The radix-64 alphabet used, e.g, by crypt (.-9A-Za-z) can be generated using the above method:

      ".:A[a{":,:^
    

    This is the shortest method I know.

    Since all characters in the desired output are in ASCII order, iterating over permutations isn't needed.

  • Not all concatenated character ranges can be pushed in the desired order using :,:^.

    For example, the range 0-9A-Za-z;-? cannot be pushed by executing :,:^ on any permutation of "0:A[a{;@".

    However, we can find a rotated variation of the desired string that can, by using the code

      A,'[,_el^'@,59>]s2*:T;"0:A[a{;@"e!{:,:^T\#:I)}=Ip
    

    which will print ([permalink][base65]) the following:

      10
      0:@[a{A;
    

    This means that

      "0:@[a{A;":,:^Am>
    

    has the same effect as

      A,'[,_el^'@,59>]s
    

    which can only be used with an empty stack without prepending a [.

  • The string containing all digits "0123456789" can be written as

      A,s
    
  • The uppercase ASCII letters (A-Z) can be pushed as

      '[,65>
    

    which generates the string of all characters up to Z, then discards the first 65 (up to @).

  • All ASCII letters (A-Za-z) can be pushed as

      '[,65>_el+
    

    which works as above, then creates a copy, converts to lowercase and appends.

    But there's a shorter way to do it!

    Then often overlooked ^ operator (symmetric differences for lists) allows to create the same ranges while saving three bytes:

      '[,_el^
    

    '[, creates the range of all ASCII characters up to z, _el creates a lowercase copy and ^ keep only characters of both strings that appear in one but not both.

    Since all letters in the first string are uppercase, all in the second are lowercase and all non-letter characters are in both strings, the result in the string of letters.

  • The RFC 1642 Base64 alphabet (A-Za-z0-9+/) can be pushed using the above technique and appending the non-letters:

      '[,_el^A,s+"+/"+
    

    An equally short way of pushing this string makes use solely of symmetric differences:

      "+,/0:[a{A0":,:^
    

    How can we find the string at the beginning?

    All used character ranges (A-Z, a-z, 0-9, +, /) can be pushed as the symmetric difference of to range that start at the null byte, namely 'A,'[,^, 'a,'{,^, '0,':,^, '+,',,^ and '/,'0,^.

    Therefore, executing :,:^ on "A[a{):+,/0" will push the desired characters, but not in the right order.

    How do we find the right order? Brute force to the rescue! The program

      '[,_el^A,s+"+/"+:T;"0:A[a{+,/0"e!{:,:^T=}=
    

    iterates over all possible permutations of the string, applies :,:^ and compares the result to the desired output (permalink).

  • The radix-64 alphabet used, e.g, by crypt (.-9A-Za-z) can be generated using the above method:

      ".:A[a{":,:^
    

    This is the shortest method I know.

    Since all characters in the desired output are in ASCII order, iterating over permutations isn't needed.

  • Not all concatenated character ranges can be pushed in the desired order using :,:^.

    For example, the range 0-9A-Za-z;-? cannot be pushed by executing :,:^ on any permutation of "0:A[a{;@".

    However, we can find a rotated variation of the desired string that can, by using the code

      A,'[,_el^'@,59>]s2*:T;"0:A[a{;@"e!{:,:^T\#:I)}=Ip
    

    which will print ([permalink][base65]) the following:

      10
      0:@[a{A;
    

    This means that

      "0:@[a{A;":,:^Am>
    

    has the same effect as

      A,'[,_el^'@,59>]s
    

    which can only be used with an empty stack without prepending a [.

added 741 characters in body
Source Link
Dennis
  • 210.6k
  • 41
  • 370
  • 825
  • The uppercase ASCII letters (A-ZA-Z) can be pushed as

      '[,65>
    

    which generates the string of all characters up to Z, then discards the first 65 (up to @).

  • All ASCII letters (A-Za-zA-Za-z) can be pushed as

      '[,65>_el+
    

    which works as above, then creates a copy, converts to lowercase and appends.

    But there's a shorter way to do it!

    Then often overlooked ^ operator (symmetric differences for lists) allows to create the same ranges while saving three bytes:

      '[,_el^
    

    '[, creates the range of all ASCII characters up to z, _el creates a lowercase copy and ^ keep only characters of both strings that appear in one but not both.

    Since all letters in the first string are uppercase, all in the second are lowercase and all non-letter characters are in both strings, the result in the string of letters.

  • The RFC 1642 Base64 alphabet (A-Za-z0-9+/A-Za-z0-9+/) can be pushed using the above technique and appending the non-letters:

      '[,_el^A,s+"+/"+
    

    An equally short way of pushing this string makes use solely of symmetric differences:

      "+,/0:[a{A0":,:^
    

    How can we find the string at the beginning?

    All used character ranges (A-ZA-Z, a-za-z, 0-90-9, ++, //) can be pushed as the symmetric difference of to range that start at the null byte, namely 'A,'[,^, 'a,'{,^, '0,':,^, '+,',,^ and '/,'0,^.

    Therefore, executing :,:^ on "A[a{):+,/0" will push the desired characters, but not in the right order.

    How do we find the right order? Brute force to the rescue! The program

      "0'[,_el^A,s+"+/"+:T;"0:A[a{+,/0"e!
      {:,:^"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"=^T=}=
    

    iterates over all possible permutations of the string, applies :,:^ and compares the result to the desired output (permalink).

  • The radix-64 alphabet used, e.g, by crypt (.-9A-Za-z.-9A-Za-z) can be generated using the above method:

      ".:A[a{":,:^
    

    This is the shortest method I know.

    Since all characters in the desired output are in ASCII order, iterating over permutations isn't needed.

  • Not all concatenated character ranges can be pushed in the desired order using :,:^.

    (Examples and workarounds to be added.) For example, the range 0-9A-Za-z;-? cannot be pushed by executing :,:^ on any permutation of "0:A[a{;@".

    However, we can find a rotated variation of the desired string that can, by using the code

      A,'[,_el^'@,59>]s2*:T;"0:A[a{;@"e!{:,:^T\#:I)}=Ip
    

    which will print ([permalink][base65]) the following:

      10
      0:@[a{A;
    

    This means that

      "0:@[a{A;":,:^Am>
    

    has the same effect as

      A,'[,_el^'@,59>]s
    

    which can only be used with an empty stack without prepending a [.

[base65]: http://cjam.aditsu.net/#code=A%2C'%5B%2C_el%5E'%40%2C59%3E%5Ds2*%3AT%3B%220%3AA%5Ba%7B%3B%40%22e!%7B%3A%2C%3A%5ET%5C%23%3AI)%7D%3DIp

  • The uppercase ASCII letters (A-Z) can be pushed as

      '[,65>
    

    which generates the string of all characters up to Z, then discards the first 65 (up to @).

  • All ASCII letters (A-Za-z) can be pushed as

      '[,65>_el+
    

    which works as above, then creates a copy, converts to lowercase and appends.

    But there's a shorter way to do it!

    Then often overlooked ^ operator (symmetric differences for lists) allows to create the same ranges while saving three bytes:

      '[,_el^
    

    '[, creates the range of all ASCII characters up to z, _el creates a lowercase copy and ^ keep only characters of both strings that appear in one but not both.

    Since all letters in the first string are uppercase, all in the second are lowercase and all non-letter characters are in both strings, the result in the string of letters.

  • The RFC 1642 Base64 alphabet (A-Za-z0-9+/) can be pushed using the above technique and appending the non-letters:

      '[,_el^A,s+"+/"+
    

    An equally short way of pushing this string makes use solely of symmetric differences:

      "+,/0:[a{A0":,:^
    

    How can we find the string at the beginning?

    All used character ranges (A-Z, a-z, 0-9, +, /) can be pushed as the symmetric difference of to range that start at the null byte, namely 'A,'[,^, 'a,'{,^, '0,':,^, '+,',,^ and '/,'0,^.

    Therefore, executing :,:^ on "A[a{):+,/0" will push the desired characters, but not in the right order.

    How do we find the right order? Brute force to the rescue! The program

      "0:A[a{+,/0"e!
      {:,:^"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"=}=
    

    iterates over all possible permutations of the string, applies :,:^ and compares the result to the desired output.

  • The radix-64 alphabet used, e.g, by crypt (.-9A-Za-z) can be generated using the above method:

      ".:A[a{":,:^
    

    This is the shortest method I know.

    Since all characters in the desired output are in ASCII order, iterating over permutations isn't needed.

  • Not all concatenated character ranges can be pushed in the desired order using :,:^.

    (Examples and workarounds to be added.)

  • The uppercase ASCII letters (A-Z) can be pushed as

      '[,65>
    

    which generates the string of all characters up to Z, then discards the first 65 (up to @).

  • All ASCII letters (A-Za-z) can be pushed as

      '[,65>_el+
    

    which works as above, then creates a copy, converts to lowercase and appends.

    But there's a shorter way to do it!

    Then often overlooked ^ operator (symmetric differences for lists) allows to create the same ranges while saving three bytes:

      '[,_el^
    

    '[, creates the range of all ASCII characters up to z, _el creates a lowercase copy and ^ keep only characters of both strings that appear in one but not both.

    Since all letters in the first string are uppercase, all in the second are lowercase and all non-letter characters are in both strings, the result in the string of letters.

  • The RFC 1642 Base64 alphabet (A-Za-z0-9+/) can be pushed using the above technique and appending the non-letters:

      '[,_el^A,s+"+/"+
    

    An equally short way of pushing this string makes use solely of symmetric differences:

      "+,/0:[a{A0":,:^
    

    How can we find the string at the beginning?

    All used character ranges (A-Z, a-z, 0-9, +, /) can be pushed as the symmetric difference of to range that start at the null byte, namely 'A,'[,^, 'a,'{,^, '0,':,^, '+,',,^ and '/,'0,^.

    Therefore, executing :,:^ on "A[a{):+,/0" will push the desired characters, but not in the right order.

    How do we find the right order? Brute force to the rescue! The program

      '[,_el^A,s+"+/"+:T;"0:A[a{+,/0"e!{:,:^T=}=
    

    iterates over all possible permutations of the string, applies :,:^ and compares the result to the desired output (permalink).

  • The radix-64 alphabet used, e.g, by crypt (.-9A-Za-z) can be generated using the above method:

      ".:A[a{":,:^
    

    This is the shortest method I know.

    Since all characters in the desired output are in ASCII order, iterating over permutations isn't needed.

  • Not all concatenated character ranges can be pushed in the desired order using :,:^.

    For example, the range 0-9A-Za-z;-? cannot be pushed by executing :,:^ on any permutation of "0:A[a{;@".

    However, we can find a rotated variation of the desired string that can, by using the code

      A,'[,_el^'@,59>]s2*:T;"0:A[a{;@"e!{:,:^T\#:I)}=Ip
    

    which will print ([permalink][base65]) the following:

      10
      0:@[a{A;
    

    This means that

      "0:@[a{A;":,:^Am>
    

    has the same effect as

      A,'[,_el^'@,59>]s
    

    which can only be used with an empty stack without prepending a [.

[base65]: http://cjam.aditsu.net/#code=A%2C'%5B%2C_el%5E'%40%2C59%3E%5Ds2*%3AT%3B%220%3AA%5Ba%7B%3B%40%22e!%7B%3A%2C%3A%5ET%5C%23%3AI)%7D%3DIp

Source Link
Dennis
  • 210.6k
  • 41
  • 370
  • 825
Loading