5 kyu

Return substring instance count - 2

631 of 3,243ineiti

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 Trained6510
Total Skips1383
Total Code Submissions22167
Total Times Completed3243
Ruby Completions631
JavaScript Completions1323
CoffeeScript Completions94
C Completions475
Python Completions760
Total Stars104
% of votes with a positive feedback rating91% of 453
Total "Very Satisfied" Votes384
Total "Somewhat Satisfied" Votes58
Total "Not Satisfied" Votes11
Ad
Contributors
  • ineiti Avatar
  • jhoffner Avatar
  • GiacomoSorbi Avatar
  • siebenschlaefer Avatar
  • JohanWiltink Avatar
  • Blind4Basics Avatar
  • user9644768 Avatar
  • Just4FunCoder Avatar
  • saudiGuy Avatar
Ad