Skip to content

Instantly share code, notes, and snippets.

@lethe2211
Created December 9, 2014 10:35
Show Gist options
  • Save lethe2211/be204724be19e2f1ecd5 to your computer and use it in GitHub Desktop.
Save lethe2211/be204724be19e2f1ecd5 to your computer and use it in GitHub Desktop.
#! /usr/bin/env python
# -*- coding: utf-8 -*-
import os
import sys
class Hoge(object):
def __init__(self):
pass
def func(self):
'''
insert your code
'''
r, c = map(int, raw_input().split())
p = []
for i in range(r):
line = raw_input()
p.append(line)
ans = 0
for i in range(len(p)):
for j in range(len(p[0])):
if i < 1 or j < 1:
continue
# print i, j, p[i][j]
for k in range(i+1):
for l in range(j+1):
# print k, l, i, j
flg = True
if k == i or l == j:
continue
for m in range(i-k+1):
for n in range(j-l+1):
# print m, n, i-k, j-l
# print k+m, l+n, i-m, j-n, p[k+m][l+n], p[i-m][j-n]
if p[k+m][l+n] != p[i-m][j-n]:
# print 'not: ', k+m, l+n, i-m, j-n, p[k+m][l+n], p[i-m][j-n]
flg = False
break
if flg == True:
# print 'ans: ', k, l, i, j
ans += 1
print ans
return None
if __name__ == '__main__':
h = Hoge()
h.func()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment