-5

how can i get the numbers that are coded in a ascii art with sticks?

the numberss are in a txt file und it contains this:

Bild of the TXT File

I must convert this txt file in 3 2 1 4 5 1 4 5

I read the text file so:

            using (StreamReader sr = new StreamReader("SourceFile.txt"))
        {
            String line;

            // Read and display lines from the file until the end of 
            // the file is reached.
            while ((line = sr.ReadLine()) != null)
            {
                sb.AppendLine(line);
            }
        }

        string allines = sb.ToString();

Now, like the answer of @Zotta i have to save in two different strings (the first 4 lines and the seconds, than then will be easier

Almir M.
  • 76
  • 9
  • 2
    @displayName Who voted for this edit? OP does not ask for libraries. – MakePeaceGreatAgain Aug 27 '15 at 11:49
  • @HimBromBeere the OP approved the edit... [see history](http://stackoverflow.com/review/suggested-edits/9306333) – Thomas Ayoub Aug 27 '15 at 11:52
  • @HimBromBeere: I know. But OPs original question is too bad and not salvageable. Looking at what OP finally wants done, this is question to be asked instead of what was originally asked by OP. – displayName Aug 27 '15 at 11:54

2 Answers2

5

Your numbers are 4 lines tall each => Split input into blocks of 4 Lines each

Your numbers are separated by columns of whitespace => Search for colums containing only whitespaces and split.

After you separated all the numbers, use a lookup table.

Zotta
  • 2,513
  • 1
  • 21
  • 27
  • Any idea hot to split into blocks of 4 lines? – Almir M. Aug 27 '15 at 12:05
  • @AlmirM. You probably shouldn't store all the lines from the file in a single `string`. Instead use an array or some other collection. Then just iterate over that collection in multiples of 4. – sab669 Aug 27 '15 at 12:15
  • @sab669 some code example? – Almir M. Aug 27 '15 at 12:21
  • `string[] lines = File.ReadAllLines(pathToFile);`. Divide `lines.Length` by 4 to know how many rows of numbers you have. Loop that many times in a `for` loop or whatever. – sab669 Aug 27 '15 at 12:23
2

I don't know why this question is down-voted so much but I think it's interesting question. I'll answer giving a general approach other than hardcoding the possible results by finding the characters and that would work with different "ASCII font".

If you're looking for a library, maybe you can look at captcha decoding on google. There is a comprehensive article here if you want to do it yourself for ASCII specifically: http://www.boyter.org/decoding-captchas/

Also, since most libraries probably only support images, maybe you'll need to convert your ascii art text file into a bitmap by rendering it yourself.

Sauleil
  • 2,573
  • 1
  • 24
  • 27
  • 2
    I would guess it's downvoted because the OP didn't present any attempt to solve the problem themselves - so there was no specific programming issue to solve. – Baldrick Aug 27 '15 at 11:54