Verify the birth number A Norwegian Birth Number consists of 11 digits, composed the following way:

DDMMYYiiikk



DD is the day (from 01-31)
MM is the month (from 01-12)
YY is the year (from 00-99). It's not differentiated between 1900 and 2000
iii is the "individual number"
kk are two control digits


iii is determined by birthyear and gender the following way


0000-1900: Disregard, there is some inconsistency and special cases
1900-1999: Range = 000-499
2000-2039: Range = 500-999 
Female: Even numbers (and 000)
Male: Odd numbers


The control numbers are determined the following way:

Let's call the 11 digits:

d1 d2 m1 m2 y1 y2 i1 i2 i3 k1 k2


Then the control digits can be calculated using the equations:

k1 = 11 - ((3 * d1 + 7 * d2 + 6 * m1 + 1 * m2 + 8 * y1 + 9 * y2 + 4 * i1 + 5 * i2 + 2 * i3) mod 11)

k2 = 11 - ((5 * d1 + 4 * d2 + 3 * m1 + 2 * m2 + 7 * y1 + 6 * y2 + 5 * i1 + 4 * i2 + 3 * i3 + 2 * k1) mod 11).


For some combinations, the control numbers k1 or k2 can become 10. If that's the case, the number will be invalid.

If the sum modulus 11 for k1 or k2 is 11, i.e. k1 = 11 - (11 mod 11), then the control digit will be 0, not 11. 

Challenge

Take a letter, M or F (male or female), and an eleven digit number as input, and check if the Birth Number is valid according to the rules above. 


Input format and order is optional
The 11 numbers must be a single number or a consecutive string (you can't take the input as DD, MM, YY, iii, kk).
You can assume the date is valid (310699xxxxx will not be given as input)
Output is a truthy/falsy value (1/0, true/false etc.)
Program or function
All standard rules apply


You can find all valid numbers on this page (in Norwegian) by choosing a date.

Examples:

M, 01010099931
True

F, 01029042620
True

M, 0101009841
False

F, 01010051866
True  

F, 08021690849
True

M, 01029040105
True

M, 01029037473
False


Shortest code in bytes win.
JavaScript (ES2016), 275 259 255 254 252 Bytes

Golfed:


f=(g,I)=&gt;{[,d,m,y,i,k]=/(..)(..)(..)(...)(..)/.exec(I.padEnd(12)),v=g.charCodeAt()%2!=i%2|y&lt;=39&amp;i&lt;500,s=k=&gt;11-([...I].slice(0,-2).map((e,i)=&gt;e*[..."376189452543276543"][i+!k|9]).reduce((a,b)=&gt;a+b)+2*k)%11,[s(0),s(s(0))].map((s,i)=&gt;v&amp;=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) =&gt; {

    /* 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 &lt;= 39 &amp; i &lt; 500;

    let n = [..."376189452543276543"];
    /* This function computes k1 if given no arguments, k2 if given one argument */
    let s = k =&gt; 11 - ([...input].slice(0, -2).map((e, i) =&gt; e * n[i + !k | 9]).reduce((a, b) =&gt; a + b) + 2 * k) % 11;

    /* Validate the control numbers k */
    [s(0), s(s(0))].map((s, i) =&gt; violation &amp;= k[i] != s);

    return !violation;
}