mirror of
https://codeberg.org/andyscott/exercism.git
synced 2024-12-22 14:43:10 -05:00
16 lines
409 B
Zig
16 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;
|
||
|
}
|