Skip to main content
added 43 characters in body
Source Link
Shaggy
  • 43.5k
  • 4
  • 36
  • 94

OK, I finally (think I) figured out how the partitioning is working! First the basics: The ò method partitions string between pairs of characters (X & Y) that return a truthy value when run through the method that's passed as an argument. We're using Í here, which is the shortcut for n2<space>. The space is used to close the ò method and the n and the 2 being split into two separate arguments, with the second being ignored as ò only expects one argument. That means that we're currently testing XnY but, by adding the !, the elements get flipped giving us YnX.

And now for the trickery: The possible combinations we can have (where L=[np] & D=[0-9]) are: DnL, LnD & DnD and, in all cases, both elements are strings, which is important. The n attempts to convert Y to an integer, run X on it as a method and convert it back to a string, with the following possible outcomes:

OK, I finally (think I) figured out how the partitioning is working! The ò method partitions string between pairs of characters (X & Y) that return a truthy value when run through the method that's passed as an argument. We're using Í here, which is the shortcut for n2<space>. The space is used to close the ò method and the n and the 2 being split into two separate arguments, with the second being ignored as ò only expects one argument. That means that we're currently testing XnY but, by adding the !, the elements get flipped giving us YnX.

The possible combinations we can have (where L=[np] & D=[0-9]) are: DnL, LnD & DnD and, in all cases, both elements are strings, which is important. The n attempts to convert Y to an integer, run X on it as a method and convert it back to a string, with the following possible outcomes:

OK, I finally (think I) figured out how the partitioning is working! First the basics: The ò method partitions string between pairs of characters (X & Y) that return a truthy value when run through the method that's passed as an argument. We're using Í here, which is the shortcut for n2<space>. The space is used to close the ò method and the n and the 2 being split into two separate arguments, with the second being ignored as ò only expects one argument. That means that we're currently testing XnY but, by adding the !, the elements get flipped giving us YnX.

And now for the trickery: The possible combinations we can have (where L=[np] & D=[0-9]) are DnL, LnD & DnD and, in all cases, both elements are strings, which is important. The n attempts to convert Y to an integer, run X on it as a method and convert it back to a string, with the following possible outcomes:

added 1379 characters in body
Source Link
Shaggy
  • 43.5k
  • 4
  • 36
  • 94

I'll have to come back later and add a separate section explaining how the partition works as it's a difficult one - I'm not sure I fully understand it myself yet! After fixing the bug I now have no idea how or why the partitioning is working!!

