Recent Changes - Search:

Oktatás

* Programozás 2
  + feladatsor
  + C feladatsor
  + Python feladatsor
  + GitHub oldal

* Szkriptnyelvek
  + feladatsor
  + quick link

* Adator. prog.
  + feladatsor
  + quick link

Teaching

* Prog. for Data Sci. (TODO)

teaching assets


Félévek

* 2025/26/1
* archívum


Linkek

* kalendárium
   - munkaszüneti napok '20
* tételsorok
* jegyzetek
* szakdolgozat / PhD
* ösztöndíjak
* certificates
* C lang.
* C++
* C#
* Clojure
* D lang.
* Java
* Nim
* Scala


[ edit | logout ]
[ sandbox | passwd ]

Hamming distance

See also:

(1) Hamming distance
import std.stdio;
import std.algorithm;  // count()
import std.range;  // zip()

int hamming_dist(const string s1, const string s2) pure
{
    if (s1.length != s2.length) {
        return -1;
    }
    // else
    // return cast(int) zip(s1, s2).count!((a, b) => a != b);  // error, unpacking doesn't work here
    return cast(int) zip(s1, s2).count!(t => t[0] != t[1]);
}

void main()
{
    const s1 = "toned";
    const s2 = "roses";

    const dist = hamming_dist(s1, s2);
    writeln(dist); // 3
}
Cloud City

  

Blogjaim, hobbi projektjeim

* The Ubuntu Incident
* Python Adventures
* @GitHub
* heroku
* extra
* haladó Python
* YouTube listák


Debrecen | la France


[ edit ]

Edit - History - Print *** Report - Recent Changes - Search
Page last modified on 2025 July 08, 17:54