+ 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

10th Jan 2018, 12:28 PM
Akash Pal
Akash Pal - avatar
15 Respostas
+ 28
https://code.sololearn.com/ci9WseBbxyxJ/?ref=app
10th Jan 2018, 1:19 PM
Gaurav Agrawal
Gaurav Agrawal - avatar
10th Jan 2018, 12:52 PM
Swapnil Srivastava
Swapnil Srivastava - avatar
10th Jan 2018, 3:40 PM
Vahid Shirbisheh
Vahid Shirbisheh - avatar
10th Jan 2018, 12:33 PM
shobhit
shobhit - avatar
+ 12
10th Jan 2018, 12:33 PM
Md. Nafis Ul Haque Shifat
Md. Nafis Ul Haque Shifat - avatar
+ 11
My first Python Code! Works for both Numbers and strings! https://code.sololearn.com/cUA0EH5XAHJu/?ref=app
10th Jan 2018, 5:32 PM
Abhishek Tandon
Abhishek Tandon - avatar
11th Jan 2018, 8:10 AM
Justine Ogaraku
Justine Ogaraku - avatar
+ 7
print(input().count(input()))
10th Jan 2018, 6:49 PM
Kartikey Sahu
Kartikey Sahu - avatar
11th Jan 2018, 6:57 AM
Mahdi Cheikhrouhou
Mahdi Cheikhrouhou - avatar
+ 6
https://code.sololearn.com/c2me2kyfKWvF/?ref=app
10th Jan 2018, 6:07 PM
abdulazizumarovich
abdulazizumarovich - avatar
10th Jan 2018, 10:53 PM
Kavya Sree Kante
Kavya Sree Kante - avatar
+ 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
11th Jan 2018, 10:09 AM
André
André - avatar
+ 3
https://code.sololearn.com/c7f8bQVW9l1o/?ref=app
2nd Feb 2018, 3:27 PM
...
- 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);
12th Jan 2018, 12:18 PM
Solo Wanderer 4315
Solo Wanderer 4315 - avatar