Week 12: Programming Assignment 1 [Due on 2025-10-16, 23:59 IST]
Autonomous Warehouse Robot Inventory Update In a modern automated warehouse, an autonomous robot manages a sorted list of product IDs to keep track of available stock. Whenever a new product arrives, the robot must insert its ID into the correct position in the sorted list to maintain order. However, due to limited programming capabilities on the robot’s chip, only append() and remove() methods are available for list operations — all other built-in list methods are restricted. Your Task Write a function: def insert(L, x) that: Takes a sorted list of integers L representing product IDs. Takes an integer x representing the new product ID to be inserted. Returns a new sorted list with x inserted at the correct position without modifying the original list. Input Format You do not need to take input from the user. The function insert(L, x) will be called directly with: L: a sorted list of integers x: a single integer to insert Output Format The function should return the new sorted list after inserting x. Constraints Do not use any list methods except append() and remove(). The list L will always be sorted in ascending order. Example # Example function call print(insert([10, 20, 30, 40], 25)) Output [10, 20, 25, 30, 40]
Week 12: Programming Assignment 2 [Due on 2025-10-16, 23:59 IST ]
Secure Sensor Data Analysis In a secure data monitoring system, a network of sensors records values periodically. The values are stored in a list L, where each position in the list corresponds to a time slot. To ensure data integrity, a special check is performed: We identify all prime-numbered time slots (based on zero-indexing) and then count how many of those slots contain prime numbers themselves. Your Task Write a function: def primes_galore(L) that: Accepts a list L of non-negative integers. Finds all indices in L that are prime numbers (considering zero-based indexing). Counts how many of those prime indices store prime numbers. Returns this count. You may define and use helper functions (e.g., to check whether a number is prime). Input Format You do not need to take input from the user. The function primes_galore(L) will be called directly with a list of integers. Output Format The function should return an integer: the count of prime indices that store prime numbers.
Week 12: Programming Assignment 3 [Due on 2025-10-16, 23:59 IST ]
Validating Nested Bracket Sequences In a code analysis system, source files may contain multiple types of brackets: round ( ), square [ ], and curly { }. To ensure correct syntax structure, the system must verify that the brackets are balanced. A bracket sequence is considered balanced if: The number of opening and closing brackets of each type is the same. An opening bracket cannot be immediately followed by a closing bracket of a different type. Every opening bracket must eventually be closed by a bracket of the same type. Your Task Write a function: def balanced(word): that: Accepts a string word (containing only the characters { } [ ] ( )). Returns True if the string is balanced, and False otherwise. You do not need to take input from the user. The function will be called directly with a string argument.
Week 11: Programming Assignment 1 Due on 2025-10-09, 23:59 IST
Goldbach’s Conjecture Problem Statement: Goldbach’s conjecture is one of the oldest and best-known unsolved problems in number theory. It states that every even number greater than 2 is the sum of two prime numbers. Your Task: Write a function Goldbach(n) where n is a positive even number (n > 2) that returns a list of tuples. Each tuple (a, b) should satisfy: a ≤ b Both a and b are prime numbers a + b = n The tuples should be returned in sorted order. Notes: n will always be an even integer greater than 2. Both numbers in a tuple must be prime. Return the tuples in sorted order. You need to take the input n from the user. Print the output. Examples: # Example 1 Input: 12 Output: [(5, 7)] # Example 2 Input: 26 Output: [(3, 23), (7, 19), (13, 13)]
Week 11: Programming Assignment 2 Due on 2025-10-09, 23:59 IST
Problem: Selecting Athletes for a Balanced Team A national sports committee is selecting players for an upcoming championship. The goal is to form a balanced team where the performance scores of the selected players are as close as possible. Task Write a function find_Min_Difference(L, P) that determines the smallest possible difference between the highest and lowest scores among any valid selection of P players from the list L. Function Details Input: L: A list of integers representing the performance scores of athletes. P: An integer, the number of athletes to be selected (P < len(L)). Output: An integer representing the smallest possible difference between the maximum and minimum scores of any group of P selected athletes. Notes The scores may not be sorted. Multiple selections may yield the same minimum difference. The function should return the minimum possible difference. Example Input: L = [3, 4, 1, 9, 56, 7, 9, 12, 13] P = 5 Possible selections: [3, 4, 7, 9, 9] → 9 - 3 = 6 [7, 9, 9, 12, 13] → 13 - 7 = 6 Output: 6
Week 11: Programming Assignment 3 Due on 2025-10-09, 23:59 IST
Problem: Secure Communication for Disaster Response Teams During emergency situations such as natural disasters, communication between rescue teams must remain confidential to prevent misuse of critical information. To achieve this, messages are encrypted using a Caesar Cipher before transmission. The Caesar Cipher works by shifting each letter in the message by a fixed number of positions in the alphabet. Example (Shift = 3): ATTACK → DWWDFN Here, A → D, T → W, Z → C (letters wrap around). Only uppercase alphabets (A–Z) are encrypted. Spaces and punctuation remain unchanged. Task Write a program to encrypt a given message using Caesar Cipher. You must define the function: def encrypt_message(message, shift): # Your code here Input Format The first line of input contains the message (string, may include spaces). The second line contains the shift value (integer). Output Format Print the encrypted message after applying the Caesar Cipher. Example Input: HELLO 3 Output: KHOOR