Skip to content

Commit 92cf30f

Browse files
committed
add 001. Laptop Battery Life
1 parent dc2d6a0 commit 92cf30f

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Problem: https://www.hackerrank.com/challenges/battery/problem
2+
# Score: 10
3+
4+
5+
import pandas as pd
6+
from sklearn.linear_model import LinearRegression
7+
8+
9+
timeCharged = float(input())
10+
data = pd.read_csv('trainingdata.txt', names=['charged', 'lasted'])
11+
train = data[data['lasted'] < 8]
12+
model = LinearRegression()
13+
model.fit(train['charged'].values.reshape(-1, 1), train['lasted'].values.reshape(-1, 1))
14+
ans = model.predict([[timeCharged]])
15+
print(min(ans[0][0], 8))

0 commit comments

Comments
 (0)