mirror of
https://codeberg.org/andyscott/exercism.git
synced 2024-11-14 07:10:48 -05:00
15 lines
409 B
Zig
15 lines
409 B
Zig
pub const DnaError = error{
|
|
EmptyDnaStrands,
|
|
UnequalDnaStrands,
|
|
};
|
|
|
|
pub fn compute(first: []const u8, second: []const u8) DnaError!usize {
|
|
if (first.len == 0 or second.len == 0) return DnaError.EmptyDnaStrands;
|
|
if (first.len != second.len) return DnaError.UnequalDnaStrands;
|
|
|
|
var count: usize = 0;
|
|
for (first, second) |i, j| {
|
|
if (i != j) count += 1;
|
|
}
|
|
return count;
|
|
}
|