Skip to main content
11 of 12
added 38 characters in body
Abhijit
  • 2.9k
  • 12
  • 26

Python 2.7 56 58 56 51 50

With the stolen Number One Dime from Scrooge McDuck, I made my fortune and now have more wealth than Scrooge.

y=lambda s:2*abs(sum((1j)**(ord(i)%15)for i in s))

Python 2.7 - 61 53 52 (case insensitive)

y=lambda s:2*abs(sum((1j)**(ord(i)%16%9)for i in s))

Implementation

>>> from random import sample
>>> y=lambda s:2*abs(sum((-1j)**(ord(i)%15)for i in s))
>>> path=sample('RLUD'*1000, 100)
>>> y(path)
20.0
>>> path=sample('RLUD'*1000, 100)
>>> y(path)
34.058772731852805
Abhijit
  • 2.9k
  • 12
  • 26