Skip to content

Instantly share code, notes, and snippets.

@abdul-shajin
Created May 28, 2013 11:24
Show Gist options
  • Select an option

  • Save abdul-shajin/5662086 to your computer and use it in GitHub Desktop.

Select an option

Save abdul-shajin/5662086 to your computer and use it in GitHub Desktop.
a)
1.upto(n).each do |num|
if num % 3 == 0
puts 'Hip'
next
elsif num % 5 == 0
puts 'Hop'
next
elsif (num % 3 == 0) && ( num % 5 == 0)
puts 'Whazaa'
next
end
puts num
end
b)
f = File.read("filename")
wf = Hash.new(0)
f.split(' ').each do |nums|
wf[nums] += 1
end
puts wf
@saurabhnanda
Copy link
Copy Markdown

Abdul, can you spot the bug in your first program?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment