Skip to main content
deleted 220 characters in body
Source Link
Ginger
  • 6k
  • 1
  • 21
  • 54

Python 3, 69 64 61 55 bytes

Takes a list of floats as input.

lambda l:sum(o*-~c*(len(l)-c)for c,o in enumerate(l))

My original code (because the above is quite confusing):

lambda l:sum(float(o)*c*(len(l)+1-c)for c,o in enumerate(l,1))

Example:

l=input().split(" ")
print(sum(float(o)*c*(len(l)+1-c)for c,o in enumerate(l,1)))
lambda l:sum(o*-~c*(len(l)-c)for c,o in enumerate(l))

Try it here!

Python 3, 69 64 61 55 bytes

Takes a list of floats as input.

lambda l:sum(o*-~c*(len(l)-c)for c,o in enumerate(l))

My original code (because the above is quite confusing):

lambda l:sum(float(o)*c*(len(l)+1-c)for c,o in enumerate(l,1))

Example:

l=input().split(" ")
print(sum(float(o)*c*(len(l)+1-c)for c,o in enumerate(l,1)))

Try it here!

Python 3, 69 64 61 55 bytes

Takes a list of floats as input.

lambda l:sum(o*-~c*(len(l)-c)for c,o in enumerate(l))

Try it here!

added 3 characters in body
Source Link
Ginger
  • 6k
  • 1
  • 21
  • 54

Python 3, 69 64 6161 55 bytes

Takes a list of numbersfloats as input.

lambda l:sum(eval(o)*o*-~c*(len(l)-c)for c,o in enumerate(l))

My original code (because the above is quite confusing):

lambda l:sum(float(o)*c*(len(l)+1-c)for c,o in enumerate(l,1))

Example:

l=input().split(" ")
print(sum(float(o)*c*(len(l)+1-c)for c,o in enumerate(l,1)))

Try it here!

Python 3, 69 64 61 bytes

Takes a list of numbers as input.

lambda l:sum(eval(o)*-~c*(len(l)-c)for c,o in enumerate(l))

My original code (because the above is quite confusing):

lambda l:sum(float(o)*c*(len(l)+1-c)for c,o in enumerate(l,1))

Example:

l=input().split(" ")
print(sum(float(o)*c*(len(l)+1-c)for c,o in enumerate(l,1)))

Try it here!

Python 3, 69 64 61 55 bytes

Takes a list of floats as input.

lambda l:sum(o*-~c*(len(l)-c)for c,o in enumerate(l))

My original code (because the above is quite confusing):

lambda l:sum(float(o)*c*(len(l)+1-c)for c,o in enumerate(l,1))

Example:

l=input().split(" ")
print(sum(float(o)*c*(len(l)+1-c)for c,o in enumerate(l,1)))

Try it here!

added 135 characters in body
Source Link
Ginger
  • 6k
  • 1
  • 21
  • 54

Python 3, 69 6464 61 bytes

Takes a list of numbers as input.

lambda l:sum(eval(o)*-~c*(len(l)-c)for c,o in enumerate(l))

My original code (because the above is quite confusing):

lambda l:sum(float(o)*c*(len(l)+1-c)for c,o in enumerate(l,1))

Example:

l=input().split(" ")
print(sum(float(o)*c*(len(l)+1-c)for c,o in enumerate(l,1)))

Try it here!

Python 3, 69 64 bytes

Takes a list of numbers as input.

lambda l:sum(float(o)*c*(len(l)+1-c)for c,o in enumerate(l,1))

Example:

l=input().split(" ")
print(sum(float(o)*c*(len(l)+1-c)for c,o in enumerate(l,1)))

Try it here!

Python 3, 69 64 61 bytes

Takes a list of numbers as input.

lambda l:sum(eval(o)*-~c*(len(l)-c)for c,o in enumerate(l))

My original code (because the above is quite confusing):

lambda l:sum(float(o)*c*(len(l)+1-c)for c,o in enumerate(l,1))

Example:

l=input().split(" ")
print(sum(float(o)*c*(len(l)+1-c)for c,o in enumerate(l,1)))

Try it here!

Thanks @AnttiP and @caird coinheringaahing!
Source Link
Ginger
  • 6k
  • 1
  • 21
  • 54
Loading
Nice
Source Link
Ginger
  • 6k
  • 1
  • 21
  • 54
Loading
Source Link
Ginger
  • 6k
  • 1
  • 21
  • 54
Loading