Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Prolog Question. I need help making this in Prolog . There is a tester at the bo

ID: 3707169 • Letter: P

Question

Prolog Question.

I need help making this in Prolog. There is a tester at the bottom. Any help is appreciated.

Return the number of times that the string "hi" appears anywhere in the given string:

count_hi(String, Count):

-----------------------

Tester

count_hi_test() :-

                count_hi("abc hi ho",1),

                count_hi("ABChi hi",2),

              count_hi("hihi",2),

                count_hi("hiHIhi",2),

                count_hi("",0),

                count_hi("h",0),

                count_hi("hi",1),

                count_hi("Hi is no HI on ahI",0),

                count_hi("hiho not HOHIhi",2).

Explanation / Answer

Write a function which will calculate how many times substrings "hi" is repeated in given string.

simple way is write following code in a function: