<repo_name>cs20b070-Yuvan/SummerSchool-Assignment<file_sep>/entropy.py
#assignment 1 1st question cs20b070

import numpy as np

n = 100

y = np.random.randint(0,2,(1,n))
y_cap = np.random.rand(n)

entropy = (-1/n)*((np.sum(y*np.log2(y_cap))) + (np.sum((1-y)*(np.log2(1-y_cap)))))

print("The cross entropy is")
print(entropy)<file_sep>/Yuan_CS20B070/indexfind.py

#assignment 1 2nd question cs20b070

class IndicesFind :
    def __init__(self,array,target) :
         self.arr = array
         self.target = target
         self.solution = {}

         ans = 0
         for i in range (len(self.arr)):
            for j in range (len(self.arr)):
              if (self.arr[i] + self.arr[j] == self.target):
                ans+=1
                self.solution[ans] = [i, j]

    def PrintSolution (self):
         print(self.solution)

array = [10,20,10,40,50,60,70]
target = 50

numbers = IndicesFind(array,target)
numbers.PrintSolution()