id int64 0 755k | file_name stringlengths 3 109 | file_path stringlengths 13 185 | content stringlengths 31 9.38M | size int64 31 9.38M | language stringclasses 1
value | extension stringclasses 11
values | total_lines int64 1 340k | avg_line_length float64 2.18 149k | max_line_length int64 7 2.22M | alphanum_fraction float64 0 1 | repo_name stringlengths 6 65 | repo_stars int64 100 47.3k | repo_forks int64 0 12k | repo_open_issues int64 0 3.4k | repo_license stringclasses 9
values | repo_extraction_date stringclasses 92
values | exact_duplicates_redpajama bool 2
classes | near_duplicates_redpajama bool 2
classes | exact_duplicates_githubcode bool 2
classes | exact_duplicates_stackv2 bool 1
class | exact_duplicates_stackv1 bool 2
classes | near_duplicates_githubcode bool 2
classes | near_duplicates_stackv1 bool 2
classes | near_duplicates_stackv2 bool 1
class |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
9,595 | secmon_cache.inc | Atmosphere-NX_Atmosphere/exosphere/program/source/secmon_cache.inc | /*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
... | 854 | C++ | .inc | 21 | 38.904762 | 76 | 0.787004 | Atmosphere-NX/Atmosphere | 14,324 | 1,207 | 54 | GPL-2.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false |
9,596 | secmon_cache_impl.inc | Atmosphere-NX_Atmosphere/exosphere/program/source/secmon_cache_impl.inc | /*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
... | 6,354 | C++ | .inc | 141 | 35.375887 | 147 | 0.578292 | Atmosphere-NX/Atmosphere | 14,324 | 1,207 | 54 | GPL-2.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false |
9,597 | secmon_pmc_access_table_data.inc | Atmosphere-NX_Atmosphere/exosphere/program/source/smc/secmon_pmc_access_table_data.inc | /*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
... | 2,650 | C++ | .inc | 46 | 56.304348 | 76 | 0.682412 | Atmosphere-NX/Atmosphere | 14,324 | 1,207 | 54 | GPL-2.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false |
9,598 | secmon_mc01_access_table_data.inc | Atmosphere-NX_Atmosphere/exosphere/program/source/smc/secmon_mc01_access_table_data.inc | /*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
... | 2,633 | C++ | .inc | 42 | 61.357143 | 76 | 0.681204 | Atmosphere-NX/Atmosphere | 14,324 | 1,207 | 54 | GPL-2.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false |
9,599 | secmon_define_pmc_access_table.inc | Atmosphere-NX_Atmosphere/exosphere/program/source/smc/secmon_define_pmc_access_table.inc | /*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
... | 961 | C++ | .inc | 22 | 41.909091 | 76 | 0.757479 | Atmosphere-NX/Atmosphere | 14,324 | 1,207 | 54 | GPL-2.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false |
9,600 | secmon_define_mc_access_table.inc | Atmosphere-NX_Atmosphere/exosphere/program/source/smc/secmon_define_mc_access_table.inc | /*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
... | 972 | C++ | .inc | 22 | 42.409091 | 88 | 0.760296 | Atmosphere-NX/Atmosphere | 14,324 | 1,207 | 54 | GPL-2.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false |
9,601 | secmon_mc_access_table_data.inc | Atmosphere-NX_Atmosphere/exosphere/program/source/smc/secmon_mc_access_table_data.inc | /*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
... | 13,881 | C++ | .inc | 194 | 70.479381 | 76 | 0.558048 | Atmosphere-NX/Atmosphere | 14,324 | 1,207 | 54 | GPL-2.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false |
9,602 | secmon_define_access_table.inc | Atmosphere-NX_Atmosphere/exosphere/program/source/smc/secmon_define_access_table.inc | /*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
... | 1,087 | C++ | .inc | 25 | 39.48 | 94 | 0.688742 | Atmosphere-NX/Atmosphere | 14,324 | 1,207 | 54 | GPL-2.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false |
9,603 | secmon_define_mc01_access_table.inc | Atmosphere-NX_Atmosphere/exosphere/program/source/smc/secmon_define_mc01_access_table.inc | /*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
... | 922 | C++ | .inc | 22 | 40.136364 | 76 | 0.750279 | Atmosphere-NX/Atmosphere | 14,324 | 1,207 | 54 | GPL-2.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false |
9,604 | fatal_display_config.inc | Atmosphere-NX_Atmosphere/exosphere/mariko_fatal/source/fatal_display_config.inc | /*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
... | 39,644 | C++ | .inc | 642 | 57.239875 | 157 | 0.727119 | Atmosphere-NX/Atmosphere | 14,324 | 1,207 | 54 | GPL-2.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false |
9,647 | pdf.h | wkhtmltopdf_wkhtmltopdf/src/lib/pdf.h | /* -*- mode: c++; tab-width: 4; indent-tabs-mode: t; eval: (progn (c-set-style "stroustrup") (c-set-offset 'innamespace 0)); -*-
* vi:set ts=4 sts=4 sw=4 noet :
*
* Copyright 2010-2020 wkhtmltopdf authors
*
* This file is part of wkhtmltopdf.
*
* wkhtmltopdf is free software: you can redistribute it and/or modif... | 4,486 | C++ | .h | 74 | 59.135135 | 128 | 0.798226 | wkhtmltopdf/wkhtmltopdf | 13,947 | 1,808 | 1,356 | LGPL-3.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false |
9,650 | image.h | wkhtmltopdf_wkhtmltopdf/src/lib/image.h | /* -*- mode: c++; tab-width: 4; indent-tabs-mode: t; eval: (progn (c-set-style "stroustrup") (c-set-offset 'innamespace 0)); -*-
* vi:set ts=4 sts=4 sw=4 noet :
*
* Copyright 2010-2020 wkhtmltopdf authors
*
* This file is part of wkhtmltopdf.
*
* wkhtmltopdf is free software: you can redistribute it and/or modif... | 3,925 | C++ | .h | 65 | 58.892308 | 128 | 0.802184 | wkhtmltopdf/wkhtmltopdf | 13,947 | 1,808 | 1,356 | LGPL-3.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | true | false | false | false | false | false | false |
9,738 | square_free_number.cpp | OpenGenus_cosmos/code/mathematical_algorithms/src/square_free_number/square_free_number.cpp | //Program to check whether a number is square_free or not
#include <iostream>
#include <cmath>
bool isSquareFree(int n)
{
if (n % 2 == 0)
n /= 2;
if (n % 2 == 0)
return false;
for (int i = 3; i <= std::sqrt(n); i += 2)
if (n % i == 0)
{
n /= i;
if (n... | 631 | C++ | .cpp | 29 | 15.965517 | 57 | 0.477462 | OpenGenus/cosmos | 13,556 | 3,669 | 2,596 | GPL-3.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
9,742 | permutation_lexicographic_order.cpp | OpenGenus_cosmos/code/mathematical_algorithms/src/permutation_lexicographic_order/permutation_lexicographic_order.cpp | #include <iostream>
#include <string>
#include <algorithm>
#include <set>
using namespace std;
set<string> s;
void permutation(string a, int i = 0)
{
if (a[i] == '\0')
{
// cout << a << endl;
s.insert(a);
return;
}
for (int j = i; a[j] != '\0'; j++)
{
swap(a[i], a[j... | 606 | C++ | .cpp | 32 | 14.34375 | 42 | 0.486772 | OpenGenus/cosmos | 13,556 | 3,669 | 2,596 | GPL-3.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
9,745 | exponentiation_by_squaring.cpp | OpenGenus_cosmos/code/mathematical_algorithms/src/exponentiation_power/exponentiation_by_squaring/exponentiation_by_squaring.cpp | #include <iostream>
// Part of Cosmos by OpenGenus Foundation
using namespace std;
int power(int num, int exp)
{
if (exp == 0)
return 1;
if (exp == 1)
return num;
int temp = power(num, exp / 2);
temp *= temp;
if (exp % 2 == 1)
temp *= num;
return temp;
}
int main()
{
... | 450 | C++ | .cpp | 22 | 16.545455 | 53 | 0.563084 | OpenGenus/cosmos | 13,556 | 3,669 | 2,596 | GPL-3.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
9,755 | gaussian_elimination.cpp | OpenGenus_cosmos/code/mathematical_algorithms/src/gaussian_elimination/gaussian_elimination.cpp | /* Part of Cosmos by OpenGenus Foundation */
#include <cmath>
#include <iostream>
#include <vector>
using namespace std;
const long double EPS = 1e-8;
/**
* Gaussian elimination (also known as row reduction). Solves systems of linear equations.
*
* @param a is an input matrix
* @param ans is result vector
* ... | 2,273 | C++ | .cpp | 91 | 18.681319 | 91 | 0.455842 | OpenGenus/cosmos | 13,556 | 3,669 | 2,596 | GPL-3.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
9,756 | add_polynomials.cpp | OpenGenus_cosmos/code/mathematical_algorithms/src/add_polynomials/add_polynomials.cpp | /* Part of Cosmos by OpenGenus Foundation */
/* Contributed by Vaibhav Jain (vaibhav29498) */
/* Refactored by Adeen Shukla (adeen-s) */
#include <iostream>
#include <stddef.h>
using namespace std;
struct term
{
int coeff;
int pow;
term* next;
term(int, int);
};
term::term(int c, int p)
{
coeff = ... | 2,673 | C++ | .cpp | 132 | 14.272727 | 58 | 0.483017 | OpenGenus/cosmos | 13,556 | 3,669 | 2,596 | GPL-3.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
9,759 | horner_polynomial_evaluation.cpp | OpenGenus_cosmos/code/mathematical_algorithms/src/horner_polynomial_evaluation/horner_polynomial_evaluation.cpp | #include <iostream>
#include <vector>
using namespace std;
// Part of Cosmos by OpenGenus Foundation
typedef long long ll;
typedef vector<ll> Poly;
// evaluate p(x) in linear time
ll evaluate(const Poly& p, ll x)
{
ll ret = 0;
for (int i = p.size() - 1; i >= 0; --i)
ret = ret * x + p[i];
return r... | 735 | C++ | .cpp | 33 | 18.151515 | 54 | 0.564029 | OpenGenus/cosmos | 13,556 | 3,669 | 2,596 | GPL-3.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
9,766 | fast_inverse_sqrt.cpp | OpenGenus_cosmos/code/mathematical_algorithms/src/fast_inverse_sqrt/fast_inverse_sqrt.cpp | // AUTHOR: Mitchell Haugen
// GITHUB: https://github.com/haugenmitch
// DATE: October 9, 2017
// SOURCE: https://stackoverflow.com/questions/1349542/john-carmacks-unusual-fast-inverse-square-root-quake-iii User: Rushyo
// DESCRIPTION: This algorithm use bit manipulation to calculate the inverse sq... | 1,074 | C++ | .cpp | 24 | 41.875 | 236 | 0.672727 | OpenGenus/cosmos | 13,556 | 3,669 | 2,596 | GPL-3.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
9,767 | newman_conway_recursion.cpp | OpenGenus_cosmos/code/mathematical_algorithms/src/newman_conway/newman_conway_recursion.cpp | #include <iostream>
class NewmanConwaySequence
{
public:
NewmanConwaySequence(unsigned int n) : n(n) {}
unsigned int calculateNewmanConwaySequenceTermRecur(unsigned int n);
private:
unsigned int n;
};
unsigned int NewmanConwaySequence::calculateNewmanConwaySequenceTermRecur(unsigned int n)
{
i... | 921 | C++ | .cpp | 24 | 34.625 | 193 | 0.76212 | OpenGenus/cosmos | 13,556 | 3,669 | 2,596 | GPL-3.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
9,768 | newman_conway_sequence.cpp | OpenGenus_cosmos/code/mathematical_algorithms/src/newman_conway/newman_conway_sequence.cpp | #include <iostream>
#include <vector>
//prints input number of teerms of Newman-Conway Sequence
std::vector<int> NewmanConwaySequence(int number)
{
std::vector<int> arr(number + 1);
arr[0] = 0;
arr[1] = 1;
arr[2] = 1;
for (int i = 3; i <= number; ++i)
arr[i] = arr[arr[i - 1]] + arr[i - arr[i... | 618 | C++ | .cpp | 24 | 21.875 | 57 | 0.581788 | OpenGenus/cosmos | 13,556 | 3,669 | 2,596 | GPL-3.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
9,772 | fibonacci_number.cpp | OpenGenus_cosmos/code/mathematical_algorithms/src/fibonacci_number/fibonacci_number.cpp | #include <iostream>
#include <vector>
/*
* Part of Cosmos by OpenGenus Foundation
* Don't use numbers bigger than (2^16)-1 as input for fib because some computers will crash due to memory issues.
*/
// Returns the nth term in the Fibonacci Sequence (dynamic): O(N) [nice performance]
unsigned long long bottom_up_fi... | 1,195 | C++ | .cpp | 34 | 31.5 | 114 | 0.644714 | OpenGenus/cosmos | 13,556 | 3,669 | 2,596 | GPL-3.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
9,774 | convolution.cpp | OpenGenus_cosmos/code/mathematical_algorithms/src/convolution/convolution.cpp | /* Part of Cosmos by OpenGenus Foundation */
#include <iostream>
#include <vector>
// This code requires you to enable the C++11 standard when compiling
/**
* @breif convolve - compute the discrete time convolution of functions vectors f and g. Coded for clarity,
* not performance.
* @return f * g
**/
template <t... | 1,252 | C++ | .cpp | 33 | 33.484848 | 107 | 0.61952 | OpenGenus/cosmos | 13,556 | 3,669 | 2,596 | GPL-3.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
9,775 | integer_to_roman.cpp | OpenGenus_cosmos/code/mathematical_algorithms/src/integer_to_roman/integer_to_roman.cpp | #include <iostream>
#include <string>
#include <map>
std::string integerToRoman(int number);
int main()
{
int number;
std::cout << "Enter a number: ";
std::cin >> number;
std::cout << "\nYour number: " << number << "\n";
std::cout << "Your number in Roman Numerals: " << integerToRoman(number) <<... | 946 | C++ | .cpp | 39 | 18.025641 | 85 | 0.480534 | OpenGenus/cosmos | 13,556 | 3,669 | 2,596 | GPL-3.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
9,776 | pythagorean_triplet.cpp | OpenGenus_cosmos/code/mathematical_algorithms/src/pythagorean_triplet/pythagorean_triplet.cpp | // A Pythagorean triplet is a set of three natural numbers, a<b<c, for which a^2 + b^2 = c^2
// Given N, Check if there exists any Pythagorean triplet for which a+b+c=N
//Find maximum possible value of abc among all such Pythagorean triplets, If there is no such Pythagorean triplet print -1.
#include <iostream>
usin... | 1,321 | C++ | .cpp | 30 | 37.466667 | 150 | 0.52795 | OpenGenus/cosmos | 13,556 | 3,669 | 2,596 | GPL-3.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
9,786 | newton_raphson.cpp | OpenGenus_cosmos/code/mathematical_algorithms/src/newton_raphson_method/newton_raphson.cpp | /* Part of Cosmos by OpenGenus Foundation */
#include <cmath>
#include <iostream>
#include <limits>
#include <string>
#include <stdexcept>
// This code requires you to enable the C++11 standard when compiling
void helpAndExit()
{
std::cout << "Newton-Raphson iteration for the function x*log10(x)-1.2\n"
... | 1,999 | C++ | .cpp | 56 | 27.839286 | 102 | 0.558031 | OpenGenus/cosmos | 13,556 | 3,669 | 2,596 | GPL-3.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
9,789 | spiral_matrix_clockwise_cycle.cpp | OpenGenus_cosmos/code/mathematical_algorithms/src/spiral_matrix/spiral_matrix_clockwise_cycle.cpp | /*
* Part of Cosmos by OpenGenus Foundation
*/
#include <iostream>
#include <vector>
using namespace std;
void print_top_row(int x, int y, int X, int Y, vector<vector<int>>matrix) {
for (int i = y; i<= Y; ++i) cout<<matrix[x][i]<<" ";
}
void print_right_column(int x, int y, int X, int Y, vector<vector<int>>matr... | 1,688 | C++ | .cpp | 50 | 25.5 | 80 | 0.472292 | OpenGenus/cosmos | 13,556 | 3,669 | 2,596 | GPL-3.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false |
9,790 | recursive_spiral_matrix.cpp | OpenGenus_cosmos/code/mathematical_algorithms/src/spiral_matrix/recursive_spiral_matrix.cpp | /* Part of Cosmos by OpenGenus Foundation */
#include <iostream>
#include <vector>
using namespace std;
/*
This algorithm takes in a 2-dimensional vector and
outputs its contents in a clockwise spiral form.
Example Input:
[ [ 1 2 3 4 ],
[ 5 6 7 8 ],
[ 9 10 11 12 ],
... | 3,751 | C++ | .cpp | 97 | 28.082474 | 79 | 0.447931 | OpenGenus/cosmos | 13,556 | 3,669 | 2,596 | GPL-3.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
9,791 | method2_power_recursion_with_even_odd_optimization.cpp | OpenGenus_cosmos/code/mathematical_algorithms/src/power/method2_power_recursion_with_even_odd_optimization.cpp | #include<bits/stdc++.h>
using namespace std;
// O(log2(p))
int power(int base,int p,int mod){
if(p==0)
return 1;
else if(p%2==0)
return power( ((base %mod)*(base %mod)) %mod, p/2, mod);
else if(p%2==1)
return ( (base%mod) * (power(((base %mod)*(base %mod))%mod, p/2, mod) %mod)) %... | 458 | C++ | .cpp | 18 | 20.555556 | 90 | 0.537209 | OpenGenus/cosmos | 13,556 | 3,669 | 2,596 | GPL-3.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false |
9,792 | method1_power_recursion_with_even_odd_optimization.cpp | OpenGenus_cosmos/code/mathematical_algorithms/src/power/method1_power_recursion_with_even_odd_optimization.cpp | #include<bits/stdc++.h>
using namespace std;
// O(log2(p))
long long power(int base,int p){
if(p==0)
return 1;
else if(p%2==0)
return power(base*base,p/2);
else if(p%2==1)
return base*power(base*base,p/2);
}
int main(){
int base,p;
while(cin>>base>>p){
cout<< ... | 364 | C++ | .cpp | 18 | 15.444444 | 41 | 0.556213 | OpenGenus/cosmos | 13,556 | 3,669 | 2,596 | GPL-3.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false |
9,797 | matrix_row_reduction.cpp | OpenGenus_cosmos/code/mathematical_algorithms/src/matrix_row_reduction/matrix_row_reduction.cpp | #include<iostream>
#include<string>
#include<vector>
#include<set>
using namespace std;
void PrintMatrix(vector<vector<float>>& matrix); //Prints matrix to console
int FirstNonZero(vector<float>& vec); //find first non-zero coefficient in a given row, returns -1 if unfound
void RowReduction(vector<vector<flo... | 6,644 | C++ | .cpp | 212 | 26.523585 | 250 | 0.587867 | OpenGenus/cosmos | 13,556 | 3,669 | 2,596 | GPL-3.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false |
9,799 | decimal_to_bin.cpp | OpenGenus_cosmos/code/mathematical_algorithms/src/integer_conversion/decimal_to_bin.cpp | #include <iostream>
using namespace std;
int main()
{
int decimal;
cout << "Enter a decimal: ";
cin >> decimal;
cout << "The number in binary: ";
for (int i = 31; i >= 0; i--)
cout << ((decimal >> i) & 1);
cout << endl;
return 0;
}
| 271 | C++ | .cpp | 13 | 16.846154 | 37 | 0.537255 | OpenGenus/cosmos | 13,556 | 3,669 | 2,596 | GPL-3.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
9,801 | next_larger_number.cpp | OpenGenus_cosmos/code/mathematical_algorithms/src/next_larger_number/next_larger_number.cpp | #include <iostream>
#include <algorithm>
#include <cstring>
// Part of Cosmos by OpenGenus Foundation
void nextgr(char num[], int n)
{
int i, j;
for (i = n - 1; i >= 0; --i)
if (num[i - 1] < num[i])
break;
if (i == 0)
{
std::cout << "No such greater number exists";
... | 727 | C++ | .cpp | 33 | 16.939394 | 53 | 0.500732 | OpenGenus/cosmos | 13,556 | 3,669 | 2,596 | GPL-3.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
9,802 | 2sum.cpp | OpenGenus_cosmos/code/mathematical_algorithms/src/2sum/2sum.cpp | //Given an array and a sum, print two numbers from the array that add-up to sum
#include <iostream>
#include <map>
using namespace std;
// Part of Cosmos by OpenGenus Foundation
#define ll long long
map<ll, ll> m;
//Function to find two numbers which add up to sum
void twoSum(ll a[], ll sum, int n)
{
for (int i ... | 693 | C++ | .cpp | 28 | 20.178571 | 79 | 0.534039 | OpenGenus/cosmos | 13,556 | 3,669 | 2,596 | GPL-3.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
9,803 | simpsons_rule.cpp | OpenGenus_cosmos/code/mathematical_algorithms/src/simpsons_rule/simpsons_rule.cpp | #include <iostream>
#include <cmath>
float create(int x)
{
return log(x);
}
int simpson(int x1, int x2)
{
float h = (x2 - x1) / 6;
int x[10];
float y[10];
for (int i = 0; i <= n; ++i) {
x[i] = x1 + i * h;
y[i] = create(x[i]);
}
float value = 0;
for (int i = 0; i <= n; ... | 690 | C++ | .cpp | 35 | 14.6 | 36 | 0.434716 | OpenGenus/cosmos | 13,556 | 3,669 | 2,596 | GPL-3.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
9,804 | steepest_descent.cpp | OpenGenus_cosmos/code/mathematical_algorithms/src/steepest_descent/steepest_descent.cpp | /*
* The method of steepest descent
* -------------------
* An algorithm for finding the nearest local minimum of a function.
* It solves an equation in quadratic form: Ax = b where x is the values we seek.
* A is a matrix of size NxN, and b is a vector of N values.
*
* Time complexity
* ---------------
* O(e^... | 3,957 | C++ | .cpp | 137 | 24.262774 | 95 | 0.563947 | OpenGenus/cosmos | 13,556 | 3,669 | 2,596 | GPL-3.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
9,806 | sum_of_primes.cpp | OpenGenus_cosmos/code/mathematical_algorithms/src/prime_factors/sum_of_primes.cpp | // A C++ program to find the sum of all the primes not greater than given N.
// Constraints: 1<=N<=10^6
// Constraints : 1<=t<=10^6
// Part of Cosmos by OpenGenus Foundation
#include <iostream>
typedef long long int ll;
using namespace std;
int a[1000005] = {0}; ll b[1000005] = {0};
void sieve(int n)
{
ll s = 0;... | 996 | C++ | .cpp | 42 | 18.261905 | 97 | 0.490011 | OpenGenus/cosmos | 13,556 | 3,669 | 2,596 | GPL-3.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
9,809 | gcd_and_lcm.cpp | OpenGenus_cosmos/code/mathematical_algorithms/src/gcd_and_lcm/gcd_and_lcm.cpp | #include <stdio.h>
#include <algorithm>
// Part of Cosmos by OpenGenus Foundation
int gcd(int x, int y)
{
while (y > 0)
{
x %= y;
std::swap(x, y);
}
return x;
}
//should use this recursive approach.
// int gcd(int c,int d)
// {
// if(d==0)
// return a;
// return gcd(d,c%... | 516 | C++ | .cpp | 30 | 14.366667 | 41 | 0.511387 | OpenGenus/cosmos | 13,556 | 3,669 | 2,596 | GPL-3.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
9,810 | replace_0_with_5.cpp | OpenGenus_cosmos/code/mathematical_algorithms/src/replace_0_with_5/replace_0_with_5.cpp | #include <iostream>
// Part of Cosmos by OpenGenus Foundation
using namespace std;
int main()
{
int n; cin >> n;
int a = 1;
while (n / a >= 1)
{
a = a * 10;
int temp = n % a - n % (a / 10);
temp = temp / (a / 10);
int temp2;
if (temp == 0)
{
... | 428 | C++ | .cpp | 21 | 13.809524 | 41 | 0.418782 | OpenGenus/cosmos | 13,556 | 3,669 | 2,596 | GPL-3.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
9,813 | Binary_GCD_Recursive.cpp | OpenGenus_cosmos/code/mathematical_algorithms/src/Binary_GCD_Algorithm/Binary_GCD_Recursive.cpp | // Recursive program
#include <bits/stdc++.h>
using namespace std;
// Function to implement the
// Stein's Algorithm
int gcd(int x, int y)
{
if (x == y)
return x;
if (x == 0)
return y;
if (y == 0)
return x;
// look for factors of 2
if (~x & 1) // x is even
{
if (y & 1) // y is odd
re... | 695 | C++ | .cpp | 35 | 17.085714 | 45 | 0.543645 | OpenGenus/cosmos | 13,556 | 3,669 | 2,596 | GPL-3.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
9,814 | Binary_GCD_Iterative.cpp | OpenGenus_cosmos/code/mathematical_algorithms/src/Binary_GCD_Algorithm/Binary_GCD_Iterative.cpp | // Iterative Approach
#include <bits/stdc++.h>
using namespace std;
//GCD Function
int gcd(int x, int y)
{
if (x == 0)
return y;
if (y == 0)
return x;
/*Finding K, where K is the
greatest power of 2
that divides both a and b. */
int k;
for (k = 0; ((x | y) && 1) == 0; ++k)
{
x >>= 1;
y >>= 1;
} ... | 776 | C++ | .cpp | 41 | 16.390244 | 48 | 0.535912 | OpenGenus/cosmos | 13,556 | 3,669 | 2,596 | GPL-3.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
9,816 | coprime_numbers.cpp | OpenGenus_cosmos/code/mathematical_algorithms/src/coprime_numbers/coprime_numbers.cpp | #include <iostream>
// Part of Cosmos by OpenGenus Foundation
using namespace std;
template<typename int_type>
int_type gcd(int_type i, int_type j)
{
while (j != 0)
{
int_type x = i;
i = j;
j = x % j;
}
return i;
}
template<typename int_type>
bool isCoPrime(int_type i, int_type... | 520 | C++ | .cpp | 27 | 15.777778 | 41 | 0.587755 | OpenGenus/cosmos | 13,556 | 3,669 | 2,596 | GPL-3.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
9,817 | lexicographic_string_rank.cpp | OpenGenus_cosmos/code/mathematical_algorithms/src/lexicographic_string_rank/lexicographic_string_rank.cpp | /* Part of Cosmos by OpenGenus Foundation */
/* Lexicographic String Rank */
/* O(n) time algorithm */
#include <iostream>
#include <string.h>
using namespace std;
typedef long long ll;
void factorial(ll fact[], int n)
{
fact[0] = 1;
for (int i = 1; i <= n; i++)
fact[i] = fact[i - 1] * i;
}
void initia... | 2,280 | C++ | .cpp | 62 | 32.903226 | 149 | 0.613718 | OpenGenus/cosmos | 13,556 | 3,669 | 2,596 | GPL-3.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
9,819 | std.cpp | OpenGenus_cosmos/code/mathematical_algorithms/src/std/std.cpp | #include <cmath>
template <typename T>
typename T::value_type mean(const T& container)
{
typename T::value_type result;
for (const auto& value : container)
result += value;
if (container.size() > 0)
result /= container.size();
return result;
}
template <typename T>
typename T::value_ty... | 734 | C++ | .cpp | 30 | 20.4 | 49 | 0.644286 | OpenGenus/cosmos | 13,556 | 3,669 | 2,596 | GPL-3.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
9,820 | Iteration Method.cpp | OpenGenus_cosmos/code/numerical_analysis/iteration/src/Iteration Method.cpp | #include<bits/stdc++.h>
using namespace std;
/*
Program to Find Root of the equation x*x*x+x-5=0 by Iteration Method
By simplified this equation we got eq=pow(5-x,(1/3)) then differentiate eq we got (-1/3*pow(5-x,(2/3)))
then we checked if we put natural number in x, will it lower than 1 for all natural numbe... | 1,004 | C++ | .cpp | 40 | 19.1 | 109 | 0.536458 | OpenGenus/cosmos | 13,556 | 3,669 | 2,596 | GPL-3.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false |
9,821 | Newton Rapson Method.cpp | OpenGenus_cosmos/code/numerical_analysis/newton_rapson/src/Newton Rapson Method.cpp | #include<bits/stdc++.h>
using namespace std;
/*
Program to Find Root of the equation x*x*x-18=0 by Newton Rapson Method
First we take 2 values from function of the Equation (negative/positive) then place it in x and y
then we Differentiate This equation;
then apply formula
*/
double func(double x)
{
... | 859 | C++ | .cpp | 33 | 20.636364 | 100 | 0.577723 | OpenGenus/cosmos | 13,556 | 3,669 | 2,596 | GPL-3.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false |
9,822 | False Position.cpp | OpenGenus_cosmos/code/numerical_analysis/false_position/src/False Position.cpp | #include<bits/stdc++.h>
using namespace std;
/*
Program to Find Root of the equation x*x*x-x-1=0 by False Position Method
First we take 2 values from function of the Equation (negative/positive) then place it in a and b;
then we check that if we assigned the right a and b
then we apply False Position Fo... | 1,155 | C++ | .cpp | 45 | 19.4 | 102 | 0.512217 | OpenGenus/cosmos | 13,556 | 3,669 | 2,596 | GPL-3.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false |
9,823 | integral_rectangle.cpp | OpenGenus_cosmos/code/numerical_analysis/integral/src/integral_rectangle.cpp | #include <iostream>
#include <functional>
//Part of Cosmos by OpenGenus Foundation
double integralRectangle(double a, double b, double step, std::function<double(double)> f)
{
double fragment, res;
fragment = (b - a) / step;
res = step * (f(a) + f(b)) / 6.0;
for (int i = 1; i <= fragment; ++i)
... | 939 | C++ | .cpp | 31 | 25.967742 | 90 | 0.533702 | OpenGenus/cosmos | 13,556 | 3,669 | 2,596 | GPL-3.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
9,824 | integral_trapezoid.cpp | OpenGenus_cosmos/code/numerical_analysis/integral/src/integral_trapezoid.cpp | #include <iostream>
#include <functional>
//Part of Cosmos by OpenGenus Foundation
double integralTrapezoid(double a, double b, double step, std::function<double(double)> f)
{
double fragment, res;
fragment = (b - a) / step;
res = step * (f(a) + f(b)) / 2.0;
for (int i = 1; i <= fragment - 1; ++i)
... | 822 | C++ | .cpp | 29 | 24.241379 | 90 | 0.553729 | OpenGenus/cosmos | 13,556 | 3,669 | 2,596 | GPL-3.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
9,826 | Bisection Method.cpp | OpenGenus_cosmos/code/numerical_analysis/bisection/src/Bisection Method.cpp | #include<bits/stdc++.h>
using namespace std;
/*
Program to Find Root of the equation x*x-2*x-2=0 by Bisection Method
First we take 2 values from function of the Equation (negative/positive) then place it in a and b;
then we check that if we assigned the right a and b
then we apply Bisection Method Formu... | 1,111 | C++ | .cpp | 47 | 17.425532 | 102 | 0.50566 | OpenGenus/cosmos | 13,556 | 3,669 | 2,596 | GPL-3.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false |
9,827 | rk4.cpp | OpenGenus_cosmos/code/numerical_analysis/runge_kutt/src/rk4.cpp | #include <iostream>
#include <vector>
#include <functional>
#include <cmath>
using xy = std::pair<double, double>;
std::vector<xy> rungeKutt(xy startConditions,
double startInterval,
double finishInterval,
double step,
... | 2,125 | C++ | .cpp | 54 | 32.12963 | 93 | 0.569908 | OpenGenus/cosmos | 13,556 | 3,669 | 2,596 | GPL-3.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
9,829 | pi_monte_carlo.cpp | OpenGenus_cosmos/code/numerical_analysis/monte_carlo/src/pi_monte_carlo.cpp | #include <iostream>
#include <random>
//Part of Cosmos by OpenGenus Foundation
double piMonteCarlo(double pointCount)
{
double circlePoints = 0;
double pi, x, y;
std::random_device rd;
std::mt19937 gen(rd());
std::uniform_real_distribution<> dis;
for (int i = 0; i < pointCount; ++i)
{
... | 701 | C++ | .cpp | 29 | 19.655172 | 52 | 0.58209 | OpenGenus/cosmos | 13,556 | 3,669 | 2,596 | GPL-3.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
9,830 | integral_monte_carlo.cpp | OpenGenus_cosmos/code/numerical_analysis/monte_carlo/src/integral_monte_carlo.cpp | #include <iostream>
#include <functional>
#include <random>
//Part of Cosmos by OpenGenus Foundation
double integralMonteCarlo(double a, double b, double pointCount, std::function<double(double)> f)
{
double res, randX, randY;
std::random_device rd;
std::mt19937 gen(rd());
std::uniform_real_distributio... | 977 | C++ | .cpp | 35 | 23.657143 | 97 | 0.573404 | OpenGenus/cosmos | 13,556 | 3,669 | 2,596 | GPL-3.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
9,832 | nfa.cpp | OpenGenus_cosmos/code/theory_of_computation/src/nondeterministic_finite_atomaton/nfa.cpp | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>
int row = 0;
struct node
{
int data;
struct node* next;
char edgetype;
}typedef node;
node* push(node* first , char edgetype , int data)
{
node* new_node = (node*)malloc(sizeof(node));
new_node->edg... | 2,339 | C++ | .cpp | 117 | 16.230769 | 69 | 0.566621 | OpenGenus/cosmos | 13,556 | 3,669 | 2,596 | GPL-3.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false |
9,833 | dfa.cpp | OpenGenus_cosmos/code/theory_of_computation/src/deterministic_finite_automaton/dfa.cpp | #include "dfa.hh"
#include <stdlib.h>
#include <string.h>
using namespace std;
void dfa_makeNextTransition(dfa* dfa, char symbol)
{
int transitionID;
DFAState* pCurrentState = dfa->states[dfa->currentStateID];
for (transitionID = 0; transitionID < pCurrentState->numberOfTransitions; transitionID++)
{
if (pCurre... | 1,525 | C++ | .cpp | 53 | 26.849057 | 90 | 0.764022 | OpenGenus/cosmos | 13,556 | 3,669 | 2,596 | GPL-3.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false |
9,834 | vector-to-map.cpp | OpenGenus_cosmos/code/languages/cpp/vector-to-map.cpp | #include <bits/stdc++.h>
using namespace std;
int main() {
map<string,int> mp1;
mp1["Shivani"] = 500;
mp1["Kumari"] = 100;
mp1["Hacktoberfest"] = 400;
vector<pair<string,int>> vec1;
for(auto i : mp1) //inserting map values into vector
{
vec1.push_back(make_pair(i.first,i.second));
}
for(auto j : vec1)
cout<<j.... | 363 | C++ | .cpp | 16 | 21.1875 | 54 | 0.682216 | OpenGenus/cosmos | 13,556 | 3,669 | 2,596 | GPL-3.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false |
9,835 | Largest_element.cpp | OpenGenus_cosmos/code/languages/cpp/largest-element-in-an-array/Largest_element.cpp | #include <iostream>
using namespace std;
int findlargestelement(int arr[], int n){
int largest = arr[0];
for(int i=0; i<n; i++) {
if(largest<arr[i]) {
largest=arr[i];
}
}
return largest;
}
int main() {
int n;
cout<<"Enter the size of array: ";
cin>>n;
int arr[n];
... | 506 | C++ | .cpp | 24 | 16.833333 | 44 | 0.578616 | OpenGenus/cosmos | 13,556 | 3,669 | 2,596 | GPL-3.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
9,838 | sorting_vector.cpp | OpenGenus_cosmos/code/languages/cpp/sort_vector/sorting_vector.cpp | //sorting using vectors
#include<bits/stdc++.h>
using namespace std;
int main;
{
vector<int> v;
cout<<"size of array"<<endl;
cin>>n;
for(int i=0;i<n;i++)
{
v.push_back(i);
}
for(int i=0;i<n;i++)
{
cout<<v[i]<<" ";
}
sort(v.begin(),vec.end());
for(int x:v)
{
cout<<x<<" ";
}
return... | 326 | C++ | .cpp | 23 | 11.434783 | 30 | 0.547855 | OpenGenus/cosmos | 13,556 | 3,669 | 2,596 | GPL-3.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false |
9,839 | multimap.cpp | OpenGenus_cosmos/code/languages/cpp/initializing_multimap/multimap.cpp | #include<iostream>
#include<cstdlib>
#include<map>
using namespace std;
int main()
{
//common way to initialize a multimap
std::multimap<char, int> m; //empty multimap container
m.insert({'a',1}); //inserting (a,1)
m.insert({'a',1}); //inserting (a,1)
m.insert({'b',2}); //inserting (b,2)
m.ins... | 2,711 | C++ | .cpp | 74 | 31.472973 | 60 | 0.546045 | OpenGenus/cosmos | 13,556 | 3,669 | 2,596 | GPL-3.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
9,841 | begin_and_end.cpp | OpenGenus_cosmos/code/languages/cpp/begin_and_end/begin_and_end.cpp | // Implementation of begin() function
#include <array>
#include <iostream>
using namespace std;
int main()
{
// declaration of array container
array<int, 5> myarray{ 1, 2, 3, 4, 5 };
// using begin() to print array
for (auto it = myarray.begin(); it! =myarray. end(); ++it)
cout << ' ' << *it;
retur... | 661 | C++ | .cpp | 27 | 21.703704 | 60 | 0.632166 | OpenGenus/cosmos | 13,556 | 3,669 | 2,596 | GPL-3.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
9,844 | Linear Search In A LinkedList With Duplicates.cpp | OpenGenus_cosmos/code/languages/cpp/linear_search/Linear Search In A LinkedList With Duplicates.cpp | #include <bits/stdc++.h>
using namespace std;
struct node
{
int data;
struct node *nptr; // next pointer
};
struct node *hptr = NULL; // head pointer
void insert(int pos, int x)
{
struct node *temp = new node;
if (temp == NULL)
cout<<"Insertion not possible\n";
temp->data = x; // storing ... | 1,658 | C++ | .cpp | 84 | 14.011905 | 75 | 0.493308 | OpenGenus/cosmos | 13,556 | 3,669 | 2,596 | GPL-3.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false |
9,845 | Linear Search In Duplicate Array.cpp | OpenGenus_cosmos/code/languages/cpp/linear_search/Linear Search In Duplicate Array.cpp | // C++ code to linearly search x in arr[].
//If x is present then return its location, otherwise return -1
#include <iostream>
using namespace std;
int *linearSearch(int arr[], int result[], int N, int x)
{
int pos = -1, ind = 0;
for (int i = 0; i <N; ++i)
{
if (arr[i] == x)
{
... | 910 | C++ | .cpp | 35 | 20.828571 | 68 | 0.525892 | OpenGenus/cosmos | 13,556 | 3,669 | 2,596 | GPL-3.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false |
9,848 | free_vs_delete.cpp | OpenGenus_cosmos/code/languages/cpp/delete_vs_free/free_vs_delete.cpp | //Example of free() function using malloc and realloc:
#include <iostream>
#include <cstdlib>
#include <cstring>
using namespace std;
int main()
{
char *ptr;
ptr = (char*) malloc(10*sizeof(char)); //Allocating memory to thr character pointer
strcpy(ptr,"Hello C++");
cout << "Before reallocat... | 1,450 | C++ | .cpp | 38 | 36.105263 | 96 | 0.612347 | OpenGenus/cosmos | 13,556 | 3,669 | 2,596 | GPL-3.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
9,850 | int8_t_test.cpp | OpenGenus_cosmos/code/languages/cpp/uint8_t/int8_t_test.cpp | #include <iostream>
int main() {
uint8_t number = 4;
std::cout << "Number=" << +number << std::endl;
return 0;
} | 119 | C++ | .cpp | 6 | 17.833333 | 49 | 0.60177 | OpenGenus/cosmos | 13,556 | 3,669 | 2,596 | GPL-3.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false |
9,851 | double_to_str.cpp | OpenGenus_cosmos/code/languages/cpp/double_to_string/double_to_str.cpp | //double to String using C++’s std::to_string:
#include <iostream>
#include <string>
#include <sstream> //to use ostringstream
#include <cstring> //to use sprintf
#include <boost/lexical_cast.hpp> //to use boost's lexical cast
using namespace std;
int main()
{
double d1 = 23.43;
double d2 = 1e-9;
double... | 4,389 | C++ | .cpp | 130 | 28.938462 | 142 | 0.530675 | OpenGenus/cosmos | 13,556 | 3,669 | 2,596 | GPL-3.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
9,852 | continue.cpp | OpenGenus_cosmos/code/languages/cpp/loop/continue.cpp | #include <iostream>
int main()
{
for (int j=0; j<=8; j++)
{
if (j==5)
{
/* The continue statement is encountered when
* the value of j is equal to 5.
*/
continue;
}
/* This print statement would not execute for the
* loop iteration where j ==5 because in that ca... | 428 | C++ | .cpp | 23 | 14.478261 | 56 | 0.568238 | OpenGenus/cosmos | 13,556 | 3,669 | 2,596 | GPL-3.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
9,853 | life.cpp | OpenGenus_cosmos/code/cellular_automaton/src/conways_game_of_life/life.cpp | #include <iostream>
#include <fstream>
#include <cstdlib>
using namespace std;
// Part of Cosmos by OpenGenus Foundation
// Defines the world size parameters
const int SIZE_X = 50;
const int SIZE_Y = 160;
// Number of random cells are filled
const int number = SIZE_X * SIZE_Y / 8;
void loadConfig(char world[][SIZE_Y])... | 4,512 | C++ | .cpp | 150 | 24.26 | 83 | 0.549712 | OpenGenus/cosmos | 13,556 | 3,669 | 2,596 | GPL-3.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | false | false | false | true | true | false |
9,854 | genetic.cpp | OpenGenus_cosmos/code/cellular_automaton/src/genetic_algorithm/genetic.cpp | /**
* Root finding using genetic algorithm (Uses C++11).
* Reference: https://arxiv.org/abs/1703.03864
*/
#include <algorithm>
#include <cmath>
#include <iostream>
#include <random>
#include <vector>
struct StopCondition
{
StopCondition(double tol, long iter)
: tolerance(tol)
, iterations(iter)... | 1,929 | C++ | .cpp | 70 | 21.771429 | 76 | 0.576299 | OpenGenus/cosmos | 13,556 | 3,669 | 2,596 | GPL-3.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
9,855 | langtons_ant.cpp | OpenGenus_cosmos/code/cellular_automaton/src/langtons_ant/langtons_ant.cpp | #include <iostream>
#include <vector>
#include <array>
using std::cout;
using std::cin;
using std::vector;
using std::array;
class Direction
{
public:
int x;
int y;
const static Direction north;
const static Direction east;
const static Direction south;
const static Direction west;
const s... | 2,293 | C++ | .cpp | 103 | 16.640777 | 64 | 0.545078 | OpenGenus/cosmos | 13,556 | 3,669 | 2,596 | GPL-3.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
9,857 | baconian_test.cpp | OpenGenus_cosmos/code/cryptography/test/baconian_cipher/baconian_test.cpp | #include <assert.h>
#include <iostream>
#include "./../../src/baconian_cipher/baconian.cpp"
// Part of Cosmos by OpenGenus Foundation
int main()
{
std::string baconianString = "AABBBAABAAABABBABABBABBBA BABBAABBBABAAABABABBAAABB";
std::string englishString = "HELLO WORLD";
std::map<char, std::string> gener... | 537 | C++ | .cpp | 13 | 38.384615 | 87 | 0.751434 | OpenGenus/cosmos | 13,556 | 3,669 | 2,596 | GPL-3.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
9,864 | aes_128.cpp | OpenGenus_cosmos/code/cryptography/src/aes_128/aes_128.cpp | /*
* National University from Colombia
* Author:Andres Vargas, Jaime
* Gitub: https://github.com/jaavargasar
* webpage: https://jaavargasar.github.io/
* Language: C++
*
* Description: Given an array 1 ( outpu1 ), an array2 (output2) and a key
* we gotta decipher the messege and read what the messege i... | 12,097 | C++ | .cpp | 286 | 37.979021 | 100 | 0.58169 | OpenGenus/cosmos | 13,556 | 3,669 | 2,596 | GPL-3.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
9,865 | atbash_cipher.cpp | OpenGenus_cosmos/code/cryptography/src/atbash_cipher/atbash_cipher.cpp | #include <iostream>
#include <string>
#include <cctype>
using namespace std;
//Atbash Cipher modified for English
string atbash(string s);
int main()
{
string s;
cout << "Enter message to encrypt/decrypt: ";
getline(cin, s);
cout << endl << atbash(s) << endl;
}
string atbash(string s)
{
string ne... | 609 | C++ | .cpp | 27 | 17.888889 | 49 | 0.537133 | OpenGenus/cosmos | 13,556 | 3,669 | 2,596 | GPL-3.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
9,870 | autokey_cipher.cpp | OpenGenus_cosmos/code/cryptography/src/autokey_cipher/autokey_cipher.cpp | #include <iostream>
std::string autokeycipher(std::string text, char key, int encrypt)
{
for (int i = 0; i < text.length(); ++i)
{
if (isalpha(text[i]))
{
text[i] = toupper(text[i]);
}
}
int nextkey, keyvalue, result;
nextkey = toupper(key) - 'A';
for (int ... | 1,799 | C++ | .cpp | 60 | 22.883333 | 77 | 0.53619 | OpenGenus/cosmos | 13,556 | 3,669 | 2,596 | GPL-3.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
9,872 | columnar_transposition_cipher.cpp | OpenGenus_cosmos/code/cryptography/src/columnar_transposition_cipher/columnar_transposition_cipher.cpp | // CPP program for
// Columnar Transposition Cipher
#include <string>
#include <iostream>
#include <map>
using namespace std;
map<int, int> keyMap;
void setPermutationOrder(string key)
{
// Add the permutation
for (size_t i = 0; i < key.length(); i++)
keyMap[key[i]] = i;
}
// Encryption code for ciph... | 3,008 | C++ | .cpp | 97 | 24.216495 | 84 | 0.529453 | OpenGenus/cosmos | 13,556 | 3,669 | 2,596 | GPL-3.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
9,873 | test_push_relabel.cpp | OpenGenus_cosmos/code/graph_algorithms/test/push_relabel/test_push_relabel.cpp | #define CATCH_CONFIG_MAIN
#include "../../../../test/c++/catch.hpp"
#include "../../src/push_relabel/push_relabel.cpp"
#include <iostream>
int g_testCounter = 0;
std::vector<std::vector<int>> g_graph;
std::vector<std::vector<int>> g_flow;
int test(int s, int t, bool empty)
{
int k = (empty ? maxFlowEmpty(g_graph... | 2,714 | C++ | .cpp | 61 | 40.098361 | 78 | 0.577685 | OpenGenus/cosmos | 13,556 | 3,669 | 2,596 | GPL-3.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
9,876 | travelling_salesman_dp.cpp | OpenGenus_cosmos/code/graph_algorithms/src/travelling_sales_man_dp/travelling_salesman_dp.cpp | #include <bits/stdc++.h>
using namespace std;
class brute_force
{
public:
int shortest_path_sum(int** edges_list, int num_nodes)
{
int source = 0;
vector<int> nodes;
for(int i=0;i<num_nodes;i++)
{
if(i != source)
{
nodes.push_back(i);
... | 2,951 | C++ | .cpp | 106 | 20.575472 | 123 | 0.535639 | OpenGenus/cosmos | 13,556 | 3,669 | 2,596 | GPL-3.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
9,877 | bipartite_checking2.cpp | OpenGenus_cosmos/code/graph_algorithms/src/bipartite_checking/bipartite_checking2.cpp | #include <iostream>
#include <vector>
#include <algorithm>
/* Part of Cosmos by OpenGenus Foundation */
bool dfs(int v, std::vector<std::vector<int>> &g, std::vector<int> &dp)
{
for (int u : g[v])
{
if (!dp[u])
{
dp[u] = 3 - dp[v]; // 3 - 1 = 2; 3 - 2 = 1
dfs(u, g, dp);... | 1,376 | C++ | .cpp | 55 | 18.963636 | 92 | 0.482838 | OpenGenus/cosmos | 13,556 | 3,669 | 2,596 | GPL-3.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
9,878 | bipartite_checking.cpp | OpenGenus_cosmos/code/graph_algorithms/src/bipartite_checking/bipartite_checking.cpp | #include <iostream>
#include <queue>
using namespace std;
int bipartite(int g[][10], int s, int n)
{
int *col = new int [n];
for (int i = 0; i < n; i++)
col[i] = -1;
queue<int> q;
col[s] = 1;
q.push(s);
while (!q.empty())
{
int u = q.front();
q.pop();
i... | 875 | C++ | .cpp | 41 | 14.02439 | 54 | 0.372405 | OpenGenus/cosmos | 13,556 | 3,669 | 2,596 | GPL-3.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
9,880 | kuhn_munkres_algorithm.cpp | OpenGenus_cosmos/code/graph_algorithms/src/kuhn_munkres_algorithm/kuhn_munkres_algorithm.cpp | /*
* Part of Cosmos by OpenGenus Foundation
*
* Kuhn-Munkres algorithm: find the perfect matching in a balanced and weighted bipartite graph
* that gives the maximum sum of weights.
*/
#include <memory>
#include <vector>
#include <type_traits>
#include <limits>
#include <algorithm>
#include <iostream>
#include <in... | 5,670 | C++ | .cpp | 139 | 32.251799 | 100 | 0.582336 | OpenGenus/cosmos | 13,556 | 3,669 | 2,596 | GPL-3.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
9,882 | hamiltonian_path.cpp | OpenGenus_cosmos/code/graph_algorithms/src/hamiltonian_path/hamiltonian_path.cpp | #include <iostream>
#include <vector>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <cstring>
using namespace std;
const int MAXN = 8000;
const int INF = (int)1e9;
int n, m, *deg, *par, tl = -1;
bool *used;
vector <vector <int>> G;
inline void count_degs()
{
for (int i = 0; i < n; i++)
... | 1,861 | C++ | .cpp | 81 | 15.901235 | 50 | 0.411964 | OpenGenus/cosmos | 13,556 | 3,669 | 2,596 | GPL-3.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
9,885 | transitive_closure_graph.cpp | OpenGenus_cosmos/code/graph_algorithms/src/transitive_closure_graph/transitive_closure_graph.cpp | #include <stdio.h>
#include <iostream>
using namespace std;
void printSolution(int reach[][4])
{
cout << "Following matrix is transitive closure of the given graph\n";
for (int i = 0; i < 4; i++)
{
for (int j = 0; j < 4; j++)
cout << reach[i][j];
cout << endl;
}
}
void transi... | 883 | C++ | .cpp | 34 | 19.029412 | 74 | 0.429752 | OpenGenus/cosmos | 13,556 | 3,669 | 2,596 | GPL-3.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | true | false |
9,889 | dijkstra_shortest_path.cpp | OpenGenus_cosmos/code/graph_algorithms/src/dijkstra_shortest_path/dijkstra_shortest_path.cpp | #include <iostream>
#include <vector>
#include <set>
#include <utility>
using namespace std;
// Part of Cosmos by OpenGenus Foundation
const int N = 1E4 + 1;
vector<pair<int, int>> graph[N];
set<pair<int, int>> pq;
int dist[N], vis[N];
int main()
{
int n, m; cin >> n >> m;
while (m--)
{
int u, v, ... | 987 | C++ | .cpp | 41 | 17.95122 | 53 | 0.466102 | OpenGenus/cosmos | 13,556 | 3,669 | 2,596 | GPL-3.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
9,891 | push_relabel.cpp | OpenGenus_cosmos/code/graph_algorithms/src/push_relabel/push_relabel.cpp | #include <vector>
#include <queue>
// push as much excess flow as possible from f to t
void push(std::vector<std::vector<int>> graph, std::vector<std::vector<int>>& flow,
std::vector<std::vector<int>>& residual, std::vector<int>& excess, int f, int t)
{
if (excess[f] <= 0)
{
std::cerr << "ex... | 4,385 | C++ | .cpp | 128 | 25.851563 | 97 | 0.523855 | OpenGenus/cosmos | 13,556 | 3,669 | 2,596 | GPL-3.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
9,893 | topological_sort.cpp | OpenGenus_cosmos/code/graph_algorithms/src/topological_sort/topological_sort.cpp | /* Part of Cosmos by OpenGenus Foundation */
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
using namespace std;
#define NUM_V 100005
vector<int> adjList[NUM_V + 5];
int inDegree[NUM_V + 5];
int vertex;
vector<int> toposort()
{
vector<int> result;
queue<int> q;
... | 1,678 | C++ | .cpp | 67 | 19.283582 | 80 | 0.528231 | OpenGenus/cosmos | 13,556 | 3,669 | 2,596 | GPL-3.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
9,894 | kahn_algorithm_basic.cpp | OpenGenus_cosmos/code/graph_algorithms/src/topological_sort/kahn_algorithm_basic.cpp | /*
* Implementation of the Kahn's algorithm
* for topological sort in a directed acyclic graph
*/
#include <iostream>
#include "bits/stdc++.h"
using namespace std;
queue<int> q, q2;
long long n = 100000;
int v, e, v1, v2, visited[10000], level[100000], indegree[100000];
vector<int> g[100000];
void bfs(int i)
{
w... | 1,229 | C++ | .cpp | 60 | 16.383333 | 66 | 0.491789 | OpenGenus/cosmos | 13,556 | 3,669 | 2,596 | GPL-3.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false |
9,895 | kahn_algo_unique_toposort.cpp | OpenGenus_cosmos/code/graph_algorithms/src/topological_sort/kahn_algo_unique_toposort.cpp | // Sample problem for using this algorithm - UVA 11060 Beverages
#include <bits/stdc++.h>
#define all(a) a.begin(), a.end()
#define ll long long
#define inp(a) scanf("%d", &a)
#define out(a) printf("%d\n", a)
#define inp2(a) scanf("%lld", &a)
#define out2(a) printf("%lld\n", a)
#define arrinput(a, n) for (int i = 0; i ... | 2,478 | C++ | .cpp | 86 | 23.011628 | 81 | 0.543287 | OpenGenus/cosmos | 13,556 | 3,669 | 2,596 | GPL-3.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
9,902 | centroid_decomposition.cpp | OpenGenus_cosmos/code/graph_algorithms/src/centroid_decomposition/centroid_decomposition.cpp | #include <iostream>
#include <vector>
class Graph
{
public:
int ver_;
std::vector<std::vector<int>> adj_;
std::vector<std::vector<int>> centroidTree_;
std::vector<int> sizes_;
std::vector<bool> marked_;
Graph(int num) :
ver_(num),
adj_(num + 1),
centroidTree_(num + 1),
... | 3,006 | C++ | .cpp | 100 | 23.84 | 92 | 0.550915 | OpenGenus/cosmos | 13,556 | 3,669 | 2,596 | GPL-3.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
9,904 | cut_vertices.cpp | OpenGenus_cosmos/code/graph_algorithms/src/cut_vertices/cut_vertices.cpp | #include <iostream>
#include <vector>
#include <climits>
using namespace std;
typedef long long ll;
// Part of Cosmos by OpenGenus Foundation
const int MAXN = 1e4 + 5;
vector<int> adj[MAXN];
bool vis[MAXN], AP[MAXN];
int n, m, currTime, disc[MAXN];
int low[MAXN]; // low[i] is the minimum of visited currTime of all ve... | 1,523 | C++ | .cpp | 59 | 19.627119 | 104 | 0.503429 | OpenGenus/cosmos | 13,556 | 3,669 | 2,596 | GPL-3.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
9,906 | boruvka_minimum_spanning_tree.cpp | OpenGenus_cosmos/code/graph_algorithms/src/boruvka_minimum_spanning_tree/boruvka_minimum_spanning_tree.cpp | #include <iostream>
#include <vector>
const int MAXN = 10000;
const int inf = 0x3fffffff;
int nodeCount, edgesCount;
std::vector<std::pair<int, int>> graf[MAXN];
void readGraph()
{
std::cin >> nodeCount >> edgesCount;
for (int i = 0; i < edgesCount; i++)
{
int x, y, w;
std::cin >> x >> y ... | 2,639 | C++ | .cpp | 101 | 18.722772 | 89 | 0.497032 | OpenGenus/cosmos | 13,556 | 3,669 | 2,596 | GPL-3.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | true | true | true | false |
9,910 | count_of_ways_n.cpp | OpenGenus_cosmos/code/graph_algorithms/src/count_of_ways_n/count_of_ways_n.cpp | #include <iostream>
#include <vector>
const int MOD = 1000000007;
int size, n;
std::vector< std::vector<long long>> multiple (std::vector< std::vector<long long>> a,
std::vector< std::vector<long long>> b)
{
std::vector< std::vector<long long>> res(size);
for ... | 1,495 | C++ | .cpp | 51 | 22.215686 | 100 | 0.490169 | OpenGenus/cosmos | 13,556 | 3,669 | 2,596 | GPL-3.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
9,912 | lowest_common_ancestor.cpp | OpenGenus_cosmos/code/graph_algorithms/src/lowest_common_ancestor/lowest_common_ancestor.cpp | #include <iostream>
#include <vector>
#include <array>
using namespace std;
// Part of Cosmos by OpenGenus Foundation
// Problem Statement
/*
* Given a tree with n nodes
* Your task is to process q queries of the following form:
* who is the lowest common ancestor of nodes a and b in the tree?
*
* The lowest com... | 1,812 | C++ | .cpp | 67 | 22.134328 | 102 | 0.547977 | OpenGenus/cosmos | 13,556 | 3,669 | 2,596 | GPL-3.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | false | false | false | false | false | false |
9,913 | cycle_undirected_graph_union_find.cpp | OpenGenus_cosmos/code/graph_algorithms/src/cycle_undirected_graph/cycle_undirected_graph_union_find.cpp | /*this includes code for cheking the cycle is undirected graph using unionfind disjoint data structure
*
* the implementation is very fast
* as it implements unionfind disjoint structure using path-compression and rank heuristics
*/
#include <vector>
#include <cstddef>
int p[1000000]; //stores parent
int rnk[100... | 1,188 | C++ | .cpp | 44 | 21.795455 | 102 | 0.596137 | OpenGenus/cosmos | 13,556 | 3,669 | 2,596 | GPL-3.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
9,915 | breadth_first_search.cpp | OpenGenus_cosmos/code/graph_algorithms/src/breadth_first_search/breadth_first_search.cpp | #include <iostream>
#include <map>
#include <set>
#include <queue>
/* Part of Cosmos by OpenGenus Foundation */
void bfs(int start, // the node that we are currently at
std::map<int, std::set<int>>& adjList, // the adjacency list for each nod... | 2,733 | C++ | .cpp | 76 | 29.855263 | 124 | 0.569161 | OpenGenus/cosmos | 13,556 | 3,669 | 2,596 | GPL-3.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
9,917 | redundant_connection.cpp | OpenGenus_cosmos/code/graph_algorithms/src/redundant-connection/redundant_connection.cpp | /*
* Part of Cosmos by OpenGenus foundation
*
* Redundant Connection
*
* Description
*
* Return an edge that can be removed from an undirected graph so that the resulting graph is a tree of N nodes
*/
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
vector<int> parent; //dis... | 1,450 | C++ | .cpp | 63 | 17.825397 | 111 | 0.554269 | OpenGenus/cosmos | 13,556 | 3,669 | 2,596 | GPL-3.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
9,921 | depth_first_search.cpp | OpenGenus_cosmos/code/graph_algorithms/src/depth_first_search/depth_first_search.cpp | #include <iostream>
#include <map>
#include <set>
/* Part of Cosmos by OpenGenus Foundation */
void dfs(int current, // the node that we are currently at
std::map<int, std::set<int>>& adjList, // the adjacency list for each node
std::map<int, ... | 1,435 | C++ | .cpp | 53 | 22.075472 | 108 | 0.534545 | OpenGenus/cosmos | 13,556 | 3,669 | 2,596 | GPL-3.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
9,922 | test_kruskal.cpp | OpenGenus_cosmos/code/greedy_algorithms/test/kruskal_minimum_spanning_tree/test_kruskal.cpp | #include "../../src/kruskal_minimum_spanning_tree/kruskal.cpp"
#include "../../../data_structures/src/tree/multiway_tree/union_find/union_find_dynamic.cpp"
#include <iostream>
using namespace std;
pair<int, int> edgeFunc(pair<pair<int, int>, int> edge)
{
return edge.first;
}
class HeapCompare
{
public:
bool ... | 2,173 | C++ | .cpp | 73 | 19.041096 | 92 | 0.301769 | OpenGenus/cosmos | 13,556 | 3,669 | 2,596 | GPL-3.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
9,924 | SplitArrayLargestSum.cpp | OpenGenus_cosmos/code/greedy_algorithms/src/SplitArrayLargestSum/SplitArrayLargestSum.cpp | //CODE
#include <bits/stdc++.h>
using namespace std;
class Solution {
private:
/*
Parameters:
nums - The input array;
cuts - How many cuts are available (cuts = #groups - 1);
max - The maximum of the (sum of elements in one group);
Return:
Whethe... | 3,569 | C++ | .cpp | 82 | 32.878049 | 125 | 0.560335 | OpenGenus/cosmos | 13,556 | 3,669 | 2,596 | GPL-3.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
9,925 | kruskal.cpp | OpenGenus_cosmos/code/greedy_algorithms/src/kruskal_minimum_spanning_tree/kruskal.cpp | #include <algorithm>
#include <vector>
namespace kruskal_impl {
using namespace std;
template<typename _ForwardIter, typename _ValueType>
pair<_ValueType, _ValueType> edgeFuncPolicy(_ForwardIter it);
template<typename _ValueType>
struct UnionFindPolicy
{
void merge(_ValueType a, _ValueType b);
bool connecte... | 1,348 | C++ | .cpp | 42 | 26.5 | 75 | 0.67284 | OpenGenus/cosmos | 13,556 | 3,669 | 2,596 | GPL-3.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
9,932 | min_operation.cpp | OpenGenus_cosmos/code/greedy_algorithms/src/min_operation_to_make_gcd_k/min_operation.cpp | #include <bits/stdc++.h>
using namespace std;
int main()
{
int n; // no. of elements in array
int k; // new GCD
cout << "Enter number of elements in array: ";
cin >> n;
cout << "\nEnter the array: ";
int arr[n]; // array
for(int i = 0 ; i < n ; i++)
cin >... | 895 | C++ | .cpp | 31 | 20.774194 | 68 | 0.460648 | OpenGenus/cosmos | 13,556 | 3,669 | 2,596 | GPL-3.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
9,939 | partitions_of_set.cpp | OpenGenus_cosmos/code/backtracking/src/partitions_of_set/partitions_of_set.cpp | /// Part of Cosmos by OpenGenus Foundation
#include <stdio.h>
#include <vector>
void backtrack(int level);
void print_sol();
std::vector<int> v;
std::vector<int> solution;
int maxfromSol = 0;
int N;
int solsFound = 0;
int main()
{
scanf("%d", &N);
v.reserve(N + 1);
solution.reserve(N + 1);
for (int i = ... | 1,027 | C++ | .cpp | 49 | 15.77551 | 45 | 0.507677 | OpenGenus/cosmos | 13,556 | 3,669 | 2,596 | GPL-3.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.