Skip to main content
deleted 167 characters in body
Source Link
ar4093
  • 611
  • 3
  • 7

Pyth, 24 bytes24 15 bytes

M?HgH%GHGeSmeSm.U/*bZgbZd*bZibZd./

Try it online!Try it online!

M?HgH%GHG         # Lambda function to compute the GCD (Euclid's algorithm)
M                 # g = lambda G,H:
   gH%GH          #   g(H, G%H)
 ?H     G         #      if H else G

eSm.U/*bZgbZd./Q  # Main function (implicit Q at the end)
             ./Q  # List of partitions of the input
  m               # map that over lambda d:
   .U       d     # reduce d (with starting value first element of the list) on lambda b,Z:
     /*bZgbZ      # (b * Z) / gGCD(b, Z)
 S                # this gives the list of lcms of all partitions. Sort this
e                 # and take the last element (maximum)

-9 bytes: paid attention and noticed that Pyth actually has a GCD builtin (i).

Pyth, 24 bytes

M?HgH%GHGeSm.U/*bZgbZd./

Try it online!

M?HgH%GHG         # Lambda function to compute the GCD (Euclid's algorithm)
M                 # g = lambda G,H:
   gH%GH          #   g(H, G%H)
 ?H     G         #      if H else G

eSm.U/*bZgbZd./Q  # Main function (implicit Q at the end)
             ./Q  # List of partitions of the input
  m               # map that over lambda d:
   .U       d     # reduce d (with starting value first element of the list) on lambda b,Z:
     /*bZgbZ      # (b * Z) / g(b, Z)
 S                # this gives the list of lcms of all partitions. Sort this
e                 # and take the last element (maximum)

Pyth, 24 15 bytes

eSm.U/*bZibZd./

Try it online!

             ./Q  # List of partitions of the input
  m               # map that over lambda d:
   .U       d     # reduce d (with starting value first element of the list) on lambda b,Z:
     /*bZgbZ      # (b * Z) / GCD(b, Z)
 S                # this gives the list of lcms of all partitions. Sort this
e                 # and take the last element (maximum)

-9 bytes: paid attention and noticed that Pyth actually has a GCD builtin (i).

Source Link
ar4093
  • 611
  • 3
  • 7

Pyth, 24 bytes

M?HgH%GHGeSm.U/*bZgbZd./

Try it online!

M?HgH%GHG         # Lambda function to compute the GCD (Euclid's algorithm)
M                 # g = lambda G,H:
   gH%GH          #   g(H, G%H)
 ?H     G         #      if H else G

eSm.U/*bZgbZd./Q  # Main function (implicit Q at the end)
             ./Q  # List of partitions of the input
  m               # map that over lambda d:
   .U       d     # reduce d (with starting value first element of the list) on lambda b,Z:
     /*bZgbZ      # (b * Z) / g(b, Z)
 S                # this gives the list of lcms of all partitions. Sort this
e                 # and take the last element (maximum)