This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ | |
| Post Lookup — JSONPlaceholder API | |
| ==================================== | |
| API : https://jsonplaceholder.typicode.com (free, no key, never goes down) | |
| Endpoint: GET /posts/{id} — fetch a single post by ID (1 to 100) | |
| Clean JSON output (4 fields): | |
| { "status": 200, "post_id": int, "title": str, | |
| "body": str, "user_id": int } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def find_unique_pairs(arr, target): | |
| if not isinstance(target, (int, float)): | |
| raise TypeError(f"Target must be a numeric value, got {type(target).__name__!r}") | |
| if not isinstance(arr, (list, tuple, set)): | |
| raise TypeError(f"Input must be a valid list or array, got {type(arr).__name__!r}") | |
| clean_arr = [x for x in arr if isinstance(x, (int, float)) and not isinstance(x, bool)] | |
| if len(clean_arr) < 2: | |
| return [] | |
| seen = set() | |
| result_pairs = set() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ | |
| Rate Limiter — Event Log Deduplicator | |
| ====================================== | |
| For each userId, an event is ALLOWED only if the same user | |
| has not had an allowed event within the last `window` seconds. | |
| Comparison is always against the last ALLOWED event, not blocked ones. | |
| """ | |
| import warnings |