code_dataset / data.jsonl
ADHIZ's picture
Upload folder using huggingface_hub
8811d09 verified
Raw
History Blame Contribute Delete
751 Bytes
{"language":"python","prompt":"Write a Python function to reverse a string.","code":"def reverse_string(s):\n return s[::-1]","explanation":"This function uses slicing."}
{"language":"javascript","prompt":"Check if a number is prime.","code":"function isPrime(n) {\n for (let i = 2; i < n; i++) {\n if (n % i === 0) return false;\n }\n return n > 1;\n}","explanation":"This loops from 2 to n-1 to test divisibility."}
{"language":"java","prompt":"Binary search algorithm.","code":"int binarySearch(int[] arr, int target) {\n int l=0,r=arr.length-1;\n while(l<=r){ int m=(l+r)\/2; if(arr[m]==target)return m; else if(arr[m]<target)l=m+1; else r=m-1; }\n return -1;\n}","explanation":"This implements standard binary search logic in Java."}