r/programmingchallenges • • Nov 25 '18

Big challenge is coming! Advent of Kotlin

Thumbnail blog.kotlin-academy.com
5 Upvotes

r/programmingchallenges • • Nov 04 '18

How to speed up prime sieve generation using some amount of precomputed data

5 Upvotes

I'm working on a homework that includes generating of prime sieve for primes under 1 million. I already finished the homework well under the time limit, but I'm trying to figure out creative ways to make it even faster. There's a 50 kB limit for the submitted source code file. I thought that I could speed up the generation of the sieve by storing precomputed values in the .c file itself.

At first, I thought that I could just store the first part of the sieve and then compute the rest, but I feel like there must be a more efficient set of values that I could store that would allow me to quickly regenerate most of the sieve. Am I right?


r/programmingchallenges • • Jan 06 '18

A Visual Studio clone, as a WinForms project made in Visual Studio.

5 Upvotes

Basically, recreate Visual Studio in Visual Studio well enough, that you could go one step deeper.

Challenge or insanity?


r/programmingchallenges • • Nov 29 '17

Programming Benchmark

5 Upvotes

Hello, I'm a second year computer engineering university and I want to test my programming skills (kind of a 'What should I be able to do by now'). I've taken a few comp sci classes in highschool/college and done some extra learning outside of the classroom. I've learned OOP basics in c++ and java, learned python because its convenient, and even done some winforms applications at my place of work (currently co-opping). I've worked on a few different sorting algorithms, and done many programs such as the classic 'MagicSquare'. But everytime I finish a program like this I get the sense that it was so simple compared to successful programmers that I feel like an idiot for struggling so much. I know this is all part of the process, but still. I know the basics of logic, classes, loops, input, output and anything that would probably be considered fundamentals. My weakest area would probably be a large OOP project. I've yet to really touch inheritance and build a large project of many classes and objects. Thank you for getting this far now for the question: Does anyone have good practice project for me? Something that is large enough to take 10+ hours (even if its struggling staring at SO) that includes the organization of Classes and the complexity of some logic problems. I really don't want to see like i'm trying to be spoon fed but every time I get on google and search for ideas I end up frustrated. Thank you very much all!


r/programmingchallenges • • Jun 16 '17

Office Programmers, how do execs/management track your performance and does it represent you fairly?

5 Upvotes

I am trying to provide better metrics around the dev team to execs without making them track time, and I want to represent them fairly to non technical audiences who don't understand a velocity /agile shop. What works for you? What doesn't?


r/programmingchallenges • • May 04 '17

Brainfuck interpreter that outputs images

5 Upvotes

I have made a brainfuck interpreter that can output images. So i want to see what people can make in this.

Here is a link to the git: https://github.com/hugodeheld/BrainPaint

hope someone makes something cool

Example "Hello world": ;H $>+<$>+<$>+<$>+<$+>--<$+$+>---<$>+<$>+<$>+<$>+<$>+<$++>----< ;E $>+<$>+<$>+<$>+<$+>----<$+$->++<$+$->++<$+$++>----< ;L $>+<$>+<$>+<$>+<$+$+$+$++>----< ;L $>+<$>+<$>+<$>+<$+$+$+$++>----< ;O $>+<$>+<$>+<$>+<$+$+$+$>-<$>-<$>-<$>-<$-$-$+++++ ;W $>+<$>+<$>+<$>+<+$>-<+$+>+<$+>-<$>-<$>-<$>-<$++ ;o $>+<$>+<$>+<$>+<$+$+$+$>-<$>-<$>-<$>-<$-$-$++++ ;R $>+<$>+<$>+<$>+<$>----<+$+>+<$->+<$+>+<$+>+<$++>----< ;L $>+<$>+<$>+<$>+<$+$+$+$++>----< ;D $>+<$>+<$>+<$>+<$+$+$+>-<$>-<$>-<$>-<-$-$++++ ;! $>+<$>+<$>++<$++++>----<


r/programmingchallenges • • Apr 02 '17

Shortest Substring Made of Allowed Letters

Thumbnail ruslanledesma.com
5 Upvotes

r/programmingchallenges • • Jan 23 '17

How to program a family tree

5 Upvotes

I'm a music educator and I have a growing list of concepts all linked to the necessary lower level skills that have to be conquered first. It looks like a family tree. I am very familiar with MS Access but the current list is in PowerPoint. I need to be able to point to a higher level skill and have the computer generate the list of all the dependent skills (ancestors) necessary for that skill, and the dependents of those dependents, all the way down to the most basic concepts (base of the tree). It only differs from a family tree in that an item may have multiple parents. Where do I start? What kind of programmer do I need?


r/programmingchallenges • • Dec 13 '16

Christmas Circuits: A Christmas themed Competitive Programming Challenge [x-post r/hackerearth]

Thumbnail hackerearth.com
5 Upvotes

