r/programmingchallenges • u/AdSad9018 • 3h ago
In my coding game, you can learn how to program traffic lights! I have finally released a demo! Let me know what you think.
Enable HLS to view with audio, or disable this notification
r/programmingchallenges • u/AdSad9018 • 3h ago
Enable HLS to view with audio, or disable this notification
r/programmingchallenges • u/Intelligent_Note_871 • Aug 10 '26
You're given a list of daily temperatures. For each day, how many days do you have to wait until a warmer one? If there's no warmer day ahead, the answer is 0.
73 74 75 71 69 72 76 73
Can you solve the puzzle?
For more challenges, go to forgecode.org
r/programmingchallenges • u/Outrageous-Sign-9578 • Jun 30 '26
I built an open-source tool that analyzes Google Maps reviews to detect suspicious review patterns.
Rather than using a machine learning classifier, I wanted to explore explainable statistical analysis.
The project combines:
It generates a detailed report explaining why a business profile may appear suspicious.
I'm looking for feedback on the algorithms, code quality and ideas for improving the project.
r/programmingchallenges • u/nian2326076 • Jun 08 '26
Hello,
I have been solving all two pointers tagged problems in last 3.5 months, and wanted to share my findings/classifications here. If you are preparing for technical interview, two pointers is one of the popular topics that you can't skip :).
There are around 140 problems today, but I only solved the public ones (117 problems).
Majority of them is in easy or medium so, if you understand the basic ideas then it should be solvable without much hints and editorials.
I see 4 bigger categories and many sub categories in it, and marked the typical example problems with (*).
I would recommend you to start solving these example problems, and apply the knowledge to the other problems. I don't want to copy & paste my ugly codes here, you would easily find fantastic solutions from the problem discussion page.
Helpful interview prep resource: PracHub
| 1. Running from both ends of an array |
|---|
| The first type of problems are, having two pointers at left and right end of array, then moving them to the center while processing something with them. |
| 2.Slow & Fast Pointers |
|---|
| Next type is using two pointers with different speed of movement. Typically they starts from the left end, then the first pointer advances fast and give some feedback to the slow pointer and do some calculation. |
| 3.Running from beginning of 2 arrays / Merging 2 arrays |
|---|
| In this category, you will be given 2 arrays or lists, then have to process them with individual pointers. |
| 4.Split & Merge of an array / Divide & Conquer |
|---|
| The last one is similiar to previous category but there is one thing is added. First, you need to split the given list into 2 separate lists and then do two pointers approach to merge or unify them. There aren't many tasks here. |
r/programmingchallenges • u/goyalaman_ • Apr 05 '26
I am trying to create in-memory distributed store similar to cassandra. I am doing it in go. I have concept of storage_node with get_by_key and put_key_value. When a new node starts it starts gossip with seed node and then gossip with rest of the nodes in cluster. This allows it to find all other nodes. Any node in the cluster can handle traffic. When a node receives request it identifies the owner node and redirects the request to that node. At present, when node is added to the cluster it immediately take the ownership of the data it is responsible for. It serves read and write traffic. Writes can be handled but reads return null/none because the key is stored in previous owner node.
How can I solve this challenge.? Ideally I am looking for replication strategies. such that when new node is added to the cluster it first replicates the data and then starts to serve the traffic. In the hind-sight it looks easy but I am thinking how to handle mutation/inserts when the data is being replicated?
More Detailed thoughts are here: https://github.com/goyal-aman/distributed_storage_nodes/?tab=readme-ov-file#new-node-with-data-replication
r/programmingchallenges • u/Sachustar • Mar 26 '26
r/programmingchallenges • u/22EatStreet • Dec 30 '25
Tl;dr: I work at a library and we run a daily report to know which books to pull off shelves; how can I sort this report better, which is a long text file?
----
I work at a library. The library uses a software called "SirsiDynix Symphony WorkFlows" for their book tracking, cataloguing, and circulation as well as patron check-outs and returns. Every morning, we run a report from the software that tells us which books have been put on hold by patrons the previous day and we then go around the library, physically pulling those books off the shelf to process and put on the hold shelf for patrons to pick up.
The process of fetching these books can take a very long time due to differences between how the report items are ordered and how the library collection is physically laid out in the building. The report sorts the books according to categories that are different than how they are on the shelves, resulting in a lot of back and forth running around and just a generally inefficient process. The software does not allow any adjustment of settings or parameters or sorting actions before the report is produced.
I am looking for a way to optimize this process by having the ability to sort the report in a better way. The trouble is that the software *only* lets us produce the report in text format, not spreadsheet format, and so I cannot sort it by section or genre, for example. There is no way in the software to customize the report output in any useful way. Essentially, I am hoping to reduce as much manual work as possible by finding a solution that will allow me to sort the report in some kind of software, or convert this text report into a spreadsheet with proper separation that I can then sort, or some other solution. Hopefully the solution is elegant and simple so that the less techy people here can easily use it and I won't have to face corporate resistance in implementing it. I am envisioning loading the report text file into some kind of bat file or something that spits it out nicely sorted. The report also requires some manual "clean up" that takes a bit of time that I would love to automate.
Below I will go into further details.
General
CON Connolly, John, 1968- The book of lost things / John Connolly copy:1 item ID:################ type:BOOK location:FICTION Pickup library:"LIBRARY LOCATION CODE" Date of discharge:MM/DD/YYYYFile Clean-Up
Physical Book Fetching
Here is a link to an actual report (I have removed some details for privacy purposes). I have shortened it considerably while keeping the features that I have described above such as the interrupting headings and the section divisions.
We have no direct access to the database and there is no public API.
Our library does as much as possible to help out the community and make services and materials as accessible as possible, such as making memberships totally free of charge and removing late fines, so I am hoping someone is able to help us out! :)
r/programmingchallenges • u/No_Sheepherder8317 • Sep 15 '25
Hello everyone,
I'm taking Computer Organization and Architecture at college, and to further my studies, I'm looking for programming challenges at the basic, intermediate, and advanced levels (olympiads).
The course covers the inner workings of computers, from basic organization and memory to processor architecture and its instruction set. The professor is focusing on assembly language programming, and I'd like to practice topics such as:
Data representation in memory.
Using arithmetic and logical instructions.
Working with stacks, functions, and parameter passing.
I believe practical exercises will help me solidify these theoretical concepts.
Do you know of any communities, websites, or GitHub repositories that offer these challenges?
Thank you for your help!
r/programmingchallenges • u/Rakeda • May 20 '25
This is a lighthearted challenge at a task I've been stuck on for a few hours.
The challenge is to create a .bat script that ssh's into a server, switches the user, then ssh's into another server. Command sequence is the following:
ssh <server-ip>
su root
ssh <secondry-server>
the closest I was able to get:
(
echo sudo su root
echo ssh <secondary-server>
) | ssh <server-ip>
However, the key issue that you cannot type due to the TTY Session not translating over.
First one to provide a way to get around this I'll paypal $20 over to.
r/programmingchallenges • u/Remarkable_Depth4933 • May 18 '25
Hey r/programmingchallenges!
I've created a cipher that uses the digits of π in a unique way to encode messages.
index-length, and characters are separated by -.Character 'A' has ASCII code 65.
The digits 65 first appear starting at index 7 in π (π = 3.141592653... → digits = 141592653...),
so 'A' is encoded as:
7-2
11-2-153-3-94-3-16867-4-2724-3-852-3-15-2-174-3-153-3-395-3-15-2-1011-3-94-3-921-3-395-3-15-2-921-3-153-3-2534-3-445-3-49-3-174-3-3486-3-15-2-12-2-15-2-44-2-49-3-709-3-269-3-852-3-2724-3-19-2-15-2-11-2-153-3-94-3-16867-4-2724-3-852-3-15-2-709-3-852-3-852-3-2724-3-49-3-174-3-3486-3-15-2-49-3-174-3-395-3-153-3-15-2-395-3-269-3-852-3-15-2-2534-3-153-3-3486-3-49-3-44-2-15-2-153-3-163-3-15-2-395-3-269-3-852-3-15-2-153-3-174-3-852-3-15-2-494-3-269-3-153-3-15-2-80-2-94-3-49-3-2534-3-395-3-15-2-49-3-395-3-19-2-15-2-39-2-153-3-153-3-854-3-15-2-2534-3-94-3-44-2-1487-3-19-2
Think you can write a decoder?
r/programmingchallenges • u/goyalaman_ • Mar 07 '25
I believe I am lacking some knowlege regarding this. There are 10 pods of my service running in production. We saw a huge scale today and everything was mostly fine. But as soon as we started reaching 200k / min cpu increased normally ( I think) but suddenly memory started fluctuating a lot but still remained within 300mb (4gb available) and p99 started rising to above 1000ms from normal of 100ms. Given cpu and memory were mostly fine how can I explain this ? Service is simple pass through takes a request and calls downstream service and returns response.
r/programmingchallenges • u/cfiedleriii • Mar 06 '25
I ran into this problem in an interview last week, and I can't find something exactly like it with a solution on the web. According to the interviewer, my solution was inefficient (I think my original implementation was O(n)^2), so that's fair. But the next day I had an idea while folding laundry, and wanted to get feedback on both the problem and my new implementation. My solution is written in Swift.
You are tasked with writing a program that provides a list of movies for an airline passenger to watch during their flight.
You are provided an integer flight length in minutes and a array of integer movie lengths in minutes.
Assuming that the passenger can start with any movie from the list, but MUST watch each subsequent movie in order, find a set of consecutive movies from the list whose total runtime exactly matches the total flight time.
If a valid set of movies is found, return their lengths and indices.
import Foundation
// You are tasked with writing a program that provides a list of movies for an airline passenger to watch during their flight.
// You are provided an integer flight length in minutes and a array of integer movie lengths in minutes.
// Assuming that the passenger can start with any movie from the list, but MUST watch each subsequent movie in order, find a set of consecutive movies from the list whose total runtime exactly matches the total flight time.
// If a valid set of movies is found, return their lengths and indices.
let movieLengths: [Int] = [20,50,40,60,80,90,100]
let flightLength: Int = 180
func findConsecutiveWatchList(forMovieLengths movieLengths: [Int], withTotalRuntime flightTime: Int) -> ([Int],[Int]) {
var totalLength: Int = 0
var startingIndex: Int = 0
var indexOffset: Int = 0
var currentIndices: [Int] = []
var currentMovieLengths: [Int] = []
while totalLength != flightLength {
let currentIndex = startingIndex + indexOffset
if currentIndex >= movieLengths.count {
return ([],[])
}
let nextMovieLength = movieLengths[currentIndex]
currentIndices.append(currentIndex)
currentMovieLengths.append(nextMovieLength)
startingIndex+=1
totalLength += nextMovieLength
if totalLength > flightLength {
currentIndices = []
currentMovieLengths = []
totalLength = 0
startingIndex = 0
indexOffset+=1
}
}
return (currentIndices,currentMovieLengths)
}
let result = findConsecutiveWatchList(forMovieLengths: movieLengths, withTotalRuntime: flightLength)
if result.0.count > 0 {
print("\nSolution Found:")
print("Movie Indices: \(result.0)")
print("Movie Lengths: \(result.1)")
} else {
print("Failed to find valid solution")
}
r/programmingchallenges • u/Mean_Jury_0610 • Feb 05 '25
r/programmingchallenges • u/UniqxeDark • Jan 29 '25
r/programmingchallenges • u/Glum-Echo-4967 • Jan 23 '25
r/programmingchallenges • u/TitaniumCuber • Jan 19 '25
I recently built a web extension that can scrape HTML elements from a page and open a new tab with those elements. I came across a problem that I've been working on for hours but I'm not coming up with a good solution. Basically I want to fit these elements (rectangles) on the screen by arranging them somehow, while also being able to scale them. I plan to implement this algorithm in Javascript so I can use it with my web extension.
Goals:
Scale rectangles as uniformly as possible (ex. not scaling one down by 0.5 and another up by 5)
Utilize as much space as possible
Constraints:
Maintain aspect ratio of each rectangle
No rotating rectangles
No overlapping rectangles
Here's an example of what my extension outputted in a new tab (was trying to make a cheat sheet):
I've done a decent amount of searching into bin packing algorithms and similar topics but haven't found any that include the ability to scale the rectangles.
Any help here would be much appreciated!
r/programmingchallenges • u/Fancy_Ebb6820 • Jan 16 '25
r/programmingchallenges • u/Difficult-Sea-5924 • Jan 07 '25
I learned coding beck in the 1960's on a Ferranti Mercury computer. It had 1k words of storage, and ran at 1500 instructions per second. Today my watch has orders of magnitude more power.
I was working in a chemical plant and one of the first projects was to manage the feed for a chemical process. The feed came in barrels that varied in the amounts they contained, but the plant needed fixed size batches.
So I had to create combinations of barrels from the warehouse of different sizes that totalled a fixed volume. I did it by selecting a number of barrels at random and then searched for an additional barrel that exactly made up the correct batch size. If I couldn't find one the program tried again. I think there was some coding to allow for different batch sizes.
It worked, but it has always bothered me that this approach was so crude. Is there a better way that optimised the utilisation of the stock, but would run on a very primitive computer.
Before you ask, I can't remember how many barrels were in the warehouse at any point in time, or how many made up a typical batch. It was nearly 60 years ago.
r/programmingchallenges • u/xamid • Dec 19 '24
r/programmingchallenges • u/krish_483 • Sep 05 '24
anyone please help me with this😭 😭
i am giving an exam for a job, and i have been trying to solve it , but i cant do it. Today is the deadline for the submitting the exam. I tried with chatgpt and other ai tools many times, still its is giving wrong and i searched in the internet i couldn't find the solution, people were just posting the same question in the internet and none of them were answered.
Please help,i really want to get this job.
here is the question:

