1 Replies - 2381 Views - Last Post: 25 February 2012 - 12:38 PM Rate Topic: -----

#1 whamp  Icon User is offline

  • New D.I.C Head

Reputation: -3
  • View blog
  • Posts: 10
  • Joined: 16-February 12

String input

Posted 25 February 2012 - 12:21 PM

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.

Is This A Good Question/Topic? 0
  • +

Replies To: String input

#2 Karel-Lodewijk  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 449
  • View blog
  • Posts: 849
  • Joined: 17-March 11

Re: String input

Posted 25 February 2012 - 12:38 PM

If I understand correctly, they want

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

Was This Post Helpful? 2
  • +
  • -

Page 1 of 1