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.139 tracks/delphi/exercises/hamming/uHammingExample.pas
trackler-2.2.1.138 tracks/delphi/exercises/hamming/uHammingExample.pas
trackler-2.2.1.137 tracks/delphi/exercises/hamming/uHammingExample.pas
trackler-2.2.1.136 tracks/delphi/exercises/hamming/uHammingExample.pas
trackler-2.2.1.135 tracks/delphi/exercises/hamming/uHammingExample.pas
trackler-2.2.1.134 tracks/delphi/exercises/hamming/uHammingExample.pas
trackler-2.2.1.133 tracks/delphi/exercises/hamming/uHammingExample.pas
trackler-2.2.1.132 tracks/delphi/exercises/hamming/uHammingExample.pas
trackler-2.2.1.131 tracks/delphi/exercises/hamming/uHammingExample.pas
trackler-2.2.1.130 tracks/delphi/exercises/hamming/uHammingExample.pas
trackler-2.2.1.129 tracks/delphi/exercises/hamming/uHammingExample.pas
trackler-2.2.1.128 tracks/delphi/exercises/hamming/uHammingExample.pas
trackler-2.2.1.127 tracks/delphi/exercises/hamming/uHammingExample.pas
trackler-2.2.1.126 tracks/delphi/exercises/hamming/uHammingExample.pas
trackler-2.2.1.125 tracks/delphi/exercises/hamming/uHammingExample.pas
trackler-2.2.1.124 tracks/delphi/exercises/hamming/uHammingExample.pas
trackler-2.2.1.123 tracks/delphi/exercises/hamming/uHammingExample.pas
trackler-2.2.1.122 tracks/delphi/exercises/hamming/uHammingExample.pas
trackler-2.2.1.121 tracks/delphi/exercises/hamming/uHammingExample.pas
trackler-2.2.1.120 tracks/delphi/exercises/hamming/uHammingExample.pas