Python|2018蓝桥杯--字母列阵

前言在语言的学习中我们经常会遇到关于列阵的问题,而字母列阵就是其中的常见的一种。问题描述仔细寻找,会发现:在下面的8x8的方阵中,隐藏着字母序列:"LANQIAO"。SLANQIAOZOEXCCGBMOAYWKHIBCCIPLJQSLANQIAORSFWFNYAXIFZVWALCOAIQNAL我们约定: 序列可以水平,垂直,或者是斜向;并且走向不限(实际上就是有一共8种方向)。上图中一共有4个满足要求的串。下面有一个更大的(100x100)的字母方阵。你能算出其中隐藏了多少个“LANQIAO”吗?FOAIQNALWIKEGNICJWAOSXDHTHZPOLGYELORAUHOHCZIERPTOOJUITQJCFNIYYQHSBEABBQZPNGYQTCLSKZFCYWDGOAIADKLSNGJGSOZTQKCCSDWGUWAUOZKNILGVNLMCLXQVBJENIHIVLRPVVXXFTHQUXUAVZZOFFJHYLMGTLANQIAOQQILCDCJERJASNCTLYGRMHGFTSDFYTLVIBHKLJVVJUDMKGJZGNNSTPVLCKTOFMUEUFSVQIAUVHNVFTGBDDARPKYNNCUOYUAZXQJNOEEYKLFRMOEMHUKJTPETHLESFKVINSLWEVGAGMKVFVIUBMYOIAFHLVNKNTYKTZWVXQWRWIGPENFXYDTKRVPKRTHMGHVYOCLDCKMEKRLGEKBYUCLOLYPAKPFSOREHKWPUOLOVMOFBIXYACWRDYBINTMPASPCEOKHXQIGBQQMCEOIVULIEOPFSCSIHENAJCVDPJDOIWIIULFDNOZOFVAMCABVGKAKCOZMGXWMYRTAFGFOCNHLBGNGOXPJSTWLZUNNAGIRETGXFWAQSSJPFTQAXMTQWMZWYVEPQERKSWTSCHSQOOBGXAQTBCHOEGBDVKGWJIFTGZWWJEIISPLMXIMGHOOGDRZFTGNDDWDWMNUFWJYJGULPHNUFSAQNNIUVAAFZIAZKFXXNWCEABGJAUMGYEIEFVQXVHHHEDYUITRCQBXZHDPZQTOBECJVBZLACVXACZEDYOGVAVQRNWEOWGRAQYUEUESTEDQTYJUTEFOOITSHDDZHONJGBRCWNEQLZUTBNQI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PYMWBUPQBAAINMYZOYCEGNLFNNHZFEMSQVXJJGWBCRAVKZFWFBKMBRVBFDHKACSZIUWUXLWKFPKOCUQJEPQDZCMUJFLVCLIOQQRVKSWFIAKNHMRLNJTKGVNTGLCVPVMBLJANOBCXUGVWBJYSIXZQVAVFWILWFBQWNLTPMCYHRSKVHXLONRANWKWXUTHYQLIOFKGDBMSWDRCYRKVSAGGRJMWQYQFLMUIGGCLAUQAACTYLPZEOJBHMWRKHCRXGTGRMUPCPQKJRBLYDNPUGHCRBVYBAIRVCAWLBWVWCMKNBIRKJOUGYQEBQRHDSTWXDIWGRVMLIJFBWHLHCDAAVUDLZSCGQNOUXVUIVIZZZMDNMHGYPFUUDWKQGTAKKGCDFJFYJFNRZVXDPGZEAMWQVQZODKTXHIYFVKJSSAWVHYCUCZMLLBPXTILDYJQEMWDRUFKISOUVPUDTYPBFDAQUBXHUJYTAYNWVIJNUSQDTQDEMUAPWXRYUWONTBDZCHZOUEGPMWEZTQWWSHAYOBWVTDIMZYNVNZKUHOFCQKPHJXWNRCGUJEKOWSDAUGUTVWCVHEMOIRJJGTANUWTSAIXXEVZTBDHPGSRHHVWCDZVZYRJTLONIJVXEATHQXOUKBIGZONFRSZIOGWNTYAJYLQCGEOWY输出格式:请提交一个整数,不要填写任何多余的内容。输入样例:SLANQIAOZOEXCCGBMOAYWKHIBCCIPLJQSLANQIAORSFWFNYAXIFZVWALCOAIQNAL输出样例:4解决方案(1)输入数据很多,利用for循环简单有效的输入数据。(2)字母的走向不限,就是指包括从后向前反向查找。解决代码a = [input() for i in range(100)]count = 0# 横着找for i in range(100):for j in range(94):if a[i][j:j + 7] == "LANQIAO" or a[i][j:j + 7] ==  "OAIQNAL":count += 1# 竖着找for i in range(94):for j in range(100):if a[i][j] == "L" and a[i + 1][j] == "A" and a[i +  2][j] == "N" and a[i + 3][j] == "Q" and a[i + 4][j] == "I" and \a[i + 5][j] == "A"  and a[i + 6][j] == "O":count += 1elif a[i][j] == "O" and a[i + 1][j] == "A" and a[i  + 2][j] == "I" and a[i + 3][j] == "Q" and a[i + 4][j] == "N" and \a[i + 5][j] == "A"  and a[i + 6][j] == "L":count += 1# 斜着找(↖ or ↘)for i in range(94):for j in range(94):if a[i][j] == "L" and a[i + 1][j + 1] == "A" and  a[i + 2][j + 2] == "N" and a[i + 3][j + 3] == "Q" and a[i  + 4][j + 4] == "I" and \a[i + 5][j + 5] ==  "A" and a[i + 6][j + 6] == "O":count += 1elif a[i][j] == "O" and a[i + 1][j + 1] == "A" and  a[i + 2][j + 2] == "I" and a[i + 3][j + 3] == "Q" and \a[i + 4][j + 4] == "N"  and \a[i + 5][j + 5] ==  "A" and a[i + 6][j + 6] == "L":count += 1# 斜着找(↗ or ↙)a = [i[::-1] for i in a]  # 将每一行的str逆序for i in range(94):for j in range(94):if a[i][j] == "L" and a[i + 1][j + 1] == "A" and  a[i + 2][j + 2] == "N" and a[i + 3][j + 3] == "Q" and a[i  + 4][j + 4] == "I" and \a[i + 5][j + 5] ==  "A" and a[i + 6][j + 6] == "O":count += 1elif a[i][j] == "O" and a[i + 1][j + 1] == "A" and  a[i + 2][j + 2] == "I" and a[i + 3][j + 3] == "Q" and \a[i + 4][j + 4] == "N"  and \a[i + 5][j + 5] ==  "A" and a[i + 6][j + 6] == "L":count += 1print(count)运行实例:

