Verify the birth number
JavaScript (ES2016), 275 259 255 254 252 Bytes
Golfed:
f=(g,I)=>{[,d,m,y,i,k]=/(..)(..)(..)(...)(..)/.exec(I.padEnd(12)),v=g.charCodeAt()%2!=i%2|y<=39&i<500,s=k=>11-([...I].slice(0,-2).map((e,i)=>e*[..."376189452543276543"][i+!k|9]).reduce((a,b)=>a+b)+2*k)%11,[s(0),s(s(0))].map((s,i)=>v&=k[i]!=s);return!v}
Tests:
for (let args of [
["M", "01010099931"], // true
["F", "01029042620"], // true
["M", "0101009841"], // false
["F", "01010051866"], // true
["F", "08021690849"], // true
["M", "01029040105"], // true
["M", "01029037473"] // false
]) {
console.log(f(...args));
}
Ungolfed:
let f = (g, input) => {
/* Sanitize input, destructure arguments via RegExp */
let [, d, m, y, i, k] = /(..)(..)(..)(...)(..)/.exec(input.padRight(12));
/* Validate gender and year */
let violation = g.charCodeAt() % 2 != i % 2 | y <= 39 & i < 500;
let n = [..."376189452543276543"];
/* This function computes k1 if given no arguments, k2 if given one argument */
let s = k => 11 - ([...input].slice(0, -2).map((e, i) => e * n[i + !k | 9]).reduce((a, b) => a + b) + 2 * k) % 11;
/* Validate the control numbers k */
[s(0), s(s(0))].map((s, i) => violation &= k[i] != s);
return !violation;
}
Python 3, 227 221 bytes
Function that takes two arguments, the gender 'm', and the birthnumber 'n', both as strings. There may be some more golfing to be done, especially in the last line. I'll keep working on it.
def a(m,n):
o=[3,7,6,1,8,9,4,5,2];t=[5,4,3,2,7,6,5,4,3,2];n=list(map(int,n));y=z=b=0;q=11
for i in n[:9]:z+=o[b]*i;y+=t[b]*i;b+=1
print((q-z%q)%q==n[9] and (q-(y-z-z)%q)%q==n[-1] and len(n)<12 and ord(m)%2==n[8]%2)