##Ruby, (削除) 88 (削除ここまで) 87 bytes
Ruby, (削除) 88 (削除ここまで) 87 bytes
f=->i{o=[]
(s,l,*i=i
r=s...s+l
o[r]=[([*o[r]]+[0]).max+1]*l
o.map! &:to_i)while i[0]
o}
Inspired by grc's answer, but in a different language and just slightly shorter.
Explanation:
f=->i # lambda with parameter i, expects array of ints
{
o=[] # output
(
s,l,*i=i # pop start and length
r = s...s+l # range is used twice, so shorten it to 1 char
o[r] =
[(
[*o[r]] # o[r] returns nil if out of bounds, so splat it into another array
+[0] # max doesn't like an empty array, so give it at least a 0
).max+1]*l # repeat max+1 to fill length
o.map! &:to_i # replace nil values with 0
) while i[0] # i[0] returns nil when i is empty, which is falsy
o # return o
}
##Ruby, (削除) 88 (削除ここまで) 87 bytes
f=->i{o=[]
(s,l,*i=i
r=s...s+l
o[r]=[([*o[r]]+[0]).max+1]*l
o.map! &:to_i)while i[0]
o}
Inspired by grc's answer, but in a different language and just slightly shorter.
Explanation:
f=->i # lambda with parameter i, expects array of ints
{
o=[] # output
(
s,l,*i=i # pop start and length
r = s...s+l # range is used twice, so shorten it to 1 char
o[r] =
[(
[*o[r]] # o[r] returns nil if out of bounds, so splat it into another array
+[0] # max doesn't like an empty array, so give it at least a 0
).max+1]*l # repeat max+1 to fill length
o.map! &:to_i # replace nil values with 0
) while i[0] # i[0] returns nil when i is empty, which is falsy
o # return o
}
Ruby, (削除) 88 (削除ここまで) 87 bytes
f=->i{o=[]
(s,l,*i=i
r=s...s+l
o[r]=[([*o[r]]+[0]).max+1]*l
o.map! &:to_i)while i[0]
o}
Inspired by grc's answer, but in a different language and just slightly shorter.
Explanation:
f=->i # lambda with parameter i, expects array of ints
{
o=[] # output
(
s,l,*i=i # pop start and length
r = s...s+l # range is used twice, so shorten it to 1 char
o[r] =
[(
[*o[r]] # o[r] returns nil if out of bounds, so splat it into another array
+[0] # max doesn't like an empty array, so give it at least a 0
).max+1]*l # repeat max+1 to fill length
o.map! &:to_i # replace nil values with 0
) while i[0] # i[0] returns nil when i is empty, which is falsy
o # return o
}
##Ruby, 88(削除) 88 (削除ここまで) 87 bytes
f=->i{o=[]
(s,l,*i=i
r=s...s+l
o[r]=[([*o[r]]+[0]).max+1]*l
o.map!(&:to_i))while i[0]
o}
Inspired by grc's answer, but in a different language and just slightly shorter.
Explanation:
f=->i # lambda with parameter i, expects array of ints
{
o=[] # output
(
s,l,*i=i # pop start and length
r = s...s+l # range is used twice, so shorten it to 1 char
o[r] =
[(
[*o[r]] # o[r] returns nil if out of bounds, so splat it into another array
+[0] # max doesn't like an empty array, so give it at least a 0
).max+1]*l # repeat max+1 to fill length
o.map!(&:to_i) # replace nil values with 0
) while i[0] # i[0] returns nil when i is empty, which is falsy
o # return o
}
##Ruby, 88 bytes
f=->i{o=[]
(s,l,*i=i
r=s...s+l
o[r]=[([*o[r]]+[0]).max+1]*l
o.map!(&:to_i))while i[0]
o}
Inspired by grc's answer, but in a different language and just slightly shorter.
Explanation:
f=->i # lambda with parameter i, expects array of ints
{
o=[] # output
(
s,l,*i=i # pop start and length
r = s...s+l # range is used twice, so shorten it to 1 char
o[r] =
[(
[*o[r]] # o[r] returns nil if out of bounds, so splat it into another array
+[0] # max doesn't like an empty array, so give it at least a 0
).max+1]*l # repeat max+1 to fill length
o.map!(&:to_i) # replace nil values with 0
) while i[0] # i[0] returns nil when i is empty, which is falsy
o # return o
}
##Ruby, (削除) 88 (削除ここまで) 87 bytes
f=->i{o=[]
(s,l,*i=i
r=s...s+l
o[r]=[([*o[r]]+[0]).max+1]*l
o.map!&:to_i)while i[0]
o}
Inspired by grc's answer, but in a different language and just slightly shorter.
Explanation:
f=->i # lambda with parameter i, expects array of ints
{
o=[] # output
(
s,l,*i=i # pop start and length
r = s...s+l # range is used twice, so shorten it to 1 char
o[r] =
[(
[*o[r]] # o[r] returns nil if out of bounds, so splat it into another array
+[0] # max doesn't like an empty array, so give it at least a 0
).max+1]*l # repeat max+1 to fill length
o.map!&:to_i # replace nil values with 0
) while i[0] # i[0] returns nil when i is empty, which is falsy
o # return o
}
##Ruby, 88 bytes
f=->i{o=[]
(s,l,*i=i
r=s...s+l
o[r]=[([*o[r]]+[0]).max+1]*l
o.map!(&:to_i))while i[0]
o}
Inspired by grc's answer, but in a different language and just slightly shorter.
Explanation:
f=->i # lambda with parameter i, expects array of ints
{
o=[] # output
(
s,l,*i=i # pop start and length
r = s...s+l # range is used twice, so shorten it to 1 char
o[r] =
[(
[*o[r]] # o[r] returns nil if out of bounds, so splat it into another array
+[0] # max doesn't like an empty array, so give it at least a 0
).max+1]*l # repeat max+1 to fill length
o.map!(&:to_i) # replace nil values with 0
) while i[0] # i[0] returns nil when i is empty, which is falsy
o # return o
}
##Ruby, 88 bytes
f=->i{o=[]
(s,l,*i=i
r=s...s+l
o[r]=[([*o[r]]+[0]).max+1]*l
o.map!(&:to_i))while i[0]
o}
Explanation:
f=->i # lambda with parameter i, expects array of ints
{
o=[] # output
(
s,l,*i=i # pop start and length
r = s...s+l # range is used twice, so shorten it to 1 char
o[r] =
[(
[*o[r]] # o[r] returns nil if out of bounds, so splat it into another array
+[0] # max doesn't like an empty array, so give it at least a 0
).max+1]*l # repeat max+1 to fill length
o.map!(&:to_i) # replace nil values with 0
) while i[0] # i[0] returns nil when i is empty, which is falsy
o # return o
}
##Ruby, 88 bytes
f=->i{o=[]
(s,l,*i=i
r=s...s+l
o[r]=[([*o[r]]+[0]).max+1]*l
o.map!(&:to_i))while i[0]
o}
Inspired by grc's answer, but in a different language and just slightly shorter.
Explanation:
f=->i # lambda with parameter i, expects array of ints
{
o=[] # output
(
s,l,*i=i # pop start and length
r = s...s+l # range is used twice, so shorten it to 1 char
o[r] =
[(
[*o[r]] # o[r] returns nil if out of bounds, so splat it into another array
+[0] # max doesn't like an empty array, so give it at least a 0
).max+1]*l # repeat max+1 to fill length
o.map!(&:to_i) # replace nil values with 0
) while i[0] # i[0] returns nil when i is empty, which is falsy
o # return o
}