#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);
int retVal2 = validateIrishLicense (24,1,'C',1245891);
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+CgppbnQgdmFsaWRhdGVJcmlzaExpY2Vuc2UoaW50IHllYXIsIGludCBoYWxmWWVhciwgY2hhciBDb3VudHksIGludCBTZXF1ZW5jZTEpOwoKaW50IG1haW4odm9pZCkgewoJaW50IHZhbGlkPXZhbGlkYXRlSXJpc2hMaWNlbnNlKDEzLDEsJ0QnLDIxKTsKICAgIGludCByZXRWYWwgPSB2YWxpZGF0ZUlyaXNoTGljZW5zZSAoMTMsIDMsICdLJywgMSk7IAogICAgaW50IHJldFZhbDIgPSB2YWxpZGF0ZUlyaXNoTGljZW5zZSAoMjQsMSwnQycsMTI0NTg5MSk7CglyZXR1cm4gMDsKfQoKaW50IHZhbGlkYXRlSXJpc2hMaWNlbnNlKGludCB5ZWFyLCBpbnQgaGFsZlllYXIsIGNoYXIgQ291bnR5LCBpbnQgU2VxdWVuY2UxKXsKCiAgICBpbnQgY2hlY2s9MDsKCiAgICBpZiAoeWVhcj49MTMgJiB5ZWFyPD0yNCl7CiAgICAgICAgY2hlY2srPTE7CiAgICB9CgogICAgaWYgKGhhbGZZZWFyPT0xIHwgaGFsZlllYXI9PTIpewogICAgICAgICBjaGVjays9MTsKICAgIH0KCiAgICBjaGFyIHZhbGlkX2NvdW50eVtdPSB7J0MnLCdjJywnRCcsJ2QnLCdHJywnZycsJ0wnLCdsJywnVCcsJ3QnLCdXJywndyd9OwogICAgY29uc3QgVkFMX0NPVU5USUVTPTEyOwoKICAgICBmb3IgKGludCBpPTA7IGkgPCBWQUxfQ09VTlRJRVM7IGkrKykgewogICAgICAgICAgICBpZiAoQ291bnR5PT12YWxpZF9jb3VudHlbaV0pewogICAgICAgICAgICBjaGVjays9MTsKICAgICAgICAgICAgfQogICAgICAgIH0KCiAgICBpbnQgZGlnaXRzPTE7CiAgICBpZiAoU2VxdWVuY2UxPjApewogICAgICAgIHdoaWxlICgoU2VxdWVuY2UxLzEwKT4wKXsKICAgICAgICAgICAgZGlnaXRzKz0xOwogICAgICAgICAgICBTZXF1ZW5jZTEgLz0xMDsKICAgICAgICB9CiAgICB9CiAgICBwcmludGYoIk51bWJlciBvZiBkaWdpdHM6ICVpXG4iLCBkaWdpdHMpOwogICAgaWYgKGRpZ2l0cz49MSAmIGRpZ2l0czw9Nil7CiAgICAgICAgY2hlY2srPTE7CiAgICB9CiAgICBwcmludGYoIkNoZWNrIHZhbHVlOiAlaVxuIiwgY2hlY2spOwoKICAgIGlmIChjaGVjaz09NCl7CiAgICAgICAgcmV0dXJuIDE7CiAgICB9CiAgICBlbHNlewogICAgICAgIHJldHVybiAwOwogICAgfQp9Cg==