├── Familiarization Module - Python ├── Practice - Add 2 numbers │ ├── README.md │ └── main.py └── Practice - Multiply 2 numbers │ ├── README.md │ └── main.py ├── For CS - Module 1 - Lab 1 - Python ├── Contiguous Array │ ├── README.md │ └── main.py └── String analysis │ ├── README.md │ └── main.py ├── For CS - Module 1 - Lab 2 - Python ├── Queue using Two Stacks │ ├── README.md │ └── main.py └── Valid Sudoku │ ├── README.md │ └── main.py ├── For CS - Module 2 - Lab 1 - Python ├── Longest Substring │ ├── README.md │ └── main.py └── Simple Text Editor │ ├── README.md │ └── main.py ├── For CS - Module 2 - Lab 2 - Python ├── Lego Blocks │ ├── README.md │ └── main.py └── Sum of Numbers With Units Digit K │ ├── README.md │ └── main.py ├── For CS - Module 3 - Lab 1 - Python ├── Maximize Number of Subsequences in a String │ ├── README.md │ └── main.py └── Cookies │ ├── README.md │ └── main.py ├── For CS - Module 3 - Lab 2 - Python ├── No Prefix set │ ├── README.md │ └── main.py └── Sliding Subarray Beauty │ ├── README.md │ └── main.py ├── For CS - Module 4 - Contest - Python ├── Is Graph Bipartite │ ├── Readme.md │ └── main.py └── Transform and Compare │ ├── Readme.md │ └── main.py ├── For CS - Module 4 - Lab 1 - Python ├── Array Manipulation │ ├── README.md │ └── main.py └── Clumsy Factorial │ ├── README.md │ └── main.py ├── For CS - Module 4 - Lab 2 - Python ├── Egyptian Fraction │ ├── README.md │ └── main.py └── Query Kth Smallest Trimmed Number │ ├── README.md │ └── main.py ├── For CS - Module 1 - Contest - Python ├── 000A Time Stamp PY │ ├── README.md │ └── main.py ├── Query Kth Smallest Trimmed Number │ ├── README.md │ └── main.py ├── Recursive (super) super digit sum │ ├── README.md │ └── main.py └── job sequencing │ ├── README.md │ └── main.py ├── For CS - Module 2 and 3 - Contest - Python ├── Foursum │ ├── Readme.md │ └── main.py ├── Merge two sorted linked lists │ ├── Readme.md │ └── main.py └── Task Scheduling │ ├── Readme.md │ └── main.py └── LICENSE / Familiarization Module - Python / Practice - Add 2 numbers/README.md: -------------------------------------------------------------------------------- 1 | 2 | Problem Statement 3 | Add 2 numbers 4 | 5 | A practice lab to add two numbers and print output results. The hint provides the answer. Try entering input values and checking the output. 6 | 7 | Important Note: 8 | Ensure that you save your solution before progressing to the next question and before submitting your answer. 9 | 10 | Exercise-1 11 | input: 12 | 4 13 | 5 14 | output: 15 | 9 16 | Exercise-2 17 | input: 18 | 7 19 | -3 20 | output: 21 | 4 22 | 23 | -------------------------------------------------------------------------------- / Familiarization Module - Python / Practice - Add 2 numbers/main.py: -------------------------------------------------------------------------------- 1 | def add(a,b): 2 | return a+b 3 | 4 | 5 | num1 = int(input()) 6 | num2 = int(input()) 7 | ret = add(num1,num2) 8 | print(ret) 9 | -------------------------------------------------------------------------------- / Familiarization Module - Python / Practice - Multiply 2 numbers/README.md: -------------------------------------------------------------------------------- 1 | 2 | Multiply 2 numbers 3 | 4 | A practice lab to multiply 2 numbers and print out the result. The Hint gives the answer. Try entering input values and checking for the output. 5 | 6 | Important Note: 7 | Ensure that you save your solution before progressing to the next question and before submitting your answer. 8 | 9 | Exercise-1 10 | 11 | input: 12 | 4 13 | 5 14 | output: 15 | 20 16 | 17 | Exercise-2 18 | 19 | input: 20 | 7 21 | -3 22 | output: 23 | -21 24 | 25 | 26 | -------------------------------------------------------------------------------- / Familiarization Module - Python / Practice - Multiply 2 numbers/main.py: -------------------------------------------------------------------------------- 1 | def mul(a,b): 2 | return a*b 3 | 4 | num1 = int(input()) 5 | num2 = int(input()) 6 | ret = mul(num1,num2) 7 | print(ret) 8 | -------------------------------------------------------------------------------- / For CS - Module 1 - Lab 1 - Python / Contiguous Array/README.md: -------------------------------------------------------------------------------- 1 | 2 | Contiguous Array 3 | 4 | Given a binary array 'nums', you are required to find the maximum length of a contiguous subarray that contains an equal number of 0s and 1s. 5 | 6 | Explanation: 7 | 8 | A binary array is an array that contains only 0s and 1s. 9 | A subarray is any subset of the indices of the original array. 10 | A contiguous subarray is a subarray in which all the elements are consecutive, i.e., any element between the first and last element of the subarray is also part of it. 11 | 12 | Examples: 13 | Input :nums = [0, 1] 14 | Output : 2 15 | Explanation: The longest contiguous subarray with an equal number of 0s and 1s is [0, 1] with a length of 2. 16 | Input : nums = [0, 1, 0] 17 | Output : 2 18 | Explanation: The longest contiguous subarray with an equal number of 0s and 1s is either [0, 1] or [1, 0], both with a length of 2. 19 | Input : nums = [0, 0, 0, 1, 1, 1] 20 | Output : 6 21 | Explanation: The longest contiguous subarray with an equal number of 0s and 1s is [0, 0, 0, 1, 1, 1] with a length of 6. 22 | The problem requires finding the maximum length of a contiguous subarray in the binary array 'nums' that contains an equal number of 0s and 1s. 23 | 24 | Important Note: Ensure that you save your solution before progressing to the next question and before submitting your answer. 25 | 26 | Exercise-1 27 | 28 | Input : 29 | 0 0 0 1 1 1 1 0 30 | 31 | Output : 32 | 8 33 | 34 | Exercise-2 35 | 36 | Input: 37 | 1 0 0 1 1 1 1 0 38 | 39 | Output: 40 | 4 41 | 42 | 43 | -------------------------------------------------------------------------------- / For CS - Module 1 - Lab 1 - Python / Contiguous Array/main.py: -------------------------------------------------------------------------------- 1 | def findMaxLength(nums): 2 | nums = list(map(int, nums.split())) 3 | 4 | 5 | sum_index_map = {0: -1} 6 | max_length = 0 7 | current_sum = 0 8 | 9 | for index, num in enumerate(nums): 10 | 11 | current_sum += 1 if num == 1 else -1 12 | 13 | if current_sum in sum_index_map: 14 | max_length = max(max_length, index - sum_index_map[current_sum]) 15 | else: 16 | sum_index_map[current_sum] = index 17 | 18 | return max_length 19 | 20 | 21 | nums=input() 22 | print(findMaxLength(nums)) 23 | -------------------------------------------------------------------------------- / For CS - Module 1 - Lab 1 - Python /String analysis/README.md: -------------------------------------------------------------------------------- 1 | 2 | String Analysis 3 | 4 | You are given a string that represents an email address: "My e-mail: eMail_Address321@anymail.com". Your task is to analyze the composition of the characters in the string and determine the percentage of uppercase letters, lowercase letters, digits, and other characters such as symbols (#$., etc). 5 | 6 | To accomplish this, you need to break down the string and calculate the percentage for each category. The results are as follows: 7 | 8 | Uppercase letters: 7.5% 9 | Lowercase letters: 65% 10 | Digits: 7.5% 11 | Other characters (symbols): 20% 12 | 13 | Important Note: Ensure that you save your solution before progressing to the next question and before submitting your answer. 14 | 15 | Exercise-1 16 | 17 | Input : 18 | 19 | Support1@litwork.in 20 | 21 | Output : 22 | 23 | 5.263% 24 | 78.947% 25 | 5.263% 26 | 10.526% 27 | 28 | Exercise-2 29 | 30 | Input: 31 | 32 | Client.1234@litwork.in 33 | 34 | Output: 35 | 36 | 4.545% 37 | 63.636% 38 | 18.182% 39 | 13.636% 40 | 41 | -------------------------------------------------------------------------------- / For CS - Module 1 - Lab 1 - Python /String analysis/main.py: -------------------------------------------------------------------------------- 1 | def analyze_email_address(email): 2 | total_chars = len(email) 3 | uppercase_count = 0 4 | lowercase_count = 0 5 | digit_count = 0 6 | symbol_count = 0 7 | 8 | for char in email: 9 | if char.isupper(): 10 | uppercase_count += 1 11 | elif char.islower(): 12 | lowercase_count += 1 13 | elif char.isdigit(): 14 | digit_count += 1 15 | else: 16 | symbol_count += 1 17 | 18 | uppercase_percentage = (uppercase_count / total_chars) * 100 19 | lowercase_percentage = (lowercase_count / total_chars) * 100 20 | digit_percentage = (digit_count / total_chars) * 100 21 | symbol_percentage = (symbol_count / total_chars) * 100 22 | 23 | print(f"{uppercase_percentage:.3f}%") 24 | print(f"{lowercase_percentage:.3f}%") 25 | print(f"{digit_percentage:.3f}%") 26 | print(f"{symbol_percentage:.3f}%") 27 | 28 | # Example usage 29 | email_address = input() 30 | analyze_email_address(email_address) 31 | 32 | -------------------------------------------------------------------------------- / For CS - Module 1 - Lab 2 - Python / Queue using Two Stacks/README.md: -------------------------------------------------------------------------------- 1 | 2 | Queue 3 | 4 | Write a program to implement a custom queue using two stacks. The queue should support the following three types of queries: 5 | Enqueue: This query type is denoted by "1 x", where x is an element to be enqueued. It means that you need to insert element x at the end of the queue. 6 | Dequeue: This query type is denoted by "2". It indicates that you should remove the element at the front of the queue. 7 | Print Front: This query type is denoted by "3". It instructs you to print the element at the front of the queue without removing it. 8 | 9 | Exercise-1 10 | input: 11 | 1 42,2,1 14,3 12 | 13 | output: 14 | 14 15 | 16 | Exercise-2 17 | input: 18 | 1 23,2,1 14,3,2,1 78,3 19 | 20 | Output: 21 | 14 22 | 78 23 | 24 | -------------------------------------------------------------------------------- / For CS - Module 1 - Lab 2 - Python / Queue using Two Stacks/main.py: -------------------------------------------------------------------------------- 1 | class CustomQueue: 2 | def __init__(self): 3 | self.enqueue_stack = [] 4 | self.dequeue_stack = [] 5 | 6 | def enqueue(self, element): 7 | self.enqueue_stack.append(element) 8 | 9 | def dequeue(self): 10 | if not self.dequeue_stack: 11 | while self.enqueue_stack: 12 | self.dequeue_stack.append(self.enqueue_stack.pop()) 13 | if self.dequeue_stack: 14 | self.dequeue_stack.pop() 15 | 16 | def print_front(self): 17 | if not self.dequeue_stack: 18 | while self.enqueue_stack: 19 | self.dequeue_stack.append(self.enqueue_stack.pop()) 20 | if self.dequeue_stack: 21 | print(self.dequeue_stack[-1]) 22 | 23 | # Example usage 24 | custom_queue = CustomQueue() 25 | 26 | queries = input().strip().split(',') 27 | 28 | for query in queries: 29 | query_type, *rest = query.split() 30 | if query_type == '1': 31 | custom_queue.enqueue(int(rest[0])) 32 | elif query_type == '2': 33 | custom_queue.dequeue() 34 | elif query_type == '3': 35 | custom_queue.print_front() 36 | 37 | -------------------------------------------------------------------------------- / For CS - Module 1 - Lab 2 - Python / Valid Sudoku/README.md: -------------------------------------------------------------------------------- 1 | 2 | Sudoku board validation algorithm 3 | 4 | You have been tasked with developing an algorithm to validate a 9 x 9 Sudoku board. Your algorithm needs to verify the validity of the filled cells on the board, adhering to the following conditions: 5 | 6 | Every row should contain the numbers 1-9 exactly once, without repetition. 7 | Every column should contain the numbers 1-9 exactly once, without repetition. 8 | Each of the nine 3 x 3 sub-boxes within the grid should contain the numbers 1-9 exactly once, without repetition. 9 | 10 | Can you outline an algorithm or a step-by-step approach to determine if the given Sudoku board configuration is valid based on these conditions? 11 | 12 | Important Note: Ensure that you save your solution before progressing to the next question and before submitting your answer. 13 | 14 | Exercise-1 15 | 16 | Input : 17 | 18 | 9 19 | 5 3 . . 7 . . . . 20 | 6 . . 1 9 5 . . . 21 | . 9 8 . . . . 6 . 22 | 8 . . . 6 . . . 3 23 | 4 . . 8 . 3 . . 1 24 | 7 . . . 2 . . . 6 25 | . 6 . . . . 2 8 . 26 | . . . 4 1 9 . . 5 27 | . . . . 8 . . 7 9 28 | 29 | Output : 30 | 31 | YES 32 | 33 | Exercise-2 34 | 35 | Input: 36 | 37 | 9 38 | 5 3 . . 7 . . . . 39 | 5 . . 1 9 5 . . . 40 | . 9 8 . . . . 6 . 41 | 8 . . . 6 . . . 3 42 | 4 . . 8 . 3 . . 1 43 | 7 . . . 2 . . . 6 44 | . 6 . . . . 2 8 . 45 | . . . 4 1 9 . . 5 46 | . . . . 8 . . 7 9 47 | 48 | Output: 49 | NO 50 | 51 | -------------------------------------------------------------------------------- / For CS - Module 1 - Lab 2 - Python / Valid Sudoku/main.py: -------------------------------------------------------------------------------- 1 | from collections import Counter 2 | 3 | def isValidSudoku(board): 4 | rows = [set() for _ in range(len(board))] 5 | cols = [set() for _ in range(len(board[0]))] 6 | squares = [[set() for _ in range(3)] for _ in range(3)] 7 | 8 | for i in range(9): 9 | for j in range(9): 10 | val = board[i][j] 11 | if val != ".": 12 | if val in rows[i] or val in cols[j] or val in squares[i//3][j//3]: 13 | return False 14 | 15 | rows[i].add(val) 16 | cols[j].add(val) 17 | squares[i//3][j//3].add(val) 18 | 19 | return True 20 | 21 | # Example usage 22 | board_size = int(input().strip()) 23 | board = [list(input().strip().split()) for _ in range(board_size)] 24 | 25 | result = isValidSudoku(board) 26 | print("YES" if result else "NO") 27 | 28 | -------------------------------------------------------------------------------- / For CS - Module 2 - Lab 1 - Python / Longest Substring/README.md: -------------------------------------------------------------------------------- 1 | 2 | Longest Substring 3 | 4 | You are tasked with developing a function that finds the length of the longest substring without repeating characters in a given string s. Consider different scenarios involving various characters in the input string. 5 | 6 | Scenario: String with No Repeating Characters 7 | Input: "abcdef" 8 | Expected Output: 6 9 | Explanation: In this scenario, the input string contains no repeating characters, so the entire string itself is the longest substring without repeating characters. 10 | 11 | Scenario: String with Repeating Characters 12 | Input: "abccba" 13 | Expected Output: 3 14 | Explanation: In this case, the longest substring without repeating characters is "abc" with a length of 3. The characters 'c' and 'b' are repeated, so the substring ends at the first occurrence of the repeated character 15 | 16 | Important Note: 17 | Ensure that you save your solution before progressing to the next question and before submitting your answer. 18 | 19 | Exercise-1 20 | Input : 21 | pqrsstu 22 | 23 | Output : 24 | 4 25 | 26 | Exercise-2 27 | 28 | Input: 29 | abbedfgi 30 | 31 | Output: 32 | 6 33 | 34 | -------------------------------------------------------------------------------- / For CS - Module 2 - Lab 1 - Python / Longest Substring/main.py: -------------------------------------------------------------------------------- 1 | def longest_substring_length(s): 2 | char_index_map = {} 3 | start = 0 4 | max_length = 0 5 | 6 | for i, char in enumerate(s): 7 | if char in char_index_map and char_index_map[char] >= start: 8 | start = char_index_map[char] + 1 9 | 10 | char_index_map[char] = i 11 | current_length = i - start + 1 12 | max_length = max(max_length, current_length) 13 | 14 | return max_length 15 | 16 | 17 | input_str = input() 18 | 19 | output = longest_substring_length(input_str) 20 | print(f"{output}") 21 | 22 | -------------------------------------------------------------------------------- / For CS - Module 2 - Lab 1 - Python / Simple Text Editor/README.md: -------------------------------------------------------------------------------- 1 | 2 | Problem Statement 3 | Create a text editor using commands 4 | 5 | You are developing a text editor that allows users to perform various operations on the text using the "CustomStack" class. The class supports the following operations: 6 | 7 | insert(value): Inserts a string of characters at the current cursor position in the text. 8 | delete(value): Deletes the last value characters from the text starting from the current cursor position. 9 | get(value): Retrieves the character at index value from the text and displays it. 10 | undo(): Reverts the last executed command on the text. 11 | 12 | Each command is represented by a string in the following format: 13 | 14 | 1.Command 1: '1 value' - Inserts the string value at the current cursor position in the text. 15 | 2.Command 2: '2 value' - Deletes the last value characters from the text starting from the current cursor position. 16 | 3.Command 3: '3 value' - Retrieves the character at index value from the text and displays it. 17 | 4.Command 4: '4' - Reverts the last executed command on the text. 18 | 19 | Consider a scenario where you have a text editor with a "CustomStack" class that implements the required operations. Assume the initial text is empty. 20 | 21 | Important Note: Ensure that you save your solution before progressing to the next question and before submitting your answer. 22 | 23 | Exercise-1 24 | input: 25 | 1 abc,3 3,2 2,3 1 26 | 27 | Here 28 | 1 abc -> command and input text 29 | 3 3 -> command and index of the stack 30 | Output: 31 | c 32 | a 33 | 34 | Exercise-2 35 | Input: 36 | 37 | 1 zxy,3 3,2 2,1 def,3 2 38 | 39 | Output: 40 | y 41 | d 42 | 43 | -------------------------------------------------------------------------------- / For CS - Module 2 - Lab 1 - Python / Simple Text Editor/main.py: -------------------------------------------------------------------------------- 1 | class CustomStack: 2 | def __init__(self): 3 | self.text = "" 4 | self.commands = [] 5 | 6 | def insert(self, value): 7 | self.text += value 8 | self.commands.append(("delete", len(value))) 9 | 10 | def delete(self, value): 11 | deleted = self.text[-value:] 12 | self.text = self.text[:-value] 13 | self.commands.append(("insert", deleted)) 14 | 15 | def get(self, value): 16 | char = self.text[value - 1] 17 | print(char) 18 | 19 | def undo(self): 20 | if self.commands: 21 | operation, value = self.commands.pop() 22 | if operation == "delete": 23 | self.text += value 24 | elif operation == "insert": 25 | self.text = self.text[:-len(value)] 26 | 27 | # Example usage 28 | custom_stack = CustomStack() 29 | 30 | commands = input().strip().split(',') 31 | 32 | for command in commands: 33 | op, *rest = command.split() 34 | if op == '1': 35 | custom_stack.insert(rest[0]) 36 | elif op == '2': 37 | custom_stack.delete(int(rest[0])) 38 | elif op == '3': 39 | custom_stack.get(int(rest[0])) 40 | elif op == '4': 41 | custom_stack.undo() 42 | 43 | -------------------------------------------------------------------------------- / For CS - Module 2 - Lab 2 - Python / Lego Blocks/README.md: -------------------------------------------------------------------------------- 1 | Problem Statement 2 | Build a wall with lego blocks 3 | 4 | How many different ways can you build a wall of height 'n' and width 'm' using an infinite number of Lego bricks of four types, each with different dimensions (depth x height x width)? The types of Lego bricks available are: 5 | 6 | Depth: 1, Height: 1, Width: 1 7 | Depth: 1, Height: 1, Width: 2 8 | Depth: 1, Height: 1, Width: 3 9 | Depth: 1, Height: 1, Width: 4 10 | 11 | The wall should satisfy the following conditions: 12 | 13 | There should be no holes in the wall. 14 | The wall should be a single solid structure without a straight vertical break across all rows of bricks. 15 | The bricks must be laid horizontally. 16 | 17 | Provide the number of ways to build the wall, considering that the result should be output modulo 1000000007. 18 | 19 | Example: 20 | 21 | For n = 2 and m = 2, the output should be legoWall(n, m) = 3. 22 | For n = 3 and m = 2, the output should be legoWall(n, m) = 7. 23 | For n = 2 and m = 3, the output should be legoWall(n, m) = 9. 24 | 25 | Input/Output: 26 | 27 | 1.The input consists of two integers: n and m, representing the desired height and width of the wall, respectively. 28 | 2.The output is a long integer representing the number of ways to build the wall, modulo 1000000007. 29 | 30 | Exercise-1 31 | Input: 32 | 2 33 | 2 34 | 35 | Here 36 | First row - n value 37 | Second row - m value 38 | 39 | Output: 40 | 3 41 | 42 | Exercise-2 43 | Input: 44 | 4 45 | 4 46 | -------------------------------------------------------------------------------- / For CS - Module 2 - Lab 2 - Python / Lego Blocks/main.py: -------------------------------------------------------------------------------- 1 | import os 2 | import sys 3 | # 4 | # Complete the legoBlocks function below. 5 | # 6 | def legoBlocks(n, m): 7 | A = 1000000000+7 8 | r = [0]*(m+1) 9 | a = [0]*(m+1) 10 | 11 | a[0] = 1 12 | for j in range(1, m+1): 13 | a[j] += a[j-1] if j-1>=0 else 0 14 | a[j] += a[j-2] if j-2>=0 else 0 15 | a[j] += a[j-3] if j-3>=0 else 0 16 | a[j] += a[j-4] if j-4>=0 else 0 17 | for j in range(1, m+1): 18 | a[j] = a[j] % A 19 | a[j] = a[j] ** n 20 | a[j] = a[j] % A 21 | 22 | r[1] = 1 23 | for j in range(2, m+1): 24 | r[j] = a[j] 25 | for k in range(1, j): 26 | r[j] -= r[k]*a[j-k] 27 | r[j] = r[j] % A 28 | return r[m]%A 29 | 30 | # Example usage 31 | n = int(input().strip()) 32 | m = int(input().strip()) 33 | 34 | result = legoBlocks(n, m) 35 | print(result) 36 | 37 | -------------------------------------------------------------------------------- / For CS - Module 2 - Lab 2 - Python / Sum of Numbers With Units Digit K/README.md: -------------------------------------------------------------------------------- 1 | 2 | Problem Statement 3 | 4 | Sum of Numbers With Units Digit K 5 | 6 | You are given two integers, num and k. You need to find the minimum possible size of a set of positive integers with the following properties: 7 | 8 | Each integer in the set has the unit digit equal to k. 9 | The sum of all the integers in the set equals num. 10 | 11 | If such a set exists, return its minimum size. Otherwise, if no set satisfies the conditions, return -1. 12 | 13 | Note: 14 | The set can contain multiple instances of the same integer, and if the set is empty, its sum is considered to be 0. 15 | The unit digit of a number refers to its rightmost digit. 16 | Consider the input: 17 | 18 | num = 58 19 | k = 9 20 | 21 | The function should return 2 because there exists a valid set with two positive integers, both having the units digit 9, and their sum is equal to 58. 22 | 23 | Important Note: Ensure that you save your solution before progressing to the next question and before submitting your answer. 24 | 25 | Exercise-1 26 | 27 | Input : 28 | 56 29 | 9 30 | 31 | Output : 32 | 4 33 | 34 | Exercise-2 35 | 36 | Input: 37 | 53 38 | 39 | Output: 40 | -1 41 | 42 | -------------------------------------------------------------------------------- / For CS - Module 2 - Lab 2 - Python / Sum of Numbers With Units Digit K/main.py: -------------------------------------------------------------------------------- 1 | def minimumNumbers( num: int, k: int) -> int: 2 | if num==0: 3 | return 0 4 | if k==0: 5 | if num%10==0: 6 | return 1 7 | return -1 8 | if num aacc -> Four times 17 | abdacdbc -> aacc-> Four times 18 | abdcadbc -> acac -> Three times 19 | abdccdbc -> accc -> Three times 20 | abdcdbcc -> accc -> Three times 21 | 22 | Input and Output format: 23 | 24 | Exercise-1 25 | 26 | 27 | Input: 28 | 29 | ababc 30 | ab 31 | 32 | Output: 33 | 5 34 | 35 | 36 | Exercise-2 37 | 38 | 39 | Input: 40 | 41 | ababab 42 | ab 43 | 44 | Output: 45 | 9 46 | 47 | 48 | -------------------------------------------------------------------------------- / For CS - Module 3 - Lab 1 - Python / Maximize Number of Subsequences in a String/main.py: -------------------------------------------------------------------------------- 1 | def maximumSubsequenceCount( text: str, pattern: str) -> int: 2 | count0 = count1 = countPattern = 0 3 | for c in text: 4 | if c == pattern[1]: 5 | count1 += 1 6 | countPattern += count0 7 | if c == pattern[0]: 8 | count0 += 1 9 | 10 | return countPattern + max(count1, count0) 11 | 12 | # Example usage 13 | text = input().strip() 14 | pattern = input().strip() 15 | 16 | result = maximumSubsequenceCount(text, pattern) 17 | print(result) 18 | 19 | -------------------------------------------------------------------------------- / For CS - Module 3 - Lab 1 - Python /Cookies/README.md: -------------------------------------------------------------------------------- 1 | 2 | Problem Statement 3 | Candies 4 | 5 | You have a collection of candies, and each candy has a certain sweetness value. Your goal is to combine the candies to create new candies until you reach a specific target sweetness level. Find how many steps need to reach candies sweetness target. 6 | 7 | To achieve this, you can select any two candies with the least sweetness and combine them into a new candy with sweetness calculated as follows: 8 | 9 | sweetness = (least sweet candy + 2 * second least sweet candy) 10 | 11 | For example, consider the following scenario: 12 | 13 | You are given a target sweetness level of 12, and you have the following candies: [2, 8, 3, 7, 4, 6]. To reach the target sweetness of 12. 14 | 15 | you can perform the following steps: 16 | Ascending order = 2,3,4,6,7,8 17 | 18 | Combine the two least sweet candies: 2 + 2*3 = 8. Updated candies: [ 8, 4, 6, 7, 8]. 19 | Combine the two least sweet candies: 4 + 2*6 = 16. Updated candies: [8, 16, 7, 8]. 20 | Combine the two least sweet candies: 7 + 2*8 = 23. Updated candies: [8,16,23]. 21 | Combine the two least sweet candies: 8 + 2*16 = 17. Updated candies: [40,23]. 22 | 23 | The sweetness of the first candy in the updated candies array is now 40, which exceeds the target sweetness of 12. 24 | 25 | Exercise-1 26 | Input: 27 | 7 28 | 1 2 3 4 5 29 | 30 | Note: 31 | 32 | Line 1 : Target of the sweetness 33 | Line 2 Each candies sweetness 34 | 35 | output: 36 | 3 37 | 38 | Exercise-2 39 | input: 40 | 11 41 | 2 5 3 7 6 1 42 | output: 43 | 4 44 | 45 | -------------------------------------------------------------------------------- / For CS - Module 3 - Lab 1 - Python /Cookies/main.py: -------------------------------------------------------------------------------- 1 | import heapq 2 | 3 | def min_steps_to_target_sweetness(candies, target_sweetness): 4 | # Convert candies to a min-heap 5 | heapq.heapify(candies) 6 | 7 | steps = 0 8 | 9 | while candies[0] < target_sweetness: 10 | # Extract the two least sweet candies 11 | least_sweet = heapq.heappop(candies) 12 | second_least_sweet = heapq.heappop(candies) 13 | 14 | # Calculate the sweetness of the combined candy 15 | combined_sweetness = least_sweet + 2 * second_least_sweet 16 | 17 | # Add the combined candy back to the heap 18 | heapq.heappush(candies, combined_sweetness) 19 | 20 | # Increment the number of steps 21 | steps += 1 22 | 23 | return steps 24 | 25 | # Input reading 26 | target_sweetness = int(input().strip()) 27 | candies = list(map(int, input().strip().split())) 28 | 29 | # Output the result 30 | result = min_steps_to_target_sweetness(candies, target_sweetness) 31 | print(result) 32 | 33 | -------------------------------------------------------------------------------- / For CS - Module 3 - Lab 2 - Python / No Prefix set/README.md: -------------------------------------------------------------------------------- 1 | 2 | Problem Statement 3 | Check string prefix 4 | 5 | You are given a list of passwords, where each password consists of lowercase letters from 'a' to 'z' inclusive. The set of passwords is said to be a 'GOOD PASSWORD' if no password is a prefix of another password in the set, except for identical passwords (which are considered prefixes of each other). In this case, print 'GOOD PASSWORD'. Otherwise, print 'BAD PASSWORD' on the first line, followed by the first pair of passwords where one password is a prefix of the other. 6 | Consider the following list of words: ['apple', 'banana', 'application', 'bananas']. 7 | In this case, the word 'banana' is a prefix of 'bananas'. 8 | 9 | So we would print: 'BAD PASSWORD' 10 | 11 | Now let's take another example with a different set of words: ['cat', 'dog', 'elephant']. In this scenario, none of the strings are prefixes of each other. 12 | 13 | Therefore, we can conclude that: GOOD PASSWORD 14 | 15 | Exercise-1 16 | 17 | Input: 18 | abc zxy pqr 19 | 20 | Output: 21 | GOOD PASSWORD 22 | 23 | Exercise-2 24 | 25 | Input: 26 | abc abczxy abcpqr 27 | 28 | Output: 29 | BAD PASSWORD 30 | 31 | 32 | -------------------------------------------------------------------------------- / For CS - Module 3 - Lab 2 - Python / No Prefix set/main.py: -------------------------------------------------------------------------------- 1 | def is_good_password(passwords): 2 | passwords.sort() 3 | for i in range(len(passwords) - 1): 4 | if passwords[i + 1].startswith(passwords[i]): 5 | return "BAD PASSWORD" 6 | return "GOOD PASSWORD" 7 | 8 | # Input reading 9 | passwords = input().strip().split() 10 | 11 | # Check and output result 12 | result = is_good_password(passwords) 13 | print(result) 14 | 15 | -------------------------------------------------------------------------------- / For CS - Module 3 - Lab 2 - Python / Sliding Subarray Beauty/README.md: -------------------------------------------------------------------------------- 1 | 2 | Problem Statement 3 | Sliding Subarray Beauty: 4 | 5 | You are given an array of integers arr and an integer k. Your task is to find the given n th position of the smallest integer in each contiguous subarray of size k and print these smallest integers. 6 | A subarray is a contiguous non-empty sequence of elements within the original array. 7 | For each subarray of size k, you need to find the given n th position of the smallest integer within that subarray. 8 | The given n th position of the smallest integer in a subarray is the integer that appears at the given n th position when the subarray is sorted in ascending order. 9 | . 10 | Your task is to return an integer array containing n - k + 1 elements, denoting the beauty of the subarrays in order from the first index in the array. 11 | 12 | Exercise-1 13 | 14 | Input: 15 | 1 2 3 4 5 6 7 8 9 10 16 | 3 17 | 2 18 | Note: 19 | Line 1: input array 20 | Line 2: sub array length 21 | Line 3: position of the smallest value 22 | 23 | Output: 24 | 2 3 4 5 6 7 8 9 25 | 26 | Exercise-2 27 | 28 | Input: 29 | 1 2 3 4 5 6 7 8 9 10 30 | 4 31 | 2 32 | 33 | Output: 34 | 2 3 4 5 6 7 8 35 | 36 | 37 | -------------------------------------------------------------------------------- / For CS - Module 3 - Lab 2 - Python / Sliding Subarray Beauty/main.py: -------------------------------------------------------------------------------- 1 | def sliding_subarray_beauty(arr, k, n): 2 | result = [] 3 | for i in range(len(arr) - k + 1): 4 | subarray = arr[i:i + k] 5 | sorted_subarray = sorted(subarray) 6 | result.append(sorted_subarray[n - 1]) 7 | return result 8 | 9 | # Input reading 10 | arr = list(map(int, input().strip().split())) 11 | k = int(input().strip()) 12 | n = int(input().strip()) 13 | 14 | # Calculate and output the result 15 | result = sliding_subarray_beauty(arr, k, n) 16 | print(*result) 17 | 18 | -------------------------------------------------------------------------------- / For CS - Module 4 - Contest - Python / Is Graph Bipartite/Readme.md: -------------------------------------------------------------------------------- 1 | 2 | Problem Statement 3 | Is Graph Bipartite? 4 | 5 | You have an undirected graph with n nodes, each represented by a number between 0 and n - 1. The graph is described by a 2D array graph, where graph[u] is an array containing nodes adjacent to node u. In other words, there is an undirected edge between node u and each node v present in graph[u]. The graph satisfies the following conditions: 6 | 7 | There are no self-edges, meaning that node u is not present in graph[u]. 8 | There are no parallel edges, implying that each node appears only once in the adjacency list. 9 | The graph is undirected, so if node v is adjacent to node u, then node u is also adjacent to node v (i.e., an edge between u and v implies an edge between v and u). 10 | The graph may not be fully connected, so there can be two nodes u and v such that there is no direct path between them. 11 | The task is to determine whether the given graph is bipartite or not. A graph is considered bipartite if its nodes can be partitioned into two independent sets, denoted as set A and set B, such that each edge connects a node from set A to a node from set B. 12 | 13 | Example: 14 | 15 | Input: [[1, 2, 3], [0, 2], [0, 1, 3], [0, 2]] 16 | Output : false 17 | 18 | 0 -- 1 19 | | | 20 | 3 -- 2 21 | 22 | Important Note: Ensure that you save your solution before progressing to the next question and before submitting your answer. 23 | 24 | Exercise-1 25 | 26 | Input : 27 | 4 28 | 1 2 3 29 | 0 2 30 | 0 1 3 31 | 0 2 32 | 33 | Output : 34 | false 35 | 36 | Exercise-2 37 | 38 | Input: 39 | 4 40 | 1 2 3 41 | 0 2 42 | 0 1 43 | 0 44 | 45 | Output: 46 | false 47 | 48 | Exercise-3 49 | 50 | Input: 51 | 4 52 | 1 3 53 | 0 2 54 | 1 3 55 | 0 2 56 | 57 | Output: 58 | true 59 | 60 | 61 | -------------------------------------------------------------------------------- / For CS - Module 4 - Contest - Python / Is Graph Bipartite/main.py: -------------------------------------------------------------------------------- 1 | 2 | from typing import List 3 | 4 | class Solution: 5 | def isBipartite(self, graph: List[List[int]]) -> bool: 6 | n = len(graph) 7 | color = [-1] * n 8 | 9 | def dfs(node, c): 10 | color[node] = c 11 | for neighbor in graph[node]: 12 | if color[neighbor] == -1: 13 | if not dfs(neighbor, 1 - c): 14 | return False 15 | elif color[neighbor] == c: 16 | return False 17 | return True 18 | 19 | for i in range(n): 20 | if color[i] == -1 and not dfs(i, 0): 21 | return False 22 | 23 | return True 24 | 25 | # Input 26 | n = int(input()) 27 | graph = [list(map(int, input().split())) for _ in range(n)] 28 | 29 | # Output 30 | solution = Solution() 31 | output = solution.isBipartite(graph) 32 | print(output) 33 | -------------------------------------------------------------------------------- / For CS - Module 4 - Contest - Python / Transform and Compare/Readme.md: -------------------------------------------------------------------------------- 1 | 2 | Transform and Compare 3 | 4 | Given a string composed of 'L', 'R', and 'X' characters, such as "RXXLRXRXL", a move can be made by replacing either one occurrence of "XL" with "LX" or one occurrence of "RX" with "XR". The task is to determine if it is possible to transform the starting string, "start," into the ending string, "end," by a sequence of these moves. Return True only if such a sequence exists. 5 | 6 | Example 1: 7 | 8 | Input: start = "RXXLRXRXL", end = "XRLXXRRLX" 9 | Output: true 10 | Explanation: 11 | The starting string can be transformed into the ending string using the following steps: 12 | RXXLRXRXL -> 13 | XRXLRXRXL -> 14 | XRLXRXRXL -> 15 | XRLXXRRXL -> 16 | XRLXXRRLX 17 | 18 | Example 2: 19 | 20 | Input: start = "LLR", end = "RRL" 21 | Output: false 22 | 23 | Important Note:* Ensure that you save your solution before progressing to the next question and before submitting your answer.* 24 | 25 | Exercise-1 26 | 27 | Input: 28 | RXXLRXRXL 29 | XRLXXRRLX 30 | 31 | Output: 32 | true 33 | 34 | Exercise-2 35 | 36 | Input: 37 | RXXL 38 | XRLX 39 | 40 | Output: 41 | true 42 | 43 | -------------------------------------------------------------------------------- / For CS - Module 4 - Contest - Python / Transform and Compare/main.py: -------------------------------------------------------------------------------- 1 | def canTransform(start: str, end: str) -> bool: 2 | if len(start) != len(end): 3 | return False 4 | 5 | i, j = 0, 0 6 | while i < len(start) and j < len(end): 7 | while i < len(start) and start[i] == 'X': 8 | i += 1 9 | while j < len(end) and end[j] == 'X': 10 | j += 1 11 | 12 | if (i == len(start)) != (j == len(end)): 13 | return False 14 | 15 | if i < len(start) and j < len(end): 16 | if start[i] != end[j] or (start[i] == 'L' and i < j) or (start[i] == 'R' and i > j): 17 | return False 18 | 19 | i += 1 20 | j += 1 21 | 22 | return True 23 | 24 | 25 | start = input() 26 | end = input() 27 | 28 | # Output 29 | output = canTransform(start, end) 30 | print(output) 31 | 32 | -------------------------------------------------------------------------------- / For CS - Module 4 - Lab 1 - Python / Array Manipulation/README.md: -------------------------------------------------------------------------------- 1 | 2 | Problem Statement 3 | Mix the array 4 | 5 | Given a 1-indexed array initially filled with zeros and a list of operations, perform each operation by adding a value to each element of the array between two given indices (inclusive). After performing all operations, find and return the maximum value in the array. 6 | 7 | For example, let's consider the following scenario: 8 | q = {[2,4,5],[3,6,3],[1,7,10]} 9 | Initial Array size = 7 10 | 11 | Array: [0, 0, 0, 0, 0, 0, 0] 12 | 13 | Operations: 14 | 15 | Add 5 between indices 2 and 4: [0, 5, 5, 5, 0, 0, 0] 16 | Add 3 between indices 3 and 6: [0, 5, 8, 8, 3, 3, 0] 17 | Add 10 between indices 1 and 7: [10, 15, 18, 18, 13, 13, 10] 18 | 19 | In this scenario, the maximum value in the array is 18. 20 | 21 | Important Note: Ensure that you save your solution before progressing to the next question and before submitting your answer. 22 | 23 | Exercise-1 24 | 25 | Input: 26 | 27 | 5 28 | 3 29 | 2 4 3 30 | 4 5 9 31 | 3 3 11 32 | 33 | Output: 34 | 14 35 | 36 | Note: 37 | Line -1 : array size 38 | Line -2 : query count 39 | 40 | Exercise-2 41 | 42 | Input: 43 | 44 | 10 45 | 3 46 | 3 10 3 47 | 4 5 9 48 | 2 9 11 49 | 50 | Output: 51 | 23 52 | 53 | -------------------------------------------------------------------------------- / For CS - Module 4 - Lab 1 - Python / Array Manipulation/main.py: -------------------------------------------------------------------------------- 1 | def mix_the_array(n, q, queries): 2 | array = [0] * n 3 | 4 | for query in queries: 5 | start, end, value = query 6 | array[start - 1] += value 7 | if end < n: 8 | array[end] -= value 9 | 10 | max_value = array[0] 11 | current_value = array[0] 12 | 13 | for i in range(1, n): 14 | current_value += array[i] 15 | max_value = max(max_value, current_value) 16 | 17 | return max_value 18 | 19 | # Input reading 20 | n = int(input().strip()) 21 | q = int(input().strip()) 22 | 23 | queries = [] 24 | for _ in range(q): 25 | query = list(map(int, input().strip().split())) 26 | queries.append(query) 27 | 28 | # Calculate and output the result 29 | result = mix_the_array(n, q, queries) 30 | print(result) 31 | 32 | -------------------------------------------------------------------------------- / For CS - Module 4 - Lab 1 - Python / Clumsy Factorial/README.md: -------------------------------------------------------------------------------- 1 | 2 | Problem Statement 3 | Clumsy Factorial 4 | 5 | The clumsy factorial of a positive integer n is obtained by applying a fixed rotation of operations, including multiplication '*', division '/', addition '+', and subtraction '-', to the integers in decreasing order. The operations are applied according to the usual order of operations in arithmetic, where multiplication and division are done before addition and subtraction. 6 | For example, the clumsy factorial of n = 10 is calculated as follows: 7 | clumsy(10) = 10 x 9 / 8 + 7 - 6 x 5 / 4 + 3 - 2 x 1. 8 | We use floor division for the division operation, meaning the result is rounded down to the nearest integer. 9 | Your task is to implement a function that takes a positive integer n as input and returns the clumsy factorial of n. 10 | 11 | Important Note: 12 | Ensure that you save your solution before progressing to the next question and before submitting your answer. 13 | 14 | Exercise-1 15 | 16 | Input : 17 | 5 18 | 19 | Output : 20 | 7 21 | 22 | Exercise-2 23 | 24 | Input: 25 | 10 26 | 27 | Output: 28 | 11 29 | 30 | 31 | -------------------------------------------------------------------------------- / For CS - Module 4 - Lab 1 - Python / Clumsy Factorial/main.py: -------------------------------------------------------------------------------- 1 | def clumsy(n): 2 | if n <= 2: 3 | return n 4 | 5 | stack = [n] 6 | n -= 1 7 | operations = ['*', '//', '+', '-'] 8 | op_index = 0 9 | 10 | while n > 0: 11 | if operations[op_index] == '*': 12 | stack[-1] *= n 13 | elif operations[op_index] == '//': 14 | stack[-1] //= n 15 | elif operations[op_index] == '+': 16 | stack.append(n) 17 | else: 18 | stack.append(-n) 19 | 20 | n -= 1 21 | op_index = (op_index + 1) % 4 22 | 23 | return sum(stack) 24 | 25 | # Input reading 26 | n = int(input().strip()) 27 | 28 | # Calculate and output the clumsy factorial 29 | result = clumsy(n) 30 | print(result) 31 | 32 | -------------------------------------------------------------------------------- / For CS - Module 4 - Lab 2 - Python / Egyptian Fraction/README.md: -------------------------------------------------------------------------------- 1 | 2 | Problem Statement 3 | Egyptian Fraction 4 | 5 | You are an ancient Egyptian mathematician, and you have been tasked with representing the fraction 6/14 as a sum of unique unit fractions. You know that a unit fraction is a fraction with a numerator of 1 and a denominator of a positive integer. You also know that the sum of any number of unit fractions is always a rational number. 6 | 7 | Example: 8 | 9 | The first step is to find the largest possible unit fraction that is less than or equal to 6/14. This fraction is 1/3. The remaining fraction is 6/14 - 1/3 = 4/42. The largest possible unit fraction that is less than or equal to 4/42 is 1/11. The remaining fraction is 4/42 - 1/11 = 1/231. 10 | 11 | Therefore, the Egyptian fraction representation of 6/14 is 1/3 + 1/11 + 1/231. 12 | 13 | Exercise-1 14 | 15 | Input: 16 | 6 17 | 14 18 | 19 | Output: 20 | 3 21 | 11 22 | 231 23 | 24 | Exercise-2 25 | 26 | Input: 27 | 3 28 | 4 29 | 30 | Output: 31 | 2 32 | 4 33 | 34 | -------------------------------------------------------------------------------- / For CS - Module 4 - Lab 2 - Python / Egyptian Fraction/main.py: -------------------------------------------------------------------------------- 1 | def egyptian_fraction(numerator, denominator): 2 | result = [] 3 | 4 | while numerator != 0: 5 | unit_fraction_denominator = -(-denominator // numerator) # Ceiling division 6 | result.append(unit_fraction_denominator) 7 | 8 | numerator = numerator * unit_fraction_denominator - denominator 9 | denominator = denominator * unit_fraction_denominator 10 | 11 | return result 12 | 13 | # Input reading 14 | numerator = int(input().strip()) 15 | denominator = int(input().strip()) 16 | 17 | # Calculate and output the result 18 | result = egyptian_fraction(numerator, denominator) 19 | for fraction in result: 20 | print(fraction) 21 | -------------------------------------------------------------------------------- / For CS - Module 4 - Lab 2 - Python / Query Kth Smallest Trimmed Number/README.md: -------------------------------------------------------------------------------- 1 | 2 | Problem Statement 3 | Query Kth Smallest Trimmed Number: 4 | 5 | Given a list of strings nums, where each string has equal length and consists of only digits, and a 2D array queries containing queries in the form of [ki, trimi], you are required to perform the following steps for each query: 6 | Trim each number in nums to its right most trimi digits by removing the left most digits until only trimi digits remain. 7 | Determine the index of the kth smallest trimmed number in the modified nums. If two trimmed numbers are equal, consider the number with the lower index to be smaller. 8 | Reset each number in nums to its original length. 9 | Store the answers to each query in an array answer, where answer[i] is the answer to the ith query. 10 | 11 | Constraints: 12 | 13 | The input strings in nums are of equal length and consist of digits only. 14 | The queries in the 2D array queries are 0-indexed and represented as [ki, trimi]. 15 | Trimming to the rightmost x digits means keeping only the last x digits of each number, removing the leftmost digits until only x digits remain. 16 | The input strings in nums may contain leading zeros. 17 | 18 | Example: 19 | 20 | given input is 113 933 231 719, 21 | Take first query 1 1 (here first 1 is position , second is selecting a digit from right) So each digit we need to take one digit value form right - 113 is 3, 933 is 3 231 is 1 719 is 9 [ 3 3 1 9 ] so the first smallest value is 1 , then the index value of 1 22 | is 2. 23 | Second query 2 2 So each digit we need to take two digit value form right.So we get [ 13 33 31 19 ] first smallest value 19 , then the index value of 19 is 3. 24 | 25 | Important Note: Ensure that you save your solution before progressing to the next question and before submitting your answer. 26 | 27 | Exercise-1 28 | 29 | Input : 30 | 113 933 231 719 31 | 4 32 | 1 1 33 | 2 2 34 | 4 2 35 | 1 3 36 | 37 | Note: 38 | Line 1: input values 39 | Line 2 : Queries count 40 | From line 3 : query pair[ position, decimal length from right] 41 | 42 | Output : 43 | 2 3 1 0 44 | 45 | Exercise-2 46 | 47 | Input: 48 | 123 456 246 369 49 | 4 50 | 1 1 51 | 2 2 52 | 4 2 53 | 1 3 54 | 55 | Output: 56 | 0 2 3 0 57 | 58 | 59 | -------------------------------------------------------------------------------- / For CS - Module 4 - Lab 2 - Python / Query Kth Smallest Trimmed Number/main.py: -------------------------------------------------------------------------------- 1 | def kth_smallest_trimmed_number(nums, queries): 2 | answer = [] 3 | 4 | for query in queries: 5 | position, trim_length = query 6 | trimmed_nums = [] 7 | 8 | for num in nums: 9 | trimmed = int(num[-trim_length:] if len(num) >= trim_length else num) 10 | trimmed_nums.append(trimmed) 11 | 12 | sorted_nums = sorted(trimmed_nums) 13 | kth_smallest = sorted_nums[position - 1] if position <= len(sorted_nums) else -1 14 | kth_smallest_index = trimmed_nums.index(kth_smallest) if kth_smallest != -1 else -1 15 | answer.append(kth_smallest_index) 16 | 17 | return answer 18 | 19 | # Input reading 20 | nums = input().strip().split() 21 | queries_count = int(input().strip()) 22 | 23 | queries = [] 24 | for _ in range(queries_count): 25 | query = list(map(int, input().strip().split())) 26 | queries.append(query) 27 | 28 | # Calculate and output the result 29 | result = kth_smallest_trimmed_number(nums, queries) 30 | print(" ".join(map(str, result))) 31 | 32 | -------------------------------------------------------------------------------- /For CS - Module 1 - Contest - Python / 000A Time Stamp PY/README.md: -------------------------------------------------------------------------------- 1 | 2 | Time Stamp Archive: 3 | 4 | You are tasked with designing a Time Travelers Archive system that allows travelers to store and retrieve valuable information from different time periods. The system should support storing key-value pairs associated with specific timestamps and efficiently retrieving the latest value for a given key based on a timestamp. 5 | 6 | Design a TimeTravelersArchive class to implement the required functionality: 7 | 8 | Store(string key, string value, int timestamp): This method should store the key keywith the value value at the given timestamp. 9 | Retrieve(string key, int timestamp): This method should return the latest value 10 | associated with the key key that has a timestamp less than or equal to the given timestamp. 11 | If there is no such value found, it should return the output as empty . 12 | When you retrieve the data, if call wrong method it should print "Wrong method called, please call Store or Retrieve method" 13 | 14 | For Ex: Store language Latin 500 15 | Store language Old_English 1000 16 | Retrieve language asa 17 | 18 | Your task is to design the TimeTravelersArchive class and its methods to efficiently handle the storage and retrieval of information across different time periods. 19 | The overall run time complexity should be O(1) for Store and O(log n) for the Retrieve method. 20 | 21 | Exercise-1 22 | TimeTravelersArchive archive = new TimeTravelersArchive(); 23 | archive.Store(language,Latin,1); 24 | archive.Store(language,Old_English, 2); 25 | string result1 = archive.Retrieve(language;, 1); // Output: Latin; 26 | string result2 = archive.Retrieve(language, 3); // Output: Old English; 27 | string result3 = archive.Retrieve(language, 0); // Output: empty; 28 | 29 | Explanation: 30 | First call to retrieve method return Latin as the timestamp is equal to what is passed in the Retrieve call. 31 | Second call returns Old English; as the timestamp of that item is less than the 3 timestamp passed in the Retrieve call. 32 | Third call returns an empty string since there is no timestamp stored which is less than or equal to 0. 33 | 34 | Constraints: 35 | 36 | All key/value strings are lowercase. 37 | The input timestamp for Store and Retrieve method is in the range [1, 10^7]. 38 | The number of calls to the Retrieve method will be less than or equal to 10^4. 39 | The number of calls to the Store method will be less than or equal to 10^4. 40 | 41 | Important Note: Ensure that you save your solution before progressing to the next question and before submitting your answer. 42 | 43 | Exercise -1 44 | Input: 45 | Store key1 value1 1 //Call to Store method 46 | Store key1 value2 2 //Call to Store method 47 | Retrieve key1 1 //Call to Retrieve method 48 | Retrieve key1 3 //Call to Retrieve method 49 | Retrieve key1 0 //Call to Retrieve method 50 | 51 | Output: 52 | value1 53 | value2 54 | empty 55 | 56 | Exercise - 2 57 | Input: 58 | Store key1 value1 1 59 | Store key1 value2 2 60 | Store key2 value1 3 61 | Store key1 value3 4 62 | Store key2 value2 5 63 | Retrieve key1 1 64 | Retrieve key2 5 65 | Retrieve key1 10 66 | 67 | Output: 68 | value1 69 | value2 70 | value3 71 | 72 | Exercise - 3 73 | Input: 74 | Store language Latin 10 75 | Store language Old_English 50 76 | Store language Middle_English 90 77 | Store language2 Middle_English 90 78 | Store language1 Latin 190 79 | Store language3 Latin 5 80 | Store language1 Middle_English 20 81 | Retrieve language 2 82 | Retrieve language1 200 83 | Retrieve language3 60 84 | Retrieve language 90 85 | 86 | Output: 87 | empty 88 | Middle_English 89 | Latin 90 | Middle_English 91 | 92 | -------------------------------------------------------------------------------- /For CS - Module 1 - Contest - Python / 000A Time Stamp PY/main.py: -------------------------------------------------------------------------------- 1 | from bisect import bisect_right 2 | from collections import defaultdict 3 | 4 | class TimeTravelersArchive: 5 | def __init__(self): 6 | self.data = defaultdict(list) 7 | 8 | def Store(self, key, value, timestamp): 9 | self.data[key].append((timestamp, value)) 10 | 11 | def Retrieve(self, key, timestamp): 12 | if not self.data[key]: 13 | print("Wrong method called, please call Store or Retrieve method") 14 | return "" 15 | 16 | index = bisect_right(self.data[key], (timestamp, chr(127))) 17 | if index > 0: 18 | return self.data[key][index - 1][1] 19 | else: 20 | return "empty" 21 | 22 | # Input 23 | archive = TimeTravelersArchive() 24 | 25 | try: 26 | while True: 27 | query = input().split() 28 | if query[0] == "Store": 29 | archive.Store(query[1], query[2], int(query[3])) 30 | elif query[0] == "Retrieve": 31 | result = archive.Retrieve(query[1], int(query[2])) 32 | print(result) 33 | else: 34 | print("Invalid input") 35 | except EOFError: 36 | pass 37 | 38 | -------------------------------------------------------------------------------- /For CS - Module 1 - Contest - Python / Query Kth Smallest Trimmed Number/README.md: -------------------------------------------------------------------------------- 1 | 2 | Problem Statement 3 | Query Kth Smallest Trimmed Number: 4 | 5 | Given a list of strings nums, where each string has equal length and consists of only digits, and a 2D array queries containing queries in the form of [ki, trimi], you are required to perform the following steps for each query: 6 | Trim each number in nums to its right most trimi digits by removing the left most digits until only trimi digits remain. 7 | Determine the index of the kth smallest trimmed number in the modified nums. If two trimmed numbers are equal, consider the number with the lower index to be smaller. 8 | Reset each number in nums to its original length. 9 | Store the answers to each query in an array answer, where answer[i] is the answer to the ith query. 10 | 11 | Constraints: 12 | 13 | The input strings in nums are of equal length and consist of digits only. 14 | The queries in the 2D array queries are 0-indexed and represented as [ki, trimi]. 15 | Trimming to the rightmost x digits means keeping only the last x digits of each number, removing the leftmost digits until only x digits remain. 16 | The input strings in nums may contain leading zeros. 17 | 18 | Example: 19 | 20 | given input is 113 933 231 719, 21 | Take first query 1 1 (here first 1 is position , second is selecting a digit from right) So each digit we need to take one digit value form right - 113 is 3, 933 is 3 231 is 1 719 is 9 [ 3 3 1 9 ] so the first smallest value is 1 , then the index value of 1 22 | is 2. 23 | Second query 2 2 So each digit we need to take two digit value form right.So we get [ 13 33 31 19 ] first smallest value 19 , then the index value of 19 is 3. 24 | 25 | Important Note: Ensure that you save your solution before progressing to the next question and before submitting your answer. 26 | 27 | Exercise-1 28 | 29 | Input : 30 | 113 933 231 719 31 | 4 32 | 1 1 33 | 2 2 34 | 4 2 35 | 1 3 36 | 37 | Note: 38 | Line 1: input values 39 | Line 2 : Queries count 40 | From line 3 : query pair[ position, decimal length from right] 41 | 42 | Output : 43 | 2 3 1 0 44 | 45 | Exercise-2 46 | 47 | Input: 48 | 123 456 246 369 49 | 4 50 | 1 1 51 | 2 2 52 | 4 2 53 | 1 3 54 | 55 | Output: 56 | 0 2 3 0 57 | 58 | 59 | -------------------------------------------------------------------------------- /For CS - Module 1 - Contest - Python / Query Kth Smallest Trimmed Number/main.py: -------------------------------------------------------------------------------- 1 | def kth_smallest_trimmed_number(nums, queries): 2 | answer = [] 3 | 4 | for query in queries: 5 | position, trim_length = query 6 | trimmed_nums = [] 7 | 8 | for num in nums: 9 | trimmed = int(num[-trim_length:] if len(num) >= trim_length else num) 10 | trimmed_nums.append(trimmed) 11 | 12 | sorted_nums = sorted(trimmed_nums) 13 | kth_smallest = sorted_nums[position - 1] if position <= len(sorted_nums) else -1 14 | kth_smallest_index = trimmed_nums.index(kth_smallest) if kth_smallest != -1 else -1 15 | answer.append(kth_smallest_index) 16 | 17 | return answer 18 | 19 | # Input reading 20 | nums = input().strip().split() 21 | queries_count = int(input().strip()) 22 | 23 | queries = [] 24 | for _ in range(queries_count): 25 | query = list(map(int, input().strip().split())) 26 | queries.append(query) 27 | 28 | # Calculate and output the result 29 | result = kth_smallest_trimmed_number(nums, queries) 30 | print(" ".join(map(str, result))) 31 | 32 | -------------------------------------------------------------------------------- /For CS - Module 1 - Contest - Python /Recursive (super) super digit sum /README.md: -------------------------------------------------------------------------------- 1 | Recursive (Super) Digit Sum 2 | Problem Statement 3 | Find the super digit of a repeating number 4 | 5 | Let's consider the scenario of Alice and Bob. Alice has the number 987 and Bob wants to find the super digit of this number repeated 5 times. The super digit follows the following rules: 6 | 7 | If a number has only one digit, its super digit is equal to that digit. 8 | Otherwise, the super digit of a number is calculated as the super digit of the sum of its digits. 9 | In this case, Alice's number is 987, and Bob wants to repeat it 5 times. So, n = 987 and k = 5. Thus, n k is equal to 987987987987987. To find the super digit, we calculate the sum of the digits: (9 + 8 + 7 + 9 + 8 + 7 + 9 + 8 + 7 + 9 + 8 + 7 + 9 + 8 + 7 + 9 + 8 + 7) = 153. Since 153 has three digits, we further calculate its super digit: (1 + 5 + 3) = 9. Therefore, the super digit of 987 repeated 5 times is 9. 10 | 11 | Important Note: Ensure that you save your solution before progressing to the next question and before submitting your answer. 12 | 13 | Exercise-1 14 | input: 15 | 56785 16 | 2 17 | output: 18 | 8 19 | 20 | Exercise-2 21 | input: 22 | 65109 23 | 3 24 | Output: 25 | 9 26 | -------------------------------------------------------------------------------- /For CS - Module 1 - Contest - Python /Recursive (super) super digit sum /main.py: -------------------------------------------------------------------------------- 1 | def calculate_super_digit(number): 2 | if len(str(number)) == 1: 3 | return number 4 | else: 5 | return calculate_super_digit(sum(map(int, str(number)))) 6 | 7 | super_digit = calculate_super_digit(n * k) 8 | return super_digit 9 | 10 | n = int(input()) 11 | k = int(input()) 12 | 13 | super_digit_result = superDigit(n, k) 14 | print(super_digit_result) 15 | 16 | -------------------------------------------------------------------------------- /For CS - Module 1 - Contest - Python /job sequencing/README.md: -------------------------------------------------------------------------------- 1 | 2 | Problem Statement 3 | Job Sequencing 4 | 5 | The problem at hand involves a set of jobs, each with a deadline and an associated profit. These jobs are subject to the constraint that only one job can be scheduled at a time, and each job takes exactly one unit of time to complete. The minimum deadline for a job is 1. 6 | Input: The input consists of an array of jobs with their respective deadlines and profits. The order in which the jobs are listed in the input does not necessarily represent the optimal order. 7 | 8 | Job - Deadline - Profit 9 | 10 | A - 2 - 100 11 | 12 | C - 2 - 27 13 | 14 | D - 1 - 25 15 | 16 | E - 3 - 15 17 | 18 | B - 1 - 19 19 | 20 | 21 | The goal is to find a sequence of jobs that maximizes the total profit, subject to the constraint that each job must be completed before its deadline. 22 | 23 | Important Note: Ensure that you save your solution before progressing to the next question and before submitting your answer. 24 | 25 | Exercise-1 26 | 27 | Input: 28 | 29 | 6 30 | 31 | a b c d e 32 | 33 | 2 1 2 1 3 34 | 35 | 100 19 27 25 15 36 | 37 | Note: 38 | Line 1: job count 39 | Line 2: job name 40 | Line 3: deadline 41 | Line 4:Profit 42 | 43 | Output: 44 | 45 | c a e 46 | 47 | Exercise-2 48 | 49 | Input: 50 | 51 | 5 52 | 53 | p q r s t 54 | 55 | 2 1 3 1 3 56 | 57 | 99 190 27 25 15 58 | 59 | Output: 60 | 61 | q p r 62 | -------------------------------------------------------------------------------- /For CS - Module 1 - Contest - Python /job sequencing/main.py: -------------------------------------------------------------------------------- 1 | def job_sequencing(job_count, jobs, deadlines, profits): 2 | arr = list(zip(jobs, deadlines, profits)) 3 | arr.sort(key=lambda x: (-x[2], x[1])) 4 | 5 | result = [False] * max(deadlines) 6 | scheduled_jobs = ['-1'] * max(deadlines) 7 | 8 | for i in range(len(arr)): 9 | for j in range(min(max(deadlines) - 1, arr[i][1] - 1), -1, -1): 10 | if result[j] is False: 11 | result[j] = True 12 | scheduled_jobs[j] = arr[i][0] 13 | break 14 | 15 | return scheduled_jobs 16 | 17 | 18 | # Reading input values 19 | job_count = int(input()) 20 | jobs = input().split() 21 | deadlines = list(map(int, input().split())) 22 | profits = list(map(int, input().split())) 23 | 24 | # Calling the function 25 | scheduled_jobs = job_sequencing(job_count, jobs, deadlines, profits) 26 | 27 | # Outputting the result 28 | print(' '.join(scheduled_jobs)) 29 | -------------------------------------------------------------------------------- /For CS - Module 2 and 3 - Contest - Python /Foursum/Readme.md: -------------------------------------------------------------------------------- 1 | Given an array nums of n integers, the task is to find all unique quadruplets [nums[a], nums[b], nums[c], nums[d]] such that the sum of the elements at indices a, b, c, and d is equal to the given target. 2 | 3 | The quadruplets must satisfy the following conditions: 4 | 5 | All indices a, b, c, and d should be within the range 0 to n-1. 6 | Indices a, b, c, and d must be distinct (no repeated indices). 7 | The sum of nums[a], nums[b], nums[c], and nums[d] should be equal to the target. 8 | 9 | Return the array of all unique quadruplets that meet these conditions. The order of the quadruplets in the output array does not matter. 10 | 11 | 12 | Example 1: 13 | 14 | Input: nums = [4, 5, 3, 2, 9, 1], target = 12 15 | 16 | Output: [[9, 2, 1, 0], [5, 4, 2, 1], [9, 3, 2, -2]] 17 | 18 | Example 2: 19 | 20 | Input: nums = [-3, 1, -5, 7, 0, -2], target = -1 21 | 22 | Output: [[7, -3, -2, -5], [0, 1, -3, -1], [-2, 1, 0, -5]] 23 | 24 | The function should find all unique quadruplets in the nums array, where each quadruplet's elements sum to the given target. The quadruplets should satisfy the specified conditions and can be returned in any order. The examples provided use different number values to illustrate the problem. 25 | 26 | Exercise-1 27 | 28 | Input : 29 | 1 0 -1 0 -2 2 30 | 1 31 | 32 | Output : 33 | -2 0 1 2 34 | -1 0 0 2 35 | -------------------------------------------------------------------------------- /For CS - Module 2 and 3 - Contest - Python /Foursum/main.py: -------------------------------------------------------------------------------- 1 | def fourSum(nums, target): 2 | nums.sort() 3 | result = [] 4 | 5 | for i in range(len(nums) - 3): 6 | # Skip duplicate values for the first element 7 | if i > 0 and nums[i] == nums[i - 1]: 8 | continue 9 | 10 | for j in range(i + 1, len(nums) - 2): 11 | # Skip duplicate values for the second element 12 | if j > i + 1 and nums[j] == nums[j - 1]: 13 | continue 14 | 15 | left, right = j + 1, len(nums) - 1 16 | 17 | while left < right: 18 | current_sum = nums[i] + nums[j] + nums[left] + nums[right] 19 | 20 | if current_sum == target: 21 | result.append([nums[i], nums[j], nums[left], nums[right]]) 22 | 23 | # Skip duplicate values for the third element 24 | while left < right and nums[left] == nums[left + 1]: 25 | left += 1 26 | 27 | # Skip duplicate values for the fourth element 28 | while left < right and nums[right] == nums[right - 1]: 29 | right -= 1 30 | 31 | left += 1 32 | right -= 1 33 | 34 | elif current_sum < target: 35 | left += 1 36 | else: 37 | right -= 1 38 | 39 | return result 40 | 41 | # Input 42 | nums = list(map(int, input().split())) 43 | target = int(input()) 44 | 45 | # Output 46 | result = fourSum(nums, target) 47 | for quad in result: 48 | print(" ".join(map(str, quad))) 49 | 50 | -------------------------------------------------------------------------------- /For CS - Module 2 and 3 - Contest - Python /Merge two sorted linked lists/Readme.md: -------------------------------------------------------------------------------- 1 | Suppose we have two sorted linked lists, represented by the pointers headA and headB. Our task is to merge these two lists into a single sorted linked list. It's possible for either headX or headY to be null, indicating that the corresponding list is empty. 2 | 3 | For example, consider the following linked lists: 4 | 5 | headX refers to 2 -> 4 -> 6 -> 8 -> NULL 6 | headY refers to 1 -> 3 -> 5 -> NULL 7 | 8 | We need to merge these two lists into a new list, where the elements are sorted in ascending order. After merging, the resulting linked list would be: 9 | 10 | 1 -> 2 -> 3 -> 4 -> 5 -> 6 -> 8 -> NULL 11 | 12 | Important Note: Ensure that you save your solution before progressing to the next question and before submitting your answer. 13 | 14 | Exercise-1 15 | input: 16 | 3 17 | 1 18 | 3 19 | 7 20 | 2 21 | 1 22 | 2 23 | 24 | output: 25 | 1 26 | 1 27 | 2 28 | 3 29 | 7 30 | -------------------------------------------------------------------------------- /For CS - Module 2 and 3 - Contest - Python /Merge two sorted linked lists/main.py: -------------------------------------------------------------------------------- 1 | class ListNode: 2 | def __init__(self, value=0, next=None): 3 | self.value = value 4 | self.next = next 5 | 6 | def merge_sorted_lists(headA, headB): 7 | dummy = ListNode() 8 | current = dummy 9 | 10 | while headA is not None or headB is not None: 11 | if headA is None: 12 | current.next = ListNode(headB.value) 13 | headB = headB.next 14 | elif headB is None: 15 | current.next = ListNode(headA.value) 16 | headA = headA.next 17 | elif headA.value < headB.value: 18 | current.next = ListNode(headA.value) 19 | headA = headA.next 20 | else: 21 | current.next = ListNode(headB.value) 22 | headB = headB.next 23 | 24 | current = current.next 25 | 26 | return dummy.next 27 | 28 | # Function to print the linked list 29 | def print_linked_list(head): 30 | current = head 31 | while current is not None: 32 | print(current.value) 33 | current = current.next 34 | 35 | # Input 36 | n1 = int(input()) 37 | list1 = [int(input()) for _ in range(n1)] 38 | 39 | n2 = int(input()) 40 | list2 = [int(input()) for _ in range(n2)] 41 | 42 | # Create linked lists 43 | headA = ListNode(list1[0]) 44 | currentA = headA 45 | for value in list1[1:]: 46 | currentA.next = ListNode(value) 47 | currentA = currentA.next 48 | 49 | headB = ListNode(list2[0]) 50 | currentB = headB 51 | for value in list2[1:]: 52 | currentB.next = ListNode(value) 53 | currentB = currentB.next 54 | 55 | # Merge and print the result 56 | result_head = merge_sorted_lists(headA, headB) 57 | print_linked_list(result_head) 58 | 59 | -------------------------------------------------------------------------------- /For CS - Module 2 and 3 - Contest - Python /Task Scheduling/Readme.md: -------------------------------------------------------------------------------- 1 | Task Scheduling 2 | 3 | There are N tasks of varying durations, represented by an array A of size N. K workers are available, and each worker takes 1 unit of time to complete 1 unit of work. The goal is to find the minimum time required to complete all the tasks, with the constraint that each worker can only work on a continuous sequence of tasks. To solve this problem, we can use the binary search algorithm to find the minimum time required.. e.g., with 4 tasks of 10,20,30 & 40 time duration and 2 workers, min time is 60 mins. 4 | 5 | Important Note: Ensure that you save your solution before progressing to the next question and before submitting your answer. 6 | 7 | Exercise-1 8 | 9 | INPUT : 4 10 20 30 40 2 10 | 11 | First line => Number of tasks Second line => task durations Third line => Number of workers 12 | 13 | OUTPUT : 60 14 | 15 | Exercise-2 16 | 17 | Input: 4 60 20 40 50 2 18 | 19 | Output: 90 20 | -------------------------------------------------------------------------------- /For CS - Module 2 and 3 - Contest - Python /Task Scheduling/main.py: -------------------------------------------------------------------------------- 1 | def min_time_to_complete_tasks(tasks, workers): 2 | def is_valid(mid): 3 | current_workers = 1 4 | current_time = 0 5 | 6 | for task in tasks: 7 | current_time += task 8 | if current_time > mid: 9 | current_workers += 1 10 | current_time = task 11 | 12 | return current_workers <= workers 13 | 14 | low, high = max(tasks), sum(tasks) 15 | 16 | while low < high: 17 | mid = low + (high - low) // 2 18 | 19 | if is_valid(mid): 20 | high = mid 21 | else: 22 | low = mid + 1 23 | 24 | return low 25 | 26 | # Input 27 | num_tasks = int(input()) 28 | tasks_duration = list(map(int, input().split())) 29 | num_workers = int(input()) 30 | 31 | # Output 32 | result = min_time_to_complete_tasks(tasks_duration, num_workers) 33 | print(result) 34 | 35 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | --------------------------------------------------------------------------------