Skip to content

This repository is about the spontaneous problems that I encounter during my work and I try to find a solution for them! They can vary between very easy to hard problems!

Notifications You must be signed in to change notification settings

sepehr-mortaheb/spontaneous_problems

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Question 1: The best possible items distribution.

Q: Suppose we have N items. We want to divide these N between three groups. Two groups should get the same amount of items. How can we divide the items so that the difference between the number of items dedicated to each group is minimal? Idea: x + 2y = N

=> diff = |y - x| = |(N - 3x)/2|

=> If N is even, x also should be even to have a natural diff value. And if N is odd, x also should be odd to have a natural diff value.

= > Based on N, create the list of possible x values, calculate the diff values for each x, and then find the minimum of diff values. Then you can find the associated x and calculate the y value.

Question 2: Compound Interest Rate

Q: Suppose we have P0 dollars. We also have a saving account in a bank that proposes r% annual interest compounded every 1/n period in a year (for example, every month becomes 1/12). At the end of each period, we add P dollars to the account. After t years, how much money will we have? Idea: We can find the formula to find the final value by writing the value of our money step by step. We should consider that, at the end of each period, an interest of r/n is applied to our money. So:
0 --> P0
1 --> P0 + (r/n)P0 + P = (1+r/n)P0 + P
2 --> (1+r/n)P0 + P + (r/n)[(1+r/n)P0 + P] + P = (1+r/n)^2.P0 + [(1+r/n) + 1]P
3 --> (1+r/n)^2.P0 + [(1+r/n) + 1]P + (r/n)[(1+r/n)^2.P0 + [(1+r/n) + 1]P] + P = (1+r/n)^3.P0 + [(1+r/n)^2 + (1+r/n) + 1]P
.
.
.
nt --> ... = (1+r/n)^(nt).P0 + [(1+r/n)^(nt) + (1+r/n)^(nt - 1) + ... + (1+r/n)^2 + (1+r/n) + 1]P

So, we should write a code that calculates the final coefficients of P0 and P to calculate the final value!

Question 3: Mean Dwell Time

Q: Suppose we have a sequence of different states (shown by numbers). Calculate the mean time that the system stays in each specific state.

About

This repository is about the spontaneous problems that I encounter during my work and I try to find a solution for them! They can vary between very easy to hard problems!

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages