From c8a5cfa4d573a4d511b20a3e420337758f8d9df3 Mon Sep 17 00:00:00 2001 From: Sebastian Steger Date: Wed, 20 Aug 2025 15:40:18 +0200 Subject: [PATCH] statistics stub --- haskell/08-statistics/README.md | 16 +++++ haskell/08-statistics/data.csv | 97 +++++++++++++++++++++++++++++ haskell/08-statistics/statistics.hs | 17 +++++ 3 files changed, 130 insertions(+) create mode 100644 haskell/08-statistics/README.md create mode 100644 haskell/08-statistics/data.csv create mode 100644 haskell/08-statistics/statistics.hs diff --git a/haskell/08-statistics/README.md b/haskell/08-statistics/README.md new file mode 100644 index 0000000..b2336be --- /dev/null +++ b/haskell/08-statistics/README.md @@ -0,0 +1,16 @@ +# Assignment - Statistics + +The file `08-statistics/data.csv` contains random data of students. It consists of the following columns: + +- first name +- last name +- study subject + +The rest of the columns -- and that number may vary -- contain points for different tasks. The first row is a header. + +Your task is to Write a program that reads a filename from standard input. The corresponding csv-file shall be parsed and then the following statistics shall be computed and printed to standard output: + +- the best student, i.e. the student with the most accumulated points (name and points shall be printed) +- the average points of all rows for each subject (subject and average points shall be printed in ascending order) + +Implement your solution in the file `08-statistics/statistics.hs` and upload the file to moodle. diff --git a/haskell/08-statistics/data.csv b/haskell/08-statistics/data.csv new file mode 100644 index 0000000..9f4657a --- /dev/null +++ b/haskell/08-statistics/data.csv @@ -0,0 +1,97 @@ +First Name,Last Name,Subject,Task1,Task2,Task3,Task4,Task5 +Alice,Johnson,IB,87,45,68,92,33 +Bob,Smith,CSB,56,79,42,88,12 +Charlie,Williams,IMB,73,94,35,64,89 +David,Brown,UIB,41,59,77,29,83 +Emma,Jones,IB,99,21,48,75,56 +Frank,Garcia,CSB,32,81,94,55,23 +Grace,Miller,IMB,74,53,61,95,39 +Henry,Davis,UIB,90,40,28,76,65 +Isabella,Rodriguez,IB,57,86,72,49,100 +Jack,Martinez,CSB,64,31,59,97,14 +Liam,Hernandez,IMB,85,67,50,78,41 +Mia,Lopez,UIB,44,92,33,56,81 +Noah,Gonzalez,IB,68,39,74,82,47 +Olivia,Wilson,CSB,95,20,62,53,34 +Paul,Anderson,IMB,29,88,49,31,77 +Sophia,Thomas,UIB,81,56,93,42,69 +Ethan,Moore,IB,47,77,65,59,92 +Zoe,Taylor,CSB,38,95,40,70,58 +Lucas,Harris,IMB,99,45,83,62,37 +Ava,Clark,UIB,53,66,91,85,29 +Benjamin,Walker,IB,71,58,80,34,61 +Chloe,Hall,CSB,76,23,67,47,94 +Daniel,Allen,IMB,39,82,55,90,73 +Ella,Young,UIB,86,32,99,60,25 +James,King,IB,42,75,48,93,57 +Madison,Wright,CSB,63,54,72,51,88 +Nathan,Scott,IMB,91,37,79,68,45 +Emma,Green,UIB,50,89,31,77,61 +Jacob,Baker,IB,74,69,58,46,97 +Emily,Adams,CSB,88,41,66,79,30 +Samuel,Nelson,IMB,33,85,92,40,50 +Sophia,Carter,UIB,69,47,71,58,94 +Alexander,Mitchell,IB,57,98,36,61,82 +Victoria,Perez,CSB,92,28,64,73,49 +William,Roberts,IMB,45,76,89,55,31 +Ella,Turner,UIB,78,59,41,96,68 +Daniel,Phillips,IB,60,32,85,71,43 +Natalie,Campbell,CSB,55,74,99,28,79 +Mason,Parker,IMB,93,50,39,82,66 +Hannah,Evans,UIB,48,69,57,95,22 +Christopher,Edwards,IB,90,88,34,53,72 +Lucy,Collins,CSB,31,46,81,77,56 +Gabriel,Stewart,IMB,65,79,62,90,44 +Avery,Morris,UIB,80,23,47,36,97 +Ryan,Ross,IB,58,71,83,45,74 +Sophie,Reed,CSB,99,33,60,81,51 +Isaac,Adams,IMB,42,92,30,57,85 +Leah,Bennett,UIB,76,64,55,89,39 +Tyler,Barnes,IB,67,40,78,95,20 +Scarlett,Morgan,CSB,34,84,91,47,53 +John,White,IMB,89,25,72,69,98 +Eleanor,James,UIB,54,58,49,87,62 +Caleb,Wood,IB,31,100,37,46,81 +Amelia,Hill,CSB,73,45,79,66,50 +Julian,Scott,IMB,97,34,89,22,76 +Charlotte,Bryant,UIB,63,92,41,88,32 +Isaiah,Mitchell,IB,81,68,52,39,74 +Lily,Foster,CSB,56,97,44,85,29 +Elijah,Howard,IMB,70,61,36,90,99 +Peyton,Washington,UIB,49,82,67,31,75 +Xavier,Cook,IB,88,55,93,42,64 +Nora,Bailey,CSB,37,72,57,96,47 +Owen,Rivera,IMB,59,30,80,77,91 +Harper,Cooper,UIB,50,99,33,28,65 +Eli,Fisher,IB,78,40,85,92,53 +Mila,Harrison,CSB,62,47,71,89,31 +Adam,Romero,IMB,34,66,98,42,75 +Stella,Patel,UIB,96,39,54,87,68 +Carson,Cox,IB,42,55,79,100,27 +Luna,Sanders,CSB,88,74,46,29,83 +Connor,Henderson,IMB,97,32,53,60,98 +Brooklyn,Bishop,UIB,45,90,61,72,31 +Andrew,Griffin,IB,58,42,87,65,49 +Natalia,Russell,CSB,70,23,74,56,92 +Jason,Myers,IMB,81,67,35,48,79 +Alexa,Hayes,UIB,37,98,55,93,42 +Christian,Long,IB,64,71,82,45,57 +Zoey,Gibson,CSB,90,54,38,100,73 +Brayden,Graham,IMB,39,89,66,53,31 +Maya,Sullivan,UIB,85,77,62,94,25 +Jaxon,Ford,IB,48,35,100,71,83 +Claire,Wallace,CSB,59,46,88,38,76 +Dominic,Cole,IMB,78,92,44,67,50 +Eva,Jenkins,UIB,100,29,53,79,61 +Riley,Perkins,IB,55,97,31,84,30 +Leo,Brooks,CSB,72,40,91,45,99 +Hailey,Reynolds,IMB,31,58,77,90,28 +Aaron,Fox,UIB,83,72,61,35,48 +Kennedy,Stevens,IB,41,66,85,92,53 +Sebastian,Webb,CSB,99,33,60,81,51 +Melanie,Ward,IMB,76,64,55,89,39 +Adrian,Bishop,UIB,67,40,78,95,20 +Jasmine,Cook,IB,34,84,91,47,53 +Miles,Barnes,CSB,89,25,72,69,98 +Savannah,Wood,IMB,54,58,49,87,62 +Hudson,Hill,UIB,31,100,37,46,81 \ No newline at end of file diff --git a/haskell/08-statistics/statistics.hs b/haskell/08-statistics/statistics.hs new file mode 100644 index 0000000..b7b03fc --- /dev/null +++ b/haskell/08-statistics/statistics.hs @@ -0,0 +1,17 @@ +import Data.List (nub, sortOn) +import System.IO + +-- separator -> Input -> Separated Input +-- split :: Char -> String -> [String] + +-- data Entry = + +-- averages :: [Entry] -> [(String, Float)] + +-- content -> Entries +-- parse :: String -> [Entry] + +main :: IO () +main = do + putStrLn "Enter a filename: " + putStrLn "..."