mirror of
https://codeberg.org/andyscott/exercism.git
synced 2024-11-12 14:40:46 -05:00
19 lines
474 B
Zig
19 lines
474 B
Zig
|
const std = @import("std");
|
||
|
|
||
|
pub fn score(s: []const u8) u32 {
|
||
|
var total: u32 = 0;
|
||
|
for (s) |c| {
|
||
|
total += switch (std.ascii.toLower(c)) {
|
||
|
'a', 'e', 'i', 'o', 'u', 'l', 'n', 'r', 's', 't' => 1,
|
||
|
'd', 'g' => 2,
|
||
|
'b', 'c', 'm', 'p' => 3,
|
||
|
'f', 'h', 'v', 'w', 'y' => 4,
|
||
|
'k' => 5,
|
||
|
'j', 'x' => 8,
|
||
|
'q', 'z' => 10,
|
||
|
else => unreachable,
|
||
|
};
|
||
|
}
|
||
|
return total;
|
||
|
}
|