1
00:00:01,280 --> 00:00:03,200
Hey, guys, what's up?

2
00:00:03,800 --> 00:00:08,750
So today we are going to solve one more interesting pattern, printing problem.

3
00:00:09,830 --> 00:00:13,160
So write a program to print.

4
00:00:17,260 --> 00:00:18,210
Below baktun.

5
00:00:19,340 --> 00:00:21,920
So four and equals five.

6
00:00:21,950 --> 00:00:23,930
My pattern would look something like.

7
00:00:33,390 --> 00:00:33,600
OK.

8
00:00:33,690 --> 00:00:34,960
So four and equals five.

9
00:00:34,990 --> 00:00:37,060
I have to print this pattern.

10
00:00:37,990 --> 00:00:42,520
We have not solved this question before, so let us all discussion for the first time.

11
00:00:43,510 --> 00:00:51,370
So here the real fight is when I used to I used three, I use four and I use five.

12
00:00:52,060 --> 00:00:53,350
So one thing is very clear here.

13
00:00:53,470 --> 00:01:00,070
I need a loop that will run and times because you can see here the value of this fire if I am printing

14
00:01:00,070 --> 00:01:00,610
five rules.

15
00:01:00,700 --> 00:01:03,640
So I need a loop and this loop will run and times.

16
00:01:04,710 --> 00:01:07,410
Okay, now one more thing that we here.

17
00:01:07,880 --> 00:01:09,450
If the value of fire is too.

18
00:01:09,750 --> 00:01:12,960
I am beginning to lose the value of history.

19
00:01:13,230 --> 00:01:14,280
I am renting three.

20
00:01:14,280 --> 00:01:15,990
We're losing the value of I is four.

21
00:01:16,020 --> 00:01:18,120
I am renting for values and so on.

22
00:01:19,390 --> 00:01:25,750
OK, so one thing is very clear here, footprinting a year through for printing, a year through.

23
00:01:26,100 --> 00:01:27,780
I have to print a numbers.

24
00:01:30,470 --> 00:01:30,750
OK.

25
00:01:31,940 --> 00:01:41,530
So Androes for printing, I for printing, I drew through, I need I need to print eye numbers.

26
00:01:43,280 --> 00:01:46,830
One more thing here that we are, we have observed this.

27
00:01:47,540 --> 00:01:53,510
If I is even if I easy when I am starting from zero.

28
00:01:53,750 --> 00:01:59,150
So we can see if the value of AI is even the first number is zero of the value of AI is even the first

29
00:01:59,150 --> 00:02:00,140
number is zero.

30
00:02:01,070 --> 00:02:09,680
And if the value of AI is on, my first number is when, when and when, if the value of AI is odd.

31
00:02:12,110 --> 00:02:19,460
So if the value of AI is odd, I will start printing AI yetto from when, otherwise I will start printing

32
00:02:19,460 --> 00:02:25,070
from zero and I have to print AI numbers and each time I have to change the number.

33
00:02:25,520 --> 00:02:28,400
If I have print zero nine next time I will print one.

34
00:02:28,820 --> 00:02:30,050
Next time I will print zero.

35
00:02:30,170 --> 00:02:31,460
Next time I will print one.

36
00:02:31,790 --> 00:02:35,420
Similarly, if I have printed one, the next time I will print zero.

37
00:02:35,480 --> 00:02:37,010
The next time I will print one.

38
00:02:37,070 --> 00:02:38,690
The next time I will print zero.

39
00:02:39,110 --> 00:02:45,230
So basically they will be swiping between zero and one zero one zero one or one zero one zero.

40
00:02:47,760 --> 00:02:48,150
So.

41
00:02:49,920 --> 00:02:52,580
I equals one vial.

42
00:02:53,430 --> 00:02:59,070
I is less than articles to N and I C++.

43
00:02:59,550 --> 00:03:05,930
So this outer loop is for running the loop and times because we have to print Androes.

44
00:03:07,020 --> 00:03:12,740
Now I will check if I Yeah.

45
00:03:12,760 --> 00:03:19,160
Through is even if they throw on dividing by two gives a window zero that means I is even.

46
00:03:20,220 --> 00:03:22,620
So my first number is going to be zero.

47
00:03:22,980 --> 00:03:30,400
So when two equals zero else we can see my first value is going to be one.

48
00:03:31,380 --> 00:03:31,620
Okay.

49
00:03:31,680 --> 00:03:33,030
So this thing is clear.

50
00:03:33,510 --> 00:03:34,800
And now what we have to do.

51
00:03:35,940 --> 00:03:37,780
We have to print iron ambo's.