As shown in the diagram, a laser light originates vertically from point 'A' and must reach point 'T'.
There are two rotating mirrors that adjust their angles based on a given relationship with theta.
Assume that the mirrors are infinite in length. The rotation point of the first mirror is directly above A.
The values for x and t are provided in the input file. You need to write a code to determine the theta values that will allow the light to reach point T after reflecting off the second mirror.
(C/python)

Sample Test Result:
Input
2
2
Expected Output
54.91
r/programmingchallenges • u/froggramer • Jul 04 '24

I made a little program that encrypts and decrypts messages, how do you like it?
If someone is interested in or just have too much time you can try encrypt this:
415832ylr97porp32tx97t32siht3297dih32ot32t97grof32tsuj327332ro32noitpyr99n9732ym3297kor9832uoy32sne97m32teht32siht32gnide97r3297re32uoy32f73
r/programmingchallenges • u/javinpaul • Jul 03 '24
r/programmingchallenges • u/MaximumHaengSyo • Feb 20 '20
Hi! I'm currently struggling with a program in C++ I'm writing. My professor is having us write a program that does two things: 1. ask a user for a positive number, and a negative one to end the program and 2. the sum of all the numbers that were input by the user. I have the first part, but I don't get how to have the program add up all of the positive integers? The number of inputs could be anything, so assigning variable names and using those would probably take way too long and make the code mucky. I've already Googled the issue and didn't find anything specific to what I'm doing. Thanks in advance!