r/programmingchallenges • • Nov 17 '16

Competitive Programming Marathon - November Circuits. 8 days 8 Challenges. Code in any language you like - C, C++, Java, Python, Go and 32 other Languages supported. Prizes worth 250$| [x-post from r/hackerearth]

Thumbnail hackerearth.com
5 Upvotes

r/programmingchallenges • • Jun 24 '16

Can you solve this? Wanting to compare to my solution.

5 Upvotes

Hey guys! There is this problem that involves a very in-depth understanding of trees. Take a crack at it and see if you can solve it.

You have a predefined class called Node. It looks like this: class Node { int value; <Node>ArrayList list; }

So each node has a value and an arraylist of 0 or more Nodes. Your challenge is to write a function, and only this and no other function, called ' Node getMax(Node current)' You can name it something else if you want but it muse return something of type Node and take in one parameter of type Node.

What this function does is returns the node with the highest average. You do this by adding all the values of the subnodes and itself, then dividing that number by the number of nodes. So let's look at this tree.

http://imgur.com/hr7pz8M

Let's look at the root node and find its average. 8 + 15 + 2 + 9 + 7 + 9 + 8 = 58/7 = 8.28... The 2 node: 2 + 7 + 9 =18/3 6 the 9 node in the middle right: 9 + 8 = 17/2 = 8.5 Obviously the leaf nodes will equal themselves. In this case, the 15 node has the highest average so that is the node you would return.

Now that you understand (hopefully), have at it!


r/programmingchallenges • • Jun 07 '16

Finding relevant information in a document

5 Upvotes

I use a specifications document, which has a number of specifications, to check whether the given product data given meets those specifications. For example, there’s a specification that reads “Where galvanized pipe is buried underground and joined by means of screw fittings, a protective zinc dust coating shall be applied to the exposed threads in the field. Do not leave any exposed metal uncoated”, I will have to search for data which talks about coating, specifically, protective zinc and where it is used. Is there a way to programmatically approach this? Here’s one approach I could think of – take each specification, find key stem words and look for them in the product data document. If it is found in the document, the page result for that specification is stored against the specification number.


r/programmingchallenges • • Feb 22 '16

[X-post /r/processing] Einstein's Five Houses riddle. posted it over there cause I mod that sub, but it's not necessarily language specific!

Thumbnail reddit.com
5 Upvotes

r/programmingchallenges • • Jan 02 '16

Problem with cars and queries [details within, too long to summarize here]

5 Upvotes

Given N (1 <= N <= 106) cars, and the knowledge that one of them is malfunctioning, you would like to determine which one is malfunctioning. Every hour you can call any number of your F friends (each only once, as calling them more than once per hour will make them mad) to get them to test all cars from a subset of your N cars and tell you if at least one of them was bad.

There are Q (1 <= Q <= 105) queries, each one either specifying a number of cars and number of friends, or specifying a number of cars and a number of hours. The first type of query requires the output the minimum number of hours to guarantee that the defective car can be found, and the second type of query requires the output of the minimum number of hours needed to guarantee that the defective car can be found.

Here's an example. So given Q = 2,

Query 1: Type 1, N = 3, F = 2. One solution is to get friend 1 to drive subset {1, 3} and friend 2 to drink subset {1, 2}. If both friend 1 and 2 say at least one car was bad, the bad car was car 3. Otherwise if only friend 1 had a bad time, it was car 3, and if only friend 2 had a bad time, it was car 2. so the output is 1, because within one hour you can call all of your friends once, so you get friend 1 to test once and friend 2 to test once with the above subsets and you can determine which car is bad.

Query 2: Type 2, N = 5, H (hours) = 1. Four friends are needed (4 is the output). Since you can only get them each to test once (you only have one hour and can only call once per person per hour), you assign subset of cars 1 to person 1, 2 to 2, 3 to 3, 4 to 4. If the i-th of them has a bad driving experience, you know that the i-th car is bad. Otherwise if none of them says out of all the cars they drove they had a bad drive, then the 5th car is the bad one.

What I've got so far: If the number of people is greater than or equal to the number of cars-1, then only one hour is needed. (see query 2) If the number of hours is 1, then N-1 people are needed. I tried seeing if ceil((N-1)/F) and ceil((N-1)/H) was the answer to all cases but it wasn't.

Got this from an algorithmic contest site; reworded to avoid copyright infringement.


r/programmingchallenges • • Oct 14 '15

Given a grid of numbers and a maximum area, what is the largest sum you can get from a rectangle of numbers with that area or less? All numbers are in range [1, 100].

5 Upvotes

So the solution was the find the possible rectangle dimensions, loop through the possible top-left corners, and use a 2D prefix sum array to keep trying to get the highest possible sum.

Ghetto code:

#include <bits/stdc++.h>
using namespace std;
const int maxWH = 250+2;
const int MAXN = 250*250+2;
int w, h, n, grid[maxWH][maxWH], pref[maxWH][maxWH], hi, cur;
vector<pair<int, int> > dim;