52
00:03:39,210 --> 00:03:41,580
We have to print eye numbers.

53
00:03:41,970 --> 00:03:50,970
So since we have to print eight numbers, we need a loop and this loop children eight times so and count

54
00:03:51,320 --> 00:03:52,860
equals one.

55
00:03:54,030 --> 00:03:58,890
While count is less than articles to a

56
00:04:02,790 --> 00:04:03,390
count.

57
00:04:03,910 --> 00:04:04,660
Plus, plus.

58
00:04:05,370 --> 00:04:08,970
And here I will friend my value.

59
00:04:10,770 --> 00:04:12,290
Now I have to change the value.

60
00:04:13,170 --> 00:04:18,180
So what I will do if the value that we have printed is one.

61
00:04:18,630 --> 00:04:20,160
Then make value zero.

62
00:04:20,400 --> 00:04:22,590
Because next time we have to print zero.

63
00:04:23,660 --> 00:04:32,570
Similarly elusive, the value that we have printed now is zero, then make value one, because next

64
00:04:32,570 --> 00:04:34,280
time we have to print one.

65
00:04:35,420 --> 00:04:41,420
So why I am doing this because we have to print alternate zeros and ones.

66
00:04:42,390 --> 00:04:45,110
Okay, so we have to print alternate zeros and ones.

67
00:04:45,410 --> 00:04:48,770
So that's why I am checking if the value that we have printed is one.

68
00:04:49,100 --> 00:04:52,370
Make it zero so that next time I will print zero.

69
00:04:52,760 --> 00:04:56,600
If the value that we have printed now is zero, then make it one.

70
00:04:57,140 --> 00:04:59,930
So that next time we will print one.

71
00:05:01,010 --> 00:05:01,540
Well, guess what?

72
00:05:01,650 --> 00:05:03,390
This is the entire logic.

73
00:05:04,440 --> 00:05:05,970
Now, let us write called.

74
00:05:09,130 --> 00:05:12,190
So let us name this file as.

75
00:05:15,530 --> 00:05:19,600
One zero baktun.

76
00:05:22,480 --> 00:05:22,760
OK.

77
00:05:38,860 --> 00:05:40,620
You know, the first thing that we have to do.

78
00:05:41,130 --> 00:05:46,170
I will take an as and put fundi user simple.

79
00:05:47,220 --> 00:05:54,810
Then I will need a loop that will run and times because I have to print and rose.

80
00:05:59,120 --> 00:06:01,520
Now, this loop will run and times.

81
00:06:02,330 --> 00:06:06,730
Now, first of all, we have to decide which way do we have to print first?

82
00:06:07,490 --> 00:06:18,160
Okay, so if the I yet rule is and even Drew, if the eighth row isn't even true, I will start my first

83
00:06:18,170 --> 00:06:21,170
value that I will print is going to be zero.

84
00:06:22,340 --> 00:06:30,800
Otherwise, as my first value today, I will print is one simple.

85
00:06:32,120 --> 00:06:33,890
So let us make

86
00:06:36,730 --> 00:06:38,910
our variable and will.

87
00:06:39,880 --> 00:06:40,190
Okay.

88
00:06:41,130 --> 00:06:42,200
So you can see here.

89
00:06:46,020 --> 00:06:53,580
So you can see here, if the value of I was too low, if I was even my first number was zero.

90
00:06:53,730 --> 00:06:56,940
If the value of I was offered, my first number was one.

91
00:06:57,390 --> 00:06:59,250
So I have initialized my value.

92
00:07:01,300 --> 00:07:04,210
So I've initialized to my value now what I have to do.

93
00:07:04,690 --> 00:07:12,100
I will run a loop, I Adames, because we have to print eye numbers, okay, because we have to print

94
00:07:12,120 --> 00:07:12,700
a numbers.

95
00:07:12,760 --> 00:07:15,280
So I need a loop that will run eight times.

96
00:07:18,160 --> 00:07:20,830
So let's make a variable and count.

97
00:07:23,650 --> 00:07:26,680
So we have to run the loop eight times.

98
00:07:26,830 --> 00:07:35,550
So count less than or equal to a count plus plus simple.

99
00:07:36,490 --> 00:07:41,770
And now here we have to print sea out value.

100
00:07:42,970 --> 00:07:44,320
But this is not enough.

101
00:07:45,010 --> 00:07:47,130
Where do we have to do after printing that value?

102
00:07:47,260 --> 00:07:49,860
If the value was one, we have to make it zero.

103
00:07:50,200 --> 00:07:52,930
If the value was zero, we have to make it when.

104
00:07:54,270 --> 00:07:54,560
OK.