结语我认为本题的重点实在如何确定for循环的范围以及如何更合理的解决从后往前的四个方向的寻找。主编:欧洋稿件来源:深度学习与文旅应用实验室(DLETA)

(0)

相关推荐

  • 一键对数据进行反向计分

    每次分析数据都觉得反向计分超级麻烦 无论是Excel操作还是spss都让人很烦,就写了一个python程序,从此再也不为此烦心啦 import numpy as npimport openpyxl# ...

  • Python|2018蓝桥杯真题练习—哪天返回

    问题描述 小明被不明势力劫持.后莫名其妙被扔到x星站再无问津.小明得知每天都有飞船飞往地球,但需要108元的船票,而他却身无分文.他决定在x星战打工.好心的老板答应包食宿,第1天给他1元钱.并且,以后 ...

  • Python | 2018蓝桥杯真题练习—猴子分香蕉

    问题描述 5只猴子是好朋友,在海边的椰子树上睡着了.这期间,有商船把一大堆香蕉忘记在沙滩上离去.第1只猴子醒来,把香蕉均分成5堆,还剩下1个,就吃掉并把自己的一份藏起来继续睡觉.第2只猴子醒来,重新把 ...

  • Python | 2020蓝桥杯真题-寻找2020

    问题描述小蓝有一个数字矩阵,里面只包含数字 0 和 2.小蓝很喜欢 2020,他想找到这个数字矩阵中有多少个 2020 .小蓝只关注三种构成 2020 的方式:· 同一行里面连续四个字符从左到右构成 ...

  • Python|2020蓝桥杯真题-跑步训练

    引言蓝桥杯是国内始终领跑的人才培养选拔模式并获得行业深度认可的IT类科技竞赛.问题描述小明要做一个跑步训练.初始时,小明充满体力,体力值计为 10000.如果小明跑步,每分钟损耗600 的体力.如果小 ...

  • Python|2020蓝桥杯python组 成绩统计

    引言蓝桥杯是国内始终领跑的人才培养选拔模式并获得行业深度认可的IT类科技竞赛.问题描述小蓝给学生们组织了一场考试,卷面总分为 100 分,每个学生的得分都是一个 0 到 100 的整数.如果得分至少是 ...

  • Python | 蓝桥杯-幸运数字的解决方法

    问题描述 到x星球旅行的游客都被发给一个整数,作为游客编号.x星的国王有个怪癖,他只喜欢数字3,5和7. 国王规定,游客的编号如果只含有因子:3,5,7,就可以获得一份奖品. 前10个幸运数字是:3 ...

  • Python|2020年蓝桥杯:蛇形填数

    问题描述如下图所示,小明用从 1 开始的正整数"蛇形"填充无限大的矩阵.1 2 6 7 15 -3 5 8 14 -4 9 13 -10 12 -11 --(1)容易看出矩阵第二行 ...

  • Python|蓝桥杯真题-单词分析

    问题描述 小蓝正在学习一门神奇的语言,这门语言中的单词都是由小写英文字母组成,有些单词很长,远远超过正常英文单词的长度.小蓝学了很长时间也记不住一些单词,他准备不再完全记忆这些单词,而是根据单词中哪个 ...

  • Python|蓝桥杯之最长公共前缀

    问题描述 编写一个函数来查找字符串数组中的最长公共前缀. 如果不存在公共前缀,返回空字符串 "". 示例 1: 输入:["flower","flow& ...