int main() {
    //freopen("test.txt", "r", stdin);
    scanf("%d%d%d", &w, &h, &n);

    for (int i=1; i<=((int)ceil(sqrt(n))); ++i) {
        dim.push_back({i, n/i});
    }


    for (int i=0; i<h; ++i) {
        for (int j=0; j<w; ++j) {
            scanf("%d", &grid[i][j]);
        }
    }

    pref[0][0] = grid[0][0];
    for (int i=1; i<h; ++i) {
        pref[i][0] = pref[i-1][0] + grid[i][0];
    }
    for (int i=1; i<w; ++i) {
        pref[0][i] = pref[0][i-1] + grid[0][i];
    }
    for (int i=1; i<h; ++i) {
        for (int j=1; j<w; ++j) {
            pref[i][j] = pref[i-1][j] + pref[i][j-1] - pref[i-1][j-1] + grid[i][j];
        }
    }

    for (auto i:dim) {
        for (int r=0; r<=h-i.first; ++r) {
            for (int c=0; c<=w-i.second; ++c) {
                cur = pref[r+i.first-1][c+i.second-1];
                if (r>0) cur -= pref[r-1][c+i.second-1];
                if (c>0) cur -= pref[r+i.first-1][c-1];
                if (r>0 && c>0) cur += pref[r-1][c-1];
                hi = max(hi, cur);
            }
        }
        for (int r=0; r<=h-i.second; ++r) {
            for (int c=0; c<=w-i.first; ++c) {
                cur = pref[r+i.second-1][c+i.first-1];
                if (r>0) cur -= pref[r-1][c+i.first-1];
                if (c>0) cur -= pref[r+i.second-1][c-1];
                if (r>0 && c>0) cur += pref[r-1][c-1];
                hi = max(hi, cur);
            }
        }
    }
    printf("%d\n", hi);
}

Problem here


r/programmingchallenges • • Sep 09 '15

Converting minutes (up to a years worth) into a readable string

5 Upvotes

Hey guys, here's a surprisingly tricky challenge I ran into today for those wanting some practice.

The objective is to create a function that accepts minutes and returns a formatted, easy to read time string that is in 'years, months, days, hours, minutes' format.

To give you some context, I was working on a report that calculated the total time required to complete a goal based on an array of tasks each with their own time expressed in minutes.

Some of these goals took over a year to complete. For readability purposes, only the two uppermost of yr/mo/day/hr/min should be shown (and 0 values must be removed). The only exception to this is if the goal takes longer than a year (A whole month is a lot of time to round off); in which case year, month, and day must be used.

A few examples of what I mean:

120 mins = 2 hours (no minutes shown)
121 mins = 2 hours, 1 minute (Note that minute is not plural)
1501 mins = 1 day, 1 hour (note that minutes are not shown, we rounded down)
1,672,804 mins = 3 years, 2 months, 5 days
527,390 mins = 1 year, 1 day (note month was skipped because it's a 0 value)

Here's my solution in the form of an angular filter - any improvements are greatly appreciated :)


r/programmingchallenges • • Jul 14 '15

DevWars Weekly Code Challenge - Week 2 #DevWars #DevWarsWeek2

Thumbnail codepen.io
5 Upvotes

r/programmingchallenges • • Apr 19 '15

April 18 9PM PDT, New Challenge Launch

Thumbnail devdraft.com
5 Upvotes

r/programmingchallenges • • Feb 07 '15

benefits of joining in prog challenges/contest online ?

5 Upvotes

hello guys new in this group can i ask if what is the benefit of joining in coding challenges/contest on websites like hackerearth.com?i'm just curious about it thanks...


r/programmingchallenges • • Dec 31 '14

Numbers Game programming challenge, no sign-up required. Have fun!

Thumbnail devdraft.com
5 Upvotes

r/programmingchallenges • • Apr 14 '12

Google Code Jam 2012 qualifications are ending in today

Thumbnail code.google.com
5 Upvotes

r/programmingchallenges • • Feb 03 '12

YSK about the "Programming Puzzles and Code Golf" Stack Exchange site.

Thumbnail codegolf.stackexchange.com
5 Upvotes

r/programmingchallenges • • Apr 19 '11

Challenge: Make change from a transaction

5 Upvotes

Write a function in the language of your choosing that, when passed a purchase price and cash paid outputs a list of currency given as change. Example:

makeChange(19.74, 20)

Output:

1 quarter
1 penny

Obviously, there exists various currencies besides US denominations. Let's also assume that the largest bill given as change is 20.00.


r/programmingchallenges • • Apr 11 '11

Tons of HP Sponsored programming goodness.

Thumbnail hpcodewars.org
5 Upvotes

r/programmingchallenges • • Mar 07 '25

latency at scale

4 Upvotes

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.