Slide 1

Slide 1 text

Recrea&onal Programming Anand Chi)pothu 1

Slide 2

Slide 2 text

Who is Speaking? Anand Chi)pothu @anandology • Autodidact Programmer • Building a data science pla5orm at @rorodata • Advanced programming courses at @pipalacademy • Worked at Strand Life Sciences and Internet Archive 2

Slide 3

Slide 3 text

recrea%onal |rɛkriˈeɪʃənl| adjec2ve rela%ng to or deno%ng ac%vity done for enjoyment when one is not working 3

Slide 4

Slide 4 text

recrea%onal programming programming for the sheer joy of it! 4

Slide 5

Slide 5 text

This is How I Started Programming 5

Slide 6

Slide 6 text

This is How I Con,nued... 6

Slide 7

Slide 7 text

Interes'ng Ideas 7

Slide 8

Slide 8 text

1. Write Games 8

Slide 9

Slide 9 text

15 Puzzle h"ps://en.wikipedia.org/wiki/15_puzzle 9

Slide 10

Slide 10 text

2048 h"ps://en.wikipedia.org/wiki/2048_(video_game) 10

Slide 11

Slide 11 text

2. Solve Puzzles 11

Slide 12

Slide 12 text

Eight Queens Problem h"ps://en.wikipedia.org/wiki/Eight_queens_puzzle 12

Slide 13

Slide 13 text

Sudoku h"p://anandology.com/presenta4ons/solving-puzzles-with-python/ h"p://norvig.com/sudoku.html 13

Slide 14

Slide 14 text

3. Game of Life 14

Slide 15

Slide 15 text

The Game • infinite two-dimensional orthogonal grid of square cells • each cell is either alive or dead h"p://www.math.cornell.edu/~lipa/mec/banner.png 15

Slide 16

Slide 16 text

The Rules Any live cell with: • fewer than two live neighbours dies - loneliness • more than three live neighbours dies - overpopula7on • two or three live neighbours lives on - right living condi7ons Any dead cell with: • exactly three live neighbours becomes a live cell, as if by reproduc9on. 16

Slide 17

Slide 17 text

Interes'ng Pa,erns 17

Slide 18

Slide 18 text

Interes'ng Pa,erns More Pa(erns on h"ps://en.wikipedia.org/wiki/Conways_Game_of_Life 18

Slide 19

Slide 19 text

4. Fractals 19

Slide 20

Slide 20 text

Koch Curve 20

Slide 21

Slide 21 text

Sierpinski Carpet 21

Slide 22

Slide 22 text

Mandelbrot Set h"ps://en.wikipedia.org/wiki/Mandelbrot_set 22

Slide 23

Slide 23 text

5. Li&le Languages1 1 Programming Pearls - Jon Bentley, h5p:/ /cs448h.stanford.edu/li5le-languages.pdf 23

Slide 24

Slide 24 text

The Pic Language .PS ellipse "pic program" arrow box "PIC" arrow box "TROFF" arrow ellipse "output" .PE 24

Slide 25

Slide 25 text

.PS pi = 3.14159 n = 20 r = 3.5 s = 2*pi/n for i = 1 to n-1 do { for j = i+1 to n do { line from r*cos(s*i), r*sin(s*i) \ to r*cos(s*j), r*sin(s*j) } } .PE 25

Slide 26

Slide 26 text

Regular Expressions Li#le language for pa#ern matching. Match numbers: [0-9]+ Match HTML tags: <[^<>]*> 26

Slide 27

Slide 27 text

Extract data from readable strings: every day at 10:00 AM every month on first day at 5:00PM 27

Slide 28

Slide 28 text

6. Func(onal Programming 28

Slide 29

Slide 29 text

Recursion is Amazing! 29

Slide 30

Slide 30 text

Example: Count Change How to make change of 100 using denomina5ons 50, 25, 10, 5 and 1? Too tedious to try it manually. How about wri4ng a program? 30

Slide 31

Slide 31 text

Structure and Interpreta-on of Computer Programs2 2 h$ps:/ /mitpress.mit.edu/sicp/ 31

Slide 32

Slide 32 text

A language that doesn't affect the way you think about programming, is not worth knowing. — Alan Perlis 32

Slide 33

Slide 33 text

Happy Hacking! Anand Chi)pothu @anandology 33