#include <stdio.h>
int validateIrishLicense(int year, int halfYear, char County, int Sequence1);
int main(void) {
int valid=validateIrishLicense(13,1,'D',2156789);
printf("The license is valid or not (1=valid, 0=no): %i\n", valid
); return 0;
}
int validateIrishLicense(int year, int halfYear, char County, int Sequence1){
int check=0;
if (year>=13 & year<=24){
check+=1;
}
if (halfYear==1 | halfYear==2){
check+=1;
}
char valid_county[]= {'C','c','D','d','G','g','L','l','T','t','W','w'};
const VAL_COUNTIES=12;
for (int i=0; i < VAL_COUNTIES; i++) {
if (County==valid_county[i]){
check+=1;
}
}
int digits=1;
if (Sequence1>0){
while ((Sequence1/10)>0){
digits+=1;
Sequence1 /=10;
}
}
printf("Number of digits: %i\n", digits
); if (digits>=1 & digits<=6){
check+=1;
}
printf("Check value: %i\n", check
);
if (check==4){
return 1;
}
else{
return 0;
}
}
I2luY2x1ZGUgPHN0ZGlvLmg+CgppbnQgdmFsaWRhdGVJcmlzaExpY2Vuc2UoaW50IHllYXIsIGludCBoYWxmWWVhciwgY2hhciBDb3VudHksIGludCBTZXF1ZW5jZTEpOwoKaW50IG1haW4odm9pZCkgewoJaW50IHZhbGlkPXZhbGlkYXRlSXJpc2hMaWNlbnNlKDEzLDEsJ0QnLDIxNTY3ODkpOwogICAgcHJpbnRmKCJUaGUgbGljZW5zZSBpcyB2YWxpZCBvciBub3QgKDE9dmFsaWQsIDA9bm8pOiAlaVxuIiwgdmFsaWQpOwoJcmV0dXJuIDA7Cn0KCmludCB2YWxpZGF0ZUlyaXNoTGljZW5zZShpbnQgeWVhciwgaW50IGhhbGZZZWFyLCBjaGFyIENvdW50eSwgaW50IFNlcXVlbmNlMSl7CgogICAgaW50IGNoZWNrPTA7CgogICAgaWYgKHllYXI+PTEzICYgeWVhcjw9MjQpewogICAgICAgIGNoZWNrKz0xOwogICAgfQoKICAgIGlmIChoYWxmWWVhcj09MSB8IGhhbGZZZWFyPT0yKXsKICAgICAgICAgY2hlY2srPTE7CiAgICB9CgogICAgY2hhciB2YWxpZF9jb3VudHlbXT0geydDJywnYycsJ0QnLCdkJywnRycsJ2cnLCdMJywnbCcsJ1QnLCd0JywnVycsJ3cnfTsKICAgIGNvbnN0IFZBTF9DT1VOVElFUz0xMjsKCiAgICAgZm9yIChpbnQgaT0wOyBpIDwgVkFMX0NPVU5USUVTOyBpKyspIHsKICAgICAgICAgICAgaWYgKENvdW50eT09dmFsaWRfY291bnR5W2ldKXsKICAgICAgICAgICAgY2hlY2srPTE7CiAgICAgICAgICAgIH0KICAgICAgICB9CgogICAgaW50IGRpZ2l0cz0xOwogICAgaWYgKFNlcXVlbmNlMT4wKXsKICAgICAgICB3aGlsZSAoKFNlcXVlbmNlMS8xMCk+MCl7CiAgICAgICAgICAgIGRpZ2l0cys9MTsKICAgICAgICAgICAgU2VxdWVuY2UxIC89MTA7CiAgICAgICAgfQogICAgfQogICAgcHJpbnRmKCJOdW1iZXIgb2YgZGlnaXRzOiAlaVxuIiwgZGlnaXRzKTsKICAgIGlmIChkaWdpdHM+PTEgJiBkaWdpdHM8PTYpewogICAgICAgIGNoZWNrKz0xOwogICAgfQogICAgcHJpbnRmKCJDaGVjayB2YWx1ZTogJWlcbiIsIGNoZWNrKTsKCiAgICBpZiAoY2hlY2s9PTQpewogICAgICAgIHJldHVybiAxOwogICAgfQogICAgZWxzZXsKICAgICAgICByZXR1cm4gMDsKICAgIH0KfQo=