varuchyan
10.03.2021 01:45

Cell Tower is an interesting daily puzzle game, https://www.andrewt.net/puzzles/cell-tower/. Here we consider a simplified version. You are given 8×8 square with one character in each cell and a dictionary. Please divide the square into several parts, so that each part is a connected block and the characters in this connected block (from top to bottom and from left to right) make up a valid word (i.e., appear in the dictionary).

Two cells A,B are called connected pair, if A and B directly share the same side, or there exists another cell C so that both A,C and B,C are connected pairs.

A group of cells is called connected block if any pair of cells in this group are connected pairs and the size of this group is either 3 or 4.

input
1 1 1 1 2 3 3 3
0 4 4 4 2 2 2 3
0 0 5 5 6 6 7 7
0 9 5 5 6 8 7 7
9 9 9 1 6 8 8 8
3 1 1 1 2 2 2 2
4 5 6 0 0 4 4 3
7 8 9 0 0 4 3 3
16
1111
2222
3333
444
0000
5555
6666
7777
8888
9999
111
333
3456
789
3478
569

output
2

Нажмите на рекламу ниже и сразу увидите ответ
↓
Популярные вопросы:
Ответ:
vladyulin
29.04.2021 23:44
1.
var
  s: string;
  i, count: integer;
begin
  writeln('Vvedite stroky: ');
  readln(s);
  for i := 1 to length(s) - 2 do
    if copy(s, i, 3) = 'abc' then
      count := count + 1;
  writeln('Kol-vo: ', count);
end.
2.
var
  s1, s2: string;
  i, len1, len2: integer;
begin
  writeln('Vvedite stroky 1: ');
  readln(s1);
  writeln('Vvedite stroky 2: ');
  readln(s2);
  len1 := length(s1);
  len2 := length(s2);
  if len1 > len2 then writeln('1 stroka dlinnee')
  else if len1 < len2 then writeln('2 stroka dlinnee')
  else writeln('dlini strok ravnie')
end.
3.
var
  s1, s2, s3: string;
begin
  writeln('Vvedite stroky 1: ');
  readln(s1);
  writeln('Vvedite stroky 2: ');
  readln(s2);
  s3 := s1[1] + s1[2] + s2[1] + s2[2];
  writeln('Novaja stroka: ', s3);
end.
0,0(0 оценок)
Ответ:
tarasIT
15.10.2022 21:16
Rem BASIC-256
cls
errors = 0
print "Введите текст > ";

rem Пользователь вводит текст
input a$

rem Перебираем все буквы с начала и до предпоследней
for i=1 to length(a$)-1

rem Если встречаем букву Ч или Щ
if mid(a$, i, 1) = "ч" or mid(a$, i, 1) = "щ" then

rem Тогда проверяем следующую за ней букву.
rem Если это буква я, тогда подсчитываем очередную ошибку
if mid(a$, i + 1, 1) = "я" then errors = errors + 1
end if

rem Переходим к следующей букве
next i

rem Вывод результата
print "Количество ошибок в тексте ";
print errors

rem Конец программы
end
0,0(0 оценок)
Полный доступ
Позволит учиться лучше и быстрее. Неограниченный доступ к базе и ответам от экспертов и ai-bota Оформи подписку
logo
Начни делиться знаниями
Вход Регистрация
Что ты хочешь узнать?
Спроси ai-бота