105
00:07:54,820 --> 00:08:05,770
So if the value that we have printed is one where we have to do make it zero, value equals zero because

106
00:08:05,770 --> 00:08:10,210
we have to print alternate zeros and ones else.

107
00:08:10,220 --> 00:08:15,220
If check if the value net we have printed is zero.

108
00:08:16,960 --> 00:08:22,360
Then we have to make this value one because next time we have to print one.

109
00:08:23,770 --> 00:08:26,320
OK, so this is the end bad logic.

110
00:08:28,680 --> 00:08:30,350
Now, let us based our program.

111
00:08:33,240 --> 00:08:34,550
OK, over here, semicolon.

112
00:08:36,190 --> 00:08:38,100
Now let us test our program.

113
00:08:41,060 --> 00:08:43,010
Let's say, and there's three.

114
00:08:44,730 --> 00:08:46,290
OK, so what is the mistake here?

115
00:08:47,560 --> 00:08:50,270
So the mistake is very common after printing.

116
00:08:50,860 --> 00:08:57,450
So after printing the numbers, after printing one entire drawer, I have to go to next to do so see

117
00:08:57,460 --> 00:08:59,230
out and Lane.

118
00:09:00,190 --> 00:09:01,090
Now, this is correct.

119
00:09:02,530 --> 00:09:03,820
Let's say they're really off.

120
00:09:03,940 --> 00:09:04,870
And there's three.

121
00:09:07,150 --> 00:09:10,440
Again, with outproduce, correct, not a distaste.

122
00:09:10,520 --> 00:09:11,210
One more time.

123
00:09:11,990 --> 00:09:15,170
Let's say the value of an is five.

124
00:09:18,000 --> 00:09:18,870
So now four days.

125
00:09:19,470 --> 00:09:19,860
Correct.

126
00:09:20,370 --> 00:09:20,600
OK.

127
00:09:22,200 --> 00:09:23,880
Now, what you can do is.

128
00:09:25,220 --> 00:09:31,520
So instead of writing this, we can also write like this.

129
00:09:31,640 --> 00:09:34,280
So value equals.

130
00:09:34,470 --> 00:09:36,830
When my nose value.

131
00:09:39,070 --> 00:09:39,310
OK.

132
00:09:39,470 --> 00:09:44,780
So they both ask him this thing and this thing, they bought the same.

133
00:09:46,510 --> 00:09:47,260
Let me show you.

134
00:09:47,830 --> 00:09:54,520
So if the value of an is five, some output is correct.

135
00:09:55,450 --> 00:09:55,720
OK.

136
00:09:56,140 --> 00:09:57,340
So they both are the same.

137
00:09:57,610 --> 00:10:01,330
Now, why the you ask him now?

138
00:10:01,630 --> 00:10:02,860
This thing was obvious.

139
00:10:03,400 --> 00:10:04,450
This thing was obvious.

140
00:10:04,990 --> 00:10:10,390
So what it was doing, if the value is when it will make value equals zero.

141
00:10:10,780 --> 00:10:14,830
Similarly, if the value is zero, it will make value equals one.

142
00:10:15,340 --> 00:10:17,380
Now this line will also do the same book.

143
00:10:18,240 --> 00:10:18,440
OK.

144
00:10:18,550 --> 00:10:22,780
Suppose value equals one minus value.

145
00:10:24,370 --> 00:10:28,900
So first case, suppose the value is initially one.

146
00:10:29,710 --> 00:10:30,970
OK, so put one here.

147
00:10:31,480 --> 00:10:32,770
So one minus one zero.

148
00:10:33,010 --> 00:10:34,660
So new value will become two.

149
00:10:35,830 --> 00:10:37,540
Now suppose the value is initially zero.

150
00:10:37,620 --> 00:10:38,830
Now put zero here.

151
00:10:38,920 --> 00:10:40,630
So value equals one minus zero.

152
00:10:40,900 --> 00:10:42,880
So new value will become one.

153
00:10:43,300 --> 00:10:46,660
So you can see here it is also changing the values.

154
00:10:48,290 --> 00:10:51,970
Obviously, this line and this line, the bow tie.

155
00:10:52,500 --> 00:10:55,030
Same you can write any one of them.

156
00:10:57,780 --> 00:11:04,930
OK, so I recommended this out for the reference that this line and this line.

157
00:11:05,050 --> 00:11:06,720
They're both the same.

158
00:11:07,870 --> 00:11:08,110
OK.

159
00:11:08,920 --> 00:11:10,270
So this is it for this video.

160
00:11:10,450 --> 00:11:10,870
Thank you.
