Skip to main content
Commonmark migration
Source Link

##Pyth - 15 10 * .5 = 5

Pyth - 15 10 * .5 = 5

smr-QdhQUQ

Try it online.

Expects input on stdin. Independently discovered algorithm. Thanks @Sp3000 for helping me stick the last Q in there :P Also, irony? XD

Explanation:

Q=eval(input())       : implicit
s                     : The sum of...
 m      UQ            : map(...,range(Q))
  r-QdhQ              : range(Q-d,Q+1)
     

##Pyth - 15 10 * .5 = 5

smr-QdhQUQ

Try it online.

Expects input on stdin. Independently discovered algorithm. Thanks @Sp3000 for helping me stick the last Q in there :P Also, irony? XD

Explanation:

Q=eval(input())       : implicit
s                     : The sum of...
 m      UQ            : map(...,range(Q))
  r-QdhQ              : range(Q-d,Q+1)
     

Pyth - 15 10 * .5 = 5

smr-QdhQUQ

Try it online.

Expects input on stdin. Independently discovered algorithm. Thanks @Sp3000 for helping me stick the last Q in there :P Also, irony? XD

Explanation:

Q=eval(input())       : implicit
s                     : The sum of...
 m      UQ            : map(...,range(Q))
  r-QdhQ              : range(Q-d,Q+1)
     
deleted 138 characters in body
Source Link
FryAmTheEggman
  • 17.5k
  • 3
  • 40
  • 97

##Pyth - 1515 10 * .5 = 7.55

s+mrhQsmr-Qdr1Q]]QQdhQUQ

Try it online.

Expects input on stdin. Independently discovered algorithm. Thanks @Sp3000 for helping me stick the last Q in there :P Also, irony? XD

Explanation:

Q=eval(input())       : implicit
s                     : The sum of...
 +          ]]Q       : Add [[Q]] to the end of...
m  m    UQ  r1Q          : map(...,range(1,Q))
   rhQr-QdQdhQ              : range(Q-d,Q+1)[::-1]
     

Sadly, pyth's sum function will crash on an empty list, so I lose a byte having to add Q to the list before summing (otherwise 1 would crash).

##Pyth - 15 * .5 = 7.5

s+mrhQ-Qdr1Q]]Q

Try it online.

Expects input on stdin. Independently discovered algorithm.

Explanation:

Q=eval(input())       : implicit
s                     : The sum of...
 +          ]]Q       : Add [[Q]] to the end of...
  m      r1Q          : map(...,range(1,Q))
   rhQ-Qd             : range(Q-d,Q+1)[::-1]

Sadly, pyth's sum function will crash on an empty list, so I lose a byte having to add Q to the list before summing (otherwise 1 would crash).

##Pyth - 15 10 * .5 = 5

smr-QdhQUQ

Try it online.

Expects input on stdin. Independently discovered algorithm. Thanks @Sp3000 for helping me stick the last Q in there :P Also, irony? XD

Explanation:

Q=eval(input())       : implicit
s                     : The sum of...
 m      UQ            : map(...,range(Q))
  r-QdhQ              : range(Q-d,Q+1)
     
Source Link
FryAmTheEggman
  • 17.5k
  • 3
  • 40
  • 97

##Pyth - 15 * .5 = 7.5

s+mrhQ-Qdr1Q]]Q

Try it online.

Expects input on stdin. Independently discovered algorithm.

Explanation:

Q=eval(input())       : implicit
s                     : The sum of...
 +          ]]Q       : Add [[Q]] to the end of...
  m      r1Q          : map(...,range(1,Q))
   rhQ-Qd             : range(Q-d,Q+1)[::-1]

Sadly, pyth's sum function will crash on an empty list, so I lose a byte having to add Q to the list before summing (otherwise 1 would crash).