Skip to content

Commit af2b22d

Browse files
author
Musa Kaçmaz
committed
2 parents 634110d + 5a12385 commit af2b22d

File tree

2 files changed

+94
-0
lines changed

2 files changed

+94
-0
lines changed

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2021 musa kaçmaz
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# Bitmap Challenge
2+
3+
## 🎯 Target
4+
5+
There is given a rectangular bitmap of size n*m. Each pixel of the bitmap is either white or
6+
black, but at least one is white. The pixel in i-th line and j-th column is called the pixel (i,j). The
7+
distance between two pixels p1=(i1,j1) and p2=(i2,j2) is defined as d(p1,p2)=|i1-i2|+|j1-j2|.
8+
9+
The aim of the program is;
10+
- read the description of the bitmap from the standard input
11+
- for each pixel, computes the distance to the nearest white
12+
- writes the results to the standard output
13+
14+
## ⚙️ Prerequests
15+
16+
You will need [Node.js](https://nodejs.org) and [TypeScript](https://www.typescriptlang.org) installed on your system.
17+
18+
## 🚀 Setup & Run
19+
20+
Get the code by either cloning this repository using git or download
21+
22+
```
23+
git clone https://github.com/musakacmaz/dott-assignment.git
24+
```
25+
26+
Once downloaded, open the terminal in the project directory, and install dependencies with:
27+
28+
```
29+
npm install
30+
```
31+
32+
To run tests:
33+
34+
```
35+
npm run test
36+
```
37+
38+
To fix lint:
39+
40+
```
41+
npm run lint-fix
42+
```
43+
44+
Formatting:
45+
46+
```
47+
npm run prettier-format
48+
```
49+
50+
You can run the program with:
51+
52+
```
53+
cat input.txt | npm run start
54+
```
55+
## 🎉 Result
56+
The program should read bitmaps from the given [text document](https://github.com/musakacmaz/dott-assignment/blob/master/input.txt) and print the result. For example;
57+
Input:
58+
```shell
59+
1 // number of test cases
60+
3 4 // line x column sizes
61+
0001 // pixels - 0: black, 1: white
62+
0011
63+
0110
64+
```
65+
Output:
66+
```shell
67+
3 2 1 0 // distances to the nearest white pixel
68+
2 1 0 0
69+
1 0 0 1
70+
```
71+
## ⚠️ Limitations
72+
- The number of test cases t must be in the range of (1≤t≤1000)
73+
- The line and column sizes n x m must be in the ranges of (1 <= n <= 182), (1 <= m <=182)

0 commit comments

Comments
 (0)