Strings Problem Set 8

Part I - Raptor Programs

String.22 Bob Three

Display true if the given string contains a "bob" string, but where the middle 'o' char can be any char.

Test Case
Input
Program Output
1 abcbob true
2 b9b true
3 bac false

Solutions:

python

raptor

String.23 XY Balance

We'll say that a String is xy-balanced if for all the 'x' chars in the string, there is a 'y' char somewhere later in the string. So "xxy" is balanced, but "xyx" is not. Return true if the given string is xy-balanced.

Test Case
Input
Program Output
1 aaxbby true
2 aaxbb false
3 yaaxbb false

Solutions:

python

raptor

String.24 Mix String

Given two strings, A and B, create a bigger string made of the first char of A, the first char of B, the second char of A, the second char of B, and so on. Any leftover chars go at the end of the result.

Test Case
Input
Input
Program Output
1 abc xyz true
2 Hi There false
3 xxxx There true

Solutions:

python

raptor