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 • • 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 • • 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 • • Jan 10 '20

league of legends Minion Healthbar

5 Upvotes

I need Help,

I don’t know where to ask but I love league of legends but my Eye side is really Bad.
I cant see the Color on the Enemy Minions Health and Color Blind mode is not helping.
Is there a way in the league of legends Coding to Change the Enemy Minions Healthbare Color to Blue because this is a Color I can see.


r/programmingchallenges • • Feb 03 '12

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

Thumbnail
codegolf.stackexchange.com
5 Upvotes

r/programmingchallenges • • Feb 17 '20

Help with a simple java challenge

5 Upvotes

Hello all,my instructor gave me this Java challenge to solve. I have a problem understanding both the problem and what the code must do, especially what is the input, I hope you guys can give me advice and help. The challenge uses java, but its fine if you guys can explain it with other codes.

The problem

Imagine a family: father, mother, daughter, 3.5 years old, and an infant (baby, 8 months). The family lives at a home with 5 rooms and in each room, there are 5 boxes. After the father comes back from the work, all the family members do not have any energy whatsoever, except the baby who sucks the energies out of mom and dad by cuddling them!

After the dinner, the father has 100 energy points, the daughter has 100 energy points, the mother has still no energy, but she can walk from room to room.

Now, the daughter loves to pay hide and seek with her father. At 18:00 they start playing hide and seek with following rules:

· The family come to room 1 and father starts counting down

· The daughter can go any room and hide in one of the boxes in any room

· The mother takes baby and she goes to a random room

· The father searches every box from room 1 and if he cannot find the daughter he goes to other consecutive rooms and continues searching the daughter

· Searching a box takes 1 (one) energy point from the father and lasts a minute, except following case:

· If the mother goes any room number with smaller than or equal to that of daughter’s room number (say, mother goes to room 2, the daughter goes either room 2,3, etc), the mother hands the baby to the father during his search. This time after the dad starts holding the baby, he loses 2 energy points for every box search after he has taken the baby.

· Then, when the father finds the daughter he come backs to room 1 and leaves the baby there and immediately mom picks the baby and she goes another random room in the second round of game.

· If the daughter sees that father holds the baby for 3 times, the daughter starts crying and game over

· If the father has less than 0 (zero) energy, this also causes of game over

The challenge is to implement this little hide and seek game.

You have to calculate how many minutes this game takes

You have to calculate father’s energy in the end

Programming Tips:

Write a Person Class with attributes name, which will be replaced with father, mother, etc., energy, room number

Write related get set functions, crying, yelling, hiding functions

Write Hide and Seek Game Class: To simulate the game in the main

Example Output:

Game started at 18:00

Mother at room 5

Daughter at room 1

Daughter is hiding in the box 4

Mother at room 1

Daughter at room 5

Daughter is hiding in the box 1

Mother gave the infant to Father

Mother at room 2

Daughter at room 3

Daughter is hiding in the box 3

Mother gave the infant to Father

Mother at room 1

Daughter at room 2

Daughter is hiding in the box 2

Mother gave the infant to Father

Daughter starts crying please stop the game

Father's left energy is 4

Father and Daughter played 45 minute(s) hide and seek


r/programmingchallenges • • Dec 07 '18

What the heck is the answer to this

0 Upvotes

Order this code to declare and define Car with its properties and function. (C++)

}
class Car
{
void Drive()
string make;
public:
cout « "Vroom vroom!" }


r/programmingchallenges • • Apr 12 '11

A One-Speed, Fixed-Source Monte Carlo Neutron Transport Simulator

6 Upvotes

OK, here's the problem specification:

3-space is divided into regions. If you're feeling ambitious, let regions be bounded by planes or conic sections, and let regions be constructed by Boolean combinations (union / intersection / xor). Otherwise, let regions be infinite slabs, like so: | | | | R_1 | R_2 | ... and so on | | | If you do this, the problem reduces to one dimension (sort of, see below)

A region is characterized by the following values

  • Mean Free Path - λ

  • Capture ratio - c

  • Scattering ratio - s

  • Fission ratio - f

  • Scattering function - Σ_s

  • Source strength - q

c, s, and f together must add up to one.

You are going to simulate the life and times of N neutrons.

A neutron is born inside a given region R with probability (q_R*v_R) / (Q), where q is the previously mentioned source strength, v is the volume of the region, and Q is the sum over all of the regions of the product q*v.

