← 목록

Synth · CodeAlpaca일부

총 20,022개 · 페이지 574/668
🔀 랜덤
불러오는 중…

[output] | #!/bin/bash DIR=$1 result=$(find "$DIR" -name '*.gitconfig' | wc -l) if [ $result -gt 0 ] then echo "Found $result .gitconfig files in $DIR" else echo "No .gitconfig files found in $DIR" fi [instruction] | Create a bash script that takes a path argument and checks for pattern `.gitconfig`. [input] | /home/user/

[output] | <html> <head> <title>Table Data</title> </head> <body> <table> <thead> <tr> <th>Id</th> <th>First Name</th> <th>Last Name</th> <th>Age</th> </tr> [instruction] | Create an HTML page with a table containing the following data in four rows. [input] | Id | First Name | Last Name | Age 1 | John | Doe | 30 2 | Jane | Doe | 25 3 | Brian | Smith | 32 4 | Maria | Smith | 28

[output] | <?php if(isset($_POST['submit'])) { $text = $_POST['text']; echo $text; } ?> <form action="" method="POST"> <input type="text" name="text"/> <input type="submit" name="submit"/> </form> [instruction] | Write a PHP code to accept text from a text box and print it to the screen. [input] |

[output] | function findNonMatchingPos(str1, str2) { let positions = []; if(str1.length != str2.length) { return -1; //handle unequal lengths } for(let i = 0; i < str1.length; i++) { if(str1.charAt(i) !== str2.charAt(i)) { positions.push(i); } } return positions; } [instruction] | Create a JavaScript function that takes two strings of equal length and returns the positions of the characters which don't match. [input] | "abcdefg", "hijklmn"

[output] | #include <stdio.h> int compare_strings(char *str1, char *str2) { int count = 0; while (*str1 != '\0' && *str2 != '\0') { if (*str1 != *str2) count++; str1++; str2++; } return count; } int main() { char str1[100]; char str2[100]; i [instruction] | Write a C code to compare two strings letter-wise and print out the number of times they differ. [input] | "abc", "bcd"

[output] | The location of a person can be stored in a database in the form of a latitude and longitude pair, as a set of geographic coordinates or as a physical address. [instruction] | How would you store the location of a person in a database? [input] |

[output] | class List: def __init__(self): self.items = [] def append(self, item): if item not in self.items: self.items.append(item) def remove(self, item): try: self.items.remove(item) except ValueError: pass def remove_at_index(sel [instruction] | Suggest ways to improve the performance of the following list implementation. [input] | class List: def __init__(self): self.items = [] def append(self, item): self.items.append(item) def remove(self, item): self.items.remove(item)

[output] | function sum(a, b) { return a + b; } [instruction] | Write a function in Javascript that takes two numbers and combines them in order to calculate their sum. [input] |

[output] | We can traverse the linked list and keep track of the count of the visited nodes. For every node whose count is divisible by 3, we delete the node by adjusting the references of the preceding and succeeding nodes. [instruction] | How would you delete every third element of a given linked list? [input] |

[output] | <table> <tr> <th>Book</th> <th>Author</th> </tr> <tr> <td>The Great Gatsby</td> <td>F. Scott Fitzgerald</td> </tr> <tr> <td>The Catcher in the Rye</td> <td>J.D. Salinger</td> </tr> <tr> <td>To Kill a Mockingbird</td> <td>Harper Lee</td> </tr> </table [instruction] | Write an HTML table to show a list of 3 books and respective authors. [input] | Book 1: The Great Gatsby, Author: F. Scott Fitzgerald Book 2: The Catcher in the Rye, Author: J. D. Salinger Book 3: To Kill a Mockingbird, Author: Harper Lee

[output] | def determinant(matrix): a = matrix[0][0] b = matrix[0][1] c = matrix[1][0] d = matrix[1][1] return a*d - b*c [instruction] | Given a matrix, write a program that finds its determinant in Python. [input] | [[a, b],  [c, d]]

[output] | def combine(arr1, arr2): res = [] # Combine two arrays for i in range(len(arr1)): res.append(arr1[i] + arr2[i]) # Sort by grade in ascending order res.sort(key=lambda x: x[1]) # Sort by age in descending order res.sort(key=lambda x: x[2], reverse=True) return res [instruction] | Create a function to combine two arrays, sorting first by grade in ascending order, and then by age in descending order. [input] | Array 1: [['Tom', 10], ['Sam', 8], ['Bob', 8]] Array 2: [['Tom', 15], ['Sam', 12], ['Bob', 13]]

[output] | function arrayToString(arr, separator="|") { return arr.join(separator); } arrayToString(array1); // returns "1|2|3|4|5" [instruction] | Write a JavaScript function to convert an array to a string separated by key-pair value separator such as "|". [input] | const array1 = [1,2,3,4,5];

[output] | function combineArray(arr1, arr2) { let combined = []; let l = 0; let r = 0; while ((l < arr1.length) && (r < arr2.length)) { if (arr1[l] < arr2[r]) { combined.push(arr1[l]); l++; } else { combined.push(arr2[r]); r [instruction] | Combine two sorted Arrays into one sorted Array. [input] | arr1 = [1, 5, 8, 9, 10]; arr2 = [2, 3, 4, 6, 7];

[output] | public abstract class Shape { public abstract double surfaceArea(); } [instruction] | Write a Java class named "Shape" which has an abstract method named "surfaceArea". [input] |

[output] | db.shapes.find( { area: { $gte: 200, $lte: 500 } } ) [instruction] | Create a MongoDB query to find documents with a field value within a certain range. [input] | collectionName: shapes fieldName: area range: [200, 500]

[output] | fetch('https://api.example.com/getProducts', { method: 'GET', headers: { Authorization: `Bearer ${token}`, 'Content-Type': 'application/json' }, body: JSON.stringify(data) }).then(res=>res.json()) [instruction] | Make a call to the "getProducts" API Endpoint. [input] |

[output] | .rounded-box { border-radius: 8px; background-color: #f5f5f5; } [instruction] | Create a CSS class with border radius and a background colour. [input] |

[output] | db.customers.update( { name: "John Doe" }, { $set: { name: "John Doe" } } ) [instruction] | Update a MongoDB document such that it replace a specific field with a new value. [input] | db_name: "users" collection_name: "customers" field_name: "name" new_value: "John Doe"

[output] | def remove_chars(string): for char in "abc": string = string.replace(char, '') return string [instruction] | Write a Python code to remove the characters 'a', 'b', and 'c' from a given string. [input] | String: abcabcabc

[output] | # This program will print numbers from 0 to 9 # i is used to keep track of the loop's iteration count # The while block will be run until i reaches 10 # Each iteration, i is incremented by 1 [instruction] | Comment the code snippet. [input] | i = 0 while i < 10: print(i) i = i + 1

[output] | nums = [int(x) for x in my_string if x.isdigit()] [instruction] | Separate the numbers in the given string variable. [input] | String: 1a2b34c

[output] | Both dictionaries and lists are container data structures in Python which allow for the storage and retrieval of data. They are both mutable, meaning the contents can be updated, changed and manipulated. They also both contain an ordered sequence of elements, allowing for indexing into each one. How [instruction] | What are the similarities between dictionaries and Lists in Python? [input] |

[output] | names.sort() [instruction] | Write a Python code to sort the names into ascending order. [input] | names = ["Vladimir Putin","Joe Biden","Xi Jinping"]

[output] | newList = [x**2 for x in givenList] [instruction] | Generate a new List from the given list such that the elements are squares of the preceding numbers. [input] | givenList = [1, 2, 3, 4]

[output] | <!-- flexbox design --> <div class="layout-wrapper" style="display: flex; flex-direction: row;"> <div class="header" style="flex: 1; background-color: red;"> Header </div> <div class="body" style="flex: 3; display:flex; flex-direction: row;"> <div class="left-column" style="flex: 1; ba [instruction] | Develop an HTML/CSS code for creating a three column layout with a header, footer and content. [input] |

[output] | SELECT COUNT(*) FROM people WHERE year_of_birth < 1992; [instruction] | Develop a SQL query to count the number of people who are born before 1992. [input] |

[output] | <select> <option value="">Select an option</option> <option value="animal"> Animal</option> <option value="plant"> Plant</option> <option value="mineral"> Mineral</option> </select> [instruction] | Write an HTML code snippet to create an interactive dropdown menu. [input] |

[output] | import numpy as np import pandas as pd import sklearn from sklearn.preprocessing import LabelEncoder from sklearn.feature_extraction.text import TfidfVectorizer from sklearn.model_selection import train_test_split from sklearn.naive_bayes import MultinomialNB # Read the dataset data = pd.read_csv(' [instruction] | Develop a machine learning model in Python to classify emails as either important or not important. [input] |

[output] | import React from 'react'; const ModalWindow = ({ showModal, closeModal }) => { return ( showModal && ( <div> <div> <h3> Modal Window </h3> </div> <div> <form> ... </form> </div> <div> [instruction] | Create a ReactJS component to display a modal window with a form. [input] |

← → 방향키로 페이지 이동 · 숫자 입력 후 Enter로 점프