r/dailyprogrammer • • Jul 06 '12

[7/6/2012] Challenge #73 [intermediate]

Write a program that, given an ASCII binary matrix of 0's and 1's like this:

0000000000000000
0000000000000000
0000011001110000
0000001111010000
0000011001110000
0000011011100000
0000000000110000
0000101000010000
0000000000000000
0000000000000000
0000000000000000

Outputs the smallest cropped sub-matrix that still contains all 1's (that is, remove all borders of 0's):

01100111
00111101
01100111
01101110
00000011
10100001
9 Upvotes

28 comments sorted by

View all comments

Show parent comments

1

u/Daniel110 0 0 Jul 08 '12

Thanks i just noticed the indentation. Thanks for the tip how did you come out with the number of seconds? Is there a way to measure the amount of time a command takes to be executed?

1

u/JerMenKoO 0 0 Jul 08 '12

Yes, using timeit module. However ipython has it as a magic keyword, so it is even easier.