From adcb5e97c3e2891a0de08ae609257bc6093b4f12 Mon Sep 17 00:00:00 2001 From: Aleksi Mustonen Date: Wed, 11 Jan 2017 22:52:42 +0200 Subject: [PATCH] =?UTF-8?q?opin=20k=C3=A4ytt=C3=A4m=C3=A4=C3=A4n=20injecti?= =?UTF-8?q?=C3=A4=20ja=20k=C3=A4ytt=C3=A4m=C3=A4=C3=A4n=20float=20arvoja?= 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..c76f19b 100644 --- a/koodi.rb +++ b/koodi.rb @@ -1 +1,7 @@ -# kirjoita koodi tänne +def keskiarvo(taulukko) + 1.0* taulukko.inject(0){|tulos,x| tulos + x}/ taulukko.length +end + + + +puts(keskiarvo([2,1]))