Skip to main content
98 - 87
Source Link
Natte
  • 1.1k
  • 5
  • 9

Ruby, 9898 87 bytes

p`dd`.splitgsub(?/)\d+-/,'*\00.flat_map{|x|x.').split(?:/).map{|r|eval"[#flat_map{r|x|eval"[%s].gsub /product(\d+[%s])-/,'*\1..'}]"}"%x.injectsplit(?:product)}

Try it online!Try it online!

Explanation

 `dd`.splitgsub(?/\d+-/,'*\00..')                                 # split input on "/"
            and replace "number-" with flat_map{|x|x"*number-0.split(?:).map{|r| # map each side of ":", at theruby end,syntax concatfor (flat_map)ranges
{|r|        r.gsub /split(\d+)-?/,'*\1..'             # make all "a-b" ranges to "*a..b" (ruby syntax)
    eval"[#{       .flat_map                }]"       # split on #"/" interpolateand intomap "[...]"block, andthen evalconcat
}{|x|eval"[%s].inject:product([%s])"%x.split(?:)}                               # reduce with :productstring (injectinterpolate soundsand cooler)eval
p                                               # print

Ruby, 98 bytes

p`dd`.split(?/).flat_map{|x|x.split(?:).map{|r|eval"[#{r.gsub /(\d+)-/,'*\1..'}]"}.inject:product}

Try it online!

Explanation

 `dd`.split(?/)                                 # split input on "/"
                flat_map{|x|x.split(?:).map{|r| # map each side of ":", at the end, concat (flat_map)
{|r|        r.gsub /(\d+)-/,'*\1..'             # make all "a-b" ranges to "*a..b" (ruby syntax)
    eval"[#{                       }]"          # interpolate into "[...]" and eval
}.inject:product}                               # reduce with :product (inject sounds cooler)
p                                               # print

Ruby, 98 87 bytes

p`dd`.gsub(/\d+-/,'*\00..').split(?/).flat_map{|x|eval"[%s].product([%s])"%x.split(?:)}

Try it online!

Explanation

 `dd`.gsub(/\d+-/,'*\00..')               # input and replace "number-" with "*number-0..", ruby syntax for ranges
.split(?/).flat_map                       # split on "/" and map block, then concat
{|x|eval"[%s].product([%s])"%x.split(?:)} # string interpolate and eval
p                                         # print
Source Link
Natte
  • 1.1k
  • 5
  • 9

Ruby, 98 bytes

p`dd`.split(?/).flat_map{|x|x.split(?:).map{|r|eval"[#{r.gsub /(\d+)-/,'*\1..'}]"}.inject:product}

Try it online!

Explanation

 `dd`.split(?/)                                 # split input on "/"
                flat_map{|x|x.split(?:).map{|r| # map each side of ":", at the end, concat (flat_map)
{|r|        r.gsub /(\d+)-/,'*\1..'             # make all "a-b" ranges to "*a..b" (ruby syntax)
    eval"[#{                       }]"          # interpolate into "[...]" and eval
}.inject:product}                               # reduce with :product (inject sounds cooler)
p                                               # print