fork download
  1. import re
  2.  
  3. def count_journey_segments(journey_log):
  4. """
  5. Count the number of journey segments in the log.
  6. The function expects a string return a long integer.
  7. """
  8. if not journey_log:
  9. return 0
  10. # Pattern matches: journey_log[i]='segment_name'
  11. pattern = r"journey_log\[\d+\]='([^']+)'"
  12. matches = re.findall(pattern, journey_log)
  13. result = len(matches)
  14. print(result)
  15. return result
  16.  
Success #stdin #stdout 0.16s 15548KB
stdin
aeiouxaa
stdout
Standard output is empty