Menu Close

Afghanistan “DDXDDD-DD” tag validation…[Cprgm] FcukTheCode

Afghanistan has surrounded by attackers. A truck enters the city. The driver claims the load is food and medicine from Pakistanis.  Yasir is one of the soldier in Afghanistan. He doubts about the truck, maybe it’s from the siege. 

He knows that a tag is valid if the sum of every two consecutive digits of it is even and its letter is not a vowel. 
If the tag is invalid then Yasir need to arrest the driver of the truck with invalid tab. If it is valid the truck is allowed inside the country.

Can you help yasir in determine if he need to arrest or allow the truck?

Input: 12E345-67

The first line contains a string. And the format is "DDXDDD-DD", where D stands for a digit (non zero) and X is an uppercase english letter.


Output: Arrest

Print "Allowed" if the tag is valid, print "Arrest" otherwise.
#include <stdio.h>
#include <string.h>
int main()
{char tag[9];scanf("%s",tag);
int i=0,flag=0,c=0;
for(i=0;i<strlen(tag);i++){
    if(i==6){ continue;}
    else if(i==2){flag=(tag[i]=='A'||tag[i]=='E'||tag[i]=='I'||tag[i]=='O'||tag[i]=='U');}
    else{c=c + tag[i]-'0';}}
if(c%2==0 && flag==0) {printf("Allowed");}
else{printf("Arrest");}
return 0;
}

INPUT_1:
12E345-67

OUTPUT:
Arrest


INPUT_2:
11B242-73

OUTPUT:
Allowed


INPUT_3:
55C333-55

OUTPUT:
Arrest


INPUT_4:
44Z333-12

OUTPUT:
Allowed


ILLUSTRATION

EXECUTED USING PYTHON3