Update data.jsonl
Browse files- data.jsonl +41 -1
data.jsonl
CHANGED
|
@@ -492,4 +492,44 @@
|
|
| 492 |
|
| 493 |
{"messages":[{"role":"user","content":"Show me how to convert list to dictionary in Python using index."},{"role":"assistant","content":"{i: v for i, v in enumerate(my_list)}"}]}
|
| 494 |
|
| 495 |
-
{"messages":[{"role":"user","content":"I need a Java example for sorting an array in descending order."},{"role":"assistant","content":"Arrays.sort(arr, Collections.reverseOrder());"}]}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 492 |
|
| 493 |
{"messages":[{"role":"user","content":"Show me how to convert list to dictionary in Python using index."},{"role":"assistant","content":"{i: v for i, v in enumerate(my_list)}"}]}
|
| 494 |
|
| 495 |
+
{"messages":[{"role":"user","content":"I need a Java example for sorting an array in descending order."},{"role":"assistant","content":"Arrays.sort(arr, Collections.reverseOrder());"}]}
|
| 496 |
+
|
| 497 |
+
{"messages":[{"role":"user","content":"Check if a number is prime in Python"},{"role":"assistant","content":"To determine whether a number is prime, we test divisibility from 2 up to the square root of the number. If any divisor works, the number is not prime.\n\n```python\ndef is_prime(n):\n if n < 2:\n return False\n for i in range(2, int(n**0.5) + 1):\n if n % i == 0:\n return False\n return True\n```\n\nThis function efficiently reduces checks using the √n optimization."}]}
|
| 498 |
+
|
| 499 |
+
{"messages":[{"role":"user","content":"Debounce a function in JavaScript"},{"role":"assistant","content":"Debouncing ensures a function only runs after a pause in activity, useful for input fields or resize events.\n\n```javascript\nfunction debounce(fn, delay) {\n let timer;\n return function(...args) {\n clearTimeout(timer);\n timer = setTimeout(() => fn.apply(this, args), delay);\n };\n}\n```\n\nThis prevents repeated rapid execution and improves performance."}]}
|
| 500 |
+
|
| 501 |
+
{"messages":[{"role":"user","content":"Check if a slice contains a value in Go"},{"role":"assistant","content":"To search for a value in a Go slice, we iterate through each element until we find a match.\n\n```go\nfunc contains(arr []int, val int) bool {\n for _, v := range arr {\n if v == val {\n return true\n }\n }\n return false\n}\n```\n\nThis returns true immediately once the value is found."}]}
|
| 502 |
+
|
| 503 |
+
{"messages":[{"role":"user","content":"Write a factorial function in Rust"},{"role":"assistant","content":"A factorial multiplies a number by all integers below it. In Rust, recursion makes this concise.\n\n```rust\nfn factorial(n: u64) -> u64 {\n if n == 0 { return 1; }\n n * factorial(n - 1)\n}\n```\n\nThis function calls itself until it reaches the base case."}]}
|
| 504 |
+
|
| 505 |
+
{"messages":[{"role":"user","content":"Implement factorial in C++"},{"role":"assistant","content":"Factorial in C++ can be implemented recursively by multiplying the number with the factorial of the previous number.\n\n```cpp\nint factorial(int n) {\n if (n == 0) return 1;\n return n * factorial(n - 1);\n}\n```\n\nThis continues until n reaches zero."}]}
|
| 506 |
+
|
| 507 |
+
{"messages":[{"role":"user","content":"Generate Fibonacci numbers in Python"},{"role":"assistant","content":"The Fibonacci sequence builds each number from the sum of the previous two. Iteration is a simple way to generate it.\n\n```python\ndef fib(n):\n a, b = 0, 1\n for _ in range(n):\n print(a)\n a, b = b, a + b\n```\n\nEach step shifts the pair forward in the sequence."}]}
|
| 508 |
+
|
| 509 |
+
{"messages":[{"role":"user","content":"Factorial example in Java"},{"role":"assistant","content":"Factorial computation in Java uses recursion similarly to other languages, reducing the problem step by step.\n\n```java\nint factorial(int n) {\n if (n == 0) return 1;\n return n * factorial(n - 1);\n}\n```\n\nThe recursion ends at zero, returning the accumulated result."}]}
|
| 510 |
+
|
| 511 |
+
{"messages":[{"role":"user","content":"Check even number in JavaScript"},{"role":"assistant","content":"To check if a number is even, we use the modulo operator to see if there is no remainder when dividing by 2.\n\n```javascript\nconst isEven = n => n % 2 === 0;\n```\n\nIf true, the number is evenly divisible by 2."}]}
|
| 512 |
+
|
| 513 |
+
{"messages":[{"role":"user","content":"Merge two Python lists"},{"role":"assistant","content":"Merging lists in Python is straightforward using the plus operator, which concatenates them.\n\n```python\nmerged = list1 + list2\n```\n\nThis creates a new combined list without modifying the originals."}]}
|
| 514 |
+
|
| 515 |
+
{"messages":[{"role":"user","content":"Find duplicate emails in SQL"},{"role":"assistant","content":"To detect duplicates in a database column, we group by the field and filter groups with more than one occurrence.\n\n```sql\nSELECT email, COUNT(*) FROM users GROUP BY email HAVING COUNT(*) > 1;\n```\n\nThis helps identify repeated email entries."}]}
|
| 516 |
+
|
| 517 |
+
{"messages":[{"role":"user","content":"Recursive factorial in C#"},{"role":"assistant","content":"C# supports recursion for factorial calculations by calling the same method repeatedly until the base case.\n\n```csharp\nint Factorial(int n) {\n if (n == 0) return 1;\n return n * Factorial(n - 1);\n}\n```\n\nEach call reduces the value until completion."}]}
|
| 518 |
+
|
| 519 |
+
{"messages":[{"role":"user","content":"Factorial in Go language"},{"role":"assistant","content":"In Go, factorial is commonly implemented recursively for simplicity and clarity.\n\n```go\nfunc factorial(n int) int {\n if n == 0 {\n return 1\n }\n return n * factorial(n - 1)\n}\n```\n\nThe function multiplies downward until zero is reached."}]}
|
| 520 |
+
|
| 521 |
+
{"messages":[{"role":"user","content":"Palindrome check in Python"},{"role":"assistant","content":"A palindrome reads the same forward and backward. Python slicing makes this easy to verify.\n\n```python\ndef is_palindrome(s):\n return s == s[::-1]\n```\n\nThe reversed string is compared directly to the original."}]}
|
| 522 |
+
|
| 523 |
+
{"messages":[{"role":"user","content":"Reverse palindrome checker in JavaScript"},{"role":"assistant","content":"To check for palindromes in JavaScript, we reverse the string and compare it to the original.\n\n```javascript\nconst isPalindrome = s => s === s.split('').reverse().join('');\n```\n\nIf both match, the string is symmetrical."}]}
|
| 524 |
+
|
| 525 |
+
{"messages":[{"role":"user","content":"Even number check in Rust"},{"role":"assistant","content":"Rust uses the modulo operator to determine if a number is even by checking divisibility by 2.\n\n```rust\nfn is_even(n: i32) -> bool {\n n % 2 == 0\n}\n```\n\nA zero remainder indicates an even value."}]}
|
| 526 |
+
|
| 527 |
+
{"messages":[{"role":"user","content":"Prime check in C++"},{"role":"assistant","content":"Prime checking in C++ involves testing divisibility up to the square root of the number.\n\n```cpp\nbool isPrime(int n) {\n if (n < 2) return false;\n for (int i = 2; i * i <= n; i++) {\n if (n % i == 0) return false;\n }\n return true;\n}\n```\n\nThis efficiently eliminates non-prime candidates."}]}
|
| 528 |
+
|
| 529 |
+
{"messages":[{"role":"user","content":"Maximum of three numbers in Python"},{"role":"assistant","content":"Finding the maximum value among multiple numbers can be done using Python's built-in max function.\n\n```python\nmax(a, b, c)\n```\n\nIt returns the largest value among the inputs."}]}
|
| 530 |
+
|
| 531 |
+
{"messages":[{"role":"user","content":"Palindrome in Java example"},{"role":"assistant","content":"In Java, we can check palindromes by reversing a string and comparing it to the original.\n\n```java\nboolean isPalindrome(String s) {\n return new StringBuilder(s).reverse().toString().equals(s);\n}\n```\n\nThis confirms whether the string reads identically in reverse."}]}
|
| 532 |
+
|
| 533 |
+
{"messages":[{"role":"user","content":"Reverse a string in Go"},{"role":"assistant","content":"Reversing strings in Go requires converting to a rune slice to properly handle Unicode characters.\n\n```go\nfunc reverse(s string) string {\n r := []rune(s)\n for i, j := 0, len(r)-1; i < j; i, j = i+1, j-1 {\n r[i], r[j] = r[j], r[i]\n }\n return string(r)\n}\n```\n\nThis safely reverses multi-byte characters."}]}
|
| 534 |
+
|
| 535 |
+
{"messages":[{"role":"user","content":"Get max salary from SQL table"},{"role":"assistant","content":"To retrieve the highest salary in a dataset, we use the MAX aggregate function.\n\n```sql\nSELECT MAX(salary) FROM employees;\n```\n\nThis returns the single largest salary value."}]}
|