All language subtitles for 6. Challenge 1 - Solution

af Afrikaans
ak Akan
sq Albanian
am Amharic
ar Arabic
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bem Bemba
bn Bengali
bh Bihari
bs Bosnian
br Breton
bg Bulgarian
km Cambodian
ca Catalan
chr Cherokee
ny Chichewa
zh-CN Chinese (Simplified)
zh-TW Chinese (Traditional)
co Corsican
hr Croatian
cs Czech
da Danish
nl Dutch
en English
eo Esperanto
et Estonian
ee Ewe
fo Faroese
tl Filipino
fi Finnish
fr French
fy Frisian
gaa Ga
gl Galician
ka Georgian
de German
el Greek
gn Guarani
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hu Hungarian Download
is Icelandic
ig Igbo
id Indonesian
ia Interlingua
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
rw Kinyarwanda
rn Kirundi
kg Kongo
ko Korean
kri Krio (Sierra Leone)
ku Kurdish
ckb Kurdish (Soranî)
ky Kyrgyz
lo Laothian
la Latin
lv Latvian
ln Lingala
lt Lithuanian
loz Lozi
lg Luganda
ach Luo
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mfe Mauritian Creole
mo Moldavian
mn Mongolian
sr-ME Montenegrin
ne Nepali
pcm Nigerian Pidgin
nso Northern Sotho
no Norwegian
nn Norwegian (Nynorsk)
oc Occitan
or Oriya
om Oromo
ps Pashto
fa Persian
pl Polish
pt-BR Portuguese (Brazil)
pt-PT Portuguese (Portugal)
pa Punjabi
qu Quechua
ro Romanian
rm Romansh
nyn Runyakitara
ru Russian
gd Scots Gaelic
sr Serbian
sh Serbo-Croatian
st Sesotho
tn Setswana
crs Seychellois Creole
sn Shona
sd Sindhi
si Sinhalese
sk Slovak
sl Slovenian
so Somali
es Spanish
es-419 Spanish (Latin American)
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
tt Tatar
te Telugu
th Thai
ti Tigrinya
to Tonga
lua Tshiluba
tum Tumbuka
tr Turkish
tk Turkmen
tw Twi
ug Uighur
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese
cy Welsh
wo Wolof
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu
Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated: 1 00:00:00,210 --> 00:00:06,360 So hearing this solution, there may actually be a couple of different solutions, and that's probably 2 00:00:06,360 --> 00:00:07,060 okay. 3 00:00:07,380 --> 00:00:09,960 If your solution is not exactly as mine. 4 00:00:10,080 --> 00:00:15,840 So if the program you've written works and you can see that for a different number as you provide, 5 00:00:16,190 --> 00:00:24,450 there are the same numbers of asterisks printed to the screen, then your program probably is correct. 6 00:00:24,510 --> 00:00:25,660 OK, it's. 7 00:00:25,780 --> 00:00:26,070 Don't. 8 00:00:26,130 --> 00:00:28,650 Don't be afraid if it's not the same as the program. 9 00:00:28,740 --> 00:00:30,390 I'm going to show you right now. 10 00:00:30,390 --> 00:00:32,490 I'm going to show you just one option. 11 00:00:32,640 --> 00:00:38,370 So in my option, we've, first of all, will create a variable that will hold the number of asterisks 12 00:00:38,460 --> 00:00:40,410 that need to be printed to the screen. 13 00:00:40,440 --> 00:00:41,450 So let's see. 14 00:00:41,450 --> 00:00:46,280 Is something like this int narm of asterisks. 15 00:00:46,480 --> 00:00:49,350 Ask the risks. 16 00:00:49,550 --> 00:00:50,780 Right, if I'm not mistaken. 17 00:00:50,910 --> 00:00:53,430 Then of course we need to use some input function. 18 00:00:53,430 --> 00:00:53,790 Right. 19 00:00:53,880 --> 00:00:56,090 To read from the user than that number. 20 00:00:56,430 --> 00:01:03,390 So we are going to print enter a number of asterisks. 21 00:01:03,420 --> 00:01:04,500 You would like to see. 22 00:01:04,610 --> 00:01:04,810 OK. 23 00:01:04,920 --> 00:01:05,800 Something like that. 24 00:01:05,850 --> 00:01:07,580 Would like to do. 25 00:01:07,600 --> 00:01:08,850 You would like to see. 26 00:01:09,180 --> 00:01:11,840 We would like to see semicolon at the end. 27 00:01:11,900 --> 00:01:20,220 And here we are going to use the scanning function and to read the value from the console and place 28 00:01:20,220 --> 00:01:23,460 it inside and put it inside these variable. 29 00:01:23,590 --> 00:01:28,950 And now at this point, you already have the number of asterisks that you have to print to the screen. 30 00:01:29,070 --> 00:01:35,400 So to accomplish our task, we are going to use our new body, the loop body, the while loop body. 31 00:01:35,490 --> 00:01:40,500 So simply write the wild statement while here's the parentheses. 32 00:01:40,600 --> 00:01:47,820 And in the parentheses, you specify the condition for when the loop is going to be executed. 33 00:01:47,850 --> 00:01:49,980 So none of asterisks. 34 00:01:50,130 --> 00:01:54,930 As long as normal fast risk is greater than the is then zero. 35 00:01:55,080 --> 00:02:00,180 There in this case, if this condition happens to be true, as long as this condition happens to be 36 00:02:00,180 --> 00:02:03,840 true, we are going to execute a bunch of commands. 37 00:02:03,930 --> 00:02:08,670 So the first command is, of course, the print an asterisk to the screen. 38 00:02:08,810 --> 00:02:09,090 Right. 39 00:02:09,150 --> 00:02:10,190 And that's how you do it. 40 00:02:10,320 --> 00:02:12,390 You printed out one asterisk. 41 00:02:12,510 --> 00:02:16,410 And if you're to run this program right now, actually, let's do it. 42 00:02:16,440 --> 00:02:18,270 But very, very carefully. 43 00:02:18,360 --> 00:02:22,700 If you're about to do it on your own in your home, make sure you're safe. 44 00:02:22,800 --> 00:02:23,190 All right. 45 00:02:23,220 --> 00:02:28,440 So let's build it or run it and let's place here right on all three, for example. 46 00:02:28,590 --> 00:02:31,080 Oh, and we got an infinite loop. 47 00:02:31,110 --> 00:02:33,690 So press control, see if you're using windows. 48 00:02:33,810 --> 00:02:37,710 And we got an infinite loop in this section. 49 00:02:37,830 --> 00:02:39,910 And that's not something that we wanted. 50 00:02:39,990 --> 00:02:40,230 Right. 51 00:02:40,260 --> 00:02:46,140 We want to now at some point to get out of this loop to make sure that this condition in the future 52 00:02:46,140 --> 00:02:53,250 wants seats printed out, all of the necessary asterisks to the screen that it will stop and it will 53 00:02:53,520 --> 00:02:54,930 move on to the next command. 54 00:02:54,960 --> 00:03:02,870 So for that, we are just going to reduce the value of these variables by this variable, by one at 55 00:03:02,870 --> 00:03:03,950 every iteration. 56 00:03:04,020 --> 00:03:08,610 So simply right now or fast risk equals to normal fast risks. 57 00:03:08,760 --> 00:03:09,780 Minus one. 58 00:03:10,110 --> 00:03:12,600 Or you may also use just something like that. 59 00:03:12,630 --> 00:03:14,310 I'm putting it in the comments here. 60 00:03:14,610 --> 00:03:15,520 Now I'm off ask. 61 00:03:15,600 --> 00:03:16,710 There are risks. 62 00:03:17,040 --> 00:03:17,940 Minus minus. 63 00:03:18,030 --> 00:03:25,470 And now on each duration we are going to decrease meant the value of normal fast risks by one. 64 00:03:25,560 --> 00:03:26,700 And we will do so. 65 00:03:26,730 --> 00:03:33,870 And we will do so until we reach zero, which means all the asterisks have been printed on the screen. 66 00:03:34,350 --> 00:03:35,200 And while I. 67 00:03:35,250 --> 00:03:36,750 Your program works. 68 00:03:37,110 --> 00:03:41,160 So let's try to build and run it once again and see what happens. 69 00:03:41,250 --> 00:03:43,080 So let's build and run it. 70 00:03:43,230 --> 00:03:44,820 There we have the message. 71 00:03:44,850 --> 00:03:46,380 Let's use three. 72 00:03:47,100 --> 00:03:49,290 So we have three asterisks. 73 00:03:49,890 --> 00:03:53,400 And also, if we are going to use here, I don't know, a hundred. 74 00:03:53,610 --> 00:03:54,170 Let's see. 75 00:03:54,300 --> 00:03:57,480 So that's probably going to be one hundred of asterisks. 76 00:03:57,600 --> 00:04:00,360 And one less thing to mention here. 77 00:04:00,360 --> 00:04:06,210 And we want to a little bit to separate these message from this default message printed out on the console 78 00:04:06,210 --> 00:04:06,840 application. 79 00:04:07,680 --> 00:04:11,790 So for that, we are going to use a basic Pring def command. 80 00:04:12,030 --> 00:04:19,050 Once we are out, once we are out of the while loop, we are going to use brute F and just print F a 81 00:04:19,060 --> 00:04:19,900 new line. 82 00:04:20,340 --> 00:04:24,390 After we are done printing out all the asterisks here. 83 00:04:24,510 --> 00:04:25,200 All right. 84 00:04:25,230 --> 00:04:25,980 Good, good, good. 85 00:04:26,010 --> 00:04:27,540 So that will work. 86 00:04:27,570 --> 00:04:32,130 And now let's quickly take a look at another solution which is also valid. 87 00:04:32,280 --> 00:04:36,250 Will first define some auxiliary variable and call it. 88 00:04:36,330 --> 00:04:37,200 Let's call it. 89 00:04:37,800 --> 00:04:38,610 I didn't. 90 00:04:38,700 --> 00:04:42,780 I just said it to be equals to zero. 91 00:04:42,970 --> 00:04:48,130 And now let's modify a little bit the while, the while condition. 92 00:04:48,750 --> 00:04:56,280 We are going to say that while I is less than narm of asterisks, because in this solution, in this 93 00:04:56,280 --> 00:04:59,910 example, which by the way, the previous one is valid and this one is a. 94 00:05:00,360 --> 00:05:05,640 Both of them are okay, but some of you may use the previous ones, some of you will use these one, 95 00:05:05,650 --> 00:05:08,700 I just want to show you another way to how it can be done. 96 00:05:08,790 --> 00:05:12,480 So in this case, we don't want to change these variable. 97 00:05:12,480 --> 00:05:17,340 We are just using some auxillary variable called eye that will help us with the solution. 98 00:05:17,430 --> 00:05:24,270 So as long as I is less than an arm of asterisk, we are going to print half an asterisk to the screen. 99 00:05:24,600 --> 00:05:26,100 And also, we are going. 100 00:05:26,280 --> 00:05:29,190 Of course, to increment I by one. 101 00:05:29,220 --> 00:05:36,100 So you either may use I equals two, I plus one or you can just use I plus plus. 102 00:05:36,420 --> 00:05:44,640 So I will increment on each iteration until it reaches out to be equal or greater than normal fast risks. 103 00:05:44,700 --> 00:05:50,850 And when it happens you just step out of the while loop and proceed with this command. 104 00:05:50,970 --> 00:05:53,000 So this is it for these video guys. 105 00:05:53,040 --> 00:05:54,330 Many you find out. 106 00:05:54,420 --> 00:06:00,000 Maybe you found out some other approach to how you can solve it using a while loop. 107 00:06:00,510 --> 00:06:03,780 So just make sure that you can see the expected result. 108 00:06:04,190 --> 00:06:08,250 And the result should be the same of what you see on the screen. 109 00:06:08,490 --> 00:06:08,760 Right. 110 00:06:09,060 --> 00:06:14,520 There are maybe different ways to solve it, but the result here in this example should be the same. 111 00:06:14,610 --> 00:06:15,750 So, as always, guys. 112 00:06:15,810 --> 00:06:17,160 Thank you so much for watching. 113 00:06:17,160 --> 00:06:18,480 And I'll see you in the next video. 9762

Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.