simple-exercises/ruby-exercises/easy-4.rb
# Assign Pods
# ------------------------------------------------------------------------------
# You are a JumpStart TA and you need to assign students to sit with other
# students who are at the same place in the curriculum.
#
# Given a list of students ordered by how far they are in the course and a
# list of pods, return their seat assignments.  Assume you can only seat four
# people per pod.  "Fill up" each pod as you go.  It's OK to have a pod with
# four people and the next pod with one person).  It's OK to have empty pods
# if there aren't enough students.
Assign Pods
You are a JumpStart TA and you need to assign students to sit with other
students who are at the same place in the curriculum.

Given a list of students ordered by how far they are in the course and a
list of pods, return their seat assignments.  Assume you can only seat four
people per pod.  "Fill up" each pod as you go.  It's OK to have a pod with
four people and the next pod with one person).  It's OK to have empty pods
if there aren't enough students.
Assign Pods You are a JumpStart TA and you need to assign students to sit with other students who are at the same place in the curriculum . Given a list of students ordered by how far they are in the course and a list of pods return their seat assignments . Assume you can only seat four people per pod . " Fill up " each pod as you go . It ' s OK to have a pod with four people and the next pod with one person ) . It ' s OK to have empty pods if there aren ' t enough students .
def assign_pods(students, pods)
  assignments = Hash.new([])
  j = nil
  pods.each_with_index do |pod, i|
    x, y = 4*i, 4*(i + 1)
    row = students[x...y]
    assignments[pod] = row
    if x >= students.length or y >=students.length
      break
    end
  end
  assignments
end
def assign_pods ( students , pods ) assignments = Hash . new ( [ ] ) j = nil pods . each_with_index do | pod , i | x , y = 4 * i , 4 * ( i + 1 ) row = students [ x ... y ] assignments [ pod ] = row if x >= students . length or y >= students . length break end end assignments end
Assign Pods
You are a JumpStart TA and you need to assign students to sit with other
students who are at the same place in the curriculum.
Assign Pods You are a JumpStart TA and you need to assign students to sit with other students who are at the same place in the curriculum .
# four people per pod # if pod is empty will not be included in the # hashmap
students
<not_specific>
pods
<not_specific>