Os irmãos da ordem de São Golfo, o Conciso, têm a tradição de recitar uma breve oração sempre que vêem alguém fazer o sinal da cruz . Devido ao alto nível de pecado medido entre os turistas recentemente, eles instalaram o sistema de CFTV no mosteiro e contrataram você para ajudá-los a manter a velha tradição viva na era da IA.
Sua tarefa é analisar a produção do software de rastreamento de dedos dos frades e dizer quantas orações são devidas. A entrada é uma matriz contendo números inteiros entre 0 e 4. 1,2,3,4 representam as posições dos dedos em momentos consecutivos no tempo. 0 representa não dedos.
O One True Way TM para atravessar a si mesmo é:
.1.
3.4
.2.
("." corresponde a qualquer dígito). No entanto, devido à incerteza sobre a rotação da câmera e à presença de piedosos irmãos ortodoxos orientais na multidão (cuja One True Way TM está na direção oposta lateral), você deve contar todas as rotações e reflexões também:
.4. .2. .3. .1. .3. .2. .4.
1.2 4.3 2.1 4.3 1.2 3.4 2.1
.3. .1. .4. .2. .4. .1. .3.
Um dígito pode fazer parte de várias cruzes. Ajude os frades a determinar o número de vezes que sua IA deve .pray()
contar contando quantas das submatrizes 3x3 acima estão presentes. Escreva um programa ou uma função. Receba informações de qualquer forma conveniente e razoável.
Casos de testamento:
// in
[[0,4,2,0],
[1,3,2,4],
[2,3,1,0]]
// out
2
// in
[[4,3,3,2,4,4,1,3,2,2],
[0,3,0,2,1,1,2,3,2,3],
[0,3,1,3,2,4,3,3,1,1],
[4,3,2,3,2,4,1,4,2,3],
[0,4,2,3,4,0,2,3,2,4],
[2,1,0,0,2,0,0,1,2,4],
[4,0,3,1,3,2,0,3,2,3],
[1,4,3,3,1,4,0,1,4,4],
[0,2,4,3,4,3,1,3,0,4],
[3,0,1,0,4,0,3,3,3,3]]
// out
3
// in
[[3,2,3,1,0,3,4,2,1,1,1,1,4,0,1,3,1,1,2,1,1,3,0,1,0,1,1,0,0,1,0,3,4,0,1,1,2,3,1,2,4,1,0,2,3,0,2,4,3,2],
[2,4,1,1,0,3,0,2,4,2,3,2,1,3,0,2,3,2,4,4,4,3,2,1,1,3,2,1,2,3,2,4,0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,2,4,3,3,3,3,1,2,2,3,3,3,1,3,4],
[3,4,1,2,1,1,1,0,4,0,1,1,0,4,1,3,1,1,2,0,2,1,4,1,4,4,3,2,0,3,0,3,0,1,1,2,1,3,0,4,4,2,2,2,1,3,4,1,1,1],
[3,0,1,4,2,0,0,3,1,1,1,4,4,0,2,2,0,4,0,3,1,0,2,2,4,4,4,0,4,4,4,4,4,4,3,0,4,4,4,1,2,4,4,3,0,0,4,0,4,2],
[2,0,1,2,1,1,3,0,3,1,0,4,3,1,2,1,1,3,0,1,2,4,2,1,2,3,4,2,4,4,2,2,3,4,0,0,1,0,0,4,1,3,3,4,1,2,1,3,3,2],
[4,0,2,0,3,1,2,1,1,1,1,2,3,0,3,1,0,4,3,0,0,0,2,0,1,4,0,2,1,3,4,2,2,4,2,3,1,2,0,2,0,2,4,0,1,2,3,4,1,3],
[3,0,2,4,2,0,3,4,3,2,3,4,2,0,4,1,0,4,3,3,1,0,2,2,2,1,3,3,1,1,0,3,3,0,3,2,1,1,0,1,2,2,0,4,4,2,0,1,3,1],
[0,4,4,4,0,3,0,3,0,2,2,0,1,2,3,3,4,3,0,4,1,2,3,3,0,2,2,3,0,0,0,2,4,2,3,4,2,3,4,0,2,0,1,1,3,4,2,2,4,4],
[2,1,2,3,4,3,1,2,0,0,0,0,0,0,3,4,3,3,1,2,2,1,3,4,1,2,4,0,1,4,1,0,0,0,2,1,1,1,3,0,0,3,1,1,4,2,1,3,4,1],
[1,0,3,0,2,1,4,2,3,3,1,1,3,4,4,0,1,2,1,3,0,3,1,1,3,0,2,4,4,4,2,3,1,4,3,4,0,1,4,1,1,1,4,0,0,2,3,4,0,4]]
// out
8
"Bendito seja o menor dos mais curtos, porque vence o reino dos votos positivos." Livro de São Golfo 13:37
"Não usarás brechas, pois são as obras perversas de Lúcifer." - Carta ao Meta 13: 666
Ligeira visualização de pessoas que fazem a cruz
Obrigado @Tschallacka pela visualização.