Skip to content

Latest commit

 

History

History
46 lines (28 loc) · 1.49 KB

string-and-integer-riddles.markdown

File metadata and controls

46 lines (28 loc) · 1.49 KB

String and Integer Riddles

Strings

  • How can I tell how many characters are in a string? Do spaces count?

  • How can I capitalize the first character of a string? What happens if it is a number?

  • How can I turn a string backwards?

  • How can I tell if two words have the same number of characters?

  • How can I tell if a word has all capital letters?

  • How can I tell if a word has all lower case letters?

  • How can I tell if a word is a palindrome? (The word is the same forwards and backwards.)

  • How can I tell if a sentence is the same forwards and backwards? (ignoring spaces and punctuation)

  • How can I replace an occurrence of a single character in a string with another character?

  • How can I replace ALL occurrences of a single character in a string with another character?

  • How do I insert 5 asterisks at the start of a string? What about at the end of a string? What about x asterisks?

  • What if I wanted to have a string that's four characters long, but I want to make a big string thats 14 characters in length, with the original string in the middle, with asterisks on either side of the original string to make it reach the desired length?

  • What if I wanted to replace the padding character with spaces? And a variable total length?

  • What are two ways in which you can determine if an integer is odd? (Or even.)

  • How can I convert a string into a number?

  • How can you tell if a number is a palindrome? (303, 1221, 123321)

  • How can you tell if a number is divisible by 3? By 9? By x?