【checkio】the Moore neighbourhood
来源:互联网 发布:初中语文软件 编辑:程序博客网 时间:2024/05/17 23:39
早上起来就开始做这道题 顺便学了下python二维数组的东西 主要就是确定边界 还有 好像没什么了
row 和 col 弄反了一直报错越界 也是逗了
觉得 还是慢慢来吧
代码:
def count_neighbours(tuples, the_row,the_col):
rows = len(tuples)
cols = len(tuples[0])
count = 0
for j in range(the_row-1,the_row+2):
for k in range(the_col-1,the_col+2):
if j>=0 and k>=0 and j<rows and k<cols:
if tuples[j][k] == 1 :
count+=1
if tuples[the_row][the_col] == 1:
count-=1
return count
0 0
- 【checkio】the Moore neighbourhood
- checkio-moore neighbourhood
- CheckIO: Moore Neighbourhood
- checkio (Determine the order)
- checkio-the flat dictionary
- CheckIO The Longest Palindromic
- checkio-the most wanted letter
- checkio the most frequent weekdays
- CheckIO The Most Wanted Letter
- checkio--
- Python checkio "The Most Frequent Weekdays"解决方案
- The Boyer-Moore Majority Vote Algorithm
- Checkio - What does the cow say? 题目和答案
- NCA: Neighbourhood Components Analysis
- The COM Course - Part 3--By Karl Moore
- The COM Course - Part 2--By Karl Moore
- The COM Course - Part 1--by karl moore
- checkio (Brackets)
- RTP 简单的发送端程序和接收端程序
- 使用Makefile链接so库文件
- 时间复杂度的计算
- 如何遍历memcached里面所有key的命令
- [leetcode]32 Length of Last Word
- 【checkio】the Moore neighbourhood
- [Windows]_[MacOSX]_[获取程序的执行文件所在路径(目录)]
- listView条目不能点击问题
- 算法训练 2的次幂表示
- 使用MapWinGis ActiveX控件在shapefile文件图层上画直线
- OJ 系列之字符串转换为整数
- 【jQuery】利用表单的序列化根据name取表单,做表单的验证
- mysql参数备注
- 黑马程序员——java基础学习第一天