-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFirst.py
114 lines (102 loc) · 3 KB
/
First.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
import time
import pandas as pd
import math
from datetime import date
import datetime
def best_day():
dt = datetime.datetime.today()
df = pd.read_excel("temp_data.xlsx","Sheet1")
#print(df['dates'][91])
if(dt.month==11):
i =dt.day-1
no_of_days=30
if(dt.month==12):
i=dt.day+30
no_of_days=31
#print(i)
profit = [0,0,0,0,0,0,0,0,0,0,0,0,0,0]
j=i+40
k=0
#print(j)
#print(df['dates'][j])
for i in range(i,i+14):
#print(i)
for j in range(i+40,i+54):
#print(j)
#print("hello")
#print(k)
#print("hello")
#print(df['dates'][j+40])
if (df['max'][j]<33 and df['max'][j]>30):
profit[k]=profit[k]+1
if (df['max'][j]>33):
greater=33-df['max'][j]
greater=greater/100
#print(greater)
profit[k]=profit[k]+math.exp(greater)
if (df['max'][j]<30):
lesser=df['max'][j]-30
lesser=lesser/100
#print(lesser)
profit[k]=profit[k]+math.exp(lesser)
k=k+1
#print(profit[i])
'''
def bubble_sort(nums):
swapped = True
while swapped:
swapped = False
for i in range(len(nums) - 1):
if nums[i] > nums[i + 1]:
# Swap the elements
nums[i], nums[i + 1] = nums[i + 1], nums[i]
# Set the flag to True so we'll loop again
swapped = True
# Verify it works
bubble_sort(profit)
print(random_list_of_nums)
'''
max_date=dt.day
max_profit=profit[0]
for i in range(14):
#print(profit[i])
#max_profit=profit[0]
#max_date=dt.day
if(profit[i]>max_profit):
max_profit=profit[i]
value=i
#print(i)
#print(value)
max_date=max_date+value
if(max_date>no_of_days):
max_date=max_date-no_of_days
profit[value]=0.0
#print("test")
max_date_1=dt.day
max_profit_1=profit[0]
for t in range(14):
#print(profit[t])
#max_profit_1=profit[0]max_profit_1=profit[0]
#max_date_1=dt.day
if(profit[t]>max_profit_1):
max_profit_1=profit[t]
value=t
# #print(i)
#print(max_date_1)
#print(i)
#print(value)
max_date_1=max_date_1+value
if(max_date_1>no_of_days):
max_date_1=max_date_1-no_of_days
#print(max_date_1)
#print(max_profit)
#print(max_profit_1)
print(max_date)
print(max_date_1)
output_file= open("output_file.txt","w+")
#output_file.write(str(max_profit))
output_file.write(str(max_date))
output_file.write(" And ")
output_file.write(str(max_date_1))
output_file.write(" are the most favorable days for seed plantat ")
return(max_date)