Download data/code_valid.txt from razz-123/disease_detection: direct link, hf CLI and curl.
- Browser
- Download file 1.73 kB
-
https://huggingface.co/razz-123/disease_detection/resolve/main/data/code_valid.txt
- Command line
-
hf download hf://razz-123/disease_detection/data/code_valid.txt
-
curl -L -o code_valid.txt https://huggingface.co/razz-123/disease_detection/resolve/main/data/code_valid.txt
1.73 kB
| def quicksort(arr): | |
| if len(arr) <= 1: | |
| return arr | |
| pivot = arr[len(arr)//2] | |
| left = [x for x in arr if x < pivot] | |
| middle = [x for x in arr if x == pivot] | |
| right = [x for x in arr if x > pivot] | |
| return quicksort(left) + middle + quicksort(right) | |
| class Animal: | |
| def __init__(self, name): | |
| self.name = name | |
| def speak(self): | |
| return f"{self.name} makes a sound" | |
| class Dog(Animal): | |
| def speak(self): | |
| return f"{self.name} barks" | |
| class Cat(Animal): | |
| def speak(self): | |
| return f"{self.name} meows" | |
| def parse_json(json_str): | |
| import json | |
| return json.loads(json_str) | |
| def to_json(obj): | |
| import json | |
| return json.dumps(obj) | |
| def read_csv(filepath): | |
| import csv | |
| with open(filepath, 'r') as f: | |
| reader = csv.reader(f) | |
| return list(reader) | |
| def write_csv(filepath, data): | |
| import csv | |
| with open(filepath, 'w', newline='') as f: | |
| writer = csv.writer(f) | |
| writer.writerows(data) | |
| class ListNode: | |
| def __init__(self, val=0, next=None): | |
| self.val = val | |
| self.next = next | |
| def reverse_linked_list(head): | |
| prev = None | |
| current = head | |
| while current: | |
| next_node = current.next | |
| current.next = prev | |
| prev = current | |
| current = next_node | |
| return prev | |
| def detect_cycle(head): | |
| slow = fast = head | |
| while fast and fast.next: | |
| slow = slow.next | |
| fast = fast.next.next | |
| if slow == fast: | |
| return True | |
| return False | |
| def find_middle(head): | |
| slow = fast = head | |
| while fast and fast.next: | |
| slow = slow.next | |
| fast = fast.next.next | |
| return slow | |