-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdev-challenge-9.emojic
54 lines (39 loc) · 1.47 KB
/
dev-challenge-9.emojic
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
💭 This declares the start of the main code block
🏁 🍇
💭🔜
Closure that generates the array of random numbers
🔚💭
🍇➡️🍨🐚🔢🍆
💭 Create an empty list
🆕🍨🐚🔢🍆🐸❗️ ➡️ 🖍🆕 list
💭 Here we create a pseudo-random number generator
🆕🎰🆕❗️➡️ randomNumberGenerator
💭 List size will be a constant 1k..
🔂 i 🆕⏩⏭ 0 1000 1❗️🍇
💭 Construct a random number within 1-10k and append it to the list in O(1)
🔢 randomNumberGenerator 1 10000 ❗️➡️ rand
🐻 list rand ❗️
🍉
↩️ list
🍉 ➡️ generateList
💭🔜
Closure that generates the array of random numbers. Time efficiency > space efficiency in our case
🔚💭
🍇inputList🍨🐚🔢🍆 ➡️ 🍨🐚🔢🍆
💭 Create an empty list
🆕🍨🐚🔢🍆🐸❗️ ➡️ 🖍🆕 outputList
💭 For each element in the input list, if the element is odd (element%2 == 1), add it to the output list
🔂 element inputList 🍇
↪️ element 🚮 2 🙌 1 🍇
🐻 outputList element❗️
🍉
🍉
↩️ outputList
🍉 ➡️ removeEven
💭 Generate the odds only list
⁉️removeEven ⁉️generateList❗️❗️➡️ oddsList
💭 Print the results
🔂 element oddsList 🍇
😀 🔡 element 10❗️❗️
🍉
🍉 💭 This is the end of the main code block