+ 14
Challenge :: Occurrence
Task is to make code to in which you have to input two number.First will be multi-digit and second will be one digit.You have to find the occurrence of second number in the first number. Example :- Input :- 15451271 and 1 Output :- The occurrence of 1 is 3 times https://code.sololearn.com/c7MHqt4k018P/#cpp
15 Respuestas
+ 28
https://code.sololearn.com/ci9WseBbxyxJ/?ref=app
+ 16
My one liner
https://code.sololearn.com/WW3WLn11u2aD/?ref=app
+ 16
Here is my try:
https://code.sololearn.com/WApNraAay9rZ/?ref=app
+ 12
it was really easy
https://code.sololearn.com/clhhAIjMVK8r/?ref=app
+ 12
Playing a challenge 1st time..
https://code.sololearn.com/WIT736yC54Rd/?ref=app
+ 11
My first Python Code!
Works for both Numbers and strings!
https://code.sololearn.com/cUA0EH5XAHJu/?ref=app
+ 11
One-linear Python)😉
https://code.sololearn.com/cLJspOxzdm10/?ref=app
+ 7
print(input().count(input()))
+ 6
https://code.sololearn.com/c2me2kyfKWvF/?ref=app
+ 5
In Ruby:
def occur(num, dig)
num.to_s.chars.delete_if { |x| x != dig.to_s }.length
end
https://code.sololearn.com/cYw6zjF3eBeE/?ref=app
+ 3
https://code.sololearn.com/c7f8bQVW9l1o/?ref=app
- 3
Is it necessary that the input is 'stored' as a number as well?
C++:
int n; cin>>n; string num=to_string(n);
char d; cin>>d;
cout<<count(num.begin(),num.end(),d);