Skip to content
This repository was archived by the owner on Dec 1, 2021. It is now read-only.
Original file line number Diff line number Diff line change
@@ -1 +1,104 @@
trash
# Description

Welcome to this week's rebooted challenges. While this challenge is very simple at its core (which I think gives it an Easy rating), it gives me a chance to teach a bit of physics while I'm at it, so I may as well!
Newton's Law of Universal Gravitation says that:
Any two objects in the universe attract **each other** gravitationally...
With a force that's proportional to the product of their masses, and...
Inversely proportional to the square of the distance between them. (distance is measured from the center of the object - so if you're standing on Earth, you are about 6353 km away from it.
Because this is only a proportionality (not an equality), you will need a constant multiplier - this is called G, the gravitational constant.
This gives us the remarkably simple formula:
```
mass of first object × mass of second object
force = G × --------------------------------------------
(distance between objects)²
```
This force is applied on both objects equally and in opposite directions, toward each other. The value of G is currently known to be about **6.67e-11** which is why gravity is so weak - you can overcome the force of the entire planet just by jumping!
These 4 simple rules were used to describe gravity in nearly its entirety before Albert Einstein found out it was incomplete and discovered Special and General relativity - which you won't need today! Anyway, this is the only bit of physics you'll need for today's challenge - the rest is basic maths.

We're going to assume all planets are perfect spheres. This means you can find the volume of a planet, given its radius, with the fomula `V = 4/3 × π × radius³` like a normal sphere. We'll also assume they are made of a material which has the exact same density everywhere - so a handful of material from one bit of the planet weighs the same as any other. This means, given a density (in kilograms per cubic metre), and using the volume you worked out, you can compute the mass of the planet with the formula `mass = volume × density`. Assume the units you are using are kilograms and metres. Sorry, imperial folk!

Now, in case you are new to physics, you may need to know a little bit about forces. Forces are measured in Newtons (N) and measure, essentially, how hard an object is pushing another object. The object could be pushing physically - eg. pushing a lawn mower - or via an elementary force, such as Earth's gravity pushing you toward it. They can all be measured in Newtons. The force of a planet on something due to gravity is called weight - which is not to be confused with [mass](https://en.wikipedia.org/wiki/Mass), which is measured in kilograms and is a measure of how much matter something contains. As we saw before, the more mass two objects have, the greater the force they exert on each other. As gravitational force is dependent on the product of the masses of both objects, an object will weigh more if either the object itself, or the planet, is heavier - which is why you weigh less on the Moon!

Anyway, after that lengthy backstory, the challenge for you today is, given the dimensions of several planets and an object's mass, calculate how much force is applied on the object at the surface of the planet. Pretend the object is quite small for simplicity of your caluclations.

This is certainly a lot of physics to get your teeth into, so if you need any help, leave a comment and either I or someone else should be happy to help you out.

## Input Description

You will be given a number M which is the mass of an object in kilograms, on its own line, for example:
```
100
```

Followed by a number N:
```
4
```

You will then, on separate lines, be given a list of N planets. This will be given as its name, its radius (in metres), and its average density (in kilograms per cubic metre), like so:
```
Mercury, 2439700, 5427
```

## Output Description

Print the weight (in Newtons) of the object if it were at the surface of each planet, like so:
```
Mercury: 314.623
```

#Example Inputs and Outputs

## Example Input
```
100
4
Tantalus, 3104500, 5009
Reach, 7636500, 4966
Circumstance, 4127000, 4132
Tribute, 2818000, 4358
```
## Example output
```
Tantalus: 434.467
Reach: 1059.536
Circumstance: 476.441
Tribute: 343.117
```
# Challenge

## Challenge Input

```
75
9
Mercury, 2439700, 5427
Venus, 6051900, 5243
Earth, 6367445, 5515
Mars, 3386000, 3934
Jupiter, 69173000, 1326
Saturn, 57316000, 687
Uranus, 25266000, 1270
Neptune, 24553000, 1638
Pluto, 1173000, 2050
```

## Expected Challenge Output

```
Mercury: 277.442
Venus: 664.886
Earth: 735.845
Mars: 279.124
Jupiter: 1922.011
Saturn: 825.103
Uranus: 672.382
Neptune: 842.741
Pluto: 50.388
```

(These values are all very nearly exact!)

# Notes

You have a chance to utilise some OOP here. If your programming language supports it, you may want to create a *Planet* object.
Original file line number Diff line number Diff line change
@@ -1 +1,59 @@
trash
#Description

**Standard deviation** is one of the most basic measurments in statistics. For some collection of values (known as a "population" in statistics), it measures how dispersed those values are. If the standard deviation is high, it means that the values in the population are very spread out; if it's low, it means that the values are tightly clustered around the mean value.
For today's challenge, you will get a list of numbers as input which will serve as your statistical population, and you are then going to calculate the standard deviation of that population. There are statistical packages for many programming languages that can do this for you, but you are highly encouraged not to use them: the spirit of today's challenge is to implement the standard deviation function yourself.
The following steps describe how to calculate standard deviation for a collection of numbers. For this example, we will use the following values:
```
5 6 11 13 19 20 25 26 28 37
```

1. First, calculate the average (or **mean**) of all your values, which is defined as the sum of all the values divided by the total number of values in the population. For our example, the sum of the values is 190 and since there are 10 different values, the mean value is 190/10 = 19
2. Next, for each value in the population, calculate the difference between it and the mean value, and square that difference. So, in our example, the first value is 5 and the mean 19, so you calculate (5 - 19)2 which is equal to 196. For the second value (which is 6), you calculate (6 - 19)2 which is equal to 169, and so on.
3. Calculate the sum of all the values from the previous step. For our example, it will be equal to 196 + 169 + 64 + ... = 956.
4. Divide that sum by the number of values in your population. The result is known as the variance of the population, and is equal to the square of the standard deviation. For our example, the number of values in the population is 10, so the **variance** is equal to 956/10 = 95.6.
5. Finally, to get standard deviation, take the square root of the variance. For our example, sqrt(95.6) ≈ 9.7775.

# Formal inputs & outputs

## Input
The input will consist of a single line of numbers separated by spaces. The numbers will all be positive integers.

## Output
Your output should consist of a single line with the standard deviation rounded off to at most 4 digits after the decimal point.

# Sample inputs & outputs

## Sample 1
### Input
```
5 6 11 13 19 20 25 26 28 37
```
### Output
```
9.7775
```

## Sample 2
### Input
```
37 81 86 91 97 108 109 112 112 114 115 117 121 123 141
```
### Output
```
23.2908
```

# Challenge Inputs
## Input 1
```
266 344 375 399 409 433 436 440 449 476 502 504 530 584 587
```
## Input 2
```
809 816 833 849 851 961 976 1009 1069 1125 1161 1172 1178 1187 1208 1215 1229 1241 1260 1373
```

# Notes

For you statistics nerds out there, note that this is the population standard deviation, not the sample standard deviation. We are, after all, given the entire population and not just a sample.
If you have a suggestion for a future problem, head on over to [/r/dailyprogrammer_ideas](https://www.reddit.com/r/dailyprogrammer_ideas) and let us know about it!
Original file line number Diff line number Diff line change
@@ -1 +1,51 @@
trash
# [](#BonusIcon) _(Bonus)_: Erdos Number Calculator

In honor of the 102nd birthday of the famous mathematician, a problem named after him.

## Description

Paul Erdős (1913–1996) was an influential mathematician who spent a large portion of his later life writing papers with a large number of colleagues, working on solutions to outstanding mathematical problems. The idea of the Erdős number was originally created by the mathematician's friends as a tribute to his enormous output. However, in later years it gained prominence as a tool to study how mathematicians cooperate to find answers to unsolved problems.
The Erdös number describes the "collaborative distance" between mathematician Paul Erdős and another person, as measured by authorship of mathematical papers. Erdös himself has a number of 0, anyone he co-authored a paper with has a number of 1, anyone they co-authored a paper with (without Erdös) has a number of 2, and so forth.
Several studies have shown that leading mathematicians tend to have particularly low Erdős numbers. For example, only 134,007 mathematicians have an Erdős number, with a median value of 5. In contrast, the median Erdős number of Fields Medalists is 3. Only 7,097 (about 5%) of mathematicians with a collaboration path have an Erdős number of 2 or less.
For this challenge you'll be working with a small, toy database of Erdős and related publications and be asked to calculate the Erdős number for several authors.

## Input Description

You'll be given 2 integers on the first line, N and M. N is the number of of papers in APA format showing authors, titles, journals, and the like; think of it as a mini database. M is the number of authors to identify the Erdős number for. Note that all of the names should be in the same format of last name, then first and middle initials.

## Output Description

Your program should emit the name of the mathematician and their Erdős number.

# Sample Inputs and Outputs

## Sample Input

7 4
Thomassen, C., Erdös, P., Alavi, Y., Malde, P. J., & Schwenk, A. J. (1989). Tight bounds on the chromatic sum of a connected graph. Journal of Graph Theory, 13(3), 353-357.
Burr, S., Erdös, P., Faudree, R. J., Rousseau, C. C., & Schelp, R. H. (1988). Some complete bipartite graph—tree Ramsey numbers. Annals of Discrete Mathematics, 41, 79-89.
Burris, A. C., & Schelp, R. H. (1997). Vertex-distinguishing proper edge-colorings. Journal of graph theory, 26(2), 73-82.
Balister, P. N., Gyo˝ ri, E., Lehel, J., & Schelp, R. H. (2007). Adjacent vertex distinguishing edge-colorings. SIAM Journal on Discrete Mathematics, 21(1), 237-250.
Erdös, P., & Tenenbaum, G. (1989). Sur les fonctions arithmétiques liées aux diviseurs consécutifs. Journal of Number Theory, 31(3), 285-311.
Hildebrand, A., & Tenenbaum, G. (1993). Integers without large prime factors. Journal de théorie des nombres de Bordeaux, 5(2), 411-484.
Balister, P. N., Riordan, O. M., & Schelp, R. H. (2003). Vertex‐distinguishing edge colorings of graphs. Journal of graph theory, 42(2), 95-109.
Schelp, R. H.
Burris, A. C.
Riordan, O. M.
Balister, P. N.

## Sample Output

Schelp, R. H. 1
Burris, A. C. 2
Riordan, O. M. 2
Balister, P. N. 2

# Notes

This challenge is a shameless rip off of [*this*](http://www.programming-challenges.com/pg.php?page=downloadproblem&format=html&probid=110206). It was too good to pass up; I did, however, compile my own challenge inputs and outputs.
A full list of Erdös publications is up [*here*](http://www.renyi.hu/~p_erdos/Erdos.html).

# Finally

Got any cool challenge ideas? Submit them to /r/DailyProgrammer_Ideas!
6 changes: 5 additions & 1 deletion Hard Challenges/Challenge #0050 [Hard]/challenge_text.md
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
trash
# Description

T9 Spelling: The Latin alphabet contains 26 characters and telephones only have ten digits on the keypad. We would like to make it easier to write a message to your friend using a sequence of keypresses to indicate the desired characters. The letters are mapped onto the digits as 2=ABC, 3=DEF, 4=GHI, 5=JKL, 6=MNO, 7=PQRS, 8=TUV, 9=WXYZ. To insert the character B for instance, the program would press 22. In order to insert two characters in sequence from the same key, the user must pause before pressing the key a second time. The space character should be printed to indicate a pause. For example “2 2″ indicates AA whereas “22″ indicates B. Each message will consist of only lowercase characters a-z and space characters. Pressing zero emits a space. For instance, the message “hi” is encoded as “44 444″, “yes” is encoded as “999337777″, “foo bar” (note two spaces) is encoded as “333666 6660022 2777″, and “hello world” is encoded as “4433555 555666096667775553″.

This challenge has been taken from [Google Code Jam Qualification Round Africa 2010](http://code.google.com/codejam/contest/dashboard?c=351101#s=p2) ... Please use the link for clarifications. Thank You
Original file line number Diff line number Diff line change
@@ -1 +1,26 @@
trash
#Description

The moderators of [/r/DailyProgrammer](https://www.reddit.com/r/DailyProgrammer) give out medals (either gold or silver) as community rewards / community achievements. Though everyone has the two medal icons next to their names, the actual amount you have are reflected as two integers (gold first, then silver). The side-bar to the right has a section titled "Achievements System", which describes how medals are earned.

The problem though is that mods have to use the sub-Reddit's administration page to add the basic flair to a user and to change the medal count in any way. Though not hard, it certainly isn't a simple process, so we would like your help in building a better solution!

Your goal is to write a single web-page in JavasScript that "wraps" these admin features together in a nice single form. Essentially it should be a page with **minimal server-side code** or **you can ditch the idea of a page and just make a browser add-on (Chrome or FireFox please)**, when given Reddit login credentials, allows:

- Loading a user's flair string and type
- Saving a user's flair string and type
- Allowing a one-click +1 Gold and +1 Silver for any given Reddit username
- Load a user's [/r/DailyProgrammer](https://www.reddit.com/r/DailyProgrammer) post history for any given Reddit username

Reddit provides an external API interface for these purposes: [learn more about the web-based API here](http://www.reddit.com/dev/api).

**Though this will be a typical [hard] level challenge, we will be giving out a gold medal and Reddit gold (3 months) for the person who gives a fully-featured solution. Note that solutions must be open-source (hey, we want to use your system!) and you will be given full credits to it in our sub-Reddit's side-bar. Starting from today (Friday), all solutions are due in exactly 7 days: the competition ends at 11:55pm, American pacific time, UTC−8. It'll take about day to confirm who wins.**

To help get started, check out these Reddit JavaScript APIs: (note that none are a "perfect" solution, and some heavy work will be required)

- [Official Reddit API](http://www.reddit.com/dev/api)
- [Handson Reddit](https://github.com/timisbusy/handson-reddit)
- [Reddit JS Client](https://github.com/tommyvyo/reddit-js-client)

This is quite a big challenge to take on, so I'll be much more involved with responding to questions and comments. Good luck, and have fun!

**Edit 1**: Our awesome user [Skeeto](http://www.reddit.com/r/dailyprogrammer/comments/1dk7c7/05213_challenge_121_hard_medal_management/c9r4obj) has pointed out that a pure client-side implementation is not possible for security reasons; my bad! I've updated the rules to allow minimal server-side code or the choice of just making all of this a browser add-on.
Loading