diff options
| author | DJ O'Leary <dijitol@proton.me> | 2025-12-03 03:56:21 +0100 |
|---|---|---|
| committer | DJ O'Leary <dijitol@proton.me> | 2025-12-03 03:56:21 +0100 |
| commit | 2c07926330771788a0a9b789b7397a159475bea7 (patch) | |
| tree | 4a9f0f948929388aa22e224d39244c4ec1d6a73d /2025/ocaml/lib/application/d02p02.ml | |
| parent | 87f01faf1430393c1c062da2a9511c6767013ecb (diff) | |
feat(2025d2p2): remove existing rules and make validation rules OR instead of AND
Diffstat (limited to '2025/ocaml/lib/application/d02p02.ml')
| -rw-r--r-- | 2025/ocaml/lib/application/d02p02.ml | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/2025/ocaml/lib/application/d02p02.ml b/2025/ocaml/lib/application/d02p02.ml index 26cf109..c936b28 100644 --- a/2025/ocaml/lib/application/d02p02.ml +++ b/2025/ocaml/lib/application/d02p02.ml @@ -19,15 +19,10 @@ let collect_all = List.concat_map (fun range -> Range.collect range) let pp_collection = List.iter (fun c -> Logs.debug (fun m -> m "%s" (ID.pp c))) -(** [rules] is a list of rules that [ID]s must pass to be considered invalid. *) -let rules = - [ (fun id -> String.length (ID.to_string id) mod 2 = 0) - ; (fun id -> - let id' = ID.to_string id in - let id_len = String.length id' in - let left = String.sub id' 0 (id_len / 2) in - let right = String.sub id' (id_len / 2) (id_len / 2) in - String.equal left right ) ] +(** [rules] is a list of rules that denotes any ID returning true from ANY as invalid. *) +let rules = [ + (** a subset of the digits of the whole number up to len/2 is equal to segments of equal length of the remaining string *) +] (** [is_invalid id] is [true] for an [id] that passes all of the rules and is considered invalid. *) let is_invalid = ID.validate rules |
