5 kyu

Return substring instance count - 2

627 of 3,173ineiti

Description:

Complete the solution so that it returns the number of times the search_text is found within the full_text.

search_substr( full_text, search_text, allow_overlap = True )
search_substr( full_text, search_text, allow_overlap = true )
searchSubstr( fullText, searchText, allowOverlap = true )
searchSubstr( fullText, searchText, allowOverlap = true )

so that overlapping solutions are (not) counted. If the searchText is empty, it should return 0. Usage examples:

search_substr('aa_bb_cc_dd_bb_e', 'bb') # should return 2 since bb shows up twice
search_substr('aaabbbcccc', 'bbb') # should return 1
search_substr( 'aaa', 'aa' ) # should return 2
search_substr( 'aaa', '' ) # should return 0
search_substr( 'aaa', 'aa', False ) # should return 1
search_substr('aa_bb_cc_dd_bb_e', 'bb') # should return 2 since bb shows up twice
search_substr('aaabbbcccc', 'bbb') # should return 1
search_substr( 'aaa', 'aa' ) # should return 2
search_substr( 'aaa', '' ) # should return 0
search_substr( 'aaa', 'aa', false ) # should return 1
searchSubstr('aa_bb_cc_dd_bb_e', 'bb') # should return 2 since bb shows up twice
searchSubstr('aaabbbcccc', 'bbb') # should return 1
searchSubstr( 'aaa', 'aa' ) # should return 2
searchSubstr( 'aaa', '' ) # should return 0
searchSubstr( 'aaa', 'aa', false ) # should return 1
searchSubstr('aa_bb_cc_dd_bb_e', 'bb') // should return 2 since bb shows up twice
searchSubstr('aaabbbcccc', 'bbb') // should return 1
searchSubstr( 'aaa', 'aa' ) // should return 2
searchSubstr( 'aaa', '' ) // should return 0
searchSubstr( 'aaa', 'aa', false ) // should return 1
Strings
Regular Expressions
Algorithms

Stats:

CreatedAug 24, 2013
PublishedAug 24, 2013
Warriors Trained6408
Total Skips1378
Total Code Submissions21816
Total Times Completed3173
Ruby Completions627
JavaScript Completions1291
CoffeeScript Completions94
C Completions462
Python Completions730
Total Stars102
% of votes with a positive feedback rating92% of 442
Total "Very Satisfied" Votes377
Total "Somewhat Satisfied" Votes55
Total "Not Satisfied" Votes10
Ad
Contributors
  • ineiti Avatar
  • jhoffner Avatar
  • GiacomoSorbi Avatar
  • siebenschlaefer Avatar
  • JohanWiltink Avatar
  • Blind4Basics Avatar
  • user9644768 Avatar
  • Just4FunCoder Avatar
  • saudiGuy Avatar
Ad