Text Generation
Transformers
Safetensors
GGUF
English
causal-lm
qwen2.5
reasoning
code-generation
Mixture of Experts
qlora
multimodal
tool-use
Eval Results (legacy)
conversational
Instructions to use ram1234598766/Cesium2 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use ram1234598766/Cesium2 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="ram1234598766/Cesium2") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("ram1234598766/Cesium2", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use ram1234598766/Cesium2 with llama.cpp:
Install (macOS, Linux)
curl -LsSf https://llama.app/install.sh | sh # Start a local OpenAI-compatible server with a web UI: llama serve -hf ram1234598766/Cesium2:Q8_0 # Run inference directly in the terminal: llama cli -hf ram1234598766/Cesium2:Q8_0
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf ram1234598766/Cesium2:Q8_0 # Run inference directly in the terminal: llama cli -hf ram1234598766/Cesium2:Q8_0
Use pre-built binary
# Download pre-built binary from: # https://github.com/ggerganov/llama.cpp/releases # Start a local OpenAI-compatible server with a web UI: ./llama-server -hf ram1234598766/Cesium2:Q8_0 # Run inference directly in the terminal: ./llama-cli -hf ram1234598766/Cesium2:Q8_0
Build from source code
git clone https://github.com/ggerganov/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-server llama-cli # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama-server -hf ram1234598766/Cesium2:Q8_0 # Run inference directly in the terminal: ./build/bin/llama-cli -hf ram1234598766/Cesium2:Q8_0
Use Docker
docker model run hf.co/ram1234598766/Cesium2:Q8_0
- LM Studio
- Jan
- vLLM
How to use ram1234598766/Cesium2 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "ram1234598766/Cesium2" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "ram1234598766/Cesium2", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/ram1234598766/Cesium2:Q8_0
- SGLang
How to use ram1234598766/Cesium2 with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "ram1234598766/Cesium2" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "ram1234598766/Cesium2", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "ram1234598766/Cesium2" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "ram1234598766/Cesium2", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Ollama
How to use ram1234598766/Cesium2 with Ollama:
ollama run hf.co/ram1234598766/Cesium2:Q8_0
- Unsloth Studio
How to use ram1234598766/Cesium2 with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for ram1234598766/Cesium2 to start chatting
Install Unsloth Studio (Windows)
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for ram1234598766/Cesium2 to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for ram1234598766/Cesium2 to start chatting
- Pi
How to use ram1234598766/Cesium2 with Pi:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf ram1234598766/Cesium2:Q8_0
Configure the model in Pi
# Install Pi: npm install -g @mariozechner/pi-coding-agent # Add to ~/.pi/agent/models.json: { "providers": { "llama-cpp": { "baseUrl": "http://localhost:8080/v1", "api": "openai-completions", "apiKey": "none", "models": [ { "id": "ram1234598766/Cesium2:Q8_0" } ] } } }Run Pi
# Start Pi in your project directory: pi
- Docker Model Runner
How to use ram1234598766/Cesium2 with Docker Model Runner:
docker model run hf.co/ram1234598766/Cesium2:Q8_0
- Lemonade
How to use ram1234598766/Cesium2 with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull ram1234598766/Cesium2:Q8_0
Run and chat with the model
lemonade run user.Cesium2-Q8_0
List all available models
lemonade list
- Hermes Agent
How to use ram1234598766/Cesium2 with Hermes Agent:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf ram1234598766/Cesium2:Q8_0
Configure Hermes
# Install Hermes: curl -fsSL https://hermes-agent.nousresearch.com/install.sh | bash hermes setup # Point Hermes at the local server: hermes config set model.provider custom hermes config set model.base_url http://127.0.0.1:8080/v1 hermes config set model.default ram1234598766/Cesium2:Q8_0
Run Hermes
hermes
- Atomic Chat
- OpenClaw
How to use ram1234598766/Cesium2 with OpenClaw:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf ram1234598766/Cesium2:Q8_0
Configure OpenClaw
# Install OpenClaw: npm install -g openclaw@latest # Register the local server and set it as the default model: openclaw onboard --non-interactive --mode local \ --auth-choice custom-api-key \ --custom-base-url http://127.0.0.1:8080/v1 \ --custom-model-id "ram1234598766/Cesium2:Q8_0" \ --custom-provider-id llama-cpp \ --custom-compatibility openai \ --custom-text-input \ --accept-risk \ --skip-health
Run OpenClaw
openclaw agent --local --agent main --message "Hello from Hugging Face"
File size: 94,277 Bytes
82f262a | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 | {"prompt": "Create an array of length 5 which contains all even numbers between 1 and 10.", "response": "arr = [2, 4, 6, 8, 10]", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Formulate an equation to calculate the height of a triangle given the angle, side lengths and opposite side length.", "response": "Height of triangle = opposite side length * sin (angle) / side length", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Write a replace method for a string class which replaces the given string with a given set of characters.", "response": "def replace(self, replace_with):\n new_string = \"\"\n for char in self:\n if char == \" \":\n new_string += replace_with\n else:\n new_string += char\n return new_string", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Create an array of length 15 containing numbers divisible by 3 up to 45.", "response": "arr = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45]", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Write a function to find the number of distinct states in a given matrix.", "response": "def find_num_distinct_states(matrix):\n states = set()\n for row in matrix:\n state = \"\".join([str(x) for x in row])\n states.add(state)\n return len(states)", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Create a nested loop to print every combination of numbers between 0-9", "response": "for i in range(10):\n for j in range(10):\n print(i, j)", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Write a function to find the maximum difference between two numbers in a given array.", "response": "def max_difference(arr):\n max_diff = 0\n for i in range(len(arr)-1):\n diff = arr[i+1] - arr[i]\n if diff > max_diff:\n max_diff = diff\n return max_diff", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Write a function to generate the nth Fibonacci number.", "response": "def fib(n):\n if n == 0:\n return 0\n elif n == 1:\n return 1\n else:\n return fib(n-2) + fib(n-1)", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Write a class to represent a 2D point with x and y coordinates.", "response": "class Point:\n def __init__(self, x, y):\n self.x = x \n self.y = y \n \n def __str__(self): \n return \"({0},{1})\".format(self.x, self.y)", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Write code that removes spaces from a given string.", "response": "def remove_spaces(string): \n return \"\".join(string.split())", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Write a function that checks if a give number is even or odd.", "response": "def is_even(n):\n if n%2 == 0:\n return True \n else:\n return False", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Write code to create a list of all prime numbers between 2 and 100.", "response": "def find_primes(n): \n prime_list = [2] \n for number in range(2, n + 1): \n is_prime = True\n for k in range(2, number): \n if number % k == 0: \n is_prime = False \n if is_prime: \n prime_list.append(number) \n return prime_list", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Edit the following code to print out all even numbers from 1 to 10.", "response": "for i in range(1,11):\n if i % 2 == 0:\n print(i)", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Write code to find the sum of all numbers between 1 and 10.", "response": "sum = 0\nfor i in range(1,11):\n sum += i\nprint(sum)", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Create a function to calculate the area of a given circle.", "response": "def area_circle(radius):\n return 3.14 * (radius**2)", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Follow the comments in the code to complete the program which prints a conversion table from Fahrenheit to Celsius.", "response": "# This program prints a conversion table from Fahrenheit to Celsius\n\n# Print a heading for the table\nprint(\"Fahrenheit to Celsius Conversion Table\")\n\n# Print the column headings\nprint(\"Fahrenheit \\t Celsius\")\n\n# Calculate and print the table body\nfor fahr in range(-50 , 121):\n celsius = (fahr - 32) * 5 / 9\n print(\"%3d \\t\\t %.2f\" % (fahr, celsius))", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Develop a classification algorithm in Python to predict whether a bird is a hawk or a falcon.", "response": "import pandas as pd\nimport numpy as np\n\n# Define features\nfeatures = [\"wing_shape\", \"size\", \"tails_length\", \"color_pattern\"] \n\n# Load the data\ndata = pd.read_csv(\"birds.csv\")\n\n# Preprocess the data to generate feature vectors\nX = np.array(data[features]) \n\n# Make a target vector \ny = np.array(data[\"species\"]) \n\n# Divide the data into training and test sets\nfrom sklearn.model_selection import train_test_split\nX_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)\n\n# Train a classification model\nfrom sklearn.tree import DecisionTreeClassifier\nmodel = DecisionTreeClassifier()\nmodel.fit(X_train, y_train)\n\n# Make predictions\ny_pred = model.predict(X_test)\n\n# Generate evaluation metrics\nfrom sklearn.metrics import accuracy_score\naccuracy = accuracy_score(y_test, y_pred)\n\nprint(\"Model accuracy: %.2f\" % accuracy)", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Create a function in Java for computing the factorial of a positive integer number.", "response": "public static long factorial(int n) {\n if (n == 0) {\n return 1;\n }\n long result = 1;\n for (int i = 1; i <= n; i++) {\n result *= i;\n }\n return result;\n}", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Create a C++ program for randomly shuffling an array of integers.", "response": "#include <iostream>\n#include <algorithm>\n#include <random>\n\nvoid shuffleArray(int array[], int size) {\n\tstd::random_device rd;\n\tstd::mt19937 g(rd()); \n\tstd::shuffle(array, array+size, g); \n}\n\nint main() \n{ \n\tint array[] = {1, 2, 3, 4, 5, 6, 7, 8}; \n\tint size = sizeof(array) / sizeof(array[0]); \n\n // Print original array\n std::cout << \"Original array: \";\n for (int i : array)\n std::cout << i << \" \";\n std::cout << \"\\n\";\n\n // Shuffle array\n\tshuffleArray(array, size); \n\n // Print shuffled array\n std::cout << \"Shuffled array: \";\n for (int i : array)\n std::cout << i << \" \";\n std::cout << \"\\n\";\n\n\treturn 0; \n}", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Use the function to debug the given program and prevent the segmentation fault.", "response": "#include <stdio.h>\n\nint main() {\n int array[] = {1, 2, 3, 4, 5};\n int n = 5;\n int i;\n // Limit loop size to the length of the array\n for (i = 0; i < n; i++) {\n printf(\"%d\\n\", array[i]);\n }\n return 0;\n}", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Replace the placeholder with a for loop for iterating over the numbers from 1 to n and printing them.", "response": "for i in range(1, n+1):\n print(i)", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Use try-except statements to detect and handle exceptions in the code.", "response": "try:\n for i in range(n):\n x = 1/i\nexcept ZeroDivisionError:\n print(\"Zero division error encountered!\")", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Re-write the code segment as a list comprehension.", "response": "numbers = [i for i in range(10) if i % 2 == 0]", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Remove the boilerplate code from the program for printing 10 random numbers.", "response": "import random\n\n# Generate 10 random numbers\nfor i in range(10):\n print(random.randrange(1, 101))", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Modify the code to perform the mathematical expression “x to the power of y”.", "response": "# Calculate x to the power of y\nx_pow_y = x**y", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Create a dictionary for counting the occurrence of each letter in the given string.", "response": "string = \"hello world\"\nletter_counts = {}\n\nfor letter in string:\n if letter in letter_counts:\n letter_counts[letter] += 1\n else:\n letter_counts[letter] = 1\n\nprint(letter_counts)", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Follow the comments to complete the code that finds the maximum value in an array.", "response": "# Find the maximum value in an array\narr = [4, 5, 2, 8, 7]\n\nmax_value = arr[0]\nfor i in range(1, len(arr)):\n if arr[i] > max_value:\n max_value = arr[i]\n\nprint(max_value)", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Write a function in HTML for creating a table of n rows and m columns.", "response": "<table>\n <tbody>\n <% for (let i = 0; i < n; i++) { %>\n <tr>\n <% for (let j = 0; j < m; j++) { %>\n <td>Cell Content</td>\n <% } %>\n </tr>\n <% } %>\n </tbody>\n</table>", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Create a CSS script that centers the login form on the webpage.", "response": ".login-form {\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n}", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Create a Java program that prints out the sum of the numbers in the array.", "response": "public class SumOfArray {\n public static void main(String[] args) {\n int[] numbers = {1, 2, 3 , 4, 5};\n int sum = 0;\n for(int i=0; i < numbers.length;i++) {\n sum = sum + numbers[i];\n }\n System.out.println(\"The sum of numbers in the given array is: \" + sum);\n }\n}", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Write a SQL query to calculate the total number of orders in the \"orders\" table.", "response": "SELECT COUNT(*) AS \"Total Number of Orders\" \nFROM orders;", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Write a Python function to convert a given string to lowercase.", "response": "def to_lowercase(string):\n return string.lower()\n\nstring = \"FOO\"\nprint(to_lowercase(string))", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Create a C program that prints out the Fibonacci sequence.", "response": "#include <stdio.h>\n\nint main()\n{\n int i, num, first=0, second=1, next;\n printf(\"Enter the number of elements: \");\n scanf(\"%d\", &num);\n printf(\"Fibonacci Series: \");\n for (i = 0; i < num; i++)\n {\n if (i <= 1)\n next = i;\n else\n {\n next = first + second;\n first = second;\n second = next;\n }\n printf(\"%d \", next);\n }\n return 0;\n}", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Write a function in JavaScript to count the number of vowels in a given string.", "response": "function countVowels(string) {\n let vowelCount = 0;\n const vowels = [\"a\",\"e\",\"i\",\"o\",\"u\"];\n \n for (let i = 0; i < string.length; i++) {\n if (vowels.includes(string[i])) {\n vowelCount++;\n }\n }\n \n return vowelCount;\n}\n\nconst string = \"abcdefg\";\nconsole.log(countVowels(string));", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Create a JSX code that renders a \"Hello, World!\" message in the browser.", "response": "import React from \"react\";\n\nfunction App() {\n return (\n <div>\n <h1>Hello, World!</h1>\n </div>\n );\n}\n\nexport default App;", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Write an SQL query to calculate the average order price for each product category in the \"orders\" table.", "response": "SELECT category, AVG(price) as \"Average Order Price\"\nFROM orders\nGROUP BY category;", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Create a Java program that prints out the contents of a given two-dimensional array.", "response": "public class TwoDArray {\n\n public static void main(String[] args) {\n int[][] arr = {{1,2},{3,4},{5,6}};\n\n for(int i=0;i<arr.length;i++){\n for(int j=0;j<arr[i].length;j++){\n System.out.print(arr[i][j]+\" \");\n }\n System.out.println();\n }\n }\n}", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Create a C++ program that sorts a given array in descending order.", "response": "#include<iostream>\nusing namespace std;\n \nint main()\n{\n int array[] = {6, 3, 8, 12, 9, 4};\n int arraySize = sizeof(array)/sizeof(array[0]);\n \n //ascending order sorting\n for(int i = 0; i < arraySize; i++)\n {\n // find the position of smallest element\n int small = i;\n for(int j = i+1; j < arraySize; j++)\n {\n if(array[j] > array[small])\n small = j;\n }\n \n // swap the position of smallest element\n int temp = array[i];\n array[i] = array[small];\n array[small] = temp;\n }\n \n // print the sorted array\n cout << \"Sorted array : \";\n for(int i = 0; i < arraySize; i++)\n cout << array[i] << \" \";\n \n return 0;\n}", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Edit the Python code so that it prints out the total number of elements in the list.", "response": "list = [1, 2, 3, 4, 5]\nprint(\"Total number of elements in the list: \", len(list))", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Create a Swift code that show the number of days in the given month.", "response": "let month = 5\nlet daysEndingInth = [3, 0, 3, 2, 3, 2, 3, 3, 2, 3, 2, 3]\nlet daysInMonth = daysEndingInth[month - 1] \nprint(\"The number of days in the month of \\(month) is \\(daysInMonth).\")", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Write a HTML code that create a form for user to fill out their current address.", "response": "<form action=\"\">\n <label for=\"street\">Street</label>\n <input type=\"text\" name=\"street\" id=\"street\">\n <label for=\"city\">City</label>\n <input type=\"text\" name=\"city\" id=\"city\">\n <label for=\"state\">State</label>\n <input type=\"text\" name=\"state\" id=\"state\">\n <label for=\"zip\">Zip Code</label>\n <input type=\"text\" name=\"zip\" id=\"zip\"> \n <input type=\"submit\" value=\"Submit\">\n</form>", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Write a SQL query to find the total number of orders placed between two given dates.", "response": "SELECT COUNT(*)\nFROM orders\nWHERE order_date BETWEEN '2020-01-01' AND '2020-02-01';", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Create a Ruby code that prints out the median of a given array of numbers.", "response": "nums = [1, 7, 3, 6]\nsorted_nums = nums.sort\n\n# Calculation of median \nif sorted_nums.length % 2 == 0\n mid_index = sorted_nums.length/2\n median = (sorted_nums[mid_index] + sorted_nums[mid_index - 1])/2.to_f\nelse\n mid_index = sorted_nums.length/2\n median = sorted_nums[mid_index]\nend\n\nputs median", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Create a PHP code to check if an array contains a given item.", "response": "<?php\n$input_array = array(1,2,3,4,5);\n$item_to_check = 3;\n\nif(in_array($item_to_check, $input_array)) {\n echo \"Array contains the given item.\";\n} else {\n echo \"Array doesn't contain the given item.\";\n}\n?>", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Edit the code to create a try-except block to handle the exception.", "response": "try:\n a = 5\n b = 0\n\n ans = a/b\nexcept ZeroDivisionError:\n print(\"Cannot divide by zero.\")", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Write a script using Bash that replaces all vowels with a number.", "response": "#!/bin/bash\n\nstring=\"Hello World!\"\nvowels=(\"a\" \"e\" \"i\" \"o\" \"u\" \"A\" \"E\" \"I\" \"O\" \"U\")\n\nfor i in \"${vowels[@]}\"\ndo\n string=\"${string//$i/0}\"\ndone\n\necho $string #H0ll0 W0rld!", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Change the variable `x` to the data type desired.", "response": "x = \"Hello World!\"", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Create a function that takes an array as an argument and returns the sum of all the elements in the array.", "response": "def arraySum(arr):\n total = 0\n for num in arr:\n total += num\n return total", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Sort the array in ascending order.", "response": "arr.sort() # [1, 2, 3, 4, 5]", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Generate a random integer between 4 and 8 (inclusively).", "response": "import random\nx = random.randint(4, 8)", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Write a list comprehension to square each number in the list.", "response": "arr = [x**2 for x in arr] # [1, 4, 9, 16, 25]", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Write a function that takes a string and reverses the words.", "response": "def reverseWords(text):\n return ' '.join(text.split()[::-1])\n\nreverseWords(text) # \"World! Hello\"", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Write a SQL query to return the sum of all salaries.", "response": "SELECT SUM(salary)\nFROM employees;", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Create a function that takes in two numbers as arguments and returns the product of the two.", "response": "def multiply(x, y):\n return x*y", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Sum up the numbers in the array in Javascript.", "response": "let sum = arr.reduce((total, num) => total + num);\nconsole.log(sum); // 15", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Using the given function, create a loop that counts from 0 to 9.", "response": "for (let i = 0; i < 10; i++){\n printNum(i);\n}", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Create a JSON object with three key-value pairs.", "response": "{\n \"firstName\": \"John\",\n \"lastName\": \"Doe\",\n \"age\": 30\n}", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Count the number of characters in the string.", "response": "len(text) # 12", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Generate a random number between 0 and 1 (inclusively).", "response": "Math.random(); // a random number between 0 and 1 (inclusively)", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Compose a function named average_list which takes a list of numbers as its argument and computes the average.", "response": "def average_list(nums):\n return sum(nums)/len(nums)", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Generate a snippet of code to extract all the URLs from the given string.", "response": "import re\n\nstring = \"This string contains some urls such as https://www.google.com and https://www.facebook.com.\"\n\nurls = re.findall('http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\\(\\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+', string) \n\nprint(urls)", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Write a code to convert a given spredsheet in csv format to json format.", "response": "import csv\nimport json\n\ndef csv_to_json():\n # Path of csv file\n file_csv = 'mycsvfile.csv'\n \n # Path of json file\n file_json = 'myjsonfile.json'\n \n with open(file_csv, 'r') as input_file:\n reader = csv.DictReader(input_file)\n data = list(reader)\n \n with open(file_json, 'w') as output_file:\n json.dump(data, output_file)\n\ncsv_to_json()", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Create a list comprehension to generate a list of multiples of 3 from 0 to 23.", "response": "list_of_multiples_of_3 = [x*3 for x in range(8)]", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Design a program to find the longest element in the given list.", "response": "def longest_element(list):\n max_length = 0\n max_length_item = None\n\n for item in list:\n if len(item) > max_length:\n max_length = len(item)\n max_length_item = item\n\n return max_length_item\n\nlist = [10, 100, 200, 500, 400]\nlongest_element(list) # 500", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Write a function to print all prime numbers between two given numbers.", "response": "def print_prime_numbers_in_range(start, end):\n # start = starting number\n # end = ending number\n\n for num in range(start, end+1):\n # Prime numbers are greater than 1\n if num > 1:\n for i in range(2, num):\n if (num % i) == 0:\n break\n else:\n print(num)\n---\n\n11. Instruction: Generate a snippet of code to reverse given string\n11. Input:\n<noinput>\n11. Output:\ndef reverse_string(input_string):\n string_length = len(input_string)\n reversed_string = \"\"\n \n for i in range(string_length-1,-1,-1):\n reversed_string += input_string[i]\n \n return reversed_string", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Describe the basic syntax of a Java function?", "response": "A Java function consists of a function name, return type, parameters (arguments), and body. The syntax of a Java function is as follows: \npublic <return type> <function name>(<list of parameters>) { \n // function body \n <statements> \n}", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "How to reverse a list in C++?", "response": "You can reverse a list in C++ using the std::reverse algorithm. To reverse the list, pass the list as the first parameter and the beginning and end of the list as the second and third parameter, respectively. Alternatively, you can also reverse the list using a for loop and the operator [] to access each element of the list.", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Write a SQL query to update a value x in a column y in a table z.", "response": "UPDATE payments \nSET amount = 5 \nWHERE payments.amount IS NOT NULL;", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Write an algorithm in Python to determine if a number is even or odd.", "response": "def is_even(num): \n if num % 2 == 0: \n return True \n else: \n return False", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "What is the purpose of a constructor in a class in Java?", "response": "The purpose of a constructor in a class in Java is to initialize an object of that class. A constructor is a special kind of method that is used to create an object of its associated class. When an object of the class is created, the constructor is used to set the initial state of the object.", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Write a JavaScript code to get the current browser URL.", "response": "var currentURL = window.location.href;\nconsole.log(currentURL);", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Rewrite the following C++ code using only pointer references instead of array subscripts:", "response": "int arr[3] = {1,2,3};\nint sum = 0;\nint* ptr = arr;\nfor (int i = 0; i < 3; i++) \n{\n sum += *(ptr+i); \n}", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Write a MySQL query to print the column names of a table named 'employees'.", "response": "SELECT column_name FROM information_schema.columns WHERE table_name = 'employees';", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Generate a regular expression to match a valid email address.", "response": "/^([a-zA-Z0-9_\\-\\.]+)@([a-zA-Z0-9_\\-\\.]+)\\.([a-zA-Z]{2,5})$/", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "How to delete a particular row in an SQLite database table?", "response": "To delete a particular row in an SQLite database table, you can use the DELETE statement with a WHERE clause to specify the row to be deleted. For example: DELETE FROM table_name WHERE condition;", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Is it possible to set a breakpoint that is not associated with any source code line in a GDB program?", "response": "Yes, it is possible to set a breakpoint that is not associated with any source code line in a GDB program. For example, you can set a breakpoint on a function or a memory address. You can do this by using the break command with '*' prefix followed by the address of the breakpoint.", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Write a C++ code to find the average of an array of integers.", "response": "#include <iostream>\n\nint calculateAverage(int array[], int n){\n int sum = 0; \n for (int i=0; i<n; i++){\n sum += array[i]; \n } \n int average = sum/n;\n return average;\n}", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "How can we encrypt a string in Python?", "response": "We can encrypt a string in Python using the cryptography module. The cryptography module provides high level cryptographic primitives using the Fernet cipher. The Fernet cipher uses AES-128 in CBC mode and PKCS7 padding to encrypt the string.", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "What is the purpose of declaring a function as static in C++?", "response": "The purpose of declaring a function as static in C++ is to restrict its visibility to only the translation unit in which it is declared. A static function can only be called from within the same translation unit and thus, it cannot be accessed from outside of that translation unit.", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "How to print the elements of a two-dimensional array in C?", "response": "We can use nested loops to print the elements of a two-dimensional array in C. The outer loop iterates over the rows, while the inner loop iterates over the columns. For example, the following code snippet prints the elements of a two-dimensional array: \n \nint array[3][3] = {{1,2,3},{4,5,6},{7,8,9}};\nfor (int i=0; i<3; i++)\n{ \n for(int j=0; j<3; j++) \n {\n printf(\"%d \", array[i][j]); \n }\n printf(\"\\n\");\n}", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Using the following code, clean up the bugs and make sure the output functions correctly.", "response": "def example_func(lst):\n output_lst = []\n for element in lst:\n if (type(element) == int):\n output_lst.append(element + 5)\n return output_lst\n \nexample_func([1, 2, \"hello\"])", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Write a C++ function to generate a random integer between 0 and 10.", "response": "#include <iostream> \n#include <cstdlib> \n#include <ctime> \nusing namespace std; \n\nint randomIntGenerator() \n{ \n // Setting the seed \n srand(time(0)); \n\n // Generating random integer \n return (rand()%11); \n}", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Create a table to store customer information.", "response": "CREATE TABLE customers (\n id int NOT NULL AUTO_INCREMENT,\n name varchar(100) NOT NULL,\n email varchar(100) NOT NULL,\n phone varchar(20) NOT NULL,\n address varchar(200) NOT NULL,\n PRIMARY KEY (id)\n);", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Create a class in Java named Puppy that has two instance variables, age and name and two methods, bark and sleep.", "response": "public class Puppy { \n // Instance Variables \n String name; \n int age; \n \n // Constructor \n public Puppy(String name, int age){ \n this.name = name; \n this.age = age; \n } \n \n // Methods \n public void bark(){ \n System.out.println(\"Woof Woof!\"); \n } \n \n public void sleep(){ \n System.out.println(\"Zzzzzz...\"); \n } \n}", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Parse the string and return the number of unique alphabets in the string.", "response": "int count = 0;\nfor (int i = 0; i < StringInput.length(); i++) {\n if ((StringInput.charAt(i) >= 'a' && StringInput.charAt(i) <= 'z') || (StringInput.charAt(i) >= 'A' && StringInput.charAt(i) <= 'Z')) {\n count++;\n }\n}\nSystem.out.println(\"Number of unique alphabets: \" + count);", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Write a shell script to print the top 3 most frequently used commands.", "response": "#!/bin/bash\n# Store all commands used in the last hour in command_list.\nhistory | tail -$(($(date +%H) * 60)) -n $(($(date +%M)+1)) | cut -d ' ' -f 5 > command_list\n# Create frequency database and store them in frequency.dat\ncat command_list | sort | uniq -c | sort -rn > frequency.dat\n# Print top 3 commands\nhead -3 frequency.dat", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Read the JSON string below and convert it into a dictionary.", "response": "import json\n\njsonObject = json.loads(jsonString)\ndictionary = dict(jsonObject)\nprint(dictionary)", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Implement a function that finds the maximum element in a given array.", "response": "def find_max_element(arr): \n max_element = arr[0] \n for index in range(1, len(arr)): \n if arr[index] > max_element: \n max_element = arr[index] \n return max_element\n \narr = [45, 7, 0, 82, 23]\nmax_element = find_max_element(arr) \nprint(max_element)", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Validate whether the string contains only alphabets or not.", "response": "def check_string_alphabets(myString):\n for character in myString:\n if (not character.isalpha()):\n return False\n return True\n\nmyString = \"abc123\"\nif (check_string_alphabets(myString)):\n print(\"String contains only alphabets\")\nelse:\n print(\"String contains numbers\")", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Rewrite the following code using ternary operator.", "response": "num1 = 5\nnum2 = 10\n\nprint(\"num1 is smaller than num2\") if (num1 < num2) else print(\"num1 is greater than or equal to num2\")", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Write a script to check if a given number is a palindrome or not.", "response": "# Function to check whether the inputNumber is palindrome or not\ndef is_palindrome(inputNumber):\n\n # negative numbers are not palindrome\n if inputNumber < 0:\n return False\n\n # find the number of digits in the inputNumber\n div = 1\n while (inputNumber / div >= 10):\n div *= 10\n\n # check if the most significant and least significant digits match\n while (inputNumber != 0):\n # compare first and last digits\n firstdigit = inputNumber // div\n lastdigit = inputNumber % 10\n if firstdigit != lastdigit:\n return False\n\n # remove the most and least significant digit of inputNumber\n inputNumber = (inputNumber % div) // 10\n\n # reduce div by a factor of 2, since 2 digits\n # were removed\n div = div // 100\n return True\n\n# Driver code to test above\ninputNumber = 121\nif is_palindrome(inputNumber) :\n print(\"Yes\")\nelse:\n print(\"No\")", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Edit the following code to remove the bugs.", "response": "def reverse_string(user_string): \n reversed_string = ''\n if len(user_string) == 0: \n return \"\" \n else: \n reversed_string = reverse_string(user_string[1:]) + user_string[0] \n return reversed_string\n\nuser_string = 'test'\nprint(reverse_string(user_string))", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "What is the output of the following code?", "response": "a\nbb\nccc", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Write a function to remove all whitespace characters from a given string.", "response": "def remove_whitespaces(myString):\n return ''.join(myString.split())\n\nmyString = \"Hello World \"\nprint(remove_whitespaces(myString))", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Edit the following code to add try catch block.", "response": "x = \"5\"\ny = \"2\"\ntry:\n sum = int(x) + int(y)\n print(\"Sum of x and y is\", sum)\nexcept:\n print(\"Error: Invalid input\")", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Write a Python function that takes two lists of equal length and creates a dictionary of the elements in each list that have the same index.", "response": "def list_dict(list_one, list_two):\n \"\"\"Create a dictionary of elements in the two lists which have the same index.\"\"\"\n assert len(list_one) == len(list_two), \"lists must be same length\"\n dict = {}\n for i in range(len(list_one)):\n dict[list_one[i]] = list_two[i]\n return dict", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Create a quick-sort algorithm in Python.", "response": "def quick_sort(arr):\n \"\"\"Sort a list of numbers in ascending order using the Quick-Sort algorithm\"\"\"\n if len(arr) == 0:\n return []\n\n pivot = arr[0]\n left_arr = [x for x in arr if x < pivot]\n right_arr = [x for x in arr if x > pivot]\n return quick_sort(left_arr) + [pivot] + quick_sort(right_arr)", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Develop an algorithm to find the value of n where n is the index of the Fibonacci sequence.", "response": "def nth_fibonacci_number(n):\n \"\"\"Find the value of n where n is the index of the Fibonacci Sequence.\"\"\" \n if n < 2:\n return n \n elif n == 2:\n return 1\n else:\n return nth_fibonacci_number(n-1) + nth_fibonacci_number(n-2)", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Create a program that finds all the prime numbers less than or equal to a given number.", "response": "def find_primes(num):\n \"\"\"Find all the prime numbers less than or equal to a given number.\"\"\"\n primes = []\n for i in range(2, num + 1):\n is_prime = True\n for j in range(2, int(i ** 0.5) + 1):\n if i % j == 0:\n is_prime = False\n break\n if is_prime:\n primes.append(i)\n return primes", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Write a function that takes in a list of numbers and prints out the greatest number.", "response": "def find_greatest(list):\n \"\"\"Print out the greatest number from a list of numbers.\"\"\"\n greatest = list[0]\n for num in list:\n if num > greatest:\n greatest = num\n print('The greatest number is: ', greatest)", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Design an algorithm that takes a list of strings and returns the longest string.", "response": "def find_longest(list):\n \"\"\"Return the longest string from a list of strings.\"\"\" \n longest = list[0]\n for item in list:\n if len(item) > len(longest):\n longest = item\n return longest", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Write a function that takes in a matrix of numbers and reverses the order of the rows and columns.", "response": "def reverse_matrix(matrix):\n \"\"\"Reverse the order of the rows and columns in a matrix of numbers.\"\"\"\n reversed_matrix = [[0 for i in range(len(matrix[0]))] for j in range(len(matrix))]\n for i in range(len(matrix)):\n for j in range(len(matrix[i])):\n reversed_matrix[j][i] = matrix[i][j]\n return reversed_matrix", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Design an algorithm that creates a random password of 8 characters.", "response": "def generate_password():\n \"\"\"Generate a random password of 8 characters.\"\"\"\n import random\n chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890!@#$%^&*()'\n password = ''\n for i in range(8):\n password += random.SystemRandom().choice(chars)\n return password", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "FOr a given list, create a program that prints out the standard deviation of the elements in the list.", "response": "def std_dev(list):\n \"\"\"Print the standard deviation of elements in a given list.\"\"\"\n numerator = 0\n mean = sum(list) / len(list)\n for num in list:\n numerator += (num - mean) ** 2\n sd = (numerator / (len(list) - 1)) ** 0.5\n return sd", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Create a program that can filter out words of a string that contain a specific character.", "response": "def filter_string(string, character):\n \"\"\"Filter out words of a string that contain a specific character.\"\"\"\n words = string.split(' ')\n filtered_words = []\n for word in words:\n if character not in word:\n filtered_words.append(word)\n return ' '.join(filtered_words)", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Create a program that can calculate the distance between two points in three-dimensional space.", "response": "def dist_points_3d(point1, point2):\n \"\"\"Calculate the distance between two points in three-dimensional space.\"\"\"\n distance = ((point1[0] - point2[0]) ** 2 + \n (point1[1] - point2[1]) ** 2 + \n (point1[2] - point2[2]) ** 2) ** 0.5\n return distance", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Create a program that ciphers a given text using the caesar cipher.", "response": "def caesar_cipher(text, key):\n \"\"\"Cipher a given text using the Caesar Cipher.\"\"\"\n ciphertext = \"\"\n for char in text: \n if not char.isalpha():\n ciphertext += char\n continue\n offset = ord('a') if char.islower() else ord('A')\n new_char = (ord(char) - offset + key) % 26\n ciphertext += chr(offset + new_char)\n return ciphertext", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Find the second smallest element in an integer array of size n.", "response": "def second_smallest(array):\n\nsmallest = min(array)\nsecond_smallest = float('inf')\n\nfor num in array:\n if num > smallest and num < second_smallest:\n second_smallest = num\n \nreturn second_smallest", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Write a SQL query to find all the users in a database with age greater than 25.", "response": "SELECT * FROM users WHERE age > 25", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Create a function to calculate the maximum of two numbers.", "response": "def max_of_two(x, y):\n if x > y:\n return x\n else:\n return y", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Write a Python program to split a string on a given character separator.", "response": "def split(mystring, separator):\n return mystring.split(separator)", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Write a Python program to get the day of week from a given date and time.", "response": "from datetime import datetime\n\ndef get_day_of_week(date):\n return date.strftime(\"%A\")", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Write a Javascript function to determine if the given number is an even number or not.", "response": "function isEven(num) {\nreturn num % 2 === 0;\n}", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Write a Python program to print out an ASCII art of a given word.", "response": "def draw_word(word):\n art = \"\"\"\n __\n _ / \\\\\n \\\\_/\\_/\\_/\n / |\n \\___/\n \\\\\\\\_//\n \\/ \\/\n \\/\n \"\"\"\n for letter in word:\n art += \" \" + letter\n print(art)", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Write a JavaScript function to validate a given URL.", "response": "function isValidURL(url) {\n const regex = /^(?:http(s)?:\\/\\/)?[\\w.-]+(?:\\.[\\w\\.-]+)+[\\w\\-\\._~:/?#[\\]@!\\$&'\\(\\)\\*\\+,;=.]+$/;\n return regex.test(url);\n}", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Write a C# program to find the maximum and minimum of three numbers.", "response": "public void Maximum_Minimum(int num1, int num2, int num3)\n{\n int max = Math.Max(Math.Max(num1, num2),num3);\n int min = Math.Min(Math.Min(num1,num2),num3);\n Console.WriteLine(\"Maximum Number is : \" + max);\n Console.WriteLine(\"Minimum Number is : \" + min);\n}", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Write a Java program to reverse a given string.", "response": "public class ReverseString\n{ \n\n public static void main(String[] args) \n { \n String input = \"Hello\"; \n StringBuilder input1 = new StringBuilder(); \n \n // append a string into StringBuilder input1 \n input1.append(input); \n \n // reverse StringBuilder input1 \n input1 = input1.reverse(); \n \n // print reversed String \n System.out.println(input1); \n } \n}", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Write an HTML template to display a greeting message. The message should include the name of the user who visits the website.", "response": "<html>\n\t<head>\n\t\t<title>Greeting Message</title>\n\t</head>\n\t<body>\n\t\t<h1>Hello, {{ username }}!</h1>\n\t</body>\n</html>", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Write a Python program to concatenate all elements in a list into a string separated by a given separator.", "response": "def list_to_string(input_list, separator):\n return separator.join(input_list)", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Write a C program to find the sum of all digits of a given number", "response": "#include <stdio.h>\n\nint getSumOfDigits(int num) {\n // Initialize sum\n int sum = 0;\n\n // Find the sum of digits\n while(num > 0) {\n sum += num % 10;\n num /= 10;\n }\n\n return sum;\n}\n\nint main() {\n int num;\n scanf(\"%d\", &num);\n\n printf(\"Sum of digits of %d is %d\\n\", num, getSumOfDigits(num));\n\n return 0;\n}", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Write a Java program to generate random numbers", "response": "import java.util.Random; \n \npublic class GenerateRandom { \n \n public static void main(String[] args) \n { \n \n Random rand = new Random(); \n \n // Generate random integers in range 0 to 999 \n int x = rand.nextInt(1000); \n System.out.println(\"Random Integers: \" + x); \n \n // Generate Random doubles \n double y = rand.nextDouble(); \n System.out.println(\"Random Doubles: \" + y); \n \n // Generate Random Boolean \n boolean z = rand.nextBoolean(); \n System.out.println(\"Random Boolean: \" + z); \n } \n}", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Rewrite the following Python code using a for-loop.", "response": "for i in range(11):\n print(i)", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Write a code to print the current date and time in ISO format.", "response": "from datetime import datetime\n\ndate_time_obj = datetime.now()\n\nprint(date_time_obj.isoformat()) # prints \"2020-07-29T15:10:01.584131\"", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Create a new folder called 'data' within the current working directory.", "response": "import os\n\n# create 'data' folder in the current working directory\ncurrent_directory = os.getcwd()\nnew_directory = os.path.join(current_directory, 'data')\nos.mkdir(new_directory)", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Write a code to sort the following array in increasing order.", "response": "# sorting array using insertion sort\narr = [10, 2, 7, 8, 32, 4] \n\n# traverse through all array elements \nfor i in range(1, len(arr)):\n key = arr[i]\n\n # move elements of arr[0..i-1], that are greater than key,\n # to one position ahead of their current position\n j = i-1\n while j >= 0 and key < arr[j] : \n arr[j + 1] = arr[j] \n j -= 1\n arr[j + 1] = key\n \n#print the sorted array\nprint(arr)", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Create a function in JavaScript that takes an array of integers and returns the largest number.", "response": "function findMax(arr) {\n let max = arr[0];\n for (let i = 1; i < arr.length; i++) {\n if (arr[i] > max) {\n max = arr[i];\n }\n }\n return max;\n}", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Create a regular expression to validate a URL string.", "response": "# Regular expression to validate a URL string\n^(http:\\/\\/|https:\\/\\/|ftp:\\/\\/)?(www\\.)?([a-zA-Z0-9]+(-?[a-zA-Z0-9])*\\.)+[\\w]{2,5}(\\/\\S*)?$", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Write a Python code to calculate the mean of a given array.", "response": "# calculate the mean of given array\narr = [1,2,3,4]\n\ndef calc_mean(arr):\n sum = 0\n for num in arr:\n sum += num\n return sum / len(arr)\n\nprint(calc_mean(arr)) # prints 2.5", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Create a function in Java that takes a string and prints the reversed version.", "response": "public static void reverseString(String str) { \n StringBuilder sb = new StringBuilder(); \n \n for (int i = str.length() - 1; i >= 0; i--) { \n sb.append(str.charAt(i)); \n } \n \n System.out.print(sb.toString()); \n}", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Write a code to get the time difference between two date-time objects.", "response": "from datetime import datetime\n\ndef time_difference(date1, date2):\n date1_obj = datetime.strptime(date1, '%Y-%m-%d %H:%M:%S')\n date2_obj = datetime.strptime(date2, '%Y-%m-%d %H:%M:%S')\n\n return (date2_obj - date1_obj).total_seconds() // 3600\n\nprint(time_difference('2019-05-11 21:00:00', '2019-05-13 10:00:00')) # prints 33.0", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Write a code to connect to a remote database.", "response": "import psycopg2\n\nconn = psycopg2.connect(host=\"100.10.0.10\", database=\"mydb\", user=\"john\", password=\"john123\")", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Create an HTML form with a textbox, a submit button, and two radio buttons.", "response": "<form>\n <input type=\"text\" id=\"textbox\">\n <input type=\"submit\" value=\"Submit\">\n <input type=\"radio\" name=\"choice\" value=\"yes\">Yes\n <input type=\"radio\" name=\"choice\" value=\"no\">No\n</form>", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Write a code to access the nth element of a linked list.", "response": "# defining the Node class\nclass Node: \n\tdef __init__(self, data): \n\t\tself.data = data \n\t\tself.next = None\n\ndef getNthElement(head, n): \n\tcurrent = head \n\tcount = 0\n\n\t# looping through the linked list\n\twhile(current is not None): \n\t\tif (count == n): \n\t\t\treturn current.data \n\t\tcount += 1\n\t\tcurrent = current.next\n\treturn -1", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Create a function in JavaScript to find the number of occurrences of a letter in a word.", "response": "function findOccurrences(word, letter) {\n let count = 0;\n for (let i = 0; i < word.length; i++) {\n if (word.charAt(i) === letter) {\n count++;\n }\n }\n return count;\n}", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Write a code to add two linked lists of different sizes.", "response": "# adding two linked lists\nclass Node: \n\tdef __init__(self, data): \n\t\tself.data = data \n\t\tself.next = None\n\ndef addTwoLists(first, second):\n # defining current and prev variables\n prev = None\n carry = 0\n temp = None\n\n # looping until one list has all nodes added\n while(first is not None or second is not None): \n Node = Node() \t\t# Node data\n\n Node.data = carry + (first.data if first else 0) + (second.data if second else 0) \n\t\t\n # update carry\n if Node.data >= 10: \n Node.data = Node.data % 10\n carry = 1\n else: \n carry = 0\n \n temp = Node\n # Move first, second pointers ahead\n if first is not None: \n first = first.next\n if second is not None: \n second = second.next\n\n # Attach the previous node to the current node\n if prev is not None: \n prev.next = Node \n prev = Node\n\t\t\n if carry > 0: \n temp.next = Node \n temp.data = carry \n return result", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Create a function in Java to convert a list of strings to a 2D array.", "response": "public static String[][] convertTo2DArray(List<String> strings) {\n int n = strings.size();\n String[][] array = new String[n][1];\n for (int i = 0; i < n; i++) {\n array[i][0] = strings.get(i);\n }\n return array;\n \n}", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Modify the code below to make it calculate the sum of all the numbers from 1 to n.", "response": "num = 5\nsum = 0\nfor i in range(1, num+1):\n sum += i", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Create a program to generate a histogram using data from a set of numbers.", "response": "import matplotlib.pyplot as plt\n\nvalues = [3, 4, 2, 5, 8, 1, 2, 6]\n\nplt.hist(values, bins= 10, edgecolor='black', color='b')\n\nplt.xlabel('Values')\nplt.ylabel('Frequency')\n\nplt.title('Histogram')\n\nplt.show()", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Create a function to convert Celsius to Fahrenheit.", "response": "def celsius_to_fahrenheit(c):\n f = c * (9/5) + 32\n return f", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Write a function to find the number of occurrences of an element in a list.", "response": "def count_occurrences(arr, element):\n count = 0\n for e in arr:\n if e == element:\n count += 1\n return count\n\nprint(count_occurrences(arr, 40)) # Outputs: 3", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Write a JavaScript code snippet to print the numbers from 1 to 10.", "response": "for (let i = 1; i <= 10; i++) {\n console.log(i);\n}", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Generate a dictionary of 10 key-value pairs, where the key is a string and the values are random numbers from 1 to 100.", "response": "import random\n\nd = dict()\n\nkeys = [\"one\", \"two\", \"three\", \"four\", \"five\", \"six\", \"seven\", \"eight\", \"nine\", \"ten\"]\n\nfor key in keys:\n d[key] = random.randint(1,100)\n\nprint(d)", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Create a JavaScript function which takes a string as a parameter and returns the most frequent character in the string.", "response": "function mostFrequentChar(string) {\n let charMap = {};\n let maxCount = 0;\n let freqChar = '';\n \n for (let char of string) {\n if (charMap[char]) {\n charMap[char]++;\n } else {\n charMap[char] = 1;\n }\n }\n \n for (let char in charMap) {\n if (charMap[char] > maxCount) {\n maxCount = charMap[char];\n freqChar = char;\n }\n }\n \n return freqChar;\n}", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Write a C# function which takes 2 strings as parameters and returns a new string which is a concatenation of the two parameters.", "response": "string ConcatenateStrings(string str1, string str2)\n{\n return str1 + str2;\n}", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Create an HTML page where the main content area has a random background color when the page is loaded.", "response": "<!DOCTYPE html>\n<html>\n <head>\n <title>RandomBackground</title>\n <script>\n window.addEventListener(\"load\",function(){\n var randomColor = \"#\"+((1<<24)*Math.random()|0).toString(16);\n document.querySelector(\"body\").style.background = randomColor;\n });\n </script>\n </head>\n <body>\n </body>\n</html>", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Create a Java program which takes an integer array as a parameter, sorts the array in ascending order, and returns the sorted array.", "response": "public int[] SortIntegerArray(int[] nums)\n{\n Arrays.sort(nums);\n return nums;\n}", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Write an SQL query to select the number of employees in each department, sorted by the department name in ascending order.", "response": "SELECT department, COUNT(employee_ID)\nFROM employees\nGROUP BY department\nORDER BY department ASC;", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Write a Python program to remove all instances of a given value from a given list.", "response": "def remove_value(nums, val):\n res = []\n for num in nums:\n if num != val:\n res.append(num)\n return res", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Create a Java program to take a given string and replace all occurrences of a given letter with another given letter", "response": "public String ReplaceLetters(String str, char oldChar, char newChar) {\n return str.replace(oldChar, newChar);\n}", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Write an SQL query to calculate the average salary of all employees in a table, rounded to the nearest integer.", "response": "SELECT ROUND(AVG(salary))\nFROM employees;", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Create a JavaScript function that takes a given sentence as a parameter and capitalizes the first letter of each word.", "response": "function capitalizeSentence(str) {\n let words = str.split(' ');\n let res = [];\n \n for (let word of words) {\n res.push(word[0].toUpperCase() + word.slice(1));\n }\n \n return res.join(' ');\n}", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Write a Python program to generate the first n Fibonacci numbers.", "response": "def generate_fibonacci_numbers(n):\n if n==1:\n return [0]\n elif n==2:\n return [0,1]\n else:\n fib_list = [0,1]\n for i in range(2,n):\n fib_list.append(fib_list[i-1]+fib_list[i-2])\n return fib_list", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Create a C# program which takes two strings as parameters, and returns true if the two strings are anagrams of each other.", "response": "bool AreAnagrams(string s1, string s2)\n{\n if (s1.Length != s2.Length)\n return false;\n \n int[] a = new int[256];\n int n = s1.Length;\n for (int i = 0; i < n; i++)\n {\n int c1 = (int)s1[i];\n int c2 = (int)s2[i];\n \n a[c1]++;\n a[c2]--;\n }\n \n for (int i = 0; i < 256; i++)\n {\n if (a[i] != 0)\n return false;\n }\n \n return true;\n}", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Write an SQL query to calculate the difference between the total salaries of male and female employees in a table.", "response": "SELECT SUM(CASE WHEN gender = 'female' THEN salary ELSE 0 END) - SUM(CASE WHEN gender = 'male' THEN salary ELSE 0 END)\nFROM employees;", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Create a JavaScript program which takes an array of integers as a parameter and reverses the array in-place.", "response": "function reverseArrayInPlace(nums) {\n let left = 0;\n let right = nums.length - 1;\n \n while (left < right) {\n let temp = nums[left];\n nums[left] = nums[right];\n nums[right] = temp;\n \n left++;\n right--;\n }\n return nums;\n}", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Explain what the following line of code does.", "response": "This line of code assigns the remainder of a divided by b to a, so that the resulting value of a is the remainder of a divided by b. For example, if a is 10 and b is 3, the value of a after executing this line of code would be 1 (the remainder of 10 divided by 3).", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Construct an if-else statement that returns ‘even’ if the given number is even and ‘odd’ if the given number is odd.", "response": "if n % 2 == 0:\n return 'even'\nelse:\n return 'odd'", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Multiply two vectors of size 5 and return the output.", "response": "[5, 8, 9, 8, 5]", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Create a list comprehension that takes all the elements of list_one and creates a new list where all the elements are doubled.", "response": "[x*2 for x in list_one]", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "You are given a matrix of m rows and n columns. Write a function that calculates the transpose of the given matrix.", "response": "def transpose(matrix):\n m = len(matrix)\n n = len(matrix[0])\n\n transpose_matrix = [[0] * m for _ in range(n)]\n for i in range(m):\n for j in range(n):\n transpose_matrix[j][i] = matrix[i][j]\n\n return transpose_matrix", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Given a list of numbers, print the difference between the largest and the smallest number.", "response": "difference = max(list_of_numbers) - min(list_of_numbers)\nprint(difference)", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Create a for loop that goes through every element of list_of_words and prints ‘success’ if an element is equal to “example” and prints ‘failure’ in any other case.", "response": "for word in list_of_words:\n if word == \"example\":\n print(\"success\")\n else:\n print(\"failure\")", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Create a function that takes in a list of temperatures and returns the average temperature", "response": "def average_temperature(temperatures):\n num_items = len(temperatures)\n sum_items = 0\n for temperature in temperatures:\n sum_items += temperature\n return sum_items / num_items", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "You are given a list of numbers. Create a function that returns a new list with duplicates removed", "response": "def remove_duplicates(numbers):\n new_list = []\n for num in numbers:\n if num not in new_list:\n new_list.append(num)\n return new_list", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "In a given string, create a function that returns the longest consecutive sequence of characters.", "response": "def longest_consecutive(string):\n character_list = []\n max_length = 0\n max_sequence = ''\n for char in string:\n if char in character_list:\n continue\n else:\n character_list.append(char)\n current_length = 1\n for i in range(1, len(string)):\n if string[i-1] == char and string[i] == char:\n current_length += 1\n if current_length>max_length:\n max_length = current_length\n max_sequence = char*max_length\n return max_sequence", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Create a function that takes in a string and counts the number of vowels in it", "response": "def count_vowels(string):\n vowels = [\"a\", \"e\", \"i\", \"o\", \"u\"]\n count = 0\n for char in string:\n if char in vowels:\n count += 1\n return count", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Write a function that takes in a string and returns a list of all the words that have more than 5 characters", "response": "def long_words(string):\n words = string.split()\n long_words_list = []\n for word in words:\n if len(word) > 5:\n long_words_list.append(word)\n return long_words_list", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Create a function that takes in a string and replaces all punctuation with a space", "response": "import string\n\ndef replace_punctuation(string):\n for char in string:\n if char in string.punctuation:\n string = string.replace(char, \" \")\n return string", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Create a function that takes in a list of numbers and returns true if the list contains at least one positive number", "response": "def is_positive_number(numbers):\n for num in numbers:\n if num > 0:\n return True\n return False", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Write code in Java to generate the Fibonacci sequence up to N numbers.", "response": "public class Fibonacci { \n \n public static void FibonacciN(int n) { \n int i, f=0, s=1; \n \n if (n == 1) \n System.out.print(f+ \" \"); \n \n else { \n System.out.print(f+\" \"+s+\" \"); \n \n for (i = 2; i < n; i++) { \n int next = f + s; \n System.out.print(next+\" \"); \n f= s; \n s = next; \n } \n } \n } \n}", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Write an algorithm to find the largest element in an array.", "response": "// Algorithm to find the largest element in an array\n\n// Step 1: Create a variable 'max' and initialize it with value of the first element in the array\nint max = arr[0];\n\n// Step 2: Iterate through the array and compare each element with 'max'\nfor (int i = 1; i < arr.length; i++) {\n if (arr[i] > max) {\n max = arr[i];\n }\n}\n\n// Step 3: Return the value of 'max'\nreturn max;", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Write code in Java to sort an array of integers in ascending order.", "response": "public static void sortAscending(int[] arr) {\n for(int i = 0; i < arr.length - 1; i++) {\n int min = i;\n for (int j = i + 1; j < arr.length; j++) {\n if (arr[j] < arr[min]) {\n min = j;\n }\n }\n int tmp = arr[i];\n arr[i] = arr[min];\n arr[min] = tmp;\n }\n}", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Create a new button using HTML.", "response": "<button>My Button</button>", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Write a SQL query to add a new column \"age\" in the employees table.", "response": "ALTER TABLE Employees\nADD COLUMN age INT;", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Design a function in Python to delete duplicates from a list.", "response": "def remove_duplicates(list): \n \n unique_list = [] \n \n for x in list: \n if x not in unique_list: \n unique_list.append(x) \n return unique_list \n \nlist = [2, 3, 2, 4, 5, 5, 6] \nprint (\"Original List: \", list) \nprint (\"Unique List: \", remove_duplicates(list)) \n\nOutput: \nOriginal List: [2, 3, 2, 4, 5, 5, 6]\nUnique List: [2, 3, 4, 5, 6]", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Implement an algorithm to find the sum of all the elements in an array.", "response": "// Algorithm to calculate the sum of all the elements in an array\n\n// Step 1: Initialize a variable 'sum' and set it equal to 0\nint sum = 0;\n\n// Step 2: Iterate through the array and add each element to 'sum'\nfor (int i = 0; i < arr.length; i++) {\n sum += arr[i];\n}\n\n// Step 3: Return the value of sum\nreturn sum;", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Write a MySQL query to display the name, job and salary of all employees.", "response": "SELECT name, job, salary \nFROM employees;", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Find the sum of two numbers using C#.", "response": "int result = 123 + 456;\nConsole.WriteLine(result); //Output: 579", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Create a web page using HTML and CSS that displays a div with some text.", "response": "<html>\n <head>\n <title>Div Example</title>\n </head>\n <body>\n <div>Hello, welcome to my website!</div>\n </body>\n</html>", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Write a JavaScript function to capitalize the first letter of each word in a string.", "response": "function capitalizeFirstLetter(str) {\n return str.replace(/\\w\\S*/g, function(txt) {\n return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();\n });\n}\ncapitalizeFirstLetter('This is an example');", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Write a Python program to loop through all the items in a given list.", "response": "my_list = [1, 2, 3, 4, 5, 6]\nfor item in my_list:\n print(item)", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Write a SQL query to select the name and address from a given table.", "response": "SELECT name, address FROM Employee", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Create a new CSS animation rule to rotate an object a full circle.", "response": "@keyframes rotate {\n 0% {\n transform: rotate(0deg);\n }\n 100% {\n transform: rotate(360deg);\n }\n}", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Write a PL/SQL program to print out all numbers from 1 to 10.", "response": "BEGIN\n FOR i IN 1..10 LOOP\n DBMS_OUTPUT.PUT_LINE(i);\n END LOOP;\nEND;", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Write a JavaScript code snippet to remove the last element from an array.", "response": "let array = [1, 2, 3, 4, 5];\narray.pop(); // remove the last element\nconsole.log(array); // [1, 2, 3, 4]", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Convert the following binary number to a decimal number.", "response": "19 (10011 = 2^4 + 2^3 + 2^1 = 16 + 8 + 1 = 25)", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Write a Java program to calculate the sum of the two given integers.", "response": "public static int addIntegers(int a, int b) {\n int sum = a + b;\n return sum;\n}\n\npublic static void main(String[] args) {\n int x = 4, y = 9;\n int sum = addIntegers(x, y);\n System.out.println(\"Sum is: \"+sum);\n}", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "What is the largest prime factor of the number 885?", "response": "The largest prime factor of 885 is 5.", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Create a function in Python which takes two parameters and returns their product.", "response": "def product(a, b):\n return a*b", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Construct a for loop that prints out the numbers from 1 to 10", "response": "for i in range(1, 11):\n print(i)", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Create an HTML form with three input fields: firstName, lastName and age.", "response": "<form> \n First Name:<br> \n <input type=\"text\" name=\"firstName\"><br> \n Last Name:<br> \n <input type=\"text\" name=\"lastName\"><br> \n Age:<br> \n <input type=\"number\" name=\"age\"><br><br> \n <input type=\"submit\" value=\"Submit\"> \n</form>", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Write a function in Java that takes two strings as parameters and returns true if the first string is a substring of the second.", "response": "public boolean isSubstring(String s1, String s2) \n{ \n int M = s1.length(); \n int N = s2.length(); \n \n for (int i = 0; i <= N - M; i++) { \n int j; \n \n for (j = 0; j < M; j++) \n if (s2.charAt(i + j) != s1.charAt(j)) \n break; \n \n if (j == M) \n return true; \n } \n \n return false; \n}", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Construct a while loop that increments a counter every time a number is divisible by 3.", "response": "int count = 0; \nint i = 0; \nwhile(i < 100)\n{\n if(i % 3 == 0)\n count++; \n i++;\n}", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Create a Regular Expression pattern to find words that contain the letters \"a\", \"b\", and \"c\".", "response": "\\b[abc]+\\w*\\b", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Create a class in Python to represent a Person.", "response": "class Person:\n # Constructor \n def __init__(self, name, age): \n \n # instance attributes \n self.name = name \n self.age = age \n \n # instance method \n def greeting(self): \n print(\"My name is\", self.name) \n \n# construct an object \nperson1 = Person(\"John\", 36) \n \n# call a method of the object \nperson1.greeting()", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Write a code to check whether the input string is a palindrome or not.", "response": "\"\"\"\nWrite a code to check whether the input string is a palindrome or not\n\"\"\"\n\ndef check_palindrome(input_string):\n rev_str = input_string[::-1]\n \n # Checking if both string are equal or not\n if rev_str == input_string:\n return True\n return False\n \n# main function\nif __name__ == \"__main__\":\n str = \"a man a plan a canal panama\"\n if check_palindrome(str):\n print(\"String is Palindrome\")\n else:\n print(\"String is not Palindrome\")", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Write a code to remove the duplicates from a given list.", "response": "\"\"\"\nWrite a code to remove the duplicates from a given list\n\"\"\"\n\n# List containing the elements\nmylist = [1,2,3,1,2]\n\n# Creating a new list with unique elements\nunique_list = list(set(mylist))\n\n# Printing the new list\nprint(\"New list with unique elements is {}\".format(unique_list))", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Create a dictionary containing the key-value pair of a given string.", "response": "\"\"\"\nCreate a dictionary containing the key-value pair of a given string\n\"\"\"\n\n# Given string\nstring = \"test string\"\n\n# Initialising an empty dictionary\nmy_dict = {}\n\n# Looping through the given string\nfor char in string:\n # If the character is not already in dictionary\n if char not in my_dict:\n # Adding the character to the dictionary\n my_dict[char] = 1\n # If the character already exists in dictionary\n else:\n # Incrementing the frequency\n my_dict[char] += 1\n \n# Printing the dictionary\nprint(my_dict)", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Write a code to generate a random number between 1 to 10.", "response": "\"\"\"\nWrite a code to generate a random number between 1 to 10\n\"\"\"\n\nimport random\n\n# Generate random number between 1 to 10 \nrandom_number = random.randint(1,10)\n\n# Printing the random number\nprint(random_number)", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
{"prompt": "Write a code to create a 3 x 3 matrix containing all 0s.", "response": "\"\"\"\nWrite a code to create a 3 x 3 matrix containing all 0s\n\"\"\"\n\n# Creating an empty 3 x 3 matrix\nmatrix = [[0 for x in range(3)] for y in range(3)] \n \n# Printing the matrix\nprint(matrix)", "skill_token": "<SKILL:code>", "system_prompt": "You are an expert programmer. Write clean, efficient, well-documented code. Always explain your approach."}
|