Skip to content

Commit bf86b7c

Browse files
committed
polishing v1
1 parent 2b1d62e commit bf86b7c

29 files changed

+233
-8
lines changed

Harder/Generate-Sentences.md

+5
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,8 @@ It's simple...Just run three for loops for three lists you have, each one under
2626
Damn easy, isn't it?
2727

2828

29+
 
30+
[![Next Page](assets/next-button.png)](..README.md)
31+
 
32+
33+
###### tags: `programmig-hero` `python` `float` `int` `math`

Harder/Password-generator.md

+7
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,10 @@ print('Your new password: ', new_password)
4949
The solution is rather simple. We imported the random module and the string module. Then we created a long string by joining all ascii_letters, digits and special characters.
5050

5151
For that, we ran a for loop. In the loop, we select a random letter from the all_chars. To select a random character, we used random.choice. Then we add the random character to the password.
52+
53+
54+
 
55+
[![Next Page](assets/next-button.png)](Password-with-requirements.md)
56+
 
57+
58+
###### tags: `programmig-hero` `python` `float` `int` `math`

Harder/Password-with-requirements.md

+6
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,9 @@ Make sense?
5353

5454
Keep going. Only a few more left. I am sure you can do it
5555

56+
57+
 
58+
[![Next Page](assets/next-button.png)](Permutations.md)
59+
 
60+
61+
###### tags: `programmig-hero` `python` `float` `int` `math`

Harder/Permutations.md

+8-1
Original file line numberDiff line numberDiff line change
@@ -89,4 +89,11 @@ That’s why we put current in a list as well so that it becomes a list as well.
8989

9090
This will create [3, 2, 1]. That’s why we did [current] + p to make the final permutation.
9191

92-
This code is harder. It will take a few practices to become comfortable with it.
92+
This code is harder. It will take a few practices to become comfortable with it.
93+
94+
95+
 
96+
[![Next Page](assets/next-button.png)](Generate-Sentences.md)
97+
 
98+
99+
###### tags: `programmig-hero` `python` `float` `int` `math`

Harder/Simple-Calculator.md

+5
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,8 @@ Then we have if-elif-else. And based on the operation, we call the right method
6363
That’s it.
6464

6565

66+
 
67+
[![Next Page](assets/next-button.png)](Password-generator.md)
68+
 
69+
70+
###### tags: `programmig-hero` `python` `float` `int` `math`

Medium/Armstrong-number.md