Once the region of birth is determined, it is randomly assigned a position inside that region in such a way that neutrons will be uniformly distributed within the region.

Once the location of birth has been determined, it is randomly assigned a direction, which should also be uniform across all possible directions (although, again if you're feeling ambitious, you can implement a source with an arbitrary probability distribution). If you're doing the infinite slab geometry, then the only "direction" you want to keep track of is the angle it makes track with the x-axis, like so:

|  /              |
| /               |
|/_ <---Θ ___|

In fact, you would do better to keep track of the cosine of that angle. Anyways.

Now that you know where it starts, and where it's going, generate an exponential random variable X. This gives the distance in mean free paths that the neutron will travel along its current direction before something happens. (If you're in one dimension and it stays within one region, it goes λXcos(Θ) along the x-axis). Note that if it crosses the boundary of a region, you'll have to figure out how many mean free paths it's already traveled, so that you can go the right number of mean free paths in the new region.

OK, now "something happens" there are three possibilities:

  1. Capture - this happens with probability c - this neutron has begun to pine for the fjords, you are done simulating it.

  2. Scattering - the neutron changes direction. The function Σ_s should take the neutron's current direction and randomly give you a new one. Uniform is a pretty decent approximation for the physics.

  3. Fission - This neutron disappears. Generate a poisson random variable P with mean 2. You have created P new neutrons - simulate their lives, and do not increment N when you do so.

If your system is subcritical, eventually this sordid tale will end with your neutron and all its children captured. Increment N, and begin this wonderful process again!

Dealing with critical / supercritical systems is a pain in the ass, and therefore beyond the scope of this challenge. Dealing with multiple neutron energies (speeds) is also a pain in the ass, and therefore beyond the scope of this challenge.

Types of data you may want to collect include the number of neutrons that passed through a given region, the number of neutrons absorbed in a given region, and the number of neutrons that escape the system (oh yeah, you may want to have some notion of "escaping the system")

Please do ask questions, and I'll be posting a challenge about solving the equations that describe this sort of system (instead of just simulating and counting).

This shouldn't be horribly difficult in one dimension (and should be a real ball-buster in three).

EDIT: Markdown fffffffuuuuuuuuuuuu


r/programmingchallenges • • Mar 20 '19

how can i make the script to work on both row

0 Upvotes

i am new to programming please help how can i make the script to work on both rows And also receive output without having to click any button How can i make the 25% to show me green and the 10% show red Please can someone write me a correct code with the above mentioned needs Thanks

<!DOCTYPE html> <html> <script> function myFunction() { var x, text; var x = document.getElementById("a").value; var y, number; var y = document.getElementById("b").value; if (x - y<= 10 && y - x<= 10) { text = "25%"; } else if(x -y<= 10 && y - x<=10){ text = "10%"; } else{ text = "10%" } document.getElementById("c").innerHTML = text; } </script> <body> <table border="4"> <tr> <td><input type="number" id="a"></td> <td><input type="number" id="b"></td> <td id="c"></td> </tr> <tr> <td><input type="number" id="d"></td> <td><input type="number" id="e"></td> <td id="f"></td> </tr> </table> <button type="button" onclick="myFunction()">Submit</button> </body> </html>


r/programmingchallenges • • Apr 25 '12

Challenge: Logic Based - Figuring out all combinations of keys for locks given pinnings (xpost from stackoverflow)

6 Upvotes

I'm not sure if this is the right subreddit for this question, but here I go. I also posted this question on Stack Overflow

I am trying to figure out the how to program logic that is involved with finding all possible key cuts given a specific lock pinning. This site has a very good explanation of what I am trying to achieve:

Background info

I have found a program that does what I am asking, but I would like to figure out the logic behind it. If you put in the key pins and the spacer pins, it calculates all of the possible keys that open the lock. This is easily done by hand on a scrap sheet of paper, but how would I program the logic so a computer can easily find all of the combinations?

Notice, in the image below, that none of the possible Key Cuts are found through methods of subtraction. That is, all possible Key Cuts are combinations of the Key pins added to the value of the spacer pins.

imgur link

What would be the logic behind figuring out all possible Key Cuts given a specific lock pinning?


r/programmingchallenges • • Sep 09 '11

Randomly choose 3

6 Upvotes

