DEV Community

Discussion on: Daily Challenge #168 - [Code golf] f (f (f b)) = f b

Collapse
 
dwilmer profile image
Daan Wilmer • Edited

Not a code golfer, but pretty compact with writing the way I learned in uni:

f(x)=c → f(f(f(x)))=c=f(x)
f(x)=x → f(f(f(x)))=x=f(x)
f(x)=¬x → f(f(f(x)))=¬¬¬x=¬x=f(x)

Above code is 82 characters, excluding whitespace.

EDIT: now in LaTeX

f(x)=cf(f(f(x)))=c=f(x)f(x)=xf(f(f(x)))=x=f(x)f(x)=¬xf(f(f(x)))=¬¬¬x=¬x=f(x) \begin{aligned} f(x) = c &\rightarrow f(f(f(x))) = c = f(x) \\ f(x) = x &\rightarrow f(f(f(x))) = x = f(x) \\ f(x) = \neg x &\rightarrow f(f(f(x))) = \neg \neg \neg x = \neg x = f(x) \end{aligned}