DWITE '12 R5 #3 - Triangle Count

View as PDF

Submit solution

Points: 7
Time limit: 1.0s
Memory limit: 64M

Problem type
Allowed languages
Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, CommonLisp, D, Dart, F#, Forth, Fortran, Go, Groovy, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, Nim, ObjC, OCaml, Octave, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig
DWITE, February 2013, Problem 3

A typical Q1 level problem is to draw some ASCII triangles. Well, after a bunch of students wrote their attempts, it's time to count the mess. Given a grid with some pattern, how many different triangles could it have been? The ASCII triangles have shapes such as:

        #
   #   ###
# ### ##### etc.
        

The input will contain 5 test cases. The first line of each case is a number 1 \le N \le 256 representing the size of the square grid, followed by N lines describing the grid.

The output will contain 5 lines of output, each a count of different triangles that could be counted. The orientation of the triangles is just as shown above, for the sake of simplicity. In the sample case below, there are 11 triangles of size one, 4 of size three, and 1 of size five, for a total of 11+4+1=16 (The ASCII pattern doesn't support triangles of even length.)

Sample Input

5
.....
.###.
.###.
#####
.....

Sample Output

16

Attribution-NonCommercial-ShareAlike 3.0 Unported (CC BY-NC-SA 3.0) Problem Resource: DWITE


Comments

There are no comments at the moment.