+7
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,10 @@ return result
7878
```
7979

8080

81+
 
82+
[![Next Page](../assets/next-button.png)](Greatest-common-divisor.md)
83+
 
84+
85+
###### tags: `programmig-hero` `python` `float` `int` `math`
86+
87+

Medium/Check-palindrome.md

+7
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,10 @@ The problem might sound complicated at the beginning. However, if you know the t
3636

3737
So, the more you explore, the more you try, the more shortcut trick you will master.
3838

39+
40+
 
41+
[![Next Page](../assets/next-button.png)](Dictionary-of-cubes.md)
42+
 
43+
44+
###### tags: `programmig-hero` `python` `float` `int` `math`
45+

Medium/Dictionary-of-cubes.md

+6
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,10 @@ print('Your sum of cubes are: ', sum)
4848
## Take Away
4949
Sum of a series might have an easier formula.
5050

51+
 
52+
[![Next Page](../assets/next-button.png)](Armstrong-number.md)
53+
 
54+
55+
###### tags: `programmig-hero` `python` `float` `int` `math`
56+
5157

Medium/Greatest-common-divisor.md

+11-1
Original file line numberDiff line numberDiff line change
@@ -69,4 +69,14 @@ b = int(input("Enter second number:"))
6969

7070
gcd = math.gcd(a,b)
7171
print(gcd)
72-
```
72+
```
73+
74+
75+
76+
 
77+
[![Next Page](../assets/next-button.png)](Least-Common-Multiple.md)
78+
 
79+
80+
###### tags: `programmig-hero` `python` `float` `int` `math`
81+
82+

Medium/Least-Common-Multiple.md

+9
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,12 @@ In the while loop, if we can not divide the lcm by the first number or the secon
4444
That's it.
4545

4646
It's actually much easier than it seems.
47+
48+
49+
50+
 
51+
[![Next Page](../assets/next-button.png)](README.md)
52+
 
53+
54+
###### tags: `programmig-hero` `python` `float` `int` `math`
55+

Prime-number/Check-Prime.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ There are other solutions to this problem as well. We encourage you to google,
5656
A prime number is only divisible by 1 and the number itself.
5757

5858
 
59-
[![Next Page](../assets/next-button.png)](..README.md)
59+
[![Next Page](../assets/next-button.png)](Prime-Numbers.md)
6060
 
6161

6262
###### tags: `programmig-hero` `python` `float` `int` `math`

Prime-number/Prime-Factors.md

+5
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,8 @@ print(factors)
4242
## take Away
4343
Prime factor is a prime number that divides the provided number.
4444

45+
 
46+
[![Next Page](../assets/next-button.png)](Smallest-prime- factor.md)
47+
 
48+
49+
###### tags: `programmig-hero` `python` `float` `int` `math`

Prime-number/Prime-Numbers.md

+6
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,9 @@ Inside the loop, call the is_prime function and check the return. If the return
4141
Then return the primes list.
4242

4343
That’s it.
44+
45+
 
46+
[![Next Page](../assets/next-button.png)](Prime-Factors.md)
47+
 
48+
49+
###### tags: `programmig-hero` `python` `float` `int` `math`

Prime-number/Smallest-prime- factor.md

+7
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,10 @@ print('The smallest prime factor is: ', smallest_factor)
2525
Since we need only one factor. We can do it more easily.
2626

2727
Just run a while loop. The condition of the loop is checking the remainder. If there is no remainder, the number got divided and you got the prime factor. If the remainder is not 0, then increase the factor by one.
28+
29+
30+
 
31+
[![Next Page](../assets/next-button.png)](..READMD.md)
32+
 
33+
34+
###### tags: `programmig-hero` `python` `float` `int` `math`

Reverse/Reverse-Number.md

+6
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,9 @@ Finally, set the new value of the num by dividing by 10.
5353

5454
That’s it.
5555

56+
 
57+
[![Next Page](../assets/next-button.png)](Reverse-word.md)
58+
 
59+
60+
###### tags: `programmig-hero` `python` `float` `int` `math`
61+

Reverse/Reverse-String-(recursive).md

+7
Original file line numberDiff line numberDiff line change
@@ -93,3 +93,10 @@ How would you slide a string and get the first five characters?
9393
You can slice a string to get a part of the string.
9494

9595

96+
97+
 
98+
[![Next Page](../assets/next-button.png)](Reverse-Number.md)
99+
 
100+
101+
###### tags: `programmig-hero` `python` `float` `int` `math`
102+

Reverse/Reverse-String-(stack).md

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# 8.2 Reverse a string (stack)
2+
3+
## The Problem
4+
Reverse a string using a stack.
5+
6+
## Hint
7+
This is a little fancier way to reverse the string. However, this will help you understand one concept called stack.
8+
9+
If you are not familiar with the stack. Don’t worry. We have it covered in the Data Structure galaxy.
10+
11+
For now, just remember, you have to use .pop() method to get the last element of the list.
12+
13+
## Solution
14+
```python
15+
def reverse_stack(str):
16+
# Create an empty stack (list to use as stack)
17+
stack = []
18+
# Push all characters of string to stack
19+
for char in str:
20+
stack.append(char)
21+
# Pop all characters of string
22+
# and add it to the rev
23+
rev = ''
24+
while len(stack) > 0:
25+
last = stack.pop()
26+
rev = rev + last
27+
# print(last, rev)
28+
29+
return rev
30+
usr_str = input('What is your string:')
31+
reverse = reverse_stack(usr_str)
32+
print('Reversed is: ', reverse)
33+
```
34+
35+
**[Try it on Programming Hero](https://play.google.com/store/apps/details?id=com.learnprogramming.codecamp)**
36+
37+
## Explanation
38+
In the function, we declared a list named stack. And then we loop through the input string and put every character of the string inside the list.
39+
40+
Then we have an empty string.
41+
42+
Later we ran a while loop. Inside the while loop, we used the .pop() method to get the last element of the list.
43+
44+
Then we added the last element to the reverse string.
45+
46+
The overall idea is very simple, take the last element and add keep adding it.
47+
48+
Hence, the last element will come first and you will put it in the first position. And then, in the next iteration, the second to the last element will be coming and will get added.
49+
50+
If needed, add a print command to see how it works.
51+
52+
 
53+
[![Next Page](../assets/next-button.png)](Reverse-String-(recursive).md)
54+
 
55+
56+
###### tags: `programmig-hero` `python` `float` `int` `math`
57+

Reverse/Reverse-String.md

+6
Original file line numberDiff line numberDiff line change
@@ -116,3 +116,9 @@ Will you be able to append, remove or set a character to string by the index?
116116
## take Away
117117
A string is an immutable ordered sequence.
118118

119+
120+
 
121+
[![Next Page](../assets/next-button.png)](Reverse-String-(stack).md)
122+
 
123+
124+
###### tags: `programmig-hero` `python` `float` `int` `math`

Reverse/Reverse-word.md

+8
Original file line numberDiff line numberDiff line change
@@ -109,3 +109,11 @@ print(rev)
109109
## take Away
110110
The split method breaks string into elements of a list.
111111

112+
113+
114+
 
115+
[![Next Page](../assets/next-button.png)](..README.md)
116+
 
117+
118+
###### tags: `programmig-hero` `python` `float` `int` `math`
119+

Simple-Game/Cows-and-bulls(4digits).md

+5
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,8 @@ However, solving this one by using if-else that we did for 2 digit bulls and cow
5656
That's why we created the get_bulls_cows function. Inside that, we created a loop. For each digit, check the digit in the same place.
5757

5858

59+
 
60+
[![Next Page](assets/next-button.png)](Word-completion.md)
61+
 
62+
63+
###### tags: `programmig-hero` `python` `float` `int` `math`

Simple-Game/Cows-and-bulls.md

+7
Original file line numberDiff line numberDiff line change
@@ -90,3 +90,10 @@ In summary, bulls are guessed digit matches for the same position in the secret
9090
Then we display the bulls and cows.
9191

9292
Finally, if there is no remaining try (remaining try < 1), print that user lost.
93+
94+
95+
&nbsp;
96+
[![Next Page](assets/next-button.png)](Cows-and-bulls(4digits).md)
97+
&nbsp;
98+
99+
###### tags: `programmig-hero` `python` `float` `int` `math`

Simple-Game/Guess-game.md

+7
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,10 @@ After that, we use the int to convert the user input to an integer number. We di
6565
That’s why we put the int after the check for q.
6666

6767
The bottom part of the code should be easier for you.
68+
69+
70+
&nbsp;
71+
[![Next Page](assets/next-button.png)](Rock-paper-scissor.md)
72+
&nbsp;
73+
74+
###### tags: `programmig-hero` `python` `float` `int` `math`

Simple-Game/Rock-paper-scissor.md

+8
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,11 @@ We repeated this two more times. And checked whether the first player entered pa
5252
Now think for 5 minutes, is there any different way you could have written the if-else logic here.
5353

5454
If you find a way, add a question here so that everyone can see your code.
55+
56+
57+
58+
&nbsp;
59+
[![Next Page](assets/next-button.png)](Cows-and-bulls.md)
60+
&nbsp;
61+
62+
###### tags: `programmig-hero` `python` `float` `int` `math`

Simple-Game/Word-completion.md

+5
Original file line numberDiff line numberDiff line change
@@ -101,3 +101,8 @@ The answer is: 3
101101
```
102102

