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
s = input() count = 0 for i in s: if i == '7' or 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
read = str(input()) a = 0 for i in range(0,len(read)): if read[i] == '4' or read[i] == '7': a+=1 if a==4 or a==7: ans = "YES" else: ans = "NO" print(ans)
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 x = 0, z = 0; long long n, y; cin >> n; while (n > 0) { y = n; n = n / 10; x = y - (n * 10); if (x == 4 || x == 7) z++; } if (z == 4 || z == 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
s=input() c1=s.count("4") c1+=s.count("7") s=str(c1) a=s.count("4") a+=s.count("7") if len(s)-a==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
list1 = list(map(int, input())) count = 0 count1 = 0 for i in list1: if(i == 4 or i == 7): count = count + 1 count = str(count) list2 = [int(x) for x in str(count)] for i in list2: if(i==4 or i == 7): count1 = count1 + 1 if(count1 == len(count)): 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() lfl = 1 n = ['4', '7'] dig = list(s) ld = 0 for i in dig: fl = 1 if i not in n: fl = 0 if fl == 1: ld += 1 for i in str(ld): if i not in n: lfl = 0 if lfl == 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
print('YNEOS'[(sum(d in '47' for d 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
def f(x): s = set(str(x)) if not '4' in s and not '7' in s: return False if '4' in s: s.remove('4') if '7' in s: s.remove('7') return len(s) == 0 n = input() print('YES' if f(n.count('4') + n.count('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
n = int(input()) count = 0 while(n): 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
n = input() r = n.count('4') + n.count('7') print('YES' if (r==4 or r==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
n=int(input()) count=0 for x in list(str(n)): if x in ['4','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
n = input() c = n.count("4") d = n.count("7") if c+d == 4 or c+d == 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
inp = input() count = 0 for i in inp: if i == '4' or i == '7': count += 1 else: continue if count/4 == 1.0 or count/7 == 1.0: if count == 0: print ("NO") else: 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=str(input()) digit= len(number) c=0 for i in range(digit): if number[i-1]=="4" or number[i-1]=="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
import java.util.Scanner; /** * * @author Shivansh */ public class Nearly_Lucky_number { public static void main(String[] args) { Scanner kb=new Scanner(System.in); String s=kb.next(); int count=0; for(int i=0;i<s.length();i++) { if(s.charAt(i)=='4' || s.charAt(i)=='...
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
n=input() a=str(sum([x in ['4','7']for x in n])) if all(x in ['4','7']for x in a): 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()) k=0 val = True while n!=0: if n%10==4 or n%10==7: k+=1 n=n//10 if k==0: val=False while k!=0: if k%10!=4 and k%10!=7: val=False break; k=k//10 if val==False: 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
def islucky(x): d = {}.fromkeys('0123456789', 0) for s in str(x): d[s] += 1 return d['4'] + d['7'] == len(str(x)) n = raw_input() d = {}.fromkeys('0123456789', 0) for s in n: d[s] += 1 print 'YES' if islucky(d['4'] + d['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() s=0 s=n.count('4')+n.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
n = int(input()) res = 0 while n > 0: if n % 10 == 4 or n % 10 == 7: res += 1 n //= 10 print("YES" if res == 4 or res == 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
n = int(input()) Str = str(n) result = [] for i in range(len(Str)): if Str[i] == "7" or Str[i] == "4": result.append(1) if len(result) ==4 or len(result) == 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() c=0 for i in s: if i=='4' or i=='7': c+=1 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
from collections import Counter 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
# URL: http://codeforces.com/problemset/problem/110/A # ~ Basic Implementation Problem def isLucky(n: str) -> bool: return all(x == '7' or x == '4' for x in n) def countLuckyDigits(n: str) -> int: return n.count('4') + n.count('7') def solve(n: str) -> str: if isLucky(str(countLuckyDigits(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
a = input() b = set(str(a.count('7')+a.count('4'))) if(len(b)==1 and ('7' in b or '4' in b)): 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() cnt=0 for i in range (len(s)): if(s[i]=='4' or s[i]=='7'): 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
#110A n=input() luckyCount=0 for i in range(len(n)): if n[i]=="4" or n[i]=="7" : luckyCount+=1 flag=True if luckyCount==0 : flag=False else: while (luckyCount>0 ): if luckyCount%10 !=4 and luckyCount%10 !=7: flag=False break else: luckyCount//=...
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 = input() M = 0 for i in range(len(lucky)): if lucky[i]=='4' or lucky[i]=='7' : M=M+1 if M==4 or M==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 = str(input()) count4 = 0 count7 = 0 for i in n: if(i=='4'): count4 = count4 +1 if (i=='7'): count7 = count7 +1 if (((count7+count4 == 7) or (count7+count4 == 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
x=input() t=x.count('7')+x.count('4') if all(i in ['4','7'] for i in str(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 = input() count = 0 for i in s: i = int(i) if i == 4 or i ==7: count+=1 lucky = True for i in str(count): if int(i) == 4 or int(i) ==7: continue else: lucky = False break if lucky: 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
# cook your dish here n=int(input()) count=0 countr=0 while(n>0): count=count+1 if(n%10==7): countr=countr+1 if(n%10==4): countr=countr+1 n=n//10 if 7==countr or 4==countr: 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 = input() number = str(number) number_list = list(number) counter = 0 for i in number_list: if i == "7" or i == "4": counter+=1 if counter == 7 or counter == 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
line=input() counter=0 for i in line: if i in ["4","7"]: counter+=1 N=str(counter) is_almost_lucky = True for i in N: if i not in ["4","7"]: is_almost_lucky = False print("YES" if is_almost_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
x = input() count = 0 for i in x: if i == '4' or i == '7': count += 1 count = str(count) #print(count) for j in count: if j != '4' and j != '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
a = input('') count = 0 b = len(a) for x in range(b): if a[x] == '7' or a[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
a = int(input()) res = 0 while a > 0: if a % 10 == 4 or a % 10 == 7: res += 1 a = a // 10 if res == 4 or res == 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=raw_input() if a.count('4')+a.count('7')==4 or a.count('4')+a.count('7')==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 sys n=sys.stdin.readline().strip() c=0 for i in range(len(n)): r=n[i] if r in "47": c+=1 if str(c) in "47": 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=str(input()) l=list(n) x=l.__len__() s=0 for i in range(x): if l[i]=="4" or l[i]=="7": s+=1 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
x=(input()) f=(x.count('4')+x.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 java.util.Scanner; public class NearlyLuckNumber { public static void main(String[]args) { Scanner in = new Scanner(System.in); String word = in.next(); in.close(); int count = 0; for (char c : word.toCharArray()) if (c == '4' || c=='7') count++; boolean good = true; for (char c :...
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
n=input() x=n.count('4') y=n.count('7') ans=set(str(x+y)) if ans==set(['4','7']) or ans==set(['7']) or ans==set(['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
import java.util.Scanner; public class _20NearlyLuckyNumber { public static void main(String[] args) { Scanner sc = new Scanner(System.in); long input =sc.nextLong(); int luckyNum=0; while(input>0) { if(input%10==4||input%10==7) { luckyNum++; } input/=10; } System.out.println(luckyNum==4||lu...
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
n=input() c=0 for i in n: if(i=="4" or i=="7"): c=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
def isLucky(n): if(n == 0): return 0 while(n>0): t = n%10 if(t != 4 and t != 7): return 0 n = n // 10 return 1 k = int(input()) count = 0 while(k>0): r = k%10 if(r == 7 or r == 4): count += 1 k = k // 10 if(isLucky(count) == 1): print...
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 n: if i == ('4') or 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
s=input() c=0 for _ in s: if _ == "4" or _=="7": c +=1 if set(str(c)) in ("4","7") or 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
x=input() y=x.count('4')+x.count('7') if (y==4 or 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
a= int(input()) a=str(a) count =0 for i in range(len(a)): if a[i]=='4' or a[i]=='7': # print(a[i]) count+=1 # print(count) if count >0: if count // 4==1 and count %4 ==0 or count // 7==1 and count %7==0: 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
class NearlyLuckyNumber: def solve(self, number): luckynums = [] count = 0 for x in range(0,10000): splitnum = list(int(d) for d in str(x)) if splitnum.count(4)+splitnum.count(7)==len(splitnum): luckynums.append(x) for x in str(number): ...
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 = list(input()) temp = 0 for i in range(0, len(n)): if n[i] == "4" or n[i] == "7": temp += 1 if temp == 4 or temp == 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
ch = str(input()) d = 0 for t in ch: t = int(t) if t == 4 or t == 7:d+=1 if (d == 7 or d == 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
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class Ladder1_9 { public static void main(String args[]) throws IOException { BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); String num=br.readLine(); i...
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
s = input() if s.count('4')+s.count('7') == 4 or s.count('4')+s.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
s=input() print(["YES","NO"][not (s.count('4')+s.count('7'))in [4,7,47,74,44,77]])
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
# -*- coding: utf-8 -*- """ Created on Sat Nov 2 20:46:34 2019 @author: 86138 """ #110A Nearly Lucky Number n = input() q = n.count('4') + n.count('7') if q == 4 or q == 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 = input() count = 0 for i in range(len(num)): if num[i] == '4' or num[i] == '7': count = count + 1 num = str(count) ch = 0 for i in range(len(num)): if num[i] == '4' or num[i] == '7': continue else: ch = 1 break if ch == 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
n=input() count=0 for i in n: d=int(i) if d==4 or d==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 = input() cntr = n.count('4')+n.count('7') if (cntr == 4 or cntr == 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() sum=0 for i in n: if i=='4' or i=='7':sum+=1 if sum==4 or sum==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() c = s.count("4") + s.count("7") l = len(s) print(("NO","YES")[c in (4, 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() count=0 flag=0 for i in n: if i=="4" or i=="7": count+=1 for i in str(count): if i!="4" and i!="7": flag=1 break if flag==1: 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
entry = input() fours = entry.count("4") sevens = entry.count("7") digits = ["0", "1", "2", "3", "5", "6","8", "9"] summary = int(fours) + int(sevens) if (summary == 4 and entry not in digits ) or (summary == 7 and entry not in digits): 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
arr=map(int,list(raw_input())) ln=0 def isLucky(no): return (no.count("4")+no.count("7")==len(no)) for i in arr: if i==4 or i==7: ln+=1 print "YES" if isLucky(str(ln)) 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
#include <bits/stdc++.h> using namespace std; int main() { string s; int c = 0; cin >> s; for (int i = 0; s[i] != '\0'; i++) { if (s[i] == '4' || s[i] == '7') c++; } if (c == 4 || c == 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
n=str(input()) luckydigits=0 nearlylucky=True for digit in n: if digit=='4' or digit=='7': luckydigits+=1 for digit in str(luckydigits): if digit!='4' and digit!='7': print('NO') nearlylucky=False break if nearlylucky==True: 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
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Fri Mar 27 05:16:15 2020 @author: mac """ n = input() lucky = 0 for i in range(len(n)): if n[i] in ['4','7']: lucky += 1 if lucky == 4 or lucky == 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() q = s.count('4')+s.count('7') if q 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
a=list(input()) c=0 for i in range(0,len(a)): if a[i]=='4' or a[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
n = input() x = n.count("4") + n.count("7") x = str(x) y = x.count("4") + x.count("7") if y == len(x) : 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 in ('47'): cnt += 1 for j in str(cnt): if j not in ('47'): print('NO') break 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 sys number = input() count = 0 for digit in number: if digit == "4" or digit == "7": count = count + 1 for digit in str(count): if digit != "4" and digit != "7": print("NO") sys.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
# -*- coding: utf-8 -*- """ Created on Tue Nov 26 20:26:44 2019 @author: Zheng Jiajia """ num=str(input()) digits=num.count('4')+num.count('7') l=list(str(digits)) lucky=['4','7'] for i in range(len(l)): if l[i] not in lucky: print('NO') break 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
s=input() l=list(s) a=l.count('4') b=l.count('7') if (a+b==4) or (a+b==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 getDigit(number, digit_num): return (number / 10**digit_num) % 10 def getNumberOfDigits(number): dnum = 1 while (number / 10**dnum) != 0: dnum += 1 return dnum def getHappyDigestCount(number): happy_digest_count = 0 for digit_num in range(0, getNumberOfDigits(number)): di...
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
#include <bits/stdc++.h> using namespace std; int main() { long long int n, cnt = 0; cin >> n; while (n > 0) { if ((n % 10 == 7) || (n % 10 == 4)) { cnt++; } n /= 10; } int flag = 0; while (cnt > 0) { if ((cnt % 10 != 7) && (cnt % 10 != 4)) { flag = 0; break; } else { ...
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
# -*- coding: utf-8 -*- """ Created on Fri Nov 22 13:46:15 2019 @author: Selene """ n=input() m=0 for i in n : if i=='4' or i=='7': m=m+1 if m==4 or m==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_number =[4, 7] num = list(input()) if (num.count('4') + num.count('7')) in lucky_number: 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(map(int,input())) a = n.count(4) + n.count(7) 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
x = input() count = 0 for i in range(0,len(x)): if x[i] == '4' or x[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=input() c=a.count('4') c1=a.count('7') k=c+c1 if k==4 or k==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//=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
s = raw_input() if s.count('7') + s.count('4') in (4, 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 math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools sys.setrecursionlimit(10**7) inf = 10**20 eps = 1.0 / 10**10 mod = 10**9+7 dd = [(-1,0),(0,1),(1,0),(0,-1)] ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)] def LI(): return [int(x) for x in sys.stdin....
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 n: if i in "47": count += 1 lucky = True for i in str(count): if i not in "47": lucky = False break if lucky: 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 = 0 for i in range(len(n)): if (n[i] == '4' or n[i] == '7'): k += 1 k = str(k) f = 1 for i in range(len(k)): if (k[i] != '4' and k[i] != '7'): f = 0 if (f == 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
import java.util.Scanner; public class task{ public static void main(String args[]){ Scanner in = new Scanner(System.in); String a = in.next(); int k = 0; for(int i = 0 ; i< a.length();i++){ if(a.charAt(i)=='4'||a.charAt(i)=='7'){ k+=1; } } ...
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
tmp = input() a = 0 a += list(tmp).count('7') a += list(tmp).count('4') if set(list(str(a))) <= set(['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
def nearlyLucky(n): count=0 for i in n: if i in '47': count+=1 if count == 4 or count == 7: return "YES" return "NO" # def nearlyLucky(n): # if len(n) < 2: # return # if n[0] == '4' or '7': # return 1 + nearlyLucky(n[1:]) # else: # nearlyLucky(n[1:]) print(nearlyLucky(input())) # count = nearlyLu...
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=0 for i in s: if i=='7' or i=='4': ans+=1 t=str(ans) for i in t: if i!='7' and i!='4': print('NO') exit(0) 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
def check(s): four=0 seven=0 for i in range(len(s)): if s[i]=='4': four=four+1 if s[i]=='7': seven=seven+1 if (four+seven==4 or four+seven==7): print("YES") else: print("NO") s = input() check(s)
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() m = s.count('4') n = s.count('7') y = m+n if y == 4 or y == 7 or y == 47 or y == 477 or y ==744: 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 lucky_number(number): sum=0 lucky=0 res = [int(x) for x in str(number)] for x in res: if x==4 or x==7: sum+=1 else: continue if sum==4 or sum==7: lucky=1 else: lucky=0; return lucky input1 = input() if lucky_number(input1) == 1...
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() a = n.count("4") + n.count("7") 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
#https://codeforces.com/problemset/problem/110/A s=input() n=s.count("4")+s.count("7") print(["NO","YES"]["4" in str(n) or "7" in str(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
if __name__ == '__main__': num = input() print('YES' if sum([1 for digit in num if digit == '7' or digit == '4']) == 7 or sum([1 for digit in num if digit == '7' or digit == '4']) == 4 else 'NO', end = '')
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
print 'YES' if sum(1 for c in raw_input() if c == '4' or c == '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=input() a=list(a) cond=0 for i in a: if i=="4" or i=="7": cond+=1 else: pass if cond==4 or cond==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 luckycheck(n) : lucnum = 0 while n!=0 : d = n%10 if d == 7 or d == 4: lucnum = lucnum + 1 n = n // 10 if lucnum ==7 or lucnum ==4 : print("YES") else : print("NO") return N = int(input()) luckycheck(N)
PYTHON3