The Gauntlet | Think Like A Coder, Ep 8

392,598 views ・ 2020-04-16

TED-Ed


يرجى النقر نقرًا مزدوجًا فوق الترجمة الإنجليزية أدناه لتشغيل الفيديو.

المترجم: Maram Turkya المدقّق: omar idma
فكر كمرمز
الحلقة الثامنة بعنوان "التحد"
00:21
Their fall from the tower sends Ethic and Hedge
0
21734
3050
سقوط كلًا من إيثيك وهيدج من البرج
00:24
spinning into the rapids of a river of pure energy.
1
24784
4240
يرسلهما هائمين في سرعة نهر من الطاقة الصرفة.
00:30
This torrent flows from the Bradbarrier all the way to Huxenborg.
2
30944
5937
ينساب هذا التيار من برادبارير إلى هكسنبورج.
00:36
There an entire city’s worth of factories
3
36881
3100
حيث توجد مدينة كاملة من المصانع
00:39
build the robots and house the Node of Memory,
4
39981
3080
التي تصنع الرجال الآليين وتسكنها نقطة الذاكرة،
00:43
the last of the three powerful artifacts Ethic needs to collect.
5
43061
4372
اللوحة الثالثة والأخيرة من اللوحات الفنية ذات القوة التي تحتاج إيثك لجمعها.
00:47
After a long day and a longer night
6
47433
2510
بعد يوم طويل وليلة أطول
00:49
they find themselves in a canyon of brick and steel.
7
49943
3720
وجدا نفسيهما في وادي من الحجارة والمعدن.
00:58
Just when they’re about to reach the end of the line,
8
58918
2655
عندما كادا أن يصلا لنهاية الخط،
01:01
a rope catches them.
9
61573
1750
التُقطا بوساطة حبل.
01:07
Their savior, Lemma, has been waiting for them.
10
67023
4114
منقذتهما ليما، كانت بانتظارهما.
01:11
When Ethic claimed the Node of Creation from the forest tower,
11
71137
3952
عندما حصلت إيثيك على عقدة الإبداع من برج الغابة،
01:15
radios all across the land came back to life.
12
75089
3900
عادت محطات الراديو عبر الأراضي للعمل.
01:18
Adila, the resistance leader, immediately started contacting her allies,
13
78989
4776
أديلا، قائدة المقاومة، بدأت بالتواصل مع حلفائها،
01:23
none more important than Lemma,
14
83765
2610
ليس هنالك أهم من ليما،
01:26
a brilliant scientist working from within Huxenborg to bring down the machines.
15
86375
5893
ليما عالمة بارعة تعمل داخل هوكسينبورج للقضاء على الآليات.
01:32
Unfortunately, the radios also tipped off the robots.
16
92268
4000
لسوء الحظ، حذرت محطات الراديو الرجال الآليين أيضًا.
01:36
So they’ve taken defensive measures
17
96268
2260
لذلك قاموا باتخاذ إجراءات احترازية دفاعية
01:38
to protect the final artifact in its home in the very heart of the city.
18
98528
4828
لحماية اللوحة الفنية الأخيرة في مكانها في عمق قلب المدينة.
01:43
There’s only one way to get there: the gauntlet of forking paths.
19
103356
5155
هنالك طريق واحد للوصول إلى هناك: مسارات التحدي المتفرعة.
01:48
It’s a deadly series of luminous conveyors that wind underneath Huxenborg.
20
108511
6386
هو عبارة عن سلسلة قاتلة من الناقلات المنيرة المارة أسفل هوكسينبورج.
01:54
Starting from the current position,
21
114897
1820
تبدأ من الموقع الحالي،
01:56
each section runs for a distance, then splits in two.
22
116717
4395
حيث يسير كل جزء لمسافة معينة ثم يتفرع الطريق لمسارين.
02:01
Every branch does the same thing, again and again.
23
121112
3430
كل فرع يقوم بنفس الأمر مرارًا وتكرارًا.
02:04
There are thousands of branches.
24
124542
2400
هنالك الآلاف من الفروع.
02:06
Only one path leads to the artifact; all the others to destruction.
25
126942
5942
يقود طريق واحد فقط للوحة الفنية والباقون يقودون للدمار.
02:12
Fortunately, the Node of Creation has granted Hedge a strange power:
26
132884
4619
لحسن الحظ، منحت عقدة الإبداع هيدج قوة غريبة:
02:17
he can produce slightly smaller versions of himself.
27
137503
3720
يمكنه إنشاء نسخ مصغرة قليلًا عنه.
02:21
Each version can do only two things: radio information back to its parent,
28
141223
5210
يمكن لكل نسخة أن تقوم بشيئين فقط: نقل معلومات الراديو للنسخة الأم،
02:26
and produce slightly smaller versions of itself…
29
146433
3740
وإنشاء نسخ أصغر منها قليلًا...
02:30
which can do the same two things, as can their children,
30
150173
3690
والتي يمكنها أن تقوم بشيئين، كما يقوم بها أبناؤها،
02:33
for as many generations as needed.
31
153863
2940
على مدى الأجيال المحتاج إليها.
02:36
A patrol is closing in on their position, so Ethic’s time is limited.
32
156803
5051
تقترب دورية لموقعهم، لذلك لدى إيثيك وقت ضيق جدًا.
02:41
What instructions should she give Hedge to find the one safe path?
33
161854
5203
ما هي التعليمات الواجب عليها إعطاؤها لهيدج حتى يستطيع إيجاد الطريق الوحيد الآمن؟
02:47
Pause the video to figure it out yourself.
34
167057
6778
قم بإيقاف الفيديو لتستكشف ذلك بنفسك.
02:53
Hint in 3
35
173835
990
تلميح في ثلاثة
02:54
Hint in 2
36
174825
1200
تلميح في اثنين
02:56
Hint in 1
37
176025
960
تلميح في واحد
02:57
Programmers have an elegant tool in their arsenal called recursion.
38
177825
5162
يمتلك المبرمجون في ترسانتهم أداة أنيقة تدعى العودية.
03:02
Recursion is when you have a set of instructions that refers back to itself.
39
182987
5341
العودية هي أن تقوم بضبط مجموعة من التعليمات تقود لذاتها.
03:08
It’s like using a word in its own definition,
40
188328
2960
شيء شبيه باستخدام كلمة بتعريفها الخاص بها،
03:11
except where that’s frowned upon, this is incredibly effective.
41
191288
4560
هذا فعال جدًا، باستثناء إن كان مستهجنًا.
03:15
Recursion involves repetition, but in a different way than loops.
42
195848
4512
تتضمن العودية تكرارية، ولكن بشكل مختلف عن الحلقات.
03:20
Where a loop takes one action and repeats it again and again,
43
200360
4000
حيث تأخذ الحلقة فعل واحد وتكرره مرارًا وتكرارًا،
03:24
recursion will start an action, and before it’s finished, use it again,
44
204360
4302
تبدأ العودية فعل، وقبل أن ينتهي، تقوم باستخدامه مرةً أخرى.
03:28
and before that’s finished, use it again, and so on.
45
208662
4000
وقبل أن ينتهي هذا، تقوم باستخدامه مرةً أخرى، وهكذا دواليك.
03:32
It keeps doing this until some end state is reached.
46
212662
4000
تستمر بفعل ذلك حتى الوصول إلى حالة نهاية.
03:36
It then passes the information back up, layer after layer,
47
216662
4162
ثم تقوم بنقل المعلومات عودةً، طبقة تلو طبقة،
03:40
until it reaches the top and ends the cycle.
48
220824
3620
حتى تصل لقمة وتنهي الحلقة.
03:44
Recursion is ideal for problems that involve self-similarity,
49
224444
4662
تعتبر العودية مثالية لحل المشكلات التي تتضمن التشابه الذاتي،
03:49
where each part resembles the larger whole.
50
229106
2860
حيث يمثل كل جزء العمومية الأكبر.
03:51
Like, for example, a deadly defense system designed to end any person or thing
51
231966
6004
على سبيل المثال، نظام دفاع مميت مصمم على إنهاء حياة أي شخص أو شيء
03:57
who dares tread upon it.
52
237970
1890
يتجرأ لمواجهته.
03:59
Pause the video to figure it out yourself.
53
239860
2060
قم بإيقاف الفيديو لتستكشف ذلك بنفسك.
04:01
Solution in 3
54
241920
793
الحل في ثلاثة
04:02
Solution in 2
55
242713
920
الحل في اثنين
04:03
Solution in 1
56
243633
1080
الحل في واحد
04:04
Ethic’s conundrum seems sprawling on the surface,
57
244993
3041
يبدو لغز إيثيك مترامي الأطراف ظاهريًا،
04:08
but there’s a remarkably simple solution to it using recursion.
58
248034
4366
ولكن هنالك حل مثالي بسيط له باستخدام العودية.
04:12
In order to find it, let’s first look at the simplest version of this puzzle:
59
252400
4750
للمقدرة على إيجاده، لنلقي نظرة أولًا على النسخة البسيطة من اللغز:
04:17
what if the entire maze were just two paths?
60
257150
3270
ماذا أن كانت المتاهة عبارة عن طريقين فقط؟
04:20
If Hedge copies himself, the copy that goes the wrong way will be destroyed.
61
260420
4618
إذا نسخ هيدج نفسه، سيتم تدمير النسخة التي تسلك الطريق الخاطئ.
04:25
So the other one, which will reach the artifact,
62
265038
2719
إذًا النسخة الأخرى، التي ستصل للتحفة الفنية،
04:27
can radio back the path it took, and then no matter which way is correct,
63
267757
4700
يمكنها إرسال موجات راديوية رجوعًا للطريق الذي سلكته، وعندها مهما كان الطريق الصحيح،
04:32
that’s the answer Hedge will receive.
64
272457
2401
هذا هو الجواب الذي سيتلقاه هيدج.
04:34
This is called the "base case" of the recursion.
65
274858
3580
هذا يدعى "حالة القاعدة" للعودية.
04:38
Now, suppose the maze branches twice from the starting point,
66
278438
3340
الآن، افرض أن المتاهة تتفرع مرتين من نقطة البداية،
04:41
and at every intersection, Hedge’s copies—
67
281778
2982
وعند كل تقاطع ينسخ هيدج ...
04:44
let’s call them Twig 1 and Twig 2—
68
284760
2860
لندعوهم تويغ 1 وتويغ 2...
04:47
make more copies— let’s call them Leaves 1 through 4.
69
287620
5007
سيقومان بنسخ المزيد... لندعوهم الأوراق 1 حتى 4.
04:52
Three Leaves will be destroyed.
70
292627
3120
ستُدمر ثلاثة أوراق.
04:55
The one that reaches the artifact will radio back the right answer,
71
295747
4116
النسخة التي تصل للتحفة الفنية سترسل موجات راديوية بالإجابة الصحيحة،
04:59
but only to its parent.
72
299863
1980
ولكن فقط لنسختها الأم.
05:01
So if Twig 1 or 2 is waiting at an intersection
73
301843
3880
فلذك إن كان ينتظر كلًا من تويغ 1 أو 2 عند تقاطع
05:05
and hears something over the radio,
74
305723
1990
وسمعا شيئًا على الراديو،
05:07
that’s the right way to go to the artifact from where it is.
75
307713
3560
هذا هو الطريق الصحيح المؤدي للتحفة الفنية من مكان تواجدهما.
05:11
To tell Hedge the right answer from his perspective,
76
311273
3290
ليعلم هيدج الطريق الصحيح من وجهته،
05:14
the Twig should say which way it went,
77
314563
2440
يتوجب على التويغ أن يخبر أي اتجاه سلك،
05:17
and then the route it just heard over the radio.
78
317003
3600
ثم يُسمع الطريق حالًا عن طريق الراديو.
05:20
This same process will work no matter how many times the maze branches.
79
320603
4790
هذه الطريقة ذاتها ستعمل مهما كان عدد المرات التي ستتفرع بها المتاهة.
05:25
Any answer a copy hears on the radio
80
325393
2960
أي إجابة تسمعها النسخة على الراديو
05:28
must be the way to the control room from its location,
81
328353
3300
يجب أن تكون باتجاه غرفة التحكم من موقعها،
05:31
and if it then adds the branch it took,
82
331653
2350
ثم تقوم النسخة بإضافة الفرع الذي سلكته،
05:34
it can tell its parent how to get there as well.
83
334003
3220
ويمكنها إخبار النسخة الأم بكيفية الوصول لهنالك أيضًا.
05:37
We can sum up the instructions in an action called Pathfinder
84
337223
4000
يمكننا اختصار التعليمات بفعل يدعى إيجاد الطريق
05:41
that every version of Hedge will follow:
85
341223
3130
التي ستتبعها كل نسخة من هيدج:
05:44
1. If you’ve reached the artifact,
86
344353
2290
1. إذا وصلت للتحفة الفنية،
05:46
radio to your parent whether you got there by going left or right.
87
346643
4094
قم بإرسال كيفية وصولك لهنالك هل باتجاهك يمنةً أم يسرةً عبر الراديو للنسخة الأم.
05:50
2. When you reach an intersection, move off the conveyor
88
350737
3830
2. عندما تصل لتقاطع طرق ابتعد عن الحامل
05:54
and send new copies down the left and right paths.
89
354567
3980
وأرسل نسخ جديدة لتسلك الطرق اليمينية واليسارية.
05:58
Have them each run Pathfinder.
90
358547
2280
اجعل كلًا منهم يشغل برنامج إيجاد الطرق.
06:00
This is where recursion comes in,
91
360827
2040
هنا حيث تأتي العودية،
06:02
and this may happen many times before the last instruction triggers, which is:
92
362867
5094
وهذا من الممكن أن يحدث مراتٍ عدة قبل الوصول للتعليمة الأخيرة والتي هي:
06:07
3. If you hear anything over the radio, you should radio to your parent
93
367961
4987
3. إذا سمعت أي شيء عبر الراديو، يجب أن ترسله لنسختك الأم
06:12
whether you got to your spot by going left or right,
94
372948
3629
سواءً وصلت لموقعك بالاتجاه نحو اليمين أم اليسار،
06:16
then repeat everything you just heard.
95
376577
2850
ثم قم بتكرار كل ما سمعته.
06:19
Pathfinder is an example of what programmers call functions,
96
379427
3996
إن برنامج إيجاد الطريق عبارة عن مثال لما يدعوه المبرمجون بالمهام،
06:23
subroutines, or procedures.
97
383423
2690
أو الروتينات، أو إجراءات.
06:26
No matter the terminology, the idea is the same—
98
386113
3390
مهما كان المصطلح، الفكرة هي ذاتها...
06:29
it’s a set of instructions given a label so that it can be easily reused—
99
389503
4794
هي عبارة عن سلسلة من التعليمات تُعطى عنونة حيث يمكن إعادة استخدامها بسهولة...
06:34
perhaps even by itself.
100
394297
2310
حتى من المحتمل أن يتم ذلك لوحده.
06:36
And in our case that’ll work perfectly—
101
396607
2976
ويعمل هذا بشكلٍ ممتاز في حالتنا...
06:39
an entire network of paths mapped using just three instructions.
102
399583
5230
تم رسم شبكة من الطرق كاملةً باستخدام ثلاثة تعليمات فقط.
06:46
So here's what happens.
103
406257
1630
إذًا إليك ما حدث.
07:09
By the time the patrol rounds the corner, Ethic and Lemma have improvised disguises.
104
429760
5777
في الوقت الذي أصبحت فيه الدورية قريبة ابتكرت كلًا من إيثيك وليما تنكرًا.
07:15
They try to confuse the bots long enough to buy Hedge time.
105
435537
4120
حاولتا أن تشتتا انتباه الرجال الآليين لمدة كافية لإعطاء هيدج الوقت الذي يحتاجه.
07:31
Finally, Hedge’s radio crackles to life with a series of directions.
106
451473
4778
أخيرًا، عمل راديو هيدج ليستقبل سلسلة من التوجيهات.
07:36
The three dive onto the conveyor and flee for their lives,
107
456251
3850
قفز ثلاثتهم على الحامل ونجوا بحياتهم،
07:40
with a squadron of enforcer bots in hot pursuit.
108
460101
3720
بمطاردة شديدة مع سرب من الرجال الآليين المنفذين.
حول هذا الموقع

سيقدم لك هذا الموقع مقاطع فيديو YouTube المفيدة لتعلم اللغة الإنجليزية. سترى دروس اللغة الإنجليزية التي يتم تدريسها من قبل مدرسين من الدرجة الأولى من جميع أنحاء العالم. انقر نقرًا مزدوجًا فوق الترجمة الإنجليزية المعروضة على كل صفحة فيديو لتشغيل الفيديو من هناك. يتم تمرير الترجمات بالتزامن مع تشغيل الفيديو. إذا كان لديك أي تعليقات أو طلبات ، يرجى الاتصال بنا باستخدام نموذج الاتصال هذا.

https://forms.gle/WvT1wiN1qDtmnspy7