From 4cc33d7bc19a7d1f78343191e9de095548dcde4d Mon Sep 17 00:00:00 2001 From: kukemuna Date: Sun, 25 Feb 2024 11:56:39 +0200 Subject: [PATCH] automated commit by check50 [check50=True] --- substitution.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/substitution.c b/substitution.c index ebda538..4732453 100644 --- a/substitution.c +++ b/substitution.c @@ -32,15 +32,19 @@ int validate_key(string key) { int sum = 0; - for (int i = 0; i < strlen(key); i++) + for (char c = 'A'; c <= 'Z'; c++) { - if (isalpha(key[i])) + for (int i = 0; i < 26; i++) { - sum += toupper(key[i]); + if (toupper(key[i]) == c) + { + sum++; + break; + } } } - if (sum == 2015) // Sum of 26 unique uppercase characters + if (sum == 26) // Sum of 26 unique uppercase characters, but also MMCcEFGHIJKLMNOPQRqTUVWXeZ { return 0; }