How to convert "7H15 M3554G3" into words in Pascal

1 Answer

0 votes
// 7H15 M3554G3 is written in leet speak, where numbers resemble letters. 
// place each leetspeak character with its matching letter 
// (7 -> T, 1 -> I, 5 -> S, 3 -> E) and build a new string
// 7H15 -> THIS | M3554G3 -> MESSAGE
 
// Your brain can interpret distorted or number‑substituted letters 
// surprisingly well because it recognizes the overall word 
// shapes and patterns, not just individual characters.

program LeetToText;

{$mode objfpc}

function ConvertChar(c: Char): Char;
begin
  case c of
    '7': Result := 'T';
    '1': Result := 'I';
    '5': Result := 'S';
    '3': Result := 'E';
    '4': Result := 'A';
    '0': Result := 'O';
  else
    Result := c;  // keep letters like H, M, G
  end;
end;

function LeetToText(const s: String): String;
var
  i: Integer;
begin
  SetLength(Result, Length(s));
  for i := 1 to Length(s) do
    Result[i] := ConvertChar(s[i]);
end;

var
  input: String;

begin
  input := '7H15 M3554G3';

  WriteLn(LeetToText(input));
end.



(*
run:

THIS MESSAGE

*)

 



answered 4 hours ago by avibootz
edited 3 hours ago by avibootz
...