Question: / Function mirrorEnds() // // Complete method mirrorEnds that given a string, looks for a mirror // image (backwards) string at both the beginning and

/ Function mirrorEnds() // // Complete method mirrorEnds that given a string, looks for a mirror // image (backwards) string at both the beginning and end of the given // string. In other words, zero or more characters at the very beginning // of the given string, and at the very end of the string in reverse order // (possibly overlapping). For example, "abXYZba" has the mirror end "ab". // // mirrorEnds("") returns "" // mirrorEnds("abcde") returns "" // mirrorEnds("a") returns "a" // mirrorEnds("abca") "a" // mirrorEnds("abba") returns "abba" // mirrorEnds("abbA")) returns "" (case sensitive 'a' != 'A') // // Precondition: The argument to sequence is always a string. function mirrorEnds($str) { // Test this wth your own asserts return "Under construction"; }

// Add your own tests here (reuse your own JS asserts maybe?

// Function isArraySorted // // Given an array, return true if the element are in ascending order. // Note: 'abe' < 'ben' and 5 > 3 // // Precondition $arr has all the same type of elements function isArraySorted($arr) { return ! true; }

///////////////////////////////////////////////////////////////////////////////// // function numberOfPairs // // Return the number of times a pair occurs in array. A pair is any two String // values that are equal (case sensitive) in consecutive array elements. // The array may be empty or have only one element. In both of these cases, return 0. // // numberOfPairs( array('a', 'b', 'c') ) returns 0 // numberOfPairs( array('a', 'a', 'b', 'b') ) returns 2 // numberOfPairs( array ( ) ) returns 0 // numberOfPairs( array ('a') ) returns 0 // // Precondition: $arr has all the same type of elements

function numberOfPairs($arr) { return -999; }

assert(2 == numberOfPairs( array('a', 'a', 'a', 'X' ) ) );

PHP functions please help

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!