Skip to main content
added 418 characters in body
Source Link
pxeger
  • 24.6k
  • 4
  • 53
  • 141

Python 2, 32 bytes

def f(a,b,l):l[a],l[b]=l[b],l[a]

Attempt This Online!

Mutates the input in-place.


26 bytes with a NumPy array:

def f(l,a):l[a[::-1]]=l[a]

Try it online!

Python 2, 32 bytes

def f(a,b,l):l[a],l[b]=l[b],l[a]

Attempt This Online!

Mutates the input in-place.

Python 2, 32 bytes

def f(a,b,l):l[a],l[b]=l[b],l[a]

Attempt This Online!

Mutates the input in-place.


26 bytes with a NumPy array:

def f(l,a):l[a[::-1]]=l[a]

Try it online!

-8 bytes thanks to Kevin Cruijssen
Source Link
pxeger
  • 24.6k
  • 4
  • 53
  • 141

Python 2, 4032 bytes

def f(a,b,l):l[a],l[b]=l[b],l[a];print ll[a]

Attempt This Online!Attempt This Online!

Mutates the input in-place.

Python 2, 40 bytes

def f(a,b,l):l[a],l[b]=l[b],l[a];print l

Attempt This Online!

Python 2, 32 bytes

def f(a,b,l):l[a],l[b]=l[b],l[a]

Attempt This Online!

Mutates the input in-place.

added 11 characters in body
Source Link
pxeger
  • 24.6k
  • 4
  • 53
  • 141

Python 2, 4140 bytes

def f(a,b,l=input(l)
 :l[a],l[b]=l[b],l[a]
printl[a];print l

Attempt This Online!Attempt This Online!

Python 2, 41 bytes

a,b,l=input()
 l[a],l[b]=l[b],l[a]
print l

Attempt This Online!

Python 2, 40 bytes

def f(a,b,l):l[a],l[b]=l[b],l[a];print l

Attempt This Online!

Source Link
pxeger
  • 24.6k
  • 4
  • 53
  • 141
Loading