cybersecurity · intermediate · ~15 min · safe pentest lab
Combine signals into a 0-100 DGA score using an exact integer formula.
Combine features into one score:
int dga_score(const char *label);
With L=strlen (return 0 if L==0), cr=longest consonant run, digits=count of ASCII digits, vowels=count of vowels (case-insensitive):
T1 = 10*cr, capped at 40T2 = (digits*50)/LT3 = ((vowels*100)/L < 20) ? 20 : 0score = T1 + T2 + T3, capped at 100All divisions are integer. Return score.
A domain label string.
Integer score 0-100.
Use integer arithmetic exactly as specified so the score is deterministic.
#include <stddef.h>
/* DGA score 0..100 by the EXACT formula (all integer division):
L=strlen (return 0 if L==0); cr=longest consonant run; digits=#ASCII digits;
vowels=#vowels(aeiou, case-insensitive);
T1=10*cr, cap at 40; T2=(digits*50)/L; T3=((vowels*100)/L < 20)?20:0;
score=T1+T2+T3, cap at 100. */
int dga_score(const char *label){ (void)label; return 0; }
Using floating point (rounding drift); forgetting to cap T1 at 40 or the score at 100.
Empty label -> 0; a very consonant/digit-heavy label approaches 100.
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.