Download HumanEval_137/solution/_reference.py from PRHW/loom-benchmark-humaneval: direct link, hf CLI and curl.
- Browser
- Download file 723 Bytes
-
https://huggingface.co/datasets/PRHW/loom-benchmark-humaneval/resolve/main/HumanEval_137/solution/_reference.py
- Command line
-
hf download hf://datasets/PRHW/loom-benchmark-humaneval/HumanEval_137/solution/_reference.py
-
curl -L -o _reference.py https://huggingface.co/datasets/PRHW/loom-benchmark-humaneval/resolve/main/HumanEval_137/solution/_reference.py
723 Bytes
| def compare_one(a, b): | |
| """ | |
| Create a function that takes integers, floats, or strings representing | |
| real numbers, and returns the larger variable in its given variable type. | |
| Return None if the values are equal. | |
| Note: If a real number is represented as a string, the floating point might be . or , | |
| compare_one(1, 2.5) ➞ 2.5 | |
| compare_one(1, "2,3") ➞ "2,3" | |
| compare_one("5,1", "6") ➞ "6" | |
| compare_one("1", 1) ➞ None | |
| """ | |
| temp_a, temp_b = a, b | |
| if isinstance(temp_a, str): temp_a = temp_a.replace(',','.') | |
| if isinstance(temp_b, str): temp_b = temp_b.replace(',','.') | |
| if float(temp_a) == float(temp_b): return None | |
| return a if float(temp_a) > float(temp_b) else b | |