From 621523309232b0666a143e220dd2a9f7eb5afec4 Mon Sep 17 00:00:00 2001 From: Jesper Kuutti Date: Wed, 5 Sep 2018 18:14:27 +0300 Subject: [PATCH] =?UTF-8?q?Testit=20l=C3=A4pi=20paikallisesti?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- koodi.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/koodi.rb b/koodi.rb index 932f2b3..0a7f2b3 100644 --- a/koodi.rb +++ b/koodi.rb @@ -1 +1,7 @@ -# kirjoita koodi tänne +def keskiarvo(t) + summa = t.inject(0) {|sum, x| sum + x} + 1.0*summa / t.count + end + + + puts keskiarvo [3, 5, 6, 11] \ No newline at end of file