Skip to main content
..
Source Link
Soham Chowdhury
  • 1.6k
  • 1
  • 14
  • 23

Python, 7773

def f(x,t=0):
 t=0
 if x:t=f(x-1)-x;t=t+2*x*;t+=2*x*(t*(t>0)in map(f,range(x)))
 return t

Edit 1: Thanks to @xnor's tips on the other Python answer! (I just realised that both look very similar.)

Does anyone know of some way to reduce the number of all those spaces and tabs?Edit 2: Thanks again, @xnor.

Python, 77

def f(x):
 t=0
 if x:t=f(x-1)-x;t=t+2*x*(t*(t>0)in map(f,range(x)))
 return t

Thanks to @xnor's tips on the other Python answer! (I just realised that both look very similar.)

Does anyone know of some way to reduce the number of all those spaces and tabs?

Python, 73

def f(x,t=0):
 if x:t=f(x-1);t+=2*x*(t*(t>0)in map(f,range(x)))
 return t

Edit 1: Thanks to @xnor's tips on the other Python answer! (I just realised that both look very similar.)

Edit 2: Thanks again, @xnor.

shrtr duz it
Source Link
Soham Chowdhury
  • 1.6k
  • 1
  • 14
  • 23

Python, 8177

def f(x):                                                                 
 t=0
 if x:a=ft=f(x-1);return(a-x,a+xx;t=t+2*x*(t*(t>0)[a-x in map(f,range(x))or a<=x])
 return 0t

Thanks to @xnor's tips on the other Python answer! (I just realised that both look very similar.)

Does anyone know of some way to reduce the number of all those spaces and tabs?

Python, 81

def f(x):                                                                 
 if x:a=f(x-1);return(a-x,a+x)[a-x in map(f,range(x))or a<=x]
 return 0

Python, 77

def f(x): 
 t=0
 if x:t=f(x-1)-x;t=t+2*x*(t*(t>0)in map(f,range(x)))
 return t

Thanks to @xnor's tips on the other Python answer! (I just realised that both look very similar.)

Does anyone know of some way to reduce the number of all those spaces and tabs?

fixed again
Source Link
Soham Chowdhury
  • 1.6k
  • 1
  • 14
  • 23

Python (under progress)

Python, 81

def f(x):                                                                 
 if x:a=f(x-1);return(a+x,a-x,a+x)[a-x not in map(f,range(x)) andor a>x]a<=x]
 return 0

Python (under progress)

def f(x):                                                                 
 if x:a=f(x-1);return(a+x,a-x)[a-x not in map(f,range(x)) and a>x]
 return 0

Python, 81

def f(x):                                                                 
 if x:a=f(x-1);return(a-x,a+x)[a-x in map(f,range(x))or a<=x]
 return 0
fix
Source Link
Soham Chowdhury
  • 1.6k
  • 1
  • 14
  • 23
Loading
Source Link
Soham Chowdhury
  • 1.6k
  • 1
  • 14
  • 23
Loading