All Questions
Tagged with programming-challenge c
155
questions
4
votes
2
answers
274
views
Count frequency of words and print them in sorted order
Objective:
Write a program to count the frequencies of unique words from standard input, then print them out with their frequencies, ordered most frequent first. For example, given this input:
...
4
votes
2
answers
111
views
Delete a node in binary tree
Problem Statement
Given a root node reference of a BST and a key, delete the node with the given key in the BST. Return the root node reference (possibly updated) of the BST.
Basically, the deletion ...
6
votes
2
answers
207
views
Advent of Code 2023 day 1: Trebuchet (Part 1 and 2) Follow-up
This is a follow-up to the question asked here: Advent of Code 2023 day 1:
Trebuchet (Part 1 and 2)
Changes made:
The code no longer assumes that all lines will fit into a fixed-size buffer. Although ...
4
votes
1
answer
108
views
Advent of Code 2023 day 1: Trebuchet (Part 1 and 2)
Part 1:
The task involves analyzing a calibration document containing lines of text. Each line represents a calibration value that needs to be recovered by extracting the first and last digits and ...
2
votes
5
answers
277
views
Sum of bitwise XOR of each subarray weighted by length
here is the problem statement
You are given an array a of length n consisting of non-negative integers.
You have to calculate the value of \$\sum_{l=1}^n \sum_{r=l}^n f(l,r)\cdot (r - l + 1)\$ where \...
5
votes
2
answers
141
views
Generating Pascal's Triangle in C99
I recently completed the Pascal's Triangle challenge on leetcode. I would like to have my code reviewed.
You don't need a leetcode account to see the description of the challenge linked above, but for ...
3
votes
3
answers
124
views
Solution to Codejam 2021 1C (Closest Pick) in C
The following code is my solution to the Closest Pick problem from Codejam 2021.
You are entering a raffle for a lifetime supply of pancakes. N tickets have already been sold. Each ticket contains a ...
4
votes
3
answers
139
views
Simple photomosaic generator
I wrote an implementation of Robert Heaton's Programming Exercise for Advanced Beginners #4 (photomosaics) in C99 using the MagickCore library. The full code is as follows:
...
5
votes
1
answer
82
views
Möbius function using iterators for prime factors
While working on Project Euler, I have come across a few questions involving usage of the little omega function, big omega function, and Möbius function.
My prior code wrote factors into an array and ...
6
votes
1
answer
574
views
HackerEarth challenge: Lunch boxes
I was solving the lunch boxes problem on HackerEarth but as I submitted my solution most of the test cases were passed and the rest showed 'Time Limit Exceeded'. I would be very grateful if you could ...
0
votes
1
answer
87
views
duplicate an open file descriptor [closed]
My program implements a function similar to `dup2'. I would like you to please find any problems with the code and what I could improve.
code:
...
1
vote
2
answers
101
views
It is considered a daemon if it runs in the background - creating a daemon in C
I created a daemon that creates a fifo file with a default name, then is been blocked waiting for messages on that fifo. When an interactive process writes data to that fifo, the daemon wakes up and ...
0
votes
1
answer
345
views
Round Robin algorithm implementation
I wrote a program that implements the Round Robin planning algorithm. The total number of processes is read directly from the input standard, and for each process the arrival time and execution time ...
-3
votes
3
answers
775
views
CodeForce 230 Dragon Fighting, Sorting without using array
Problem: https://codeforces.com/problemset/problem/230/A
Kirito is stuck on a level of the MMORPG he is playing now. To move on in the game, he's got to defeat all \$n\$ dragons that live on this ...
2
votes
3
answers
148
views
Finds Keywords in Log Files
This is my first project in C and I wanted a more experienced person's insight on how I made the whole program. Just looking for feedback it works how I want it to. The Github is here. Thank you so ...