From 5a0dbc0c4055857f4c9a243c7b25a0ef69cccbc7 Mon Sep 17 00:00:00 2001 From: Srijan S Bhat Date: Tue, 3 Jan 2023 00:09:59 +0530 Subject: [PATCH 1/2] Srijan S Bhat - Task-1 --- Task01A.py | 10 ++++++++++ Task01B.py | 19 +++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 Task01A.py create mode 100644 Task01B.py diff --git a/Task01A.py b/Task01A.py new file mode 100644 index 0000000..0fc796d --- /dev/null +++ b/Task01A.py @@ -0,0 +1,10 @@ +import numpy as np +import math +vec1 = np.random.rand(100) +vec2 = np.random.randint(0,2,100) +n = 100 +sum = 0 +for i in range(100): + sum = sum + (vec2[i] * math.log(vec1[i],2) + (1 - vec2[i]) * math.log(1 - vec1[i],2)) + +print(-sum/n) diff --git a/Task01B.py b/Task01B.py new file mode 100644 index 0000000..5efb362 --- /dev/null +++ b/Task01B.py @@ -0,0 +1,19 @@ +import numpy as np +class target: + def __init__(self,arr,tgtsum): + self.arr = arr + self.tgtsum = tgtsum + self.dict = {} + self.c = 1 + def pairs(self): + for i in range(len(self.arr)): + for j in range(len(self.arr)): + if self.arr[i] + self.arr[j] == self.tgtsum: + self.dict[self.c] = [i,j] + self.c += 1 + + print(self.dict) +list = np.random.randint(0,100,25) +print(list) +s = target(list,50) +s.pairs() From 4b5778c8ff91dd387eac87a6eda77b3f8ee241de Mon Sep 17 00:00:00 2001 From: Srijan S Bhat Date: Tue, 3 Jan 2023 00:28:33 +0530 Subject: [PATCH 2/2] Srijan S Bhat - Task-1 --- Task01A.py => Files/Task01A.py | 0 Task01B.py => Files/Task01B.py | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename Task01A.py => Files/Task01A.py (100%) rename Task01B.py => Files/Task01B.py (100%) diff --git a/Task01A.py b/Files/Task01A.py similarity index 100% rename from Task01A.py rename to Files/Task01A.py diff --git a/Task01B.py b/Files/Task01B.py similarity index 100% rename from Task01B.py rename to Files/Task01B.py