Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def count_occurrences(t,l)
- if t == "" then
- return 0
- else
- if t[0,1] == l then
- return 1 + count_occurrences(t[1,t.length - 1], l)
- else
- return count_occurrences(t[1,t.length - 1], l)
- end
- end
- end
- #s = "hallo"
- #puts(count_occurrences(s,'l'))
- test = gets().chomp
- letter = gets()[0,1]
- puts(count_occurrences(test,letter))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement