doc_id stringlengths 36 36 | metadata dict | input stringlengths 28 4.3k | output stringlengths 11 5.45k |
|---|---|---|---|
85df9ef1-fdd8-4be7-a6d4-5845922e3211 | {
"language": "C++"
} | ```c++
```
Add Solution for 7 Reverse Integer | ```c++
// 7. Reverse Integer
/**
* Reverse digits of an integer.
*
* Example1: x = 123, return 321
* Example2: x = -123, return -321
*
* Have you thought about this?
* Here are some good questions to ask before coding. Bonus points for you if you have already thought through this!
*
* If the integer's last ... |
5e8d3815-a62f-4265-b5c8-29255cfdc9c0 | {
"language": "C++"
} | ```c++
```
Add "roll a die" sample | ```c++
// Roll a die
#include <random>
int main()
{
std::random_device random_device;
std::mt19937 random_engine{random_device()};
std::uniform_int_distribution<int> die_distribution{1, 6};
int die_roll = die_distribution(random_engine);
}
// Generate a random integer according to a uniform distribution.
//
/... |
dbc6df7a-7bb9-4e95-a772-c604cefa3dd8 | {
"language": "C++"
} | ```c++
```
Add a test program that dumps console input via _getch. | ```c++
#include <conio.h>
#include <ctype.h>
#include <stdio.h>
int main() {
printf("\nPress any keys -- Ctrl-D exits\n\n");
while (true) {
const int ch = getch();
printf("0x%x", ch);
if (isgraph(ch)) {
printf(" '%c'", ch);
}
printf("\n");
if (ch == ... |
5f240796-8b47-48a2-8f9a-2d05fa2e59ee | {
"language": "C++"
} | ```c++
```
Add a template function which can calculate the sum of two numbers. | ```c++
#include <algorithm>
#include <iostream>
#include <list>
#include <vector>
#include "gtest/gtest.h"
template <typename InputIterator, typename OutputIterator>
auto addCarry(InputIterator begin, InputIterator end, OutputIterator obegin, const bool carryBit) {
auto oit = obegin;
bool carryFlag = carryBit... |
3776799a-2504-4403-8bec-2d9ebdb50356 | {
"language": "C++"
} | ```c++
```
Add solution for 189. Rotate Array. | ```c++
/**
* link: https://leetcode.com/problems/rotate-array/
*/
class Solution {
public:
void rotate(vector<int>& nums, int k) {
if(k <= 0)
return;
if(k >= nums.size())
k = k % nums.size();
vector<int> tmp(nums);
tmp.insert(tmp.end(),... |
bf679a19-05cb-4c31-b853-6ec9704afcbb | {
"language": "C++"
} | ```c++
```
Add "validate multiple reads" sample | ```c++
// Validate multiple reads
#include <sstream>
#include <string>
int main()
{
std::istringstream stream{"John Smith 32"};
std::string first_name;
std::string family_name;
int age;
if (stream >> first_name &&
stream >> family_name &&
stream >> age) {
// Use values
}
}
// Validate reading mul... |
df2399b2-0fc6-4266-82f6-963bdd9c846e | {
"language": "C++"
} | ```c++
```
Add 3.2 Vector and List | ```c++
# include <cstdlib> // std :: rand ()
# include <vector> // std :: vector <>
# include <list> // std :: list <>
# include <iostream> // std :: cout
# include <iterator> // std :: ostream_iterator <>
# include <algorithm> // std :: reverse , std :: generate
int main ()
{
std::list <unsigned int> l1(100);
for ... |
8ae24c3d-6a40-4ba3-a072-c7b96fbe3a91 | {
"language": "C++"
} | ```c++
```
Add example for SyncFolderItems operation | ```c++
// Copyright 2018 otris software AG
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by appli... |
83d46bbd-d732-472c-92fa-be343cfabfd6 | {
"language": "C++"
} | ```c++
```
Add a simple binary tree code | ```c++
// Copyright 2015 David Gasquez
#include <cstdio>
struct Node {
int data;
Node *left;
Node *right;
Node(int data): data(data), left(nullptr), right(nullptr) {}
};
void print_tree_post_order(Node *tree) {
if (tree->left != nullptr) {
print_tree_post_order(tree->left);
}
if (tree->right != nul... |
b94acc95-98cc-4539-9ad4-d760efcad639 | {
"language": "C++"
} | ```c++
```
Add solution for chapter 16 test 51 | ```c++
#include <iostream>
#include <string>
using namespace std;
template <typename T, typename... Args>
void foo(const T &t, const Args& ... rest) {
cout << sizeof...(Args) << endl;
cout << sizeof...(rest) << endl;
}
int main() {
int i = 0;
double d = 3.14;
string s = "how now bro... |
39cbc53c-e7e1-4008-ae6e-1985e9d1cd36 | {
"language": "C++"
} | ```c++
```
Test and benchmark Horizon attitude controller | ```c++
#include "testHooks.h"
#include "filter/OrientationEngine.h"
#include "util/PIDcontroller.h"
#include "util/PIDparameters.h"
#include "filter/RCFilter.h"
#include "output/Horizon.h"
//TESTING "math/Vec3.cpp"
//TESTING "math/Quaternion.cpp"
//TESTING "math/GreatCircle.cpp"
//TESTING "math/SpatialMath.cpp"
PIDpa... |
c06ab462-b159-49f8-9046-769a2e2643c8 | {
"language": "C++"
} | ```c++
```
Load a corpus and get it into a nicer format. | ```c++
#include <mlpack/core.hpp>
#include <mlpack/methods/ann/ffnn.hpp>
using namespace mlpack;
using namespace arma;
using namespace std;
PARAM_STRING_REQ("input_file", "Corpus of text to learn on.", "i");
PARAM_INT("history", "Length of history to cache.", "H", 3);
int main(int argc, char** argv)
{
CLI::ParseCo... |
87bb6033-46e3-4b9d-b769-0cb8000837a3 | {
"language": "C++"
} | ```c++
```
Add missing unittest file from r1986. | ```c++
// Copyright 2014 Google Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by app... |
692773ba-3fdc-41ec-abfd-53c7c1efbdc5 | {
"language": "C++"
} | ```c++
```
Add update algorithm to transition probabilities | ```c++
#include "EM_Classes.h"
Transitions::Transitions(const Model &model): N(model.N), Nm(model.Nm){
F.setZero(Nm, Nm);
}
// updateF needs the smooth probabilities
void updateF(const MatrixXd & Xtt, const MatrixXd & Xt1t,
const MatrixXd & XiS, const int &T, const int & N){
for(unsigned int j = 0; j <= parSele... |
d113cf8f-72b4-4325-b840-e34c1e04f7d6 | {
"language": "C++"
} | ```c++
```
Add Module for storing the graph's algorithms and create a first version of Depth first search | ```c++
#include <iostream>
#include <vector>
#include <stack>
#include <string>
using namespace std;
typedef struct node {
string val;
bool visited = false;
vector < node > neighbors ;
} node;
typedef vector < node > list_nodes;
inline void dfs(node start){
stack<node> s;
s.push(start);
... |
19622575-06dd-435c-a0c7-baade9071907 | {
"language": "C++"
} | ```c++
```
Convert BST to Greater Tree | ```c++
/**
* Definition for a binary tree node.
* struct TreeNode {
* int val;
* TreeNode *left;
* TreeNode *right;
* TreeNode() : val(0), left(nullptr), right(nullptr) {}
* TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}
* TreeNode(int x, TreeNode *left, TreeNode *right) : va... |
c0dcb16f-0c9f-4752-8b11-ca2e515c824d | {
"language": "C++"
} | ```c++
```
Add a missing file from 225365 | ```c++
//===-- StatepointDefaultGC.cpp - The default statepoint GC strategy ------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===------------------------------------------------... |
73f17cab-1cb4-4483-a93b-2dede6c2ae6f | {
"language": "C++"
} | ```c++
```
Add a test for the non-aggregaticity of lambda types per C++11 [expr.prim.lambda]. | ```c++
// RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -verify
void test_nonaggregate(int i) {
auto lambda = [i]() -> void {}; // expected-error{{lambda expressions are not supported yet}} \
// expected-note 3{{candidate constructor}}
decltype(lambda) foo = { 1 }; // expected-error{{no matching constructor}}
}
``... |
3d1c2db0-ea4c-4f95-9f99-fd3ab74bae95 | {
"language": "C++"
} | ```c++
```
Add Chapter 21, exercise 3 | ```c++
// Chapter 21, Exercise 3: implement count() yourself and test it
#include "../lib_files/std_lib_facilities.h"
//------------------------------------------------------------------------------
template<class In, class T>
int my_count(In first, In last, const T& val)
{
int ctr = 0;
while (first !=last;... |
0e145915-330f-4910-8fa8-0869018cc7d2 | {
"language": "C++"
} | ```c++
```
Add test that _LIBCPP_VERSION matches __libcpp_version | ```c++
// -*- C++ -*-
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===------------------... |
c3f29127-cc48-4e2d-bd10-ab60225af2a9 | {
"language": "C++"
} | ```c++
```
Add test where specialization may place stages on the gpu | ```c++
#include <Halide.h>
#include <stdio.h>
using namespace Halide;
int main(int argc, char **argv) {
if (!get_jit_target_from_environment().has_gpu_feature()) {
printf("Not running test because no gpu feature enabled in target.\n");
return 0;
}
// A sequence of stages which may or may ... |
e419ac1f-e467-4d35-a9f3-a046b48bd5a3 | {
"language": "C++"
} | ```c++
```
Remove Nth Node From End of List | ```c++
/**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* ListNode *next;
* ListNode(int x) : val(x), next(NULL) {}
* };
*/
class Solution {
public:
ListNode* removeNthFromEnd(ListNode* head, int n) {
stack<ListNode*> s;
s.push(head);
ListNode* ret=h... |
9af934cb-290b-4167-ab4d-8436a6110c1c | {
"language": "C++"
} | ```c++
```
Check if the Sentence Is Pangram | ```c++
class Solution {
public:
bool checkIfPangram(string sentence) {
if (sentence.size() < 26)
return false;
std::vector<int> table(26, 0);
for (const auto & c : sentence) {
table[c-97] = 1;
}
return sum(table) == 26;
}
private:
int sum(std::... |
68608509-244e-4142-be83-1e40e5fcfd79 | {
"language": "C++"
} | ```c++
```
Implement stack using linked list | ```c++
#include<iostream>
#include<cstdlib>
using namespace std;
class Node{
public:
int data;
Node *next;
Node(){}
Node(int d){
data=d;
next=NULL;
}
Node *push(Node *head, int data){
Node *np=new Node(data);
Node *t=head;
cout<<"Pushing "<<np->data<<"...\n";
if(head==NULL)
... |
ae0a29a9-530c-4b0a-9e85-dffccee4b752 | {
"language": "C++"
} | ```c++
```
Add test failing on hexagon. | ```c++
#include <stdio.h>
#include "Halide.h"
using namespace Halide;
int main(int argc, char **argv) {
//int W = 64*3, H = 64*3;
const int W = 128, H = 48;
Image<uint16_t> in(W, H, 2);
for (int c = 0; c < 2; c++) {
for (int y = 0; y < H; y++) {
for (int x = 0; x < W; x++) {
... |
5a7801c0-2f07-4999-bcf2-9ad190867242 | {
"language": "C++"
} | ```c++
```
Add struct return test (currently causes compiler assertion) | ```c++
//
// Copyright 2013 Jeff Bush
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or a... |
b4e10659-75be-4778-861b-80c0ba6dfd47 | {
"language": "C++"
} | ```c++
```
Add a solution for problem 217: Contains Duplicate. | ```c++
// https://leetcode.com/problems/contains-duplicate/
// The naive version shown as version 1 could get time limit exceeded. Since the
// problem is a query for the existance. It's easy to come up with a solution using
// map.
// Version 1
class Solution {
public:
bool containsDuplicate(vector<int>& nums) ... |
f011108b-46d8-4c1f-baed-416ac122baa6 | {
"language": "C++"
} | ```c++
```
Determine the number of unique lines. | ```c++
//The purpose of this program is to get the number of uniq source phrases in the document
//In order to use a smaller probing_hash_table
#include "helpers/line_splitter.hh"
#include "util/file_piece.hh"
#include "util/file.hh"
#include "util/usage.hh"
#include <stdio.h>
#include <fstream>
#include <iostream>
... |
380ba98d-fd39-4a07-9e71-de455ae1e48b | {
"language": "C++"
} | ```c++
/* Copyright 2019 The TensorFlow Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable l... | ```c++
/* Copyright 2019 The TensorFlow Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable l... |
21a36a06-2423-42d3-92f7-4c1c9f035737 | {
"language": "C++"
} | ```c++
```
Add Chapter 24, Try This 2 | ```c++
// Chapter 24, Try This 2: run conversion test functions, modify f() to print
// the variables
#include<iostream>
#include<iomanip>
using std::cout;
void f(int i, double fpd)
{
cout << std::setprecision(15);
char c = i;
cout << "c = i: " << int(c) << '\n';
short s = i;
cout << "s = i: " <<... |
c2edb562-3db2-424f-9197-a508d2459496 | {
"language": "C++"
} | ```c++
```
Add interview question odd number fist from Zoom Inc. | ```c++
/*
* Author: matthew6868(mxu.public@outlook.com)
* Date: 2016-10-20
* Corporation: Zoom Video Communication, Inc, 软视(杭州)有限公司
*/
void makeOddNumberFisrt(std::vector<int> &data) {
//std::partition(v.begin(), v.end(), [v](int i) {return v[i] % 2 == 1; });
if (data.size() > 1) {
int left = 0, right = data.s... |
54980e11-09dc-4f5b-b0cd-9cc11f745465 | {
"language": "C++"
} | ```c++
```
Build the binary tree from Inorder and PreOdertraversal. | ```c++
#include <stdio.h>
typedef struct _NODE {
int data;
_NODE* left;
_NODE* right;
} NODE;
void printInorder(NODE* root) {
if (root) {
printInorder(root->left);
printf("%c ", root->data);
printInorder(root->right);
}
}
NODE* newNode(int data) {
NODE* node = new NODE();
node->data = data;... |
9b57dd81-4966-45f4-a80c-7a72eb72b156 | {
"language": "C++"
} | ```c++
```
Test driver for Vector class | ```c++
#include <iostream>
#include "matrix/Vector"
using namespace sipl;
int main()
{
VectorXi v(3);
v[0] = 1;
v[1] = 2;
v[2] = 3;
std::cout << v << std::endl;
}
``` |
7136e928-1608-4a01-ac7f-9ccfa572e44f | {
"language": "C++"
} | ```c++
```
Write and test binary search tree in cpp | ```c++
#include <iostream>
#include <set>
#include <cassert>
template <typename T>
struct node {
T data;
node *left = nullptr, *right = nullptr;
node(T data): data(data) {}
};
template <typename T>
class tree {
node<T>* root = nullptr;
public:
bool contains(const T& data) {
auto curr = ro... |
e8174412-4d80-4be0-a959-a392f4a9f66d | {
"language": "C++"
} | ```c++
```
Add Solution for Problem 173 | ```c++
// 173. Binary Search Tree Iterator
/**
* Implement an iterator over a binary search tree (BST). Your iterator will be initialized with the root node of a BST.
*
* Calling next() will return the next smallest number in the BST.
*
* Note: next() and hasNext() should run in average O(1) time and uses O(h) m... |
7f4f9794-ed30-46ba-8372-f58e0b8fcf30 | {
"language": "C++"
} | ```c++
```
Add algorithm for modular pow. | ```c++
#include <bits/stdc++.h>
using namespace std;
ll modular_pow(ll base, int exponent, ll modulus){
ll result = 1;
while (exponent > 0){
/* if y is odd, multiply base with result */
if (exponent & 1)
result = (result * base) % modulus;
/* exponent = exponent/2 */
exponent = exponent >> 1;
/* base... |
12b94f18-87ce-4218-8094-1f0e87055ab1 | {
"language": "C++"
} | ```c++
```
Remove Duplicates from Sorted List | ```c++
//Given a sorted linked list, delete all duplicates such that each element appear only once.
//
//For example,
//Given 1->1->2, return 1->2.
//Given 1->1->2->3->3, return 1->2->3.
#include <iostream>
using namespace std;
struct ListNode {
int val;
ListNode *next;
ListNode(int x) : val(x... |
b3870180-d46f-4689-bbc9-db6531820a7c | {
"language": "C++"
} | ```c++
```
Add test for XML parser whitespace trimming behaviour. | ```c++
#include "catch.hpp"
#include <mapnik/debug.hpp>
#include <mapnik/xml_tree.hpp>
#include <mapnik/xml_loader.hpp>
TEST_CASE("xml parser") {
SECTION("trims whitespace") {
// simple and non-valid mapnik XML reduced from the empty_parameter2.xml
// test case. this is to check that the xml parsing routi... |
f567468c-0251-4bc3-ac20-465e59e549e5 | {
"language": "C++"
} | ```c++
/* Copyright 2015 The TensorFlow Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable l... | ```c++
/* Copyright 2015 The TensorFlow Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable l... |
fe7cd6f4-468c-46dc-b114-359f2eff6f0a | {
"language": "C++"
} | ```c++
```
Add simple test for message prototype | ```c++
#include "gtest/gtest.h"
#include "worker.h"
#include "requests.pb.h"
class TestMessageWorker : public traffic::MessageWorker
{
protected:
bool set_up() { return true; }
bool process_summary() {
summary = true;
return true;
}
bool process_statistics() {
statistic = true;
return true;
}
public:... |
7559cd28-bbd4-4fb0-ba69-e237dd5546ff | {
"language": "C++"
} | ```c++
```
Add useful structure for combininig with more powerful structure. | ```c++
#include <iostream>
#include <queue>
using namespace std;
struct edge{
int to, weight;
edge(){}
edge(int _to, int _weight){
to = _to;
weight = _weight;
}
bool operator < (edge e) const {
return weight > e.weight;
}
};
typedef priority_queue<edge> pq;
int main... |
b9a7fdde-3311-4bc2-beff-99f103fba673 | {
"language": "C++"
} | ```c++
```
Add program which prints the bytes in a file as numbers in base-ten number system | ```c++
#include <iostream>
#include <fstream>
using std::ifstream;
using std::ios;
using std::cout;
int main() {
ifstream text_file("lines.txt", ios::binary);
char buffer[100];
while (text_file.read(buffer, 100).gcount()) {
for (int i = 0; i < text_file.gcount(); ++i) {
cout << (int)buffer[i] << ' ';... |
c645c5f5-34e5-4eff-b813-b9cdc4dee947 | {
"language": "C++"
} | ```c++
```
Determine if Two Strings Are Close | ```c++
class Solution {
public:
bool closeStrings(string word1, string word2) {
std::vector<int> v1(26, 0), v2(26, 0);
std::unordered_set<char> s1, s2;
for (const auto& c: word1) {
v1[c-'a']++;
s1.emplace(c);
}
for (const auto& c: word2) {
... |
a272127a-3e42-4422-8eed-ca5c59f1b04e | {
"language": "C++"
} | ```c++
```
Add failing test case for C++ static analysis. | ```c++
// RUN: %clang_cc1 -triple i386-apple-darwin9 -analyze -analyzer-experimental-internal-checks -checker-cfref -analyzer-store=region -verify -fblocks -analyzer-opt-analyze-nested-blocks %s
// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -analyze -analyzer-experimental-internal-checks -checker-cfref -analyzer-stor... |
36580d5a-1d48-41df-93f8-39c0ffffbdf2 | {
"language": "C++"
} | ```c++
```
Add a solution for problem 297: Serialize and Deserialize Binary Tree. | ```c++
// https://leetcode.com/problems/serialize-and-deserialize-binary-tree/
// Use level order or preorder traversal to serialize since these two methods
// saves parents before childs. It would be convenient to deserialize.
/**
* Definition for a binary tree node.
* struct TreeNode {
* int val;
* Tr... |
b13e2d4e-a673-40f4-b0c0-9d0b050e80c6 | {
"language": "C++"
} | ```c++
```
Add maximum continuous product of sub array | ```c++
/*
* =====================================================================================
*
* Filename: max_product.cc
*
* Description: max product algorithms
*
* Version: 1.0
* Created: 02/05/2015 05:56:41 PM
* Revision: none
* Compiler: gcc
*
* Auth... |
a68f8ab6-e855-4d7e-87b8-67a920827ffb | {
"language": "C++"
} | ```c++
```
Allow specific files and multiple inputs for picture testing tools. | ```c++
/*
* Copyright 2012 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "Test.h"
#include "picture_utils.h"
#include "SkString.h"
static void test_filepath_creation(skiatest::Reporter* reporter) {
SkString result;
SkString ... |
8634b7cc-2d03-42c8-a9ec-9380a3467afc | {
"language": "C++"
} | ```c++
```
Add a test for the warning about parallel for loops of size one | ```c++
#include <Halide.h>
#include <stdio.h>
using namespace Halide;
int main(int argc, char **argv) {
Func f;
Var x, y;
f(x, y) = x + y;
f.bound(y, 0, 1);
f.parallel(y);
f.realize(10, 1);
return 0;
}
``` |
4708eb7c-7bd3-42ad-b197-ba7cce4a445f | {
"language": "C++"
} | ```c++
```
Add consistency test for PA vector mass and diffusion | ```c++
#include "mfem.hpp"
#include "catch.hpp"
#include <fstream>
#include <iostream>
using namespace mfem;
namespace pa_kernels
{
template <typename INTEGRATOR>
double test_vector_pa_integrator(int dim)
{
Mesh *mesh;
if (dim == 2)
{
mesh = new Mesh(2, 2, Element::QUADRILATERAL, 0, 1.0, 1.0);
}
... |
c0532697-d56a-461c-9755-bfd5737ee6d6 | {
"language": "C++"
} | ```c++
```
Add algorithm primaly test . | ```c++
#include <iostream>
#include <math.h>
using namespace std;
typedef long long ll;
bool is_prime(ll n){
if (n < 2) return false;
if (n < 4) return true;
if (n % 2 == 0 || n % 3 == 0) return false;
if (n < 25) return true;
for(int i = 5; i*i <= n; i += 6){
if(n % i == 0 || n % (i + 2) ... |
d552210a-6e33-49ba-9d2d-8259862474a9 | {
"language": "C++"
} | ```c++
```
Implement tests for NULL iterators for <array> re: N3644 | ```c++
//===----------------------------------------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is dual licensed under the MIT and the University of Illinois Open
// Source Licenses. See LICENSE.TXT for details.
//
//===---------------------------------... |
67a9b0ea-3e69-4029-a7ab-5c2b5133d0c4 | {
"language": "C++"
} | ```c++
```
Add test case for rune class. | ```c++
#include <peelo/text/rune.hpp>
#include <cassert>
int main()
{
peelo::rune auml(0x00e4);
assert(auml.equals(0x00e4));
assert(auml.equals_icase(0x00c4));
assert(auml.compare('a') > 0);
assert(auml.compare(0x00e4) == 0);
assert(auml.compare(0x00f6) < 0);
assert(auml.compare_icase('A') > 0);
asser... |
2ee88fc9-00ff-4a85-badb-d8202599a1cb | {
"language": "C++"
} | ```c++
```
Add a test case for r95555. | ```c++
// RUN: %clang_cc1 -fsyntax-only -verify %s
struct meta {
template<typename U>
struct apply {
typedef U* type;
};
};
template<typename T, typename U>
void f(typename T::template apply<U>::type);
void test_f(int *ip) {
f<meta, int>(ip);
}
``` |
6046a212-3b27-4b6b-986f-49c39aa72e44 | {
"language": "C++"
} | ```c++
```
Check If Two String Arrays are Equivalent | ```c++
class Solution {
public:
bool arrayStringsAreEqual(vector<string>& word1, vector<string>& word2) {
std::string s1 = "", s2 = "";
for (const auto& word : word1) {
s1 += word;
}
for (const auto& word : word2) {
s2 += word;
}
return s1 == s... |
e4630381-a077-4aab-a972-8c75f6a8361b | {
"language": "C++"
} | ```c++
```
Add c++ lambda return type test | ```c++
#include <iostream>
/**
* Need to use 'auto' return type to return a lambda since we can't type it's
* type. This is only possible in C++14 or later.
*/
auto func(void)
{
auto lmb = [](int x){ return x+1; };
return lmb;
}
int main(void)
{
auto lmb = func();
std::cout << "Lambda: " << lmb(1) << std... |
78c9bd23-7658-4fea-8d76-6702c8fdc139 | {
"language": "C++"
} | ```c++
```
Check that P is not zero initialized. | ```c++
// RUN: %llvmgxx -S %s -o - | FileCheck %s
#include <utility>
typedef std::pair<int,int> P;
// CHECK: @_ZZ1fvE1X {{.*}} undef
P f() {
static const P X = P(1,2);
return X;
}
``` |
7106be72-a2f7-4952-88e3-76f9818069e9 | {
"language": "C++"
} | ```c++
```
Add code to delete node in doubly linked list | ```c++
#include<iostream>
#include<cstdlib>
using namespace std;
class Node{
public:
int data;
Node *prev, *next;
Node(){}
Node(int d){
data=d;
prev=NULL;
next=NULL;
}
Node *insertNode(Node *head, int d){
Node *np=new Node(d);
Node *t=head;
if(head==NULL)
return np;
while(t->next!=NULL)
... |
f243f6e7-33ee-4ec9-9150-7eecdd79a753 | {
"language": "C++"
} | ```c++
```
Rename to be more descriptive correction | ```c++
#pragma once
#include <Windows.h>
#include <WinINet.h>
#include <IOStream>
#include <String>
#pragma comment(lib, "WinINet.lib")
std::string replaceAll(std::string subject, const std::string& search,
const std::string& replace) {
size_t pos = 0;
while ((pos = subject.find(search, pos)) != std::str... |
fef2f329-88f8-4e4b-8538-5e06e7fac279 | {
"language": "C++"
} | ```c++
```
Add google testing framework main | ```c++
/*
* gtest_main.cpp
*
* Created on: May 12, 2015
* Author: Vance Zuo
*/
#include "gmock/gmock.h"
#include <stdio.h>
int main(int argc, char **argv) {
printf("Running main() from gtest_main.cpp\n");
testing::InitGoogleMock(&argc, argv);
return RUN_ALL_TESTS();
}
``` |
fccacb02-d2c2-45b9-a545-bc41db6ae7d2 | {
"language": "C++"
} | ```c++
```
Add shell sort in cpp | ```c++
#include <iostream>
using namespace std;
// function to sort a using shellSort
int shellSort(int a[],int n)
{
for(int shell=n/2;shell>0; shell/=2)
{
for(int i=shell;i<n;i++)
{
int tmp=a[i];
int j;
for (j=i;(j>=shell) && (a[j-shell]>tmp); j-=shell)
a[j]=a[j-shell];
a[j]=tmp;
... |
9bb3d7a7-3742-4ff3-9959-57698d68a20a | {
"language": "C++"
} | ```c++
```
Add intersection of line and circle | ```c++
/*
* Copyright (C) 2015-2016 Pavel Dolgov
*
* See the LICENSE file for terms of use.
*/
#include <bits/stdc++.h>
typedef std::pair<double, double> DoublePair;
typedef std::vector<DoublePair> DoublePairs;
// circle
int x, y, r;
// line
int A, B, C;
bool pointOfLine(DoublePair point) {
double factor = ... |
905bf293-de6a-432f-ade7-b547470c2e4c | {
"language": "C++"
} | ```c++
```
Convert Sorted List to Binary Search Tree | ```c++
/**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* ListNode *next;
* ListNode(int x) : val(x), next(NULL) {}
* };
*/
/**
* Definition for a binary tree node.
* struct TreeNode {
* int val;
* TreeNode *left;
* TreeNode *right;
* TreeNode(int x) : val... |
af4b8fc4-e9e8-43d3-9845-a23cc08636f0 | {
"language": "C++"
} | ```c++
```
Add an example program for bulk_then | ```c++
#include <agency/agency.hpp>
#include <iostream>
#include <mutex>
int main()
{
using namespace agency;
std::cout << "Starting predecessor and continuation tasks asynchronously..." << std::endl;
std::mutex mut;
// asynchronously create 5 agents to greet us in a predecessor task
std::future<void> pre... |
7764303d-fbca-489b-8a01-62aed8a30197 | {
"language": "C++"
} | ```c++
```
Test driver for DAS (and AttrTable) classes. | ```c++
// Test the DAS class.
// Read attributes from one or more files, printing the resulting table to
// stdout. If a file is named `-' read from stdin for that file. The option
// `-d' causes new/delete run-time debugging to be turned on.
//
// jhrg 7/25/94
// $Log: das-test.cc,v $
// Revision 1.1 1994/08/02 18:... |
d42e9ab1-b52d-4372-b6ca-9707d44a0aa0 | {
"language": "C++"
} | ```c++
```
Implement is bipartite for a given graph | ```c++
// http://www.geeksforgeeks.org/bipartite-graph/
#include<iostream>
#include<queue>
#define V 4
using namespace std;
bool isBipartite(int Graph[][V], int src) {
int color[V];
for (int i = 0; i < V; i++)
color[i] = -1;
color[src] = 1;
queue<int> q;
q.push(src);
while (!q.empty()) ... |
d2eabb34-38a1-41d7-a3d0-2f3a9d268aaf | {
"language": "C++"
} | ```c++
```
Test integration of sequence and alphabet | ```c++
/*
Copyright 2015 Rogier van Dalen.
This file is part of Rogier van Dalen's Mathematical tools library for C++.
This library is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License... |
ce3d04b8-0e09-4871-a830-43e9966afdc2 | {
"language": "C++"
} | ```c++
```
Add problem: Write a program to find the increasing array with the largest sum of array. | ```c++
// Write a program to find the increasing array with the largest sum of array.
#include <stdio.h>
const int MIN = -2147483647;
void importArray(int array[], int &length);
void exportArray(int array[], int length);
void exportArray(int array[], int length, int from, int to);
void handleRequirement(int array[],... |
12908883-425a-4278-8569-38de98707713 | {
"language": "C++"
} | ```c++
```
Add (failing) test that halide reports user error when called with OpenGL in bad state | ```c++
#include <csetjmp>
#include <unistd.h>
#if defined(__APPLE__)
#include <OpenGL/gl.h>
#else
#include <GL/gl.h>
#endif
#include "Halide.h"
#include "HalideRuntimeOpenGL.h"
std::string error_message;
/*
** Don't rely on func.set_error_handler() mechanism, it doesn't seem to catch
** the user OpenGL state errors... |
15594240-5886-47b7-bf47-01179824b4b9 | {
"language": "C++"
} | ```c++
```
Add solution for chapter 19, test 1 | ```c++
#include <iostream>
#include <new>
#include <cstdlib>
using namespace std;
void* operator new (size_t size) {
cout << "operator new(" << size << ")" << endl;
if(void *mem = malloc(size)) {
return mem;
} else {
throw bad_alloc();
}
}
void operator delete(void *mem... |
9483cd36-f386-4112-9981-c563aecafd0e | {
"language": "C++"
} | ```c++
```
Update gitignore and added a test class that accepts STL class as a template template argument | ```c++
#include <iostream>
#include <vector>
#include <list>
template <template<class,class> class Container, class Object>
class UDTContainer{
private:
Container<Object,std::allocator<Object> > m_cointainer;
public:
};
int main(){
UDTContainer<std::vector,std::string> obj_udtc;
}
``` |
37fd58bf-fda7-481e-976b-96380dc1cd38 | {
"language": "C++"
} | ```c++
```
Add solution of prob 5 | ```c++
#include <stdio.h>
#include <stdlib.h> /* rand(), srand() */
#include <time.h> /* time() */
int count_one_came_out_when_throwing_dice(const int count)
{
int rc = 0;
for(int i = 0; i < count; ++i)
if(rand() % 6 + 1 == 1) ++rc;
return rc;
}
int main(void)
{
srand(time(NULL));
const... |
1a4fc118-feb2-47c3-8669-9305646f5475 | {
"language": "C++"
} | ```c++
```
Add test for dependent PredefinedExprs. | ```c++
// RUN: clang-cc %s -emit-llvm -o - | FileCheck %s
// CHECK: store i32 49, i32* %size
// CHECK: store i32 52, i32* %size
template<typename T>
class TemplateClass {
public:
void templateClassFunction() {
int size = sizeof(__PRETTY_FUNCTION__);
}
};
// CHECK: store i32 27, i32* %size
// CHECK: store i32 ... |
9efa1f21-d4bb-47ca-87db-c69685d6510b | {
"language": "C++"
} | ```c++
```
Add Swapping without a auxillary variable | ```c++
/*
* Copyright 2010, NagaChaitanya Vellanki
*
* Author NagaChaitanya Vellanki
*
* Swapping two variables without auxillary
*/
#include <iostream>
#include <inttypes.h>
using namespace std;
int main()
{
int32_t a = 10;
int32_t b = 20;
cout << "a is " << a << ",b is " << b << endl;
a = a + b;
b ... |
b1ea23a3-0b2a-4166-8b09-9e789c7f816a | {
"language": "C++"
} | ```c++
```
Create constructors for classes Data and Model | ```c++
#include "EM_Classes.h"
Model::Model(const int &N_, const int &lagsS_, const int &lagsY_,
const bool &sigma_, const bool &beta_,
const bool &meanCorrected):
N(N_), lagsS(lagsS_), lagsY(lagsY_), sigma(sigma_), beta(beta_),
meanCorrected(meanCorrected){}
Model::Model(const int &N_ = 2, const int &lagsS... |
1e345e91-15ef-44d2-ae2e-3d27ab422326 | {
"language": "C++"
} | ```c++
```
Delete Node in a Linked List. | ```c++
/**
* Delete Node in a Linked List
*
* cpselvis(cpselvis@gmail.com)
* Oct 8th, 2016
*/
struct ListNode {
int val;
ListNode *next;
ListNode(int x) : val(x), next(NULL) {}
};
class Solution {
public:
void deleteNode(ListNode* node) {
if (node != NULL)
{
node -> val = node -> next -> val;... |
6fa3935f-c219-478e-9681-1e2cb372809c | {
"language": "C++"
} | ```c++
```
Convert the given tree for sum property. | ```c++
#include <stdio.h>
typedef struct _NODE {
int data;
_NODE* left;
_NODE* right;
} NODE;
NODE* newNode(int data) {
NODE* node = new NODE();
node->data = data;
node->left = nullptr;
node->right = nullptr;
return node;
}
int toSumTree(NODE* root) {
if (root == nullptr) return 0;
int old_valu... |
47a10347-deff-4e8d-a4bb-43672088d2fc | {
"language": "C++"
} | ```c++
```
Add Solution for 155 Min Stack | ```c++
// 155. Min Stack
/**
* Design a stack that supports push, pop, top, and retrieving the minimum element in constant time.
*
* push(x) -- Push element x onto stack.
* pop() -- Removes the element on top of the stack.
* top() -- Get the top element.
* getMin() -- Retrieve the minimum element in the stack.
... |
86253a1f-16a1-436e-a489-3319ba7b13a6 | {
"language": "C++"
} | ```c++
```
Add the solution to "The Full Counting Sort". | ```c++
#include <iostream>
#include <string>
#include <map>
#include <list>
using namespace std;
typedef struct node
{
int num;
string str;
}c_node;
int main()
{
int n;
cin >> n;
c_node *a = new c_node[n];
for (int i = 0; i < n; i++) {
cin >> a[i].num >> a[i].str;
}
map< int, list<string> > int_list_map;
f... |
c06729ca-f2dc-46bb-b610-605112cbb4e3 | {
"language": "C++"
} | ```c++
```
Add a test for r158229 (overlapping fixits). This was PR10696! | ```c++
// RUN: %clang_cc1 -fsyntax-only -std=c++11 2>&1 %s | FileCheck -strict-whitespace %s
struct A {
unsigned int a;
};
// PR10696
void testOverlappingInsertions(int b) {
A var = { b };
// CHECK: A var = { b };
// CHECK: ^
// CHECK: static_cast<unsigned int>( )
}
``` |
225b7555-6538-4554-b2be-5706508f8b42 | {
"language": "C++"
} | ```c++
```
Add Solution for Problem 035 | ```c++
// 035. Search Insert Position
/**
* Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order.
*
* You may assume no duplicates in the array.
*
* Here are few examples.
* [1,3,5,6], 5 -> 2
* [1,3,5,6], 2 -> ... |
f285c65e-cbdf-4a0d-9818-1bb7bd3ce9fb | {
"language": "C++"
} | ```c++
```
Add basic test for geos::operation::OverlayOp with UNION. | ```c++
//
// Test Suite for geos::operation::OverlayOp class for UNION
#include <tut.hpp>
// geos
#include <geos/operation/overlay/OverlayOp.h>
#include <geos/geom/Geometry.h>
#include <geos/geom/GeometryFactory.h>
#include <geos/geom/PrecisionModel.h>
#include <geos/io/WKBReader.h>
#include <geos/io/WKTReader.h>
// ... |
5a916142-b7d6-423b-9b29-e7c3dfcebd69 | {
"language": "C++"
} | ```c++
```
Print top view of the binary tree. | ```c++
#include <stdio.h>
#include <map>
#include <vector>
typedef struct _NODE {
int data;
_NODE* left;
_NODE* right;
} NODE;
NODE* NewNode(int data) {
NODE* node = new NODE();
node->data = data;
node->left = node->right = nullptr;
return node;
}
void PrintTopViewUtil(NODE* node, int level, std::map<... |
aa68370b-3095-466c-8d43-dbf9336d3a68 | {
"language": "C++"
} | ```c++
```
Add test program for slur parsing. | ```c++
// Description: Print slur linking info
#include "humlib.h"
using namespace hum;
int main(int argc, char** argv) {
if (argc != 2) {
return 1;
}
HumdrumFile infile;
if (!infile.read(argv[1])) {
return 1;
}
cerr << "ANALYZING SLURS" << endl;
infile.analyzeKernSlurs();
cerr << "DONE... |
4864aacb-58bd-4956-b927-9895e7167913 | {
"language": "C++"
} | ```c++
```
Add a solution for time converter task | ```c++
#include <iostream>
#include <string>
using namespace std;
int main()
{
string time12;
cin >> time12;
char p = time12[time12.size() - 2];
if (p == 'P')
{
int t = (int)time12[0] - '0';
t = t * 10;
t += (int)time12[1] - '0';
if (t < 12)
{
t += 12;
}
cout << t;
fo... |
2d03c897-ad29-4a38-aa5a-960a1bfdacd2 | {
"language": "C++"
} | ```c++
#include <iostream>
int main() {
std::cout << "Hello, World!" << std::endl;
return 0;
}
```
Update example to demonstrate version numbers. | ```c++
#include <iostream>
#include <stdlib.h>
#include "exampleConfig.h"
#include "example.h"
/*
* Simple main program that demontrates how access
* CMake definitions (here the version number) from source code.
*/
int main() {
std::cout << "C++ Boiler Plate v"
<< PROJECT_VERSION_MAJOR
<<... |
5ee2cab7-7503-46cb-9e39-0eb13a87199b | {
"language": "C++"
} | ```c++
```
Add a solution of prob 2 | ```c++
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include "../excercise04/make_random_data/make_random_data.hpp"
#include "../excercise04/sort/heap.hpp"
#include "../excercise04/sort/swap.hpp"
#include "priority_queue/priority_queue.hpp"
#define MIN_SIZE 100
#define MAX_SIZE 10... |
d3987c8f-d374-40b0-9953-5757430a9a18 | {
"language": "C++"
} | ```c++
```
Add solution to problem 15 in C++. | ```c++
/*
* Lattice paths
*
* Starting in the top left corner of a 2×2 grid, and only being able to move
* to the right and down, there are exactly 6 routes to the bottom right corner.
*
* How many such routes are there through a 20×20 grid?
*/
#include <iostream>
using Long = unsigned long long int;
// Forwa... |
9c937589-4c24-4dfb-80e1-b5bff2251107 | {
"language": "C++"
} | ```c++
```
Add the solution to "Mark and Toys". | ```c++
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
int n, money;
cin >> n >> money;
int *toys = new int[n];
for (int i = 0; i < n ; i++) {
cin >> toys[i];
}
sort(toys, toys + n);
int sum = 0;
int count = 0;
for (int i = 0; i < n; i++) {
if (sum + toys[i] > money) {
break;
... |
8d80cfa8-ce5b-427f-bb87-6721372e47c7 | {
"language": "C++"
} | ```c++
```
Add stub for engine test with test plan | ```c++
// Copyright [2016] <Malinovsky Rodion>
#include "core/engine.h"
#include "gtest/gtest.h"
// Implement Engine test
// 1. Create a fixture, take base code from EngineLauncher
// 2. create cond var, which will emulate SIGINT
// 3. run engine -> create server socket
// 4. create tcp client and write data to serv... |
64c55112-3534-4ba8-bda5-306e4aff78d2 | {
"language": "C++"
} | ```c++
```
Add test to check implicit upcasting of float16_t works. | ```c++
#include "Halide.h"
#include <stdio.h>
#include <cmath>
using namespace Halide;
// FIXME: We should use a proper framework for this. See issue #898
void h_assert(bool condition, const char *msg) {
if (!condition) {
printf("FAIL: %s\n", msg);
abort();
}
}
int main() {
Halide::Func f... |
17b26133-66f1-47fd-ad39-c16bf4b244e9 | {
"language": "C++"
} | ```c++
```
Add node test. Fails for now. Need to figure out a way to handle osgInit. | ```c++
#include <UnitTest++.h>
// Unit tests for vec classes
#include <OpenSG/OSGNode.h>
#include <OpenSG/OSGNameAttachment.h>
TEST(CreateNode)
{
OSG::NodePtr n = OSG::Node::create();
CHECK(n != OSG::NullFC);
}
// --- Cloning --- //
TEST(TreeCloningName)
{
OSG::NodePtr root = OSG::Node::create();
OS... |
5706df45-c371-4f94-9c86-eff58036a602 | {
"language": "C++"
} | ```c++
```
Add fuzzing driver to classads HTCONDOR-814 | ```c++
#include "classad/classad_distribution.h"
#include <string>
#include <string.h>
#include <sys/types.h>
/* This is the driver for the classad fuzz tester.
* Note this is intentionally not in the cmake file, it should not be built
* by default.
*
* To use, compile all of classads with clang -fsanitize=fuzze... |
ca2c8922-c07b-48be-a25a-bfa48eaadbe7 | {
"language": "C++"
} | ```c++
```
Add 145 Binary Tree Postorder Traversal | ```c++
// 145 Binary Tree PostOrder Tranversal
/**
* Given a binary tree, return the postorder traversal of its nodes' values.
*
* For example:
* Given binary tree {1,#,2,3},
* 1
* \
* 2
* /
* 3
* return [3,2,1].
*
* Note: Recursive solution is trivial, could you do it iteratively?
*
* Tag: Tre... |
b8ad88b3-09da-4ad8-9452-d3178ce6d094 | {
"language": "C++"
} | ```c++
```
Check if sum exists in two arrays | ```c++
/*******************************************************************************
Sum exists in two arrays
========================
--------------------------------------------------------------------------------
Problem
=======
Given two arrays A[] and B[] and a number K, check if a + b == K where a belongs
t... |
494455a2-52de-4817-a35c-818ee54b82c1 | {
"language": "C++"
} | ```c++
```
Add placeholder Windows path code | ```c++
#include "path.hpp"
void Path::init()
{
// FIXME: unimplemented
}
#include <stdlib.h>
IFile *Path::openIFile(std::string const &path)
{
// FIXME: unimplemented
abort();
return NULL;
}
``` |
d7a12a90-c222-4d4b-b88e-ff7233ad61b3 | {
"language": "C++"
} | ```c++
```
Add test case to insure that implicit builtin declarations for C library functions aren't created in C++ | ```c++
// RUN: clang -fsyntax-only -verify %s
void f() {
void *p = malloc(sizeof(int) * 10); // expected-error{{no matching function for call to 'malloc'}}
}
int malloc(double);
``` |
bced9b49-a153-4829-bf5b-6e2fc039c089 | {
"language": "C++"
} | ```c++
```
ADD floating point format library example. | ```c++
#include <cmath>
#include <fmt/format.h>
struct ieee754 {
int sign;
int biased_exponent;
uint64_t fraction;
uint64_t significand() const { return 0x10'0000'0000'0000 | fraction; }
int exponent() const { return biased_exponent - 1023; }
explicit ieee754(double value) {
auto bits = fmt::internal::bit_ca... |
42094e7d-0d0c-45bc-b98e-ef7b1c3aaa25 | {
"language": "C++"
} | ```c++
```
Add test for Clamp function in math/utils | ```c++
// Copyright (c) 2017 Pierre Fourgeaud
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#include <bandit/bandit.h>
#include "core/math/utils.h"
using namespace bandit;
using namespace snowhouse;
using namespace CodeHero;
go_bandit([]() {
describe("::Clamp... |
4f91692e-9d87-4a45-ba93-cc328061eee8 | {
"language": "C++"
} | ```c++
/* Copyright 2021 The TensorFlow Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable l... | ```c++
/* Copyright 2021 The TensorFlow Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable l... |
2bdd4d26-72b8-49fd-ba05-7bcffd231e2a | {
"language": "C++"
} | ```c++
/* Copyright 2016 The TensorFlow Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable l... | ```c++
/* Copyright 2016 The TensorFlow Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable l... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.