103103

104+
&nbsp;
105+
[![Next Page](assets/next-button.png)](Word-hangman.md)
106+
&nbsp;
107+
108+
###### tags: `programmig-hero` `python` `float` `int` `math`

Simple-Game/Word-hangman.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,10 @@ Reading other’s code and trying to understand will be a common activity for a
6262

6363
So, practice it here.
6464

65-
If you don't understand any line, feel free to ask us a question.
65+
If you don't understand any line, feel free to ask us a question.
66+
67+
&nbsp;
68+
[![Next Page](assets/next-button.png)](..README.md)
69+
&nbsp;
70+
71+
###### tags: `programmig-hero` `python` `float` `int` `math`

Solution-Strategy.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ There is just one way to become good at problem-solving - Just solve more proble
4141
Keep solving more problems.
4242

4343
&nbsp;
44-
[![Next Page](assets/next-button.png)](README.md)
44+
[![Next Page](assets/next-button.png)](Prime-Numbers.md)
4545
&nbsp;
4646

4747
###### tags: `programmig-hero` `python` `float` `int` `math`

User-Submitted/Birthday-remaining.md

+7
Original file line numberDiff line numberDiff line change
@@ -88,3 +88,10 @@ At last, we calculate the difference.
8888
That’s a pretty simple way to get the days remaining for your next birthday.
8989

9090
Isn’t it cool?
91+
92+
93+
&nbsp;
94+
[![Next Page](assets/next-button.png)](Calculate-age.md)
95+
&nbsp;
96+
97+
###### tags: `programmig-hero` `python` `float` `int` `math`

User-Submitted/Calculate-age.md

+8
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,11 @@ print("Your age: ", age)
4343
You used the datetime earlier. And then, calculated the days between the birth date and today’s date.
4444

4545
Then, divide the days by 365 to get the age!
46+
47+
48+
49+
&nbsp;
50+
[![Next Page](assets/next-button.png)](README.md)
51+
&nbsp;
52+
53+
###### tags: `programmig-hero` `python` `float` `int` `math`

User-Submitted/Simple-Clock.md

+4-3
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,8 @@ Similarly, if the minute becomes 60, we add 1 hour and set minutes to 0, because
125125
Finally, if the hour is 24, we reset the hour to 0. Because, in a digital clock, there are no 24 or 25 hours. After 23 hours, it becomes 0 hours again (the midnight!)
126126

127127

128+
&nbsp;
129+
[![Next Page](assets/next-button.png)](Birthday-remaining.md)
130+
&nbsp;
128131

129-
130-
131-
132+
###### tags: `programmig-hero` `python` `float` `int` `math`

0 commit comments

Comments
 (0)