#include <stdio.h>
int validateIrishLicense(int year, int halfYear, char County, int Sequence1);
int main(void) {
int valid=validateIrishLicense(13,1,'D',21);
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+CgppbnQgdmFsaWRhdGVJcmlzaExpY2Vuc2UoaW50IHllYXIsIGludCBoYWxmWWVhciwgY2hhciBDb3VudHksIGludCBTZXF1ZW5jZTEpOwoKaW50IG1haW4odm9pZCkgewoJaW50IHZhbGlkPXZhbGlkYXRlSXJpc2hMaWNlbnNlKDEzLDEsJ0QnLDIxKTsKICAgIGludCByZXRWYWwgPSB2YWxpZGF0ZUlyaXNoTGljZW5zZSAoMTMsIDMsICdLJywgMSk7IAogICAgcHJpbnRmKCJWYWxpZCBvciBub3QgcmV0VmFsOiAlaVxuIiwgcmV0VmFsKTsKCiAgICBpbnQgcmV0VmFsMiA9IHZhbGlkYXRlSXJpc2hMaWNlbnNlICgyNCwxLCdDJywxMjQ1ODkxKTsKICAgIHByaW50ZigiVmFsaWQgb3Igbm90IHJldFZhbDI6ICVpXG4iLCByZXRWYWwyKTsKCXJldHVybiAwOwp9CgppbnQgdmFsaWRhdGVJcmlzaExpY2Vuc2UoaW50IHllYXIsIGludCBoYWxmWWVhciwgY2hhciBDb3VudHksIGludCBTZXF1ZW5jZTEpewoKICAgIGludCBjaGVjaz0wOwoKICAgIGlmICh5ZWFyPj0xMyAmIHllYXI8PTI0KXsKICAgICAgICBjaGVjays9MTsKICAgIH0KCiAgICBpZiAoaGFsZlllYXI9PTEgfCBoYWxmWWVhcj09Mil7CiAgICAgICAgIGNoZWNrKz0xOwogICAgfQoKICAgIGNoYXIgdmFsaWRfY291bnR5W109IHsnQycsJ2MnLCdEJywnZCcsJ0cnLCdnJywnTCcsJ2wnLCdUJywndCcsJ1cnLCd3J307CiAgICBjb25zdCBWQUxfQ09VTlRJRVM9MTI7CgogICAgIGZvciAoaW50IGk9MDsgaSA8IFZBTF9DT1VOVElFUzsgaSsrKSB7CiAgICAgICAgICAgIGlmIChDb3VudHk9PXZhbGlkX2NvdW50eVtpXSl7CiAgICAgICAgICAgIGNoZWNrKz0xOwogICAgICAgICAgICB9CiAgICAgICAgfQoKICAgIGludCBkaWdpdHM9MTsKICAgIGlmIChTZXF1ZW5jZTE+MCl7CiAgICAgICAgd2hpbGUgKChTZXF1ZW5jZTEvMTApPjApewogICAgICAgICAgICBkaWdpdHMrPTE7CiAgICAgICAgICAgIFNlcXVlbmNlMSAvPTEwOwogICAgICAgIH0KICAgIH0KICAgIGlmIChkaWdpdHM+PTEgJiBkaWdpdHM8PTYpewogICAgICAgIGNoZWNrKz0xOwogICAgfQoKICAgIGlmIChjaGVjaz09NCl7CiAgICAgICAgcmV0dXJuIDE7CiAgICB9CiAgICBlbHNlewogICAgICAgIHJldHVybiAwOwogICAgfQp9Cg==