|
1 | 1 |
|
2 |
| -# Pseudo-random generator |
| 2 | +# সুডো-র্যান্ডম জেনারেটর |
3 | 3 |
|
4 |
| -There are many areas where we need random data. |
| 4 | +এমন অনেক ক্ষেত্র আছে যেখানে আমাদের র্যান্ডম ডাটা জেনারেট করা লাগে। |
5 | 5 |
|
6 |
| -One of them is testing. We may need random data: text, numbers, etc. to test things out well. |
| 6 | +এর মধ্যে একটি হল টেস্টিং। টেস্ট করার জন্য আমাদের প্রয়োজন হতে পারে র্যান্ডম ডাটাঃ টেক্সট, নাম্বার ইত্যাদি। |
7 | 7 |
|
8 |
| -In JavaScript, we could use `Math.random()`. But if something goes wrong, we'd like to be able to repeat the test, using exactly the same data. |
| 8 | +জাভাস্ক্রিপ্টে আমরা `Math.random()` ব্যবহার করতে পারি। কিন্ত যদি আমরা কোন ভুল করে ফেলি এবং টেস্ট আবার একই ডাটা দিয়ে রিপিট করতে চাই। |
9 | 9 |
|
10 |
| -For that, so called "seeded pseudo-random generators" are used. They take a "seed", the first value, and then generate the next ones using a formula so that the same seed yields the same sequence, and hence the whole flow is easily reproducible. We only need to remember the seed to repeat it. |
| 10 | +এজন্য তথাকথিত "সীডেড সুডো-র্যান্ডম জেনারেটর" ব্যবহার করা হয়। এইগুলো প্রথম ভ্যালুতে একটি "সীড" নেয়, এবং তারপর একটি সূত্র ব্যবহার করে পরবর্তীটি জেনারেট করে যাতে করে একই সীড একই ক্রমধারা অনুযায়ী তৈরি করতে পারে, আর এতে করে পুরো প্রবাহটি খুব সহজে পুনরায় গঠন করা যায়। এর জন্য আমাদের কেবল কোন সীডটি পুনরায় করতে হবে সেটা মনে রাখলেই চলবে। |
11 | 11 |
|
12 |
| -An example of such formula, that generates somewhat uniformly distributed values: |
| 12 | +এ জাতীয় সূত্রের একটি উদাহরণ, যেটা কিনা কিছুটা সমানভাবে ডিস্ট্রিবিউটেড মান জেনারেট করেঃ |
13 | 13 |
|
14 | 14 | ```
|
15 | 15 | next = previous * 16807 % 2147483647
|
16 | 16 | ```
|
17 | 17 |
|
18 |
| -If we use `1` as the seed, the values will be: |
| 18 | +যদি আমরা সিড হিসেবে `1` ব্যবহার করি, মানগুলো হবেঃ |
19 | 19 | 1. `16807`
|
20 | 20 | 2. `282475249`
|
21 | 21 | 3. `1622650073`
|
22 |
| -4. ...and so on... |
| 22 | +4. ...এভাবে চলতে থাকবে... |
23 | 23 |
|
24 |
| -The task is to create a generator function `pseudoRandom(seed)` that takes `seed` and creates the generator with this formula. |
| 24 | +আপনার টাস্কটি হল একট জেনারেটর ফাংশন `pseudoRandom(seed)` তৈরি করুন যা একটি `seed` নেয় |
| 25 | +এবং জেনারেটরটি উপরের ফর্মুলা অনুযায়ী তৈরি করুন। |
25 | 26 |
|
26 |
| -Usage example: |
| 27 | +উদাহরণ: |
27 | 28 |
|
28 | 29 | ```js
|
29 | 30 | let generator = pseudoRandom(1);
|
|
0 commit comments