-
Notifications
You must be signed in to change notification settings - Fork 0
/
project_statement.txt
80 lines (56 loc) · 1.86 KB
/
project_statement.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
Maestro AI Programming Puzzle
Welcome to the programming puzzle for Maestro AI!
This challenge is designed to assess your problem-solving and programming skills. Please read the instructions carefully before you begin.
Instructions:
You will be provided links to download two files: data_small.txt and data_large.txt
Your task is to write a program that processes these files to solve the given problem.
After running your program on each file, enter the results into this form.
Ensure that you are signed into your Google account, as we will use this email to contact you regarding next steps.
Problem Description:
Write a program that reads a text file that contains 0's and 1's in a regular N x N sized grid. Here is an example of what a valid input file looks like:
0110
0100
0010
0011
After reading the file, your goal is to find the number of "connected shapes" in the data. A connected shape is defined as a group of 1's that are immediately adjacent to each other. The 1's must be immediately to the left, right, top, or bottom of each other to count as connected (diagonals do not count as connected).
In the example above, your program would return 2, because there are two connected shapes:
11
1
at position (0, 1) and
1
11
at position (2, 2)
You only need to return the number of connected shapes that you've found. You do not need to return the position of the shapes.
File Links:
Download data_small.txt
Download data_large.txt
Additional Examples:
Given this data:
001010
011011
001000
001001
000000
000000
Your function would return 3, because there are 3 connected shapes:
1
11
1
1 at position (0, 2)
1
11 at position (0, 4)
and
1 at position (3, 5)
----------
Given this data:
01000
01000
11111
00000
01100
Your function would return 2, because there are 2 connected shapes:
1
1
11111 at position (0, 1)
and
11 at position (4, 1)