File tree Expand file tree Collapse file tree 2 files changed +48
-0
lines changed Expand file tree Collapse file tree 2 files changed +48
-0
lines changed Original file line number Diff line number Diff line change
1
+ from matplotlib import pyplot as plt
2
+ import random
3
+
4
+ # generate the canvas..
5
+ def gen_grid (size ):
6
+ canvas = [[True for i in range (size )] for i in range (size )]
7
+ return canvas
8
+
9
+ # randomly put dirty tiles in the canvas..
10
+ def get_dirty (canvas ):
11
+ for i ,row in enumerate (canvas ):
12
+ for j ,_ in enumerate (row ):
13
+ canvas [i ][j ]= bool (random .getrandbits (1 ))
14
+ # TODO - func to find nearest dirty tile from our robots current position..
15
+ find_nn_dirty (canvas ,point ):
16
+ x ,y = point
17
+
18
+ # TODO - func to generate next move of our robot towards the dirt,
19
+ # if on dirt: clean it.
20
+ def move (curr ,next_dirt ):
21
+ pass
22
+
23
+ if __name__ == '__main__' :
24
+ canvas = gen_grid (100 )
25
+ get_dirty (canvas )
26
+ print (canvas )
Original file line number Diff line number Diff line change
1
+ '''Author Anurag Kumar(mailto:anuragkumarak95@gmail.com)
2
+
3
+ Module to solve a classic ancient Chinese puzzle:
4
+ We count 35 heads and 94 legs among the chickens and rabbits in a farm.
5
+ How many rabbits and how many chickens do we have?
6
+
7
+
8
+ '''
9
+ def solve (numheads ,numlegs ):
10
+ ns = 'No solutions!'
11
+ for i in range (numheads + 1 ):
12
+ j = numheads - i
13
+ if 2 * i + 4 * j == numlegs :
14
+ return i ,j
15
+ return ns ,ns
16
+
17
+ if __name__ == "__main__" :
18
+ numheads = 35
19
+ numlegs = 94
20
+
21
+ solutions = solve (numheads ,numlegs )
22
+ print (solutions )
You can’t perform that action at this time.
0 commit comments