Skip to content

Commit 27a47fb

Browse files
JakubDotPygithub-actions[bot]
authored andcommitted
Automated update
1 parent e9c2711 commit 27a47fb

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

output/invert_values.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
"""Kata - Invert values
2+
3+
completed at: 2024-09-14 15:23:07
4+
by: Jakub Červinka
5+
6+
Given a set of numbers, return the additive inverse of each. Each positive becomes negatives, and the negatives become positives.
7+
8+
```
9+
[1, 2, 3, 4, 5] --> [-1, -2, -3, -4, -5]
10+
[1, -2, 3, -4, 5] --> [-1, 2, -3, 4, -5]
11+
[] --> []
12+
```
13+
14+
```if:javascript,python,ruby,php,elixir,dart,go,lua
15+
You can assume that all values are integers. Do not mutate the input array.
16+
```
17+
18+
```if:c,riscv
19+
### Notes:
20+
- All values are greater than `INT_MIN`
21+
- The input should be modified, not returned.
22+
```
23+
24+
~~~if:riscv
25+
RISC-V: The function signature is:
26+
27+
```c
28+
void invert(int *arr, size_t size);
29+
```
30+
31+
The input array is `arr` which contains `size` elements. Mutate the array in-place according to the above specification. You do not need to return anything.
32+
~~~
33+
34+
"""
35+
36+
def invert(lst):
37+
vysledek = []
38+
for cislo in lst:
39+
vysledek.append(-cislo)
40+
return vysledek

0 commit comments

Comments
 (0)