Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions problems/queue/queue.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env ruby

class Queue
def initialize
@queue = []
end

def add(val)
@queue << val
end

def remove
@queue.shift
end
end

q = Queue.new
q.add(1)
q.add(2)
q.add(3)
puts q.remove()
puts q.remove()
puts q.remove()
puts q.remove()
15 changes: 15 additions & 0 deletions problems/substrings/substrings.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env ruby

def sub_strings(str)
sub_strs = str.split('')

str.size.times do |i|
for j in (i+1...str.size)
sub_strs << str[i..j]
end
end

sub_strs
end

puts sub_strings('abc').inspect