Skip to main content
added 2 characters in body; deleted 1 characters in body
Source Link
user8777
user8777

Python 2.7 - 6365

Nice and short one, this uses complex numbers to step through the plane:

x=lambda s:abs2*abs(sum([[1,-1,1j,-1j]['RLUD'.index(i)]for i in s]))

Props to DSM and Abhijit in other questions that showed me the use of 1j to calculate this.

Python 2.7 - 63

Nice and short one, this uses complex numbers to step through the plane:

x=lambda s:abs(sum([[1,-1,1j,-1j]['RLUD'.index(i)]for i in s]))

Props to DSM and Abhijit in other questions that showed me the use of 1j to calculate this.

Python 2.7 - 65

Nice and short one, this uses complex numbers to step through the plane:

x=lambda s:2*abs(sum([[1,-1,1j,-1j]['RLUD'.index(i)]for i in s]))

Props to DSM and Abhijit in other questions that showed me the use of 1j to calculate this.

Source Link
user8777
user8777

Python 2.7 - 63

Nice and short one, this uses complex numbers to step through the plane:

x=lambda s:abs(sum([[1,-1,1j,-1j]['RLUD'.index(i)]for i in s]))

Props to DSM and Abhijit in other questions that showed me the use of 1j to calculate this.