Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:00,420 --> 00:00:06,030
All right, it's time to have some fun with some arrays so we have a 2D array of zeros or a matrix of
2
00:00:06,030 --> 00:00:06,930
zeros, if you will.
3
00:00:07,400 --> 00:00:09,600
And we want each column to count up a number.
4
00:00:09,720 --> 00:00:12,660
So zero zero zero one one one two two two.
5
00:00:16,280 --> 00:00:20,390
Since this is a debugging exercise, I'm assuming there's something wrong with the code, so let's run
6
00:00:20,390 --> 00:00:21,350
it and see what's wrong.
7
00:00:30,060 --> 00:00:35,790
And it crashes all right now, as always, line by line, we're going to figure out what's causing the
8
00:00:35,790 --> 00:00:39,080
crash as well as the inevitable bugs that come with it.
9
00:01:04,400 --> 00:01:06,080
OK, so I started to zero.
10
00:01:10,100 --> 00:01:13,260
And as the inner loop runs, I increases instead of J.
11
00:01:13,490 --> 00:01:14,700
Well, that's kind of silly.
12
00:01:15,050 --> 00:01:17,840
This is just going to run forever, eventually hitting three.
13
00:01:17,870 --> 00:01:19,850
This array doesn't have an index of three.
14
00:01:19,850 --> 00:01:22,100
So it's Crash's Index at about.
15
00:01:23,700 --> 00:01:24,690
OK, let's fix that.
16
00:01:29,040 --> 00:01:29,670
Run the code.
17
00:01:35,820 --> 00:01:39,870
OK, another crash index, minus one out of bounds, why is that?
18
00:01:43,530 --> 00:01:45,050
OK, I start at zero.
19
00:01:45,100 --> 00:01:46,170
Everything's fine.
20
00:01:48,020 --> 00:01:49,460
But now is negative one.
21
00:01:50,760 --> 00:01:54,660
It doesn't make sense to decrease the counter by one, I don't know why this person would do that.
22
00:01:59,260 --> 00:02:00,130
Let's run the code.
23
00:02:04,830 --> 00:02:05,980
OK, we're close.
24
00:02:06,000 --> 00:02:09,960
Instead of each column counting up a number, each row is counting up a number.
25
00:02:11,910 --> 00:02:13,320
Hmmm, how do we fix that?
26
00:02:15,030 --> 00:02:16,170
Let me trace the runtime.
27
00:02:25,060 --> 00:02:26,050
There should be zero.
28
00:02:28,610 --> 00:02:30,290
All right, I still zero.
29
00:02:34,130 --> 00:02:40,160
And the next zero should go to the index one zero, but instead it's going to go to the index is zero
30
00:02:40,160 --> 00:02:42,500
one because I zero energy is one.
31
00:02:42,740 --> 00:02:44,120
But if we flip them.
32
00:02:46,810 --> 00:02:50,140
Now, the next zero is going to update the index, one zero.
33
00:02:53,800 --> 00:02:55,510
And I believe that should solve everything.
34
00:02:55,990 --> 00:02:57,370
All right, let's rerun the code.
35
00:03:06,460 --> 00:03:08,800
Perfect, every column counts up a number.
2866
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.