Skip to main content
Commonmark migration
Source Link

#K4, 27 25 bytes

K4, 27 25 bytes

Solution:

*(1+)/[{y=x*_y%x}. 1+;]1,

Explanation:

Pretty naive. Start with list of [1, x] and increment both until no longer divisible.

*(1+)/[{y=x*_y%x}. 1+;]1, / the solution
                       1, / prepend input with 1
 (  )\[              ;]   / (loop)\[condition;start]
       {        }.        / lambda taking implicit x & y
                   1+     / add 1 (vectorised) [1, 13] => [2, 14]
             y%x          / divide y by x
            _             / floor
          y*              / multiply by x
        y=                / equals y?
  1+                      / add 1 (vectorised) [1, 13] => [2, 14]
*                         / take first [2, 14] => 2

#K4, 27 25 bytes

Solution:

*(1+)/[{y=x*_y%x}. 1+;]1,

Explanation:

Pretty naive. Start with list of [1, x] and increment both until no longer divisible.

*(1+)/[{y=x*_y%x}. 1+;]1, / the solution
                       1, / prepend input with 1
 (  )\[              ;]   / (loop)\[condition;start]
       {        }.        / lambda taking implicit x & y
                   1+     / add 1 (vectorised) [1, 13] => [2, 14]
             y%x          / divide y by x
            _             / floor
          y*              / multiply by x
        y=                / equals y?
  1+                      / add 1 (vectorised) [1, 13] => [2, 14]
*                         / take first [2, 14] => 2

K4, 27 25 bytes

Solution:

*(1+)/[{y=x*_y%x}. 1+;]1,

Explanation:

Pretty naive. Start with list of [1, x] and increment both until no longer divisible.

*(1+)/[{y=x*_y%x}. 1+;]1, / the solution
                       1, / prepend input with 1
 (  )\[              ;]   / (loop)\[condition;start]
       {        }.        / lambda taking implicit x & y
                   1+     / add 1 (vectorised) [1, 13] => [2, 14]
             y%x          / divide y by x
            _             / floor
          y*              / multiply by x
        y=                / equals y?
  1+                      / add 1 (vectorised) [1, 13] => [2, 14]
*                         / take first [2, 14] => 2
shaved off 2 bytes
Source Link
mkst
  • 5.2k
  • 12
  • 19

#K4, 2727 25 bytes

Solution:

#1_{*(1+)\[/[{x=y*_x%yy=x*_y%x}.;x,1]}    1+;]1,

Explanation:

Pretty naive. Start with list of [x; 1][1, x] and increment both until no longer divisible.

#1_{*(1+)\[/[{x=y*_x%yy=x*_y%x}.;x 1+;]1,1]} / the solution
   {                      }1, / lambdaprepend takinginput implicitwith x1
    (  )\[           ;   ];]   / (loop)\[condition;start]
         {        }.     x,1   / append 1lambda totaking inputimplicit (e.g.x [13,& 1])y
          {        }.  1+     / lambdaadd taking1 implicit(vectorised) x[1, &13] y
=> [2, 14]
             y%x x%y         / divide xy by yx
               _             / floor
             y*              / multiply by yx
          y= x=               / equals xy?
     1+                      / add 1 (vectorised) [13[1, 1]13] => [14[2, 2]14]
 * 1_                        / drop first (as result includestake first failure)
 #                        [2, 14] /=> count2

#K4, 27 bytes

Solution:

#1_{(1+)\[{x=y*_x%y}.;x,1]}    

Explanation:

Pretty naive. Start with list of [x; 1] and increment both until no longer divisible.

#1_{(1+)\[{x=y*_x%y}.;x,1]} / the solution
   {                      } / lambda taking implicit x
    (  )\[           ;   ]  / (loop)\[condition;start]
                      x,1   / append 1 to input (e.g. [13, 1])
          {        }.       / lambda taking implicit x & y
                x%y         / divide x by y
               _            / floor
             y*             / multiply by y
           x=               / equals x?
     1+                     / add 1 (vectorised) [13, 1] => [14, 2]
  1_                        / drop first (as result includes first failure)
 #                          / count

#K4, 27 25 bytes

Solution:

*(1+)/[{y=x*_y%x}. 1+;]1,

Explanation:

Pretty naive. Start with list of [1, x] and increment both until no longer divisible.

*(1+)/[{y=x*_y%x}. 1+;]1, / the solution
                       1, / prepend input with 1
 (  )\[              ;]   / (loop)\[condition;start]
       {        }.        / lambda taking implicit x & y
                   1+     / add 1 (vectorised) [1, 13] => [2, 14]
             y%x          / divide y by x
            _             / floor
          y*              / multiply by x
        y=                / equals y?
  1+                      / add 1 (vectorised) [1, 13] => [2, 14]
*                         / take first [2, 14] => 2
Source Link
mkst
  • 5.2k
  • 12
  • 19

#K4, 27 bytes

Solution:

#1_{(1+)\[{x=y*_x%y}.;x,1]}    

Explanation:

Pretty naive. Start with list of [x; 1] and increment both until no longer divisible.

#1_{(1+)\[{x=y*_x%y}.;x,1]} / the solution
   {                      } / lambda taking implicit x
    (  )\[           ;   ]  / (loop)\[condition;start]
                      x,1   / append 1 to input (e.g. [13, 1])
          {        }.       / lambda taking implicit x & y
                x%y         / divide x by y
               _            / floor
             y*             / multiply by y
           x=               / equals x?
     1+                     / add 1 (vectorised) [13, 1] => [14, 2]
  1_                        / drop first (as result includes first failure)
 #                          / count