Strings Problem Set 5

Part I - Raptor Programs

String.13 n Twice

Given a string and an int n, output a string made of the first and last n chars from the string. The string length will be at least n.

Test Case
A Input

n Input

Program Output
1 Hello 2 helo
2 Chocolate 3 Choate
3 chocolate 1 ce

Solutions:

python

raptor

String.14 Middle Three

Given a string of odd length, return the string length 3 from its middle, so "Candy" yields "and". The string length will be at least 3.

Test Case
A
Program Output
1 candy and
2 and and
3 solving lvi

Solutions:

python

raptor

String.15 Has Bad

Given a string, return true if "bad" appears starting at index 0 or 1 in the string, such as with "badxxx" or "xbadxx" but not "xxbadxx". The string may be any length, including 0.

Test Case
A
Program Output
1 badxx true
2 xbadxx true
3 xxbadxx false

Solutions:

python

raptor