 # LOVNUM - Editorial

Author: Vaishnavi Chouhan
Tester: Rishabh Rathi

CAKEWALK

None

# PROBLEM:

Ganesha loves the numbers whose mirror image is exactly the number itself provided the mirror is placed below the number.

You are given a number N. Tell whether the number is lovely or not.

# EXPLANATION:

The mirror image of 0, 1, 3, and 8 is the digit itself provided the mirror is kept below the number as said in the problem.

So, the numbers containing only the digits 0, 1, 3, or 8 are LOVELY, rest all other cases form NOT LOVELY numbers.

# SOLUTIONS:

Setter's Solution (CPP)
``````#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;

void solve() {
string s; cin>>s;
ll f = 0;

for(ll i=0; i<s.size(); i++) {
if(s[i]=='2' ||  s[i]=='4' || s[i]=='5' || s[i]=='6' || s[i]=='7' || s[i]=='9') {
f = 1;
break;
}
}

if(f==1)
cout<<"NOT LOVELY\n";
else
cout<<"LOVELY\n";
}

int main() {
ll t; cin>>t;

while(t--) {
solve();
}

return 0;
}
``````
Tester's Solution (Python)
``````def solve(n):
lovely_digits = ["0", "1", "3", "8"]

for digit in n:
if digit not in lovely_digits:
return "NOT LOVELY"

return "LOVELY"

t = int(input())

for _ in range(t):
n = input()
ans = solve(n)
print(ans)
``````

Feel free to share your approach. In case of any doubt or anything is unclear, please ask it in the comments section. Any suggestions are welcome 