CIS 343 |
Ruby |
Winter 2023 |
c = 5/9(f - 32)
p1 abd p2. Each parameter should
be a Hash with keys :x and :y.rectangle(width, height) that prints a rectangle of asterisks with the given width and height.each to count the number of occurrences of item in an array.Array#select method.Array#each to print the even integers.Array.select to filter and return only the even integers, then print them out.tabulate_sections
that produces a hash that maps instrument sections to the number of instruments in that section of the ensemble. For example,
given the input
ensemble = [:piano, :clarinet, :oboe, :trumpet, :frenchhorn, :violin, :piano, :oboe, :cello] andsection = { piano: :percussion, clarinet: :woodwind, oboe: :woodwind, flute: :woodwind, trumpet: :brass, frenchhorn: :brass, violin: :string, oboe: :woodwind, cello: :string, viola: :string, timpani: :percussion}
{percussion: 2, woodwind: 3, brass: 2, strings: 2}.
Hash#values, Array#uniq, Array#select, Array#map, and Array#reduce.Array#select.Updated Monday, 3 April 2023, 9:46 AM