WEBVTT 00:05.490 --> 00:06.210 Welcome back. 00:06.840 --> 00:11.690 Last time I was talking about how to seat the random generator using time, right. 00:12.510 --> 00:13.460 Let's check it out now. 00:15.910 --> 00:22.060 To see the random number generator, I need an integer number because a seed function expects an integer. 00:22.400 --> 00:26.050 OK, so how can I get the current time as an integer? 00:26.890 --> 00:28.650 It's a time value, not an integer. 00:28.750 --> 00:29.620 So how can I get it? 00:30.830 --> 00:35.540 OK, so if you go here, it will display the current time as a Unix time. 00:36.840 --> 00:41.340 By the way, if you don't know what a Unix time is, you may read more about it by checking out the 00:41.340 --> 00:42.000 resources. 00:42.530 --> 00:47.640 OK, as you can see here, Unix time is an integer, so I can use this one. 00:48.420 --> 00:50.910 So how can I get the current Unix time go. 00:53.220 --> 00:56.640 OK, let me go to the Goldman documentation. 00:57.840 --> 01:02.460 And if you go to the documentation of the time package, you can find the method that's returning the 01:02.460 --> 01:03.660 time as Unix time. 01:03.930 --> 01:04.560 Let me show you. 01:08.060 --> 01:08.720 Here it is. 01:09.860 --> 01:17.300 As you can see, it returns the time in seconds as an indicator for value, cool, I can use this hoer 01:17.480 --> 01:19.460 there is another interesting function here. 01:19.850 --> 01:25.640 You know, this one returns the unique time in nanoseconds instead of seconds. 01:26.120 --> 01:30.510 Huge difference since nanoseconds are changing much faster than seconds. 01:30.860 --> 01:33.110 So this will produce a better seat number. 01:33.890 --> 01:36.410 By the way, this is a method of the time type. 01:37.010 --> 01:39.560 We talk about this a lot of times before. 01:40.510 --> 01:46.960 So this means that I need to create a time value first, remember that I can create a time value by 01:46.960 --> 01:49.190 using the now function of the time package. 01:49.290 --> 01:49.570 Right. 01:53.410 --> 01:59.310 So in summary, it looks like this time now returns to current time is a timely. 02:00.270 --> 02:03.470 So I can call methods on that time, Mel. 02:04.350 --> 02:10.410 When I do that, the Eunuch's nanometre to return the current time is Unix time in nanoseconds and as 02:10.410 --> 02:10.950 an integer. 02:11.900 --> 02:18.500 Then I will use that Ever-changing Unix time number to see the round package so that each time I run 02:18.500 --> 02:20.690 the program, the seat number will change. 02:21.200 --> 02:26.960 And in turn when I call the INS and function, it will generate a random number depending on that seat 02:26.960 --> 02:27.350 number. 02:28.100 --> 02:34.100 So this means that the program will generate a different set of random numbers each time it runs coding 02:34.100 --> 02:35.690 time as usual. 02:37.090 --> 02:39.830 Now, let's apply this knowledge to our program. 02:40.180 --> 02:40.500 OK? 02:42.030 --> 02:47.970 First, I'm going to call the function to create a new time value by assigning it to the T variable. 02:49.870 --> 02:52.970 As you can see, this function returns a time value, right? 02:54.920 --> 02:58.340 So now I'm going to seed it with the current Unix time like this. 03:00.190 --> 03:06.310 That's unique now, cool, as you'll see in a second, that it will generate a different set of random 03:06.310 --> 03:08.230 numbers each time I ran the program. 03:09.240 --> 03:15.060 Now, let's try running the program a few times now, each time I run it, it produces a different set 03:15.060 --> 03:16.370 of random numbers, right? 03:17.590 --> 03:21.370 Cool randomly, it finds my guest number Justan. 03:22.830 --> 03:25.990 As soon as it finds it, it stops the loop immediately. 03:26.430 --> 03:30.780 So this program will be the best algorithm of the lucky number game that I'm going to show you. 03:32.230 --> 03:36.730 By the way, I can also move this time that Nakul from here. 03:39.160 --> 03:42.430 To hear so I don't need to use a variable for that. 03:44.020 --> 03:50.370 This works because here it calls the Unix nanometre on the time value that is returned from time that 03:50.380 --> 03:54.730 now whether you are using a variable or not makes no difference. 03:55.240 --> 03:57.660 But typing it like this looks better to me. 03:58.540 --> 04:05.380 OK, so for now, you learn how we can generate random numbers properly by using a seat number in the 04:05.380 --> 04:09.140 next lecture, I'm going to start building the actual economic program. 04:09.550 --> 04:10.140 See you there.