|
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 | +ამისათვის, "seeded pseudo-random გენერატორები" გამოიყენება. ისინი იღევენ "seed"-ს, პირველ მნიშვნელობას და დანარჩენებს აგენერირებენ ფორმულით, და შესაბამისად, იგივე "seed" ყოველ ჯერზე იმავე მიმდევრობას დააბრუნებს. ტესტის გასამეორებლად მხოლოდ "seed"-ის დამახსოვრებაა საჭირო. |
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`-ს როგორც "seed"-ს, მაშინ მნიშვნელობები იქნება: |
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 |
| -Usage example: |
| 26 | +გამოყენების მაგალითი: |
27 | 27 |
|
28 | 28 | ```js
|
29 | 29 | let generator = pseudoRandom(1);
|
|
0 commit comments