"S10 Day 0: Weighted Mean"의 두 판 사이의 차이

1번째 줄: 1번째 줄:
==개요==
==개요==
;<nowiki>Day 0: Weighted Mean</nowiki>
;<nowiki>Day 0: Weighted Mean</nowiki>
;<nowiki>0일차: [[가중 평균]]</nowiki>
;<nowiki>0일차:</nowiki> [[가중 평균]]
* https://www.hackerrank.com/challenges/s10-weighted-mean/problem
* https://www.hackerrank.com/challenges/s10-weighted-mean/problem



2018년 8월 5일 (일) 09:42 판

1 개요

Day 0: Weighted Mean
0일차: 가중 평균
해커랭크 10 Days of Statistics
문제 C C++ C# Go Java node.js Perl PHP Python R Ruby
0-1 Day e
S10 Day 0: Mean, Median, and Mode
S10 Day 0: Weighted Mean
S10 Day 1: Quartiles
S10 Day 1: Interquartile Range
S10 Day 1: Standard Deviation

2 같이 보기

3 Python

N = int(input())
X = list(map(int, input().split()))
W = list(map(int, input().split()))
sum_X = sum([a*b for a,b in zip(X,W)])
print(round((sum_X/sum(W)),1))
# 32.0

4 R

a <- scan("stdin")
n <- a[1]
x <- a[1:n+1]
w <- a[n+1:n+1]
cat(sprintf("%.1f", weighted.mean(x,w) ))
a <- scan(file="stdin")
n <- a[1]
x <- a[1:n+1]
w <- a[n+1:n+1]
cat(sprintf("%.1f", weighted.mean(x,w) ))
a <- scan("stdin")
n <- a[1]
x <- a[2:(n+1)]
w <- a[(n+2):(2*n+1)]
cat(sprintf("%.1f", weighted.mean(x,w) ))
a <- scan("stdin")
n <- a[1]
x <- a[2:(n+1)]
w <- a[(n+2):(2*n+1)]
cat( format(sum(x*w)/sum(w),nsmall=1) )
lines <- readLines(file('stdin', open='r'))
x <- as.numeric(unlist(strsplit(lines[2],split=" ")))
w <- as.numeric(unlist(strsplit(lines[3],split=" ")))
cat( format(sum(x*w)/sum(w),nsmall=1) )
문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}