Tech Urja 2k24 Code War Hackathon Experience

This is an experience of an Tech Fest named Tech Urja 2k24 held in Khalsa College Of Engineering And Technology. In my previous story I have shared another experience of same event. This experience is of second day in that Tech Fest. My friend and I were very happy because we have won 3000rs in previous competition. But today we both were nervous because In this competition M.C.A, B. Tech And B.C.A students are allowed to participate. We are just in 2nd semester of B.C.A, The problems which we encountered were:

1. Pascal triangle

Python
def showPascalTriangle(n:int):
     arr = [[0 for x in range(n)] for y in range(n)] 
     for line in range (0, n):
        for i in range (0, line + 1):
            if(i is 0 or i is line):
                arr[line][i] = 1
                print(arr[line][i], end = " ") 
            else:
                arr[line][i] = (arr[line - 1][i - 1] +
                                arr[line - 1][i])
                print(arr[line][i], end = " ")             
        print("\n", end = "")
n = 5
showPascalTriangle(n)


2. Smallest sum in k sized window of an array

Python
def minimumSum(arr, n, k):
    if (n < k):
        return -1
    res = 0
    for i in range(k):
        res += arr[i]
    curr_sum = res
    for i in range(k, n):
        curr_sum += arr[i] - arr[i-k]
        res = min(res, curr_sum)
     return res

arr = [1, 4, 2, 10, 2, 3, 1, 0, 20]
k = 4
n = len(arr)
print(minimumSum(arr, n, k))

3. Find nth permutation of a string

Python
def next_pm(L):
    n = len(L)
    i = n - 2
    while i >= 0 and L[i] >= L[i + 1]:
        i -= 1
 
    if i == -1:
        return False
 
    j = i + 1
    while j < n and L[j] > L[i]:
        j += 1
    j -= 1
 
    L[i], L[j] = L[j], L[i]
 
    left = i + 1
    right = n - 1
 
    while left < right:
        L[left], L[right] = L[right], L[left]
        left += 1
        right -= 1
 
    return True
def Permutenth(string, n):
    string = list(string)
    new_string = []
 
    string.sort()
    j = 2
 
    while next_pm(string):
        new_string = string
 
        if j == n:
            break
        j += 1
    print(''.join(new_string))
 
if __name__ == "__main__":
    string = "thisismystringfortest"
    n = 20
    Permutenth(string, n)


4. Find all permutations of a string

Python
def permute(a, l, r): 
    if l == r: 
        print("".join(a)) 
    else: 
        for i in range(l, r): 
            a[l], a[i] = a[i], a[l] 
            permute(a, l+1, r) 
            a[l], a[i] = a[i], a[l]
  
  
string = "Beginner"
n = len(string) 
a = list(string)
permute(a, 0, n)


We were successfully solved 3 problems, but First problem was tough, So we were unable to solve that problem. Because I were not solved that problem, I were fully disappointed and I said my friend, lets go home but he said me don’t lose hope we have given out best, Oh sorry I forgot to tell you that each team has 2 members. So, from morning we waited till afternoon there. And finally they announces result and we stood second position and also won cash prize of 1500rs cash along with participation certificate.

I enjoyed there because… , I earned there .

Just kidding guys, But I really have a very good time because they have a very good environment in their college. If you are in Amritsar, You can choose that college for your graduation.

Thank you.



Contact Us