-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlevel26.cs
More file actions
85 lines (77 loc) · 3.16 KB
/
level26.cs
File metadata and controls
85 lines (77 loc) · 3.16 KB
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
81
82
83
84
85
using System;
using System.Drawing;
/*
* * * * * * * * * * * * * * * * * * *
* Agustín Rojas - ITChallenge 2017 *
* *
* Nivel 26 -Canada *
* * * * * * * * * * * * * * * * * * *
*
* POR SOLUCIONAR: NO TOMA EN CUENTA LOS SALTOS DE LINEA
*/
namespace ITChallenge
{
class level26
{
static void Main(string[] args)
{
Bitmap Imagen = new Bitmap("level26.png");
String Mensaje = "";
//Recorremos desde el pixel (53,53) al (645,944) de a un pixel a la derecha y 3 hacia abajo (salteando lienas vacias)
for (int height = 53; height < 944; height += 3)
{
for (int width = 53; width < 645; width++)
{
//Obtenemos el color del pixel
Color pixel = Imagen.GetPixel(width, height);
//Si el pixel es negro
if (pixel.Name == "ff000000")
{
//y el siguiente tambien es negro
if (Imagen.GetPixel(width + 1, height).Name == "ff000000")
{
//es un guion
Mensaje += "-";
//salteamos el guion
width = width + 2;
//chequeamos si en los siguientes 3 a 6 pixeles desde el final del guion hay otro guion o punto,de lo contrario hay un espacio
bool espacio = true;
for (int i = 3; i < 6; i++)
{
if (Imagen.GetPixel(width + i, height).Name == "ff000000")
{
espacio = false;
}
}
if (espacio)
{
Mensaje += " ";
}
}
//si el siguiente es blanco
else if (Imagen.GetPixel(width + 1, height).Name == "ffffffff")
{
//es un punto
Mensaje += ".";
//chequeamos si en los siguientes 3 a 5 pixeles desde el final del punto hay otro guion o punto,de lo contrario hay un espacio
bool espacio = true;
for (int i = 3; i < 5; i++)
{
if (Imagen.GetPixel(width + i, height).Name == "ff000000")
{
espacio = false;
}
}
if (espacio)
{
Mensaje += " ";
}
}
}
}
}
Console.WriteLine(Mensaje);
Console.Read();
}
}
}