[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: exercise 2019/03

From: Hans-Peter Sorge
Subject: Re: exercise 2019/03
Date: Fri, 17 Apr 2020 22:29:42 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.6.0


this case should be all zeros:
      gradeDistri 'G'
A 0 100
B 0 100
C 0 100
D 0 100
F 0 100

looks ok:
      gradeDistri 'AG'
A 1 100
B 0   0
C 0   0
D 0   0
F 0   0


Am 17.04.20 um 17:29 schrieb Otto Diesenbacher-Reinmüller:
Hi APLers,

first, many thanks to Mohammad, Kacper and Hans-Peter for your hints
regarding 2019/02. I learned a lot, and tried to incooperate in my
solution for 2019/03, having had a deeper look in ∘.X, outer product!

3: Grade Distribution

"The school's administrative department wants to publish some simple
statistics. Given anon-empty character vector of single-letter grades,
produce a 3-column, 5-row,alphabetically-sorted matrix of each grade,
the number of occurrences of that grade, andthe percentage (rounded to 1
decimal position) of the total number of occurrences ofthat grade. The
table should have a row for each grade even if there are no
occurrencesof a grade. Note: due to rounding the last column might not
total 100%.  Hint: The key operator ⌸ could be useful for this problem."
(from the exercise)

∇table←gradeDistri grades;allgr
   allgr←⍪'ABCDF'                      ⍝ all available grades
   table←allgr,+/allgr ∘.= ,grades     ⍝ outer product =, and sum 1s up
   table←table,+/table[;2]             ⍝ 3rd column with sum
   table[;3]←10÷⍨⌊0.5+1000×table[;2]÷table[;3] ⍝ calculate col2÷col3 and round
   ⍝ for sure, rounding could also be done
   ⍝ with ⍕!

br & many thanks for any hint! - Otto

Dipl. Ing. (FH) Otto Diesenbacher-Reinmüller
Salzburg, Österreich

reply via email to

[Prev in Thread] Current Thread [Next in Thread]