ò!Í®n îZèÍg"- ="òìyÈû4 Ôû6'_     :Implicit input of string
ò!Í                               :Partition into the run length groups we need (See more detailed explanation below)
   ®                              :Map each Z
    n                             :   Convert to integer (the letter at the end is ignored)
      î                           :   Repeat and slice to that length
       Zè                         :     Count the occurrences in Z of
         Í                        :     "n" (see below for the why)
          g                       :     Index into
           "- ="ò                 :     Partitions of "- =" of length 2
                 Ã                :End map
                  ¬               :Join
                   y              :Transpose
                    È             :Pass each row through the following function and transpose back
                     û4           :   Centre pad with spaces to length 4
                        Ô         :   Reverse ('cause centre padding is right-biased)
                         û6'_     :   Centre pad with "_" to length 6

OK, I finally (think I) figured out how the partitioning is working! The ò method partitions string between pairs of characters (X & Y) that return a truthy value when run through the method that's passed as an argument. We're using Í here, which is the shortcut for n2<space>. The space is used to close the ò method and the n and the 2 being split into two separate arguments, with the second being ignored as ò only expects one argument. That means that we're currently testing XnY but, by adding the !, the elements get flipped giving us YnX.

The possible combinations we can have (where L=[np] & D=[0-9]) are: DnL, LnD & DnD and, in all cases, both elements are strings, which is important. The n attempts to convert Y to an integer, run X on it as a method and convert it back to a string, with the following possible outcomes:

  • Dnp squares the integer resulting in a non-empty string, which is truthy, creating a partition.
  • Dnn negates the integer resulting in a non-empty string, which is truthy, creating a partition.
  • DnD & LnD, for some reason that I can't figure out, both result in 0, which is falsey, so no partition is created.

Hopefully, that all made some sort of sense but, if it helps, here's a handy table.

And, as a final note: the Í works exactly the same way as above when passed to the è method, which only expects a single string argument.

I'll have to come back later and add a separate section explaining how the partition works as it's a difficult one - I'm not sure I fully understand it myself yet! After fixing the bug I now have no idea how or why the partitioning is working!!

ò!Í®n îZèÍg"- ="òìyÈû4 Ôû6'_     :Implicit input of string
ò!Í                               :Partition into the run length groups we need
   ®                              :Map each Z
    n                             :   Convert to integer (the letter at the end is ignored)
      î                           :   Repeat and slice to that length
       Zè                         :     Count the occurrences in Z of
         Í                        :     "n"
          g                       :     Index into
           "- ="ò                 :     Partitions of "- =" of length 2
                 Ã                :End map
                  ¬               :Join
                   y              :Transpose
                    È             :Pass each row through the following function and transpose back
                     û4           :   Centre pad with spaces to length 4
                        Ô         :   Reverse ('cause centre padding is right-biased)
                         û6'_     :   Centre pad with "_" to length 6
ò!Í®n îZèÍg"- ="òìyÈû4 Ôû6'_     :Implicit input of string
ò!Í                               :Partition into the run length groups we need (See more detailed explanation below)
   ®                              :Map each Z
    n                             :   Convert to integer (the letter at the end is ignored)
      î                           :   Repeat and slice to that length
       Zè                         :     Count the occurrences in Z of
         Í                        :     "n" (see below for the why)
          g                       :     Index into
           "- ="ò                 :     Partitions of "- =" of length 2
                 Ã                :End map
                  ¬               :Join
                   y              :Transpose
                    È             :Pass each row through the following function and transpose back
                     û4           :   Centre pad with spaces to length 4
                        Ô         :   Reverse ('cause centre padding is right-biased)
                         û6'_     :   Centre pad with "_" to length 6

OK, I finally (think I) figured out how the partitioning is working! The ò method partitions string between pairs of characters (X & Y) that return a truthy value when run through the method that's passed as an argument. We're using Í here, which is the shortcut for n2<space>. The space is used to close the ò method and the n and the 2 being split into two separate arguments, with the second being ignored as ò only expects one argument. That means that we're currently testing XnY but, by adding the !, the elements get flipped giving us YnX.

The possible combinations we can have (where L=[np] & D=[0-9]) are: DnL, LnD & DnD and, in all cases, both elements are strings, which is important. The n attempts to convert Y to an integer, run X on it as a method and convert it back to a string, with the following possible outcomes:

  • Dnp squares the integer resulting in a non-empty string, which is truthy, creating a partition.
  • Dnn negates the integer resulting in a non-empty string, which is truthy, creating a partition.
  • DnD & LnD, for some reason that I can't figure out, both result in 0, which is falsey, so no partition is created.

Hopefully, that all made some sort of sense but, if it helps, here's a handy table.

And, as a final note: the Í works exactly the same way as above when passed to the è method, which only expects a single string argument.

deleted 224 characters in body
Source Link
Shaggy
  • 43.5k
  • 4
  • 36
  • 94
added 154 characters in body
Source Link
Shaggy
  • 43.5k
  • 4
  • 36
  • 94
Loading
deleted 233 characters in body
Source Link
Shaggy
  • 43.5k
  • 4
  • 36
  • 94
Loading
deleted 1 character in body
Source Link
Shaggy
  • 43.5k
  • 4
  • 36
  • 94
Loading
added 225 characters in body
Source Link
Shaggy
  • 43.5k
  • 4
  • 36
  • 94
Loading
added 225 characters in body
Source Link
Shaggy
  • 43.5k
  • 4
  • 36
  • 94
Loading
Source Link
Shaggy
  • 43.5k
  • 4
  • 36
  • 94
Loading