I'm suppose to write a Ruby program for the following:
A user is asked to input a string and a non-negative value for an integer n. The front of the string is the first 3 characters, or whatever is there if the string is less than length 3. The program needs to return n copies of the front.
Can someone help me out with what exactly I'm being asked to do. There's something about the wording of this that just doesn't make sense.
String input
Page 1 of 11 Replies - 2075 Views - Last Post: 25 February 2012 - 12:38 PM
Replies To: String input
#2
Re: String input
Posted 25 February 2012 - 12:38 PM
If I understand correctly, they want
Example 1:
input:
output
5 times the first 3 letters.
Example 2:
input:
output
There were only 2 letters in the string, so 3 times the two letters
Example 1:
input:
This is a string 5
output
ThiThiThiThiThi
5 times the first 3 letters.
Example 2:
input:
ab 3
output
ababab
There were only 2 letters in the string, so 3 times the two letters
This post has been edited by Karel-Lodewijk: 25 February 2012 - 12:41 PM
Page 1 of 1
|
|

New Topic/Question
Reply



MultiQuote



|