Search is not available for this dataset
name
stringlengths
2
112
description
stringlengths
29
13k
source
int64
1
7
difficulty
int64
0
25
solution
stringlengths
7
983k
language
stringclasses
4 values
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
ls=input() i47=0 for i in ls: if i=="4" or i=="7" : i47+=1 bo=True s=list(str(i47)) for i in s: if i=="4" or i=="7": bo =True else: bo=False if bo: print ("YES") else : print ("NO")
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
n = raw_input() n = n.count('4') + n.count('7') n = set(list(str(n))) if len(n)<=2 and ('7' in n or '4' in n): print 'YES' else: print "NO"
PYTHON
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
print('YNEOS'[sum([x in '47' for x in input()]) not in (4,7)::2])
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
t = input() c7 = t.count('7') c4 = t.count('4') c = c7 + c4 print("YES" if c==7 or c==4 else "NO") # if t.count("4") <= 0 or t.count("7") <= 0: # print("NO") # else: # print("YES" if len(t.replace("4", "").replace("7", "")) == 0 else "NO")
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
a = list(input()) if '4' in a or '7' in a: c = a.count('4') + a.count('7') if c == 4 or c == 7: print('YES') else: print('NO') else: print('NO')
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
#include <bits/stdc++.h> using namespace std; int main() { long long n; int digit, lucky = 0; cin >> n; while (n != 0) { digit = n % 10; n = n / 10; if (digit == 4 || digit == 7) { lucky++; } } if (lucky == 4 || lucky == 7) cout << "YES"; else cout << "NO"; return 0; }
CPP
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
a = input() r = 0 for i in range(len(a)) : if a[i] == '4' or a[i] == '7' : r += 1 if (r == 4 or r == 7) and r != 0: print('YES') else : print('NO')
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
def isSeven(n): s=0 for i in range(0,len(n)): if(n[i]=='7' or n[i]=='4'): s=s+1 return s n=input() t=isSeven(n) if(t==4 or t==7): print("YES") else: print("NO")
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
s=input() ans=["NO","YES"] print(ans[(s.count('4')+s.count('7'))== 4 or (s.count('4')+s.count('7'))==7 ])
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
n=eval(input()) x=list(str(n)) a=x.count('4') b=x.count('7') c=a+b if(c==4 or c==7 or c==47 or c==44 or c==74 or c==77): print("YES") else: print("NO")
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
myStr = str(input()) luckyCounter = myStr.count("4") + myStr.count("7") if(luckyCounter == 4 or luckyCounter == 7): print("YES") else: print("NO")
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
n=input() num=0 flag=1 for i in range(0,len(n)): if n[i]=='4'or n[i]=='7': num+=1 num=str(num) for i in range(0,len(num)): if num[i]!='4' and num[i]!='7': flag=0 break if flag: print('YES') else: print('NO')
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
count=0 n=input() for i in range(len(n)): if(n[i]=='4' or n[i]=='7'): count+=1 if(count==4 or count==7): print("YES") else: print("NO")
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
luckyN = int(input()) arr_luckyN = list(map(int, (str(luckyN)))) rest_luckyN = [x for x in arr_luckyN if x != 4 and x != 7] if rest_luckyN == [] and len(arr_luckyN) - len(rest_luckyN) == 4 or rest_luckyN == [] and len(arr_luckyN) - len(rest_luckyN) == 7 or len(arr_luckyN) - len(rest_luckyN) == 4 or len(arr_luckyN) - ...
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
import sys for line in sys.stdin: total = line.count("4") + line.count("7") if(total == 4 or total == 7 or total == 47 or total == 74): print("YES") else: print("NO")
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
s = raw_input() n = 0 for c in s: if c == '4' or c == '7': n += 1 a = True for c in str(n): if not c in ['4','7']: a = False break print a and 'YES' or 'NO'
PYTHON
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
from collections import Counter c = Counter(raw_input()) print 'YES' if set(str(c['4'] + c['7'])) < set(['4','7']) else 'NO'
PYTHON
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
n=input().strip() if n.count('4')+n.count('7')== 4 or n.count('4')+n.count('7')== 7: print("YES") else: print("NO")
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
n = input() HN1 = "4" HN2 = "7" almost_happy_nums = list(filter(lambda x: x == HN1 or x == HN2, n)) l = len(almost_happy_nums) if l == int(HN1) or l == int(HN2): print("YES") else: print("NO")
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
n=list(input()) a=0 for i in n: if i=='4' or i=='7': a+=1 if a==4 or a==7: print('YES') else: print('NO')
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
num = raw_input() numl = list(num) count = 0 for n in numl: if (int(n) == 4 or int(n) == 7): count += 1 if (count == 4 or count == 7): print "YES" else: print "NO"
PYTHON
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
s=input() cnt=0 length=len(s) for i in range(length): if(s[i]=='4' or s[i]=='7'): cnt+=1 ss=str(cnt) length=len(ss) cnt=0 for i in range(length): if(ss[i]=='4' or ss[i]=='7'): cnt+=1 if(cnt==length): print('YES') else: print('NO')
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
n=input() cnt=0 for i in n: if i=='4' or i=='7': cnt=cnt+1 if cnt ==4 or cnt ==7: print('YES') else: print('NO')
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
s = raw_input() print 'YES' if (s.count('4') + s.count('7')) in (4, 7) else 'NO'
PYTHON
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner input=new Scanner(System.in); long n=input.nextLong(); long reminder; int count=0; while(n>0) { reminder=n%10; if(reminder==4) { count++; } if(reminder==7) { count++; } n=n/10; ...
JAVA
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
k=input();print("YES" if k.count('4')+k.count('7')==4 or k.count('4')+k.count('7')==7 else "NO")
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
_1 = '236a' # count = 0 # l = [list(map(int, input().split())) for i in range(5)] # for i in range(5): # for j in range(5): # if l[i][j] == 1: # # if i > 2: # count += i - 2 # elif i < 2: # count += 2 - i # if j > 2: # count...
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
num = int(input()) def isLucky(num) : s = str(num); if (s.count('4') + s.count('7') == len(s)) : return 1 else : return 0 s = str(num) c = 0 for i in range(len(s)): if (s[i] == '4' or s[i] == '7') : c += 1 if (isLucky(c)) : print("YES") else : print("NO")
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
n = input() count = 0 for i in range(len(n)): if n[i]=='7' or n[i]=='4': count+=1 if count==4 or count ==7: print('YES') else: print('NO')
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
a=input() b=a.count('4')+a.count('7') if len(str(b))==str(b).count('4')+str(b).count('7'): print('YES') else: print('NO')
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
a = [int(x) for x in input()] s = 0 for i in a: if i == 4 or i == 7: s += 1 if s in [4, 7, 44, 47, 74, 77]: print("YES") else: print("NO")
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
n=input() print(("NO","YES")[all([x in "47" for x in str(n.count('4')+n.count('7'))])])
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
n = input() cisla = [] for x in n: if x == "4" or x == "7": cisla.append(int(x)) if len(cisla) == 4 or len(cisla) == 7: print("YES") else: print("NO")
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
n=input() c=0 for i in range(len(n)): if n[i]=='4' or n[i]=='7': c+=1 else: continue if c==4 or c==7: print('YES') else: print('NO')
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
a=input() tik=0 for i in a: if i=='4' or i=='7': tik+=1 if tik==4 or tik==7: print( "YES" ) else: print('NO')
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
def islucky(num): count = 0 for digit in num: if digit == "4" or digit == "7": count = count + 1 if count == 4 or count == 7: return "YES" else: return 'NO' number = input() print(islucky(number))
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
s=input() s1=(s.count('4')) s2=(s.count('7')) if s1+s2==4 or s1+s2==7: print("YES") else: print("NO")
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
#почти счасливое число t=input() ouns=0 for i in range(len(t)): if t[i]=='4' or t[i]=='7': ouns+=1 youns=str(ouns) god=0 for j in range(len(youns)): if youns[j]!='4' and youns[j]!='7': god=1 break if god==0: print('YES') else: print('NO')
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
#!/usr/bin/env python # coding: utf-8 # In[1]: n=input() count_ld=0 for i in range(len(n)): if n[i]=='4' or n[i]=='7': count_ld+=1 else: count_ld+=0 if count_ld==4 or count_ld==7: print('YES') else: print('NO')
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
n=int(input()) c=0 while n>0: r=n%10 n//=10 if r is 4 or r is 7: c=c+1 while c>0: r=c%10 c//=10 if r is 4 or r is 7: c=-1 else: break if c is -1: print("YES") else: print("NO")
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
Number = raw_input() number = list(Number) i = 0 four = [] seven = [] while i in range(len(number)): if number[i]=='4': four.append(number[i]) if number[i]=='7': seven.append(number[i]) i = i+1 if len(four)+len(seven)!=len(number): Count = len(four)+len(seven) digi = str(Count) d...
PYTHON
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
# 110A - Nearly Lucky Number num = input() luck = num.count('4') + num.count('7') luck = str(luck) if luck.count('4')+luck.count('7') == len(luck): print('YES') else: print('NO')
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
x=input() x=list(x) n1=x.count('4') n2=x.count('7') n3=str(n1+n2) x2=list(n3) n1=x2.count('4') n2=x2.count('7') if (n1+n2)==len(x2): print('YES') else: print('NO')
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
n = input() f = list(n) c = 0 a = f.count('4') b = f.count('7') c = a + b if c == 4 or c == 7: print('YES') else: print('NO')
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
n=input() counter=0 for i in range(len(n)): if n[i]=="4" or n[i]=="7": counter+=1 if counter==4 or counter==7: print("YES") else: print("NO")
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
import java.util.*; public class DSAA { public static void main(String[] args) { Scanner scan=new Scanner(System.in); long number=scan.nextLong(); int count=0; while(number!=0){ if(number%10==4 || number%10==7) count++; number=number/10; } boole...
JAVA
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
def lucky(n): f = n.count('4') s = n.count('7') if(f+s==4 or f+s==7): return "YES" return "NO" n = input() print(lucky(n))
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
# import sys # sys.stdin = open("test.in","r") # sys.stdout = open("test.out","w") a=list(map(int,input())) b=a.count(4) c=a.count(7) if b+c==4 or b+c==7: print('YES') else: print('NO')
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
s = input() if len(s)>1: a=s.count('4') b=s.count('7') if a + b ==4 or a+b==7: print('YES') else: print('NO') else: print('NO')
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
s=input() n=0 for lett in s: if int(lett) in [4,7,44,47,74,77,444,447,474,477,744,747,774,777]: n+=1 if n in [4,7,44,47,74,77,444,447,474,477,744,747,774,777]: print('YES') else: print('NO')
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
n=int(input()) a=[] c=0 while n>0: r=n%10 n=n//10 a.append(r) for i in a: if i==4 or i==7: c+=1 if c==4 or c==7: print('YES') else: print('NO')
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
a = input() b = list(a) i = 0 j = 0 lucky = ["4", "7"] while i < len(b): if b[i] in lucky: j += 1 i += 1 if j == 4 or j == 7: print("YES") else: print("NO")
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
#include <bits/stdc++.h> using namespace std; int main() { string n; int x = 0, l, f = 0; cin >> n; l = n.length(); for (int i = 0; i < l; i++) if (n.at(i) == '4' || n.at(i) == '7') x++; n = to_string(x); l = n.length(); for (int i = 0; i < l; i++) if (n.at(i) != '7' && n.at(i) != '4') { f...
CPP
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
T=input() c=T.count('4') d=T.count('7') e=str(c+d) if '7' in e or '4' in e: print('YES') else: print('NO')
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
s=input() count=0 for i in s: if i=="4" or i=="7": count+=1 if(count==4 or count==7): print("YES") else: print("NO")
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
#a,b=[int(a) for a in input().split()] #x = list(map(int, input().split())) x=input() a='7' b='4' count=0 for x in x: if(x=='7' or x=='4'): count+=1 if(count==7 or count==4): print("YES") else: print("NO")
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
n=list(raw_input()) sums=n.count('7')+n.count('4') if sums==7 or sums==4: print "YES" else: print "NO"
PYTHON
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
z=input() x=z.count('4') y=z.count('7') if x+y==4 or x+y==7 : print('YES') else: print('NO')
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
n=input() c = 0 for x in n: if x in '47': c += 1 if c in [4, 7]: print('YES') else: print('NO')
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
lucky = [4,7] temp = input() print('YES' if temp.count('4')+temp.count('7') in lucky else 'NO')
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
n = input() res = 0 for i in n: if i == '7' or i == '4': res += 1 if res == 7 or res == 4: print("YES") else: print("NO")
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
a=input() x=a.count("4") y=a.count("7") z=x+y print("YES" if(z==4 or z==7) else "NO")
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
a = input() r = a.count('4')+a.count("7") if(r==4 or r==7): print("YES") else: print("NO")
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
s=str(input()) truth = 0 truths = 0 for i in range(len(s)): if s[i:i+1]=="4": truth+=1 elif s[i:i+1]=="7": truths+=1 if truth+truths==4 or truth+truths==7: print("YES") else: print("NO")
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
n = int(input()) count = 0 while n != 0: if n % 10 == 4 or n % 10 == 7: count += 1 n = n // 10 if count == 4 or count == 7: print('YES') else: print('NO')
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
lucky_list = [4, 7] n = raw_input() n.split() #print n ctr=0 for dig in n: if dig=='4' or dig=='7': ctr += 1 if ctr in lucky_list: print "YES\n" else: print "NO\n"
PYTHON
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
def is_lucky_number(): number = raw_input() qnty_digits = len( number ) lucky_digits = 0 for i in xrange(0, qnty_digits): digit = int( number[i] ) if digit == 4 or digit == 7: lucky_digits += 1 if lucky_digits == 4 or lucky_digits == 7: return 'YES' else:...
PYTHON
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
n = str(input()) count = 0 for a in n: if a == '4' or a == '7': count = count + 1 if count == 4 or count == 7: print('YES') else: print('NO')
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
n=int(input()) n=list(map(int,str(n))) count=0 for i in range(0,len(n)): if(n[i]==4 or n[i]==7): count=count+1 if(count==4 or count==7): print('YES') else: ...
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
s=input() x=0 i=0 for i in range(len(s)): if s[i]=='4' or s[i]=='7': x+=1 if(x==4 or x==7): print("YES") else: print("NO")
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
""" Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of luck...
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
c=input() c=c.count('7')+c.count('4') print("YES") if c==7 or c==4 else print("NO")
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
s=raw_input() k=0 t=('4','7') for i in s: if i in t: k+=1 if k==4 or k==7: print "YES" else: print "NO"
PYTHON
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
n = input() l = n.count('4') + n.count('7') l = set(str(l)) if l == {'4'} or l == {'7'} or l == {'4', '7'}:print("YES") else:print("NO")
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
a = input() count = 0 for i in range(len(a)): if(a[i] == "4"): count+=1 elif(a[i] == "7"): count+=1 if(count == 4 or count == 7): print("YES") else: print("NO")
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
# 110A. Nearly Lucky Number nList = list(map(int, list(input()))) BM = [4, 7] cnt = 0 for n in nList: if n in BM: cnt += 1 bmSet = set(BM) cntSet = set([int(s) for s in str(cnt)]) if not cntSet.difference(bmSet): print("YES") else: print("NO")
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
n = input() nlis = list(n) count = 0 for items in nlis: if(items == '4' or items == '7'): count += 1 if(count == 4 or count == 7): print('YES') else: print('NO')
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
import string def is_happy(number: str) -> str: for x in number: if x != '4' and x != '7': return "NO" return "YES" num = str(int(input())) print(is_happy(str(num.count('4') + num.count('7'))))
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
if sum([int(i) for i in [j not in "47" for j in str(sum([int(k) for k in [l in "47" for l in input()]]))]]): print("NO") else: print("YES")
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
import math from collections import Counter as c def helper(n): if(n==0): return False while(n): p=n%10 if(not((p==4) or (p==7))): return False n/=10 return True def foo(): n= int(raw_input()) s=0 while(n): p=n%10 if((p==4) or (p==...
PYTHON
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
n=input() c=0 while n!=0: r=n%10 if r==4 or r==7: c+=1 n=n/10 if c==4 or c==7: print "YES" else: print "NO"
PYTHON
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
n=input() n=",".join(n) n=n.split(",") num=n.count("4")+n.count("7") num=str(num) if "0" not in num and "1" not in num and "2" not in num and "3" not in num and "5" not in num and "6" not in num and "8" not in num and "9" not in num: print("YES") else: print("NO")
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
n = input() k = '47' s = 0 t = True for i in range(len(n)): if n[i] in k: s += 1 n = str(s) s = 0 for i in range(len(n)): if n[i] in k: pass else: t = False if t: print('YES') else: print('NO')
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
s = raw_input() print "YES" if s.count('4') + s.count('7') in [4, 7] else "NO"
PYTHON
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
a=list(input()) s=0 s+=a.count('4') s+=a.count('7') if s==4 or s==7:print("YES") else:print("NO")
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
s=input() b=0 c=0 for i in range(len(s)): if len(s)!=1: if s[i] == '4': c+=1 elif s[i] == '7': b+=1 if b+c==4 or b+c == 7: print('YES') else: print('NO')
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
s = list(int(d) for d in input()) f = s.count(4) f += s.count(7) if f == 4 or f == 7: print("YES") else: print("NO")
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
''' import math def BearAndBigBrother(): a, b = map(int, input().split(' ')) year = 0 while 1: if a > b: break else: a *= 3 b *= 2 year += 1 print(year) return None def Tram(): n = int(input()) p = [0] for i in range(1, n+...
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
# Nearly Lucky Number: python lst = list(map(int, input())) ctn = 0 for num in lst: if num == 4 or num == 7: ctn += 1 for num in map(int, str(ctn)): if num != 4 and num != 7: print('NO') exit() print('YES')
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
#include <bits/stdc++.h> using namespace std; int main() { int count = 0; long long int n; cin >> n; while (n > 0) { if (n % 10 == 7 || n % 10 == 4) { count++; } n = n / 10; } if (count == 4 || count == 7) { cout << "YES"; } else { cout << "NO"; } }
CPP
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
n = int(input()) nb = sum([1 if c in "47" else 0 for c in str(n)]) ok = True for c in str(nb): if c not in "47": ok = False break print("YES" if ok else "NO")
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
n = input() c = n.count('7') c += n.count('4') n = 0 c = str(c) n = c.count('4') n += c.count('7') if n == len(c): print('YES') else: print('NO')
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
k = input() four = k.count("4") seven = k.count("7") if four+seven == 4 or four+seven ==7: print("YES") else: print("NO")
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
n=int(input()) c=0 while(n>0): if(n%10==4 or n%10==7): c+=1 n=n//10 if(c==4 or c==7): print('YES') else: print('NO')
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
def is_lucky_digit(n): if n == '4' or n == '7': return True else: return False def is_lucky_number(n): return all(map(is_lucky_digit,str(n))) n = int(input()) c = sum([1 if is_lucky_digit(i) else 0 for i in str(n)]) print('YES' if is_lucky_number(c) else 'NO')
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
from collections import Counter if __name__ == "__main__": #take number as string num = input() digitMap = Counter(num) count = digitMap['4']+digitMap['7'] if(count==4 or count==7): print("YES") else: print ("NO")
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
L=list(input()) def lucky(n): N=str(n) if any([i in N for i in list('01235689')]): return False else:return True if lucky(L.count('4')+L.count('7')):print('YES') else:print('NO')
PYTHON3
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
n = raw_input().strip() count = 0 for i in range(len(n)): if n[i]=='4' or n[i]=='7': count+=1 if count==4 or count==7: print "YES" else: print "NO"
PYTHON
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
import java.util.*; public class Main { public static void main(String[] args){ Scanner sc=new Scanner(System.in); String s=sc.next(); int sum=0; for(int i=0;i<s.length();i++){ if(s.charAt(i)-'0'==7 || s.charAt(i)-'0'==4) sum++; } if(sum==4 || sum==7) System.out.println("YES"); else System.o...
JAVA
110_A. Nearly Lucky Number
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky d...
2
7
print("YES" if len(list(filter((lambda c: c != '4' and c != '7'), str(len(list(filter((lambda c: c == '4' or c == '7' ), input()))))))) == 0 else "NO")
PYTHON3