DWITE '12 R5 #3 - Triangle Count

View as PDF

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 representing the size of the square grid, followed by 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 triangles of size one, of size three, and of size five, for a total of (The ASCII pattern doesn't support triangles of even length.)

Sample Input

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

Sample Output

16

Comments

There are no comments at the moment.