igorich1376

Is_one_away

Aug 24th, 2024
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 0.34 KB | None | 0 0
  1. ##
  2. function is_one_away(word1, word2: string): boolean;
  3. begin
  4. var cnt := 0;
  5. if (Length(word1) = Length(word2)) then
  6.     for var i := 1 to Length(word1) do
  7.         if (word1[i] = word2[i]) then cnt +=1;
  8. if (cnt = 3) then result := true else result := false;
  9. end;
  10. //
  11. var (word1, word2) := ReadString2;
  12. Print(is_one_away(word1, word2));
Advertisement
Add Comment
Please, Sign In to add comment