Sha256: bfb721632fc23863f6f1abde51ee9a21af2da3728af3e03fa29e13eee7ad85a6

Contents?: true

Size: 531 Bytes

Versions: 168

Compression:

Stored size: 531 Bytes

Contents

unit uHamming;

interface

type
  THamming = class
  public
    class function Distance(strand1, strand2: string): integer; static;
  end;

implementation
uses System.SysUtils;

class function THamming.Distance(strand1, strand2: string): integer;
var i: integer;
begin
  if strand1.Length <> strand2.Length  then
    raise EArgumentException.Create('error: left and right strands must be of equal length');
  result := 0;
  for i := Low(strand1) to High(strand1) do
    result := result + ord(strand1[i] <> strand2[i]);
end;

end.

Version data entries

168 entries across 168 versions & 1 rubygems

Version Path
trackler-2.2.1.180 tracks/delphi/exercises/hamming/uHammingExample.pas
trackler-2.2.1.179 tracks/delphi/exercises/hamming/uHammingExample.pas
trackler-2.2.1.178 tracks/delphi/exercises/hamming/uHammingExample.pas
trackler-2.2.1.177 tracks/delphi/exercises/hamming/uHammingExample.pas
trackler-2.2.1.176 tracks/delphi/exercises/hamming/uHammingExample.pas
trackler-2.2.1.175 tracks/delphi/exercises/hamming/uHammingExample.pas
trackler-2.2.1.174 tracks/delphi/exercises/hamming/uHammingExample.pas
trackler-2.2.1.173 tracks/delphi/exercises/hamming/uHammingExample.pas
trackler-2.2.1.172 tracks/delphi/exercises/hamming/uHammingExample.pas
trackler-2.2.1.171 tracks/delphi/exercises/hamming/uHammingExample.pas
trackler-2.2.1.170 tracks/delphi/exercises/hamming/uHammingExample.pas
trackler-2.2.1.169 tracks/delphi/exercises/hamming/uHammingExample.pas
trackler-2.2.1.167 tracks/delphi/exercises/hamming/uHammingExample.pas
trackler-2.2.1.166 tracks/delphi/exercises/hamming/uHammingExample.pas
trackler-2.2.1.165 tracks/delphi/exercises/hamming/uHammingExample.pas
trackler-2.2.1.164 tracks/delphi/exercises/hamming/uHammingExample.pas
trackler-2.2.1.163 tracks/delphi/exercises/hamming/uHammingExample.pas
trackler-2.2.1.162 tracks/delphi/exercises/hamming/uHammingExample.pas
trackler-2.2.1.161 tracks/delphi/exercises/hamming/uHammingExample.pas
trackler-2.2.1.160 tracks/delphi/exercises/hamming/uHammingExample.pas