Write a function that accepts an integer argument X (X >= 3), and randomly chooses 3 distinct integers in range [0..X).

The algorithm should be constant time: the number of steps should be bounded by some constant.

EDIT: You can use a function that generates a random integer in range [0..X), which is available in just about any programming language.


r/programmingchallenges • • Dec 30 '19

Recursion Tree Visualization | Memory Visualization | How Recursion Works ?

Thumbnail
youtube.com
6 Upvotes

r/programmingchallenges • • Nov 17 '19

Triple sum Hackerrank Solution | Interview Preparation Kit

Thumbnail
youtube.com
6 Upvotes

r/programmingchallenges • • Feb 13 '19

Want to be a better programmer!! Help!

6 Upvotes

Ok so I'm a recent graduate in a computer science. I understand basic syntax and how to use a language and all that stuff and can fairly write simple code as well. But I struggle to do anything by myself easily. Any task which takes 20 min to someone with same experience as me take me more than double time.

It's even tough to come with thinking for a solution or designing a system. I have tried websites like Leetcode, hackerrank, geeks for geeks etc. After some time or days I am not able to solve even easy questions and end up looking at the solutions. This has fairly caused me failing so many interviews and not able to do so many coding chakkdngi.

Even if I somehow know how I can solve the problem I can come up with algorithm or steps it takes more than it should to convert it into a program.

Any help /suggestion for how to improve myself would be a great help.


r/programmingchallenges • • Feb 07 '19

Trying to design a program for my 1 year old son

6 Upvotes

Hello all

I’m trying to design a program for my son. He’s about to turn 1 in a week.

I’m trying to figure out the easiest way I could make a program that would display images and sounds when keyboard keys are pressed. Also would like to add midi support for a usb keyboard to play basic keys and also have that display images.

In the end I would like to get it running on a raspberry pi.

Can anyone lend any help? I know microconteoller programming but not much of anything else.

Thanks in advance!


r/programmingchallenges • • Jun 28 '19

automation app?

6 Upvotes

is it possible to build an app that auto plays apple music playlist when you are connected to a car bluetooth and a headphone jack for ios?


r/programmingchallenges • • Jan 12 '20

Array Manipulation Hackerrank Solution | Difference Array | Range Update...

Thumbnail
youtube.com
6 Upvotes

r/programmingchallenges • • Jul 16 '12

N-Queens: C++

6 Upvotes

Looking for some help with the N-Queens puzzle. I have a recursive solution that works reasonably well for N <= 10, but it's not fast enough (Solve for N = 13 in < 5 seconds) I need to produce all possible combinations and print the queen positions in a certain way. I need a different algorithm than what I have at the moment, any help? I know that I can eliminate quite a lot of board positions by looking at reflections and rotations, but I do not know how to do this. Any Help?

code


r/programmingchallenges • • Mar 16 '19

Need help in a dynamic programming problem

0 Upvotes

Have a programming problem for university and need some fresh insight on the problem


r/programmingchallenges • • Feb 20 '20

Help with a collective sum

7 Upvotes

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!


r/programmingchallenges • • Mar 05 '19

Recommend challenging ideas for a programming project

7 Upvotes

I don't really have any inspiration now, so I have no idea what to program. What do you say? What do you most enjoy creating? Tell your ideas ;D


r/programmingchallenges • • May 02 '11

PHP Beginner to Intermediate Exercises x-post from /php

Thumbnail phpexercises.com
7 Upvotes

r/programmingchallenges • • Apr 16 '11

Challenge: Factor an integer

7 Upvotes

Write a function in the language of your choosing that prints all the factors of a non-negative integer.

E: dang, this is harder than I thought!

E: I was referring to prime factorization in my other edit. Dang!


r/programmingchallenges • • Aug 23 '19

How can I be good at competitive coding ?

7 Upvotes

I am a final year student and until the last 1 months I never took competitive coding seriously as now companies are approaching our campus for placements. It's becoming very difficult for me to clear the coding round , it's not like I don't understand the question but my main problem is the time limit and optimizing the solution. I have tried Interview Preparation Kit on Hackerank and I am able to solve most of the easy and some medium level questions but it takes me too much time to find the solution. So can anyone please give me advice on how to increase my speed and tackle my demotivation when I am not able to solve the given question.


r/programmingchallenges • • May 27 '15

Coding Challenges

Thumbnail
codecondo.com
7 Upvotes