#include <stdio.h>
int validateIrishLicense(int year, int halfYear, char County, int Sequence1);
int main(void) {
int valid=validateIrishLicense(13,1,'D',21);
printf("Valid or not %i\n", valid
);
int retVal = validateIrishLicense (13, 3, 'K', 1);
printf("Valid or not retVal: %i\n", retVal
);
int retVal2 = validateIrishLicense (24,1,'C',1245891);
printf("Valid or not retVal2: %i\n", retVal2
); 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;
}
}
if (digits>=1 & digits<=6){
check+=1;
}
if (check==4){
return 1;
}
else{
return 0;
}
}
I2luY2x1ZGUgPHN0ZGlvLmg+CgppbnQgdmFsaWRhdGVJcmlzaExpY2Vuc2UoaW50IHllYXIsIGludCBoYWxmWWVhciwgY2hhciBDb3VudHksIGludCBTZXF1ZW5jZTEpOwoKaW50IG1haW4odm9pZCkgewoJaW50IHZhbGlkPXZhbGlkYXRlSXJpc2hMaWNlbnNlKDEzLDEsJ0QnLDIxKTsKICAgIHByaW50ZigiVmFsaWQgb3Igbm90ICVpXG4iLCB2YWxpZCk7CgogICAgaW50IHJldFZhbCA9IHZhbGlkYXRlSXJpc2hMaWNlbnNlICgxMywgMywgJ0snLCAxKTsgCiAgICBwcmludGYoIlZhbGlkIG9yIG5vdCByZXRWYWw6ICVpXG4iLCByZXRWYWwpOwoKICAgIGludCByZXRWYWwyID0gdmFsaWRhdGVJcmlzaExpY2Vuc2UgKDI0LDEsJ0MnLDEyNDU4OTEpOwogICAgcHJpbnRmKCJWYWxpZCBvciBub3QgcmV0VmFsMjogJWlcbiIsIHJldFZhbDIpOwoJcmV0dXJuIDA7Cn0KCmludCB2YWxpZGF0ZUlyaXNoTGljZW5zZShpbnQgeWVhciwgaW50IGhhbGZZZWFyLCBjaGFyIENvdW50eSwgaW50IFNlcXVlbmNlMSl7CgogICAgaW50IGNoZWNrPTA7CgogICAgaWYgKHllYXI+PTEzICYgeWVhcjw9MjQpewogICAgICAgIGNoZWNrKz0xOwogICAgfQoKICAgIGlmIChoYWxmWWVhcj09MSB8IGhhbGZZZWFyPT0yKXsKICAgICAgICAgY2hlY2srPTE7CiAgICB9CgogICAgY2hhciB2YWxpZF9jb3VudHlbXT0geydDJywnYycsJ0QnLCdkJywnRycsJ2cnLCdMJywnbCcsJ1QnLCd0JywnVycsJ3cnfTsKICAgIGNvbnN0IFZBTF9DT1VOVElFUz0xMjsKCiAgICAgZm9yIChpbnQgaT0wOyBpIDwgVkFMX0NPVU5USUVTOyBpKyspIHsKICAgICAgICAgICAgaWYgKENvdW50eT09dmFsaWRfY291bnR5W2ldKXsKICAgICAgICAgICAgY2hlY2srPTE7CiAgICAgICAgICAgIH0KICAgICAgICB9CgogICAgaW50IGRpZ2l0cz0xOwogICAgaWYgKFNlcXVlbmNlMT4wKXsKICAgICAgICB3aGlsZSAoKFNlcXVlbmNlMS8xMCk+MCl7CiAgICAgICAgICAgIGRpZ2l0cys9MTsKICAgICAgICAgICAgU2VxdWVuY2UxIC89MTA7CiAgICAgICAgfQogICAgfQogICAgaWYgKGRpZ2l0cz49MSAmIGRpZ2l0czw9Nil7CiAgICAgICAgY2hlY2srPTE7CiAgICB9CgogICAgaWYgKGNoZWNrPT00KXsKICAgICAgICByZXR1cm4gMTsKICAgIH0KICAgIGVsc2V7CiAgICAgICAgcmV0dXJuIDA7CiAgICB9Cn0K