Skip to content

Instantly share code, notes, and snippets.

@kannans
Last active August 29, 2015 14:23
Show Gist options
  • Save kannans/82ee400c1d90331c38c6 to your computer and use it in GitHub Desktop.
Save kannans/82ee400c1d90331c38c6 to your computer and use it in GitHub Desktop.
Script to write a program
1) Write a program to Read line from text and sort with number of lines
#sample.txt
"Its great"
"How are you"
"I am fine thank you"
"Hi Ruby"
Eg:
# Input
$ ruby my-program.rb sample.txt 3
# Output
"I am fine thank you"
"How are you"
"Its great"
------------------------------------------------------------------
# 2) Reverse string without using ruby methods.
def reverse(string)
# your code here
end
# Input
reverse("Steve Jobs")
# output
"sboJ evetS"
------------------------------------------------------------------
# 3) Concat a text with class object
full_name = Concat.new("Steve", "jobs")
puts full_name
# Result
"Steve jobs"
------------------------------------------------------------------
# 4) Write a program to return all(1..100) values that are divisible by 3 and 7
------------------------------------------------------------------
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment