Fading Coder

One Final Commit for the Last Sprint

Insertion Sort and Shell Sort Algorithms

Insertion Sort Insertion sort constructs a sorted array incrementally. It takes one element from the input data and finds its correct position within the sorted list, repeating until no elements remain. Simple Insertion Sort For each element at index i (from 1 to n-1), the algorithm compares it with...

Calculating Sum of Numbers with Digit Sums in a Specified Range

Problem Analysis This problem requires calculating the sum of all integers from 1 to N where the sum of the digits of each integer falls within the inclusive range [A, B]. For example, with N=20, A=2, and B=5, the qualiyfing numbers are 2, 3, 4, 5, 11, 12, 13, 14, 15, and 20. Their total sum is 84....

Implementing High-Precision Arithmetic in C++ with a Custom Big Integer Class

A high-precision integer class enables arithmetic operations on numbers exceedign standard integer limits, icnluding handling negative values. This class uses a fixed-size array to store digits, with M defining the maximum length of the string representation. It overloads operators for addition, sub...

Determining Feasibility of Reaching the End in a Jump Game

The canJump function accepts an integer vector nums as input and returns a boolean value indicating weather it is possible to jump from the first element to the last element of the array. Let's analyze this code step by step: Variable Initialization: int maxReach = 0; Here, maxReach represents the f...

Dynamic Programming for Unbounded Knapsack Problems: Coin Change, Combination Sum, and Stair Climbing

Unbounded Knapsack Fundamentals In the unbounded knapsack problem, each item can be used an unlimited number of times, unlike the 0/1 knapsack where each item is used at most once. This difference requires two key implementation changes: When iterating through the knapsack capacity, we must iterate...

Solutions to the 2024 Blue Bridge Cup Provincial C++ Intermediate/Advanced Group Programming Problems

T1 - Reading Plan Problem: A book has (n) pages. On the first day, a person reads (x) pages. Each subsequent day, they read (y) pages more than the previous day. How many days are needed to finish the book? Input: Three integers (n), (x), (y) ((20 \le n \le 5000, 1 \le x, y \le 20)) separated by spa...

Determining the Champion Team in a Tournament

Problem: Find Champion I In a tournament with n teams, numbered from 0 to n - 1, you are given a square boolean matrix grid of size n x n. For all pairs (i, j) where 0 <= i, j <= n - 1 and i != j, if grid[i][j] == 1, then team i is stronger than team j. Otherwise, team j is stronger than team...

Implementing Decimal to Binary Conversion Using Loops in Python

This article explores the process of converting decimal numbers to binary representation using fundamental Python loops, without relying on advanced data structures like lists or built-in functions. Initial Attempt and Its Flaw The first approach attempted to compute the binary digits through repeat...

Optimizing Fruit Pile Merging with Minimum Energy Consumption in C++

Problem Description In a orchard, all fruits have been harvested and sorted into piles by type. The goal is to merge all piles into a single pile. Each merge operation combines two piles, with energy consumption equal to the sum of their weights. After n-1 merges, only one pile remains. The total en...