Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
exercises(pangram): test more non-alphanumeric printable ASCII (exerc…
…ism#361) Check the handling of non-alphanumeric ASCII input more thoroughly. A faulty solution from the wild that is caught by this test but not by the others: const std = @import("std"); pub fn isPangram(str: []const u8) bool { var seen = std.bit_set.StaticBitSet('z' - 'a' + 1).initEmpty(); for (str) |c| { const index = std.math.sub(u8, std.ascii.toLower(c), 'a') catch continue; // if c > 'z' then index > 25 seen.set(index); // panics when index >= 26 } return ~seen.mask == 0; }
- Loading branch information