16
PERCEIVING BEAUTY Sriram V Iyer

Perceiving beauty

Embed Size (px)

DESCRIPTION

My quick talk in 'Write Beautiful Code' HackerEarth Event in Dexetra, Bangalore. Not much text and borrowed a lot of stuff from Hannson and Cormen!

Citation preview

Page 1: Perceiving beauty

PERCEIVING BEAUTYSriram V Iyer

Page 2: Perceiving beauty

BORROWING FROM HANNSON

Beauty Leads to Happiness

Page 3: Perceiving beauty

Happiness Leads to productivity

….. So,

Page 4: Perceiving beauty

Beauty leads to Productivity

Page 5: Perceiving beauty

You can recognize truth by its beauty and simplicity. When you get it right, it is obvious that it is right.

- Richard Feynman

Page 6: Perceiving beauty
Page 7: Perceiving beauty

Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away

-Antoine de Saint-Exupery

Page 8: Perceiving beauty

vs

Page 9: Perceiving beauty

LESS IS MORE (BEAUTIFUL)

l = [ 3, 7, 8, 6, 5, 11 ]

q = []

for i in range( len(l) ):

q.insert( l[i] * 2 )

Page 10: Perceiving beauty

LESS IS MORE (BEAUTIFUL)

def dbl(x):

return x * 2

l = [ 3, 7, 8, 6, 5, 11 ]

q = []

for i in range( len(l) ):

q.insert( dbl (l[i]) )

Page 11: Perceiving beauty

LESS IS MORE (BEAUTIFUL)

def dbl(x):

return x * 2

l = [ 3, 7, 8, 6, 5, 11 ]

q = map( dbl, l )

Page 12: Perceiving beauty

LESS IS MORE (BEAUTIFUL)

l = [ 3, 7, 8, 6, 5, 11 ]

q = [ x * 2 for x in l ]

# Double only odd numbers? …

Page 13: Perceiving beauty

LESS IS MORE (BEAUTIFUL)

q = [ x * 2 for x in l if not (x % 2) ]

VS

q = map( lambda x : x * 2, filter(lambda y : y % 2 != 0, l ) )

Page 14: Perceiving beauty

ATTITUDE IS NO SUBSTITUTE FOR COMPETENCE

O(n) = log n

VS

O(n) = n log n

Page 15: Perceiving beauty

KNOWING IS EVERYTHING

Insertion Sort (n^2) vs Merge Sort (n log(n))

Computer A 10,000 MIPS vs Computer B 10 MIPS

Number of items to be Sorted

Insertion Sort or Computer A

Merge Sort on Computer B

10 Million 5.5 Hours 17 mins

100 Million 23 Days 4 hours

Page 16: Perceiving beauty

THANK YOU!