instruction stringlengths 71 95.1k |
|---|
For a hobby project, My aim is to design and implement a generic system for pooling an arbitrary class of object. I tried implementing it using templates.
This pool should support 4 actions:
"Create a pool"
"Allocate an object from this pool"
"Deallocate an object from this pool"
"Destroy this pool"
For sake of simplic... |
This is a follow-up question for ConvertAll Methods Implementation for Multidimensional Array in C#. Thanks to aepot's answer and Olivier's answer. In order to match the usage of the build-in API Array.ConvertAll, the input /output array types of the implemented methods below are similar to [], [,], [,,] and etc. style... |
I am trying to perform a certain numerical computation in Python with Numpy.
More specifically, I am doing a multivariate Kernel Density Estimation (KDE) in a Euclidean space of dimension F for objects with missing values. For each incomplete object of index "k", the kernels is no Gaussians, but a Gaussians in the subs... |
My code writes, reads, and removes program settings in the registry. I'm using Visual Studio 2019 and my target Framework is .NET Framework 4.8.
I'm looking for more elegant functions.
Is there error handling I missed in these functions?
How can I optimize the code?
I have the following functions at the moment:
public ... |
I searched the net for some bfs and dfs code but rarely found some as reference. I wrote this for an assignment, I am getting the results fine. I want to make my code more compact and remove unwanted stuff or need suggestions to make the code better. I used stack and queue data structures for the implementation
#includ... |
Faced with converting floating-point values from a sensor obtained to string on an embedded system to transmit over UART, I came up with the following dbl2str() to handle either float or double input. The accuracy of the last digit in the fractional part wasn't important as the floating point-values were from a tempera... |
I've got a method which removes quantity from inventory when an order is completed. If there is not enough inventory quantity available, the order completion fails and the sql transaction is rolled back. Otherwise, transaction is commited.
I'm using Dapper for MySQL database access
public async Task<(bool, stri... |
I am a newbie in std::thread and std::condition_variable.
I would like to use 2 threads: one for display (void showCalibration()) and the other for processing (void CaptureFrame()). These threads access a global variable (temp_pupil).
The display thread will clear the variable after a specific time to get the data (pup... |
What I try to achieve
I need to create a secure forgot password reset system. I am especially worrying about the security of this code and how to further improve it. Here's my code:
d32b6f67a9d2ff687d9b7d.php:
maintenance
placed one level above the root folder
<?php
define('WEB_MASTER_EMAIL', 'mail@example.com');
defin... |
The program itself reads 100 values from a text file named input.txt. Then sorts those values in ascending order and writes the values to a new file called output.txt.
I used two try-catches for the Scanner and the PrintWriter since to my very basic knowledge they can throw different exceptions. So if anyone can review... |
Recently, I've been going through Scott Meyer's Effective Modern C++ and found the discussion on shared_ptr really interesting. I also watched Louis Brandy's Curiously Recurring C++ Bugs at Facebook talk which also had some details about how shared_ptr works, and I thought it would be fun to implement my own to see if ... |
I want to implement Kafka Topic which sends and receives Serialized Java Objects based on this example.
I tried this:
Producer Config:
@Configuration
public class KafkaProducerConfig {
@Value(value = "${kafka.bootstrapAddress}")
private String bootstrapAddress;
@Bean
public ProducerFactory<String,... |
Original: Advent of Code 2020 - Day 2: validating passwords
Problem statement
I decided to translate my Rust solution to Advent of Code 2020 into C++ to increase my familiarity with C++. Here's the task for Day 2:
Day 2: Password Philosophy
[...]
To try to debug the problem, they have created a list (your puzzle
inpu... |
This is codechef beginner problem.
How I can make it efficient, It is taking 2.09 sec while time limit is 2.0764 secs.
Problem is:
For a given positive integer K of not more than 1000000 digits, write the value of the smallest palindrome larger than K to output. Numbers are always displayed without leading zeros.
https... |
Here is my code which will read XML files and import the data to MongoDb. Do you have any comments on my code?
const fs = require('fs');
const xml2js = require('xml2js');
const log = console.log;
const path = require( "path" );
const folderPath = 'D:/Data';
const folder = folderPath;
fs.readdirSync(folder).forEach(fi... |
Memory:O(log(max)base(mod)*mod)Speed:O(log(max)base(mod)*n)
I did a radix sort in place to not get a auxliar array. In the process i discorver a few things.
Is imposible to do LSD radix sort in place with out sacrifice speed, belive me if i say i try. THIS WILL BE NOT EXPLAING
counting sort, you can do it for in plac... |
I've written a toy example of the concurrent stack which has only three functions push(), peek(), and length(). I've used atomic variables for synchronization. Is there anything incorrect in terms of synchronization? Could you please review this code?
#include <iostream>
#include <thread>
#include <atomic>
#include <ve... |
I am trying to implement binary radix sort in C which sorts a linked list of integers stably. Although my algorithm has a time complexity of O(log2(k).n) (where k is the biggest integer in the linked list), other standard implementations of algorithms like merge sort/quick sort seem to have better execution time even w... |
The following assembly program works to print the factorial of a number:
SYS_EXIT = 60
.globl _start
_start:
# run 4! --> 4*3*2*1 = 24
mov $4, %edi
call factorial
mov %eax, %edi
mov $SYS_EXIT, %eax
syscall
.type factorial @function
factorial:
# if it is the base case, return 1 and exit... |
About
I've decided to challenge myself and write a JSON parser in C99 (i've written them in C++ before, but never in plain old C), and here's what I ended up with, it works well from what I've tried.
The code was tested with a few relatively complex json files, and it had no problem handling them, I also ran it through... |
I have a service that gets an URL from the user input, extracts the body content of this URL, apply CSS, and finally returns the result as a stream.
The tricky part is that I have different implementations depending on the URL, if the URL is not recognized, then a "default" implementation is used.
To do so, I used a Be... |
I've just started to learn recently about Direct3D, when I've learned to create a simple window I started wondering if I could automate this process, so whenever I would need to create a window I would just need to call for a function with my configs already setup. This is the essential part of the code I've come out:
... |
A while ago I created a program for fundamental analysis of stocks. Back then, I used to enter all the values by hand, which took a lot of time and was very annoying if a value was entered incorrectly.
Now the script takes care of most of that on its own. Sometimes, when the API is incomplete, the script throws a KeyEr... |
This is a beginner's attempt at implementing a linked list in C. Please read the code and provide recommendations. I do not want to limit the reader's benevolence to only these questions, but my specific questions are as follows.
Am I treating errors, exit codes, and warning messages appropriately?
How can I improve m... |
This program generates the entire sample distribution of the sample mean. The parent population has elements that have N distinct values. Samples of size n are drawn, with replacement. When N and n increase (especially N), the number of combinations becomes quite large, and the program can exhaust available RAM. I seek... |
I'm trying to get better at java by testing myself with different small projects as opposed to reading about them in a book. I've made a simple login/register system to try get my head around inheritance and abstract classes. All my code is below. Feel free to critique the code and tell me what you would do better. My ... |
As a C++ beginner coming from Java, I have become increasingly confused on the topic of memory management and how to avoid memory leaks. Is the code below risking a memory leak that I'm not currently aware of? Any help or constructive feedback would be greatly appreciated.
#pragma once
template <class T>
class Dynamic... |
My script works but I just want to know how I can protect myself from SQL injection with Procedural Oriented MySQLi. Most of the tutorials are about Object-Oriented MySQLi and I'm not familiar with it and don't want to have both Procedural and OO MySQLi in the same script. I have a lot more PHP files. I also do know ho... |
The application
I'm making a small app (currently ~500 lines) to manage and download books and other media items. Each item is uniquely identify by its (downloader, code) tuple and the index (save in a pickled file) contains the title, authors, and tags (e.g. "scfi-fi", "comedy") of each item. The "downloader" is a mod... |
This is a follow-up question for ConvertAll Methods Implementation for Multidimensional Array in C# and ConvertAll Methods Implementation for Multidimensional Array in C# - follow-up. Besides the multidimensional array ([,], [,,], [,,,]...) case, I am trying to implement another series overloading methods to deal with ... |
I come from java background and I am trying to implement lambda chaining in Python. Below is my code
li = ["amol", "vikas", "rahul"]
li2 = list(filter(lambda n: (n == "Amol"), list(map(lambda name: (name.capitalize()), li))))
print(li2)
This Function will
Capitalize the names
Filter the names with "Amol"
Currently t... |
Recently I've needed a Binary Space Partitioning (BSP) tree and I was surprised that there was not a "C++ container-ish" implementation available. I've decided to make my own with custom allocator support and to work in any number of dimensions alongside. This is my first ever code dealing with custom allocators. Is th... |
This is code for a measurement setup that receives a steady stream of UDP data, finds the trigger in one channel and operates on the data in the other channel to enhance the signal and remove noise, and display the enhanced signal.
I can see this project growing, and therefor I would like a more robust design and clean... |
import java.util.*;
public class BFS {
static LinkedList<Node> tracker = new LinkedList<>();
static Node[] nodes = new Node[]{
new Node(1),
new Node(2),
new Node(3),
new Node(4),
new Node(5),
new Node(6),
};
public static void mai... |
I believe the provided code can be rewritten shorter. Now one block is basically copy-pasted. In reality I have 6 such blocks.
This would be the data:
WITH
x(id, yr, more_info) AS
(SELECT 1, 2020, 'info1' FROM DUAL UNION
SELECT 2, 2021, 'info2' FROM DUAL UNION
SELECT 3, 2021, 'info3' FROM DUAL UNION
... |
I wrote a little game of snake that where you can see the field in which the snake moves fixed and you can also see the "viewpoint" of the snake, which is basically calculating the positions of all the things in the board taking the snake's head as the center.
Right now I'm doing it through two for loops in the followi... |
I would like to perform a right shift on a negative number. According to the linked answers, performing a right shift on a negative number is implementation-defined, because the sign bit may or may not be maintained. Here's my solution to this.
int n = -18;
printf("%d %d\n", n&0xF, ~((~n)>>4));
// Filler
I reasoning i... |
how what am i supposed to make cout so the changes i make show up as the out put because putting a just shows the original string
#include <iostream>
using namespace std;
int main()
{
string a = "w is the time for all good people to come to the aide of their country.";
for (int i = 0; a[i] != '\0'; i++)
{
switch... |
In my react application I have Tabs done with Material UI. Some of those tabs are shown or hide depending on an option is true or false.
The code is not a clean solution but I have no experience working with this and was wondering to see a better solution to what I have done.
We have 3 options:
isEngagementPortal
isRe... |
For the last couple of months, I have started to learn Haskell and since I am following a course on functional programming soon, I thought I would test my current skills. So what I did was create an HTML parser that transforms this input:
body
div#container.classA
span;attr=attr text1
span.classB text2
div#o... |
I 've made a tic-tac-toe game in C, I want some tips on how to improve it since the program is a little bit too long. (500 lines with comments)
How I done the game:
Mapped a 3x3 Matrix like the board bellow:
/*
-------------------------
| 1 || 2 || 3 |
-------------------------
| 4 || 5 || 6 |
---... |
I'm working on a program to program the bisection method:
https://www.calculushowto.com/bisection-method/
I know there's questions similar to this one but I want to see if my own one works.
double func(double x) {
return x * x - 3 * x - 1;
}
double bisect(double (*f)(double), double a, double b, double e) {
... |
I often get into the dilemma of how to use string constants, this is the way I use now:
UIImage *image = [UIImage imageNamed:@"apple.png"];
NSArray *imageNames = @[@"apple01.png",@"apple02.png"];
NSDictionary *imageKeyValues = @{@"Avatar" : @"apple.png"};
Once I encounter this type of code, I often use string poin... |
I have a script that checks if the specified set of $_POST variables are supplied and not empty and returns an error string that is human readable.
Here's my code:
if ($_SERVER["REQUEST_METHOD"] === "POST") {
// Local variables initialization
$missing = [];
$checkVariables = [
'name', 'address', 'c... |
I wanted to ask this question to my interview candidates, hence wanted to first give it a shot to see if this is doable in 45 mins. Here's the code that I was able to come up with in 45 minutes. Can folks please let me know if there are any logic flaws in this code?
Constraints:
The robot does not have any data of the... |
I have a modal for adding new contacts, in order to disable the save button if no data has entered I check if the contact object is empty, is there a shorter way to check for an empty complex object?
let isContactEmpty = true
Object.keys(contact).forEach(field => {
if (typeof contact[field] === 'string' && con... |
I've been solving K&R 1-14.
Exercise 1-14. Write a program to print a histogram of the frequencies of different characters in its input.
After several edits, it looks good to me now. But it's my first time to write a long code(it's long to me). I wonder if there is more simple and shorter code with the same logic or ... |
I'm in the process of understanding shell scripting - this is my simple code for adding test files for python unittest
I'm looking for best practice pointers, variable naming, and of course comments on structure and readability.
EDIT: Script is called by, for example
./create_tests.sh math tensor_add
dir_name="$1"
fil... |
Code
@Service
@Slf4j
public class SpendingServiceImpl implements SpendingService {
private final SpendingGroupRepository spendingGroupRepository;
private final SpendingRepository spendingRepository;
private final IdempotencyRepository idempotencyRepository;
private final TransactionTemplate transactionT... |
Given this ciphertext from a Caesar cipher:
fxeyaxklqxhkltkxqebobxtbobxplxjykvxfaflqpxfkxqebxtloiaxrkqfixfxpqyoqbaxrpfkdxqebxfkqbokbq
The task is to decrypt it without being given the key.
My solution:
napis = "fxeyaxklqxhkltkxqebobxtbobxplxjykvxfaflqpxfkxqebxtloiaxrkqfixfxpqyoqbaxrpfkdxqebxfkqbokbq".upper()
ALPHABET... |
I made this simple Tetris game where I only have 2 blocks, the square and the line. Also the game ends after 20 blocks are created and the player wins. I was wondering how I can make it better overall.
Here's the code:
#include <stdio.h>
#include <windows.h>
#include <string.h>
#include <time.h>
#define RIGA 21
#defin... |
I recently started out with C++ and I am working on an application that can watermark entire directories of images at once.
Currently you can call the program with an argument of the target directory where the images are stored and an argument for the path of which watermark image to use.
It works so far but I think my... |
I am working on an open Chess data-set (~15500 rows after cleaning), and I create nodes and edges. But the way I create the edges takes a bit of time.
A sample of my nodes tibble:
player
1
bougris
2
a-00
3
ischia
...
...
A sample picture of the per_game tibble:
The way I do it:
I iterate for each n... |
My first component
export class EditIntegrationComponentAttributeComponent implements OnInit {
constructor(
private _router: ActivatedRoute,
private _intApi: IntegrationsApiService,
private _spinner: SpinnerService,
private _fb: FormBuilder,
private _routerNavigation: Router,
private _notifica... |
Problem:
I have a weighted graph. I want to get distance from definite point to all other points in the graph.(and then get path to them)
I used modified dijkstra algorithm
So, here is code:
var get_path = function(graph, a) {
// declaration
let cache, i, v, queue, node, links, root,
j, link, c, n, d, max, w, L = ... |
I tried implementing the nQueens problem in CUDA, but it is actually slower than the sequential algorithm! What can I do to optimize this? This was run sequentially on an AMD Ryzen 5 4600H (clock speed of 3GHz) and in parallel on an Geforce RTX 1650 (894 cores with a clock speed of 1.5 GHz).
Brief introduction to the p... |
Hackerrank problem to reverse an array of size n.
https://www.hackerrank.com/challenges/30-arrays/
Sample Input:
4
1 4 3 2
Sample output:
2 3 4 1
Much of this code was already given, you can skip to the "This is what I did" section.
#include <bits/stdc++.h>
using namespace std;
vector<string> split_string(string);
... |
I believe this set of code is very repetitive in a way where every method does almost the same task but it is repeated multiple times. This is what the code looks like and its main purpose is to display the intended design on the simulator:
private void configStart() {
button1 = new JButton("start");
button1.se... |
I wrote my own implementation of generic hash table. I’m using linked list to resolve collision problem.
I want to share my code with you and get your opinion about it, and if there are any advice or optimisations that you can point to.
HashTable.h file
/**
* @author Abdelhakim RAFIK
* @version v1.0.1
* @li... |
I'm creating a class which has a raw pointer member which comes from a C function. In order to make it RAII approved, I just created a method free() that is called on the destructor of this class.
Reading some guidelines I came across that Rule of 5 (and Rule of 3) which, from my understanding, I should also create a b... |
Memory: O(log2(max)*2)~O(1)
Speed: O(log2(max)*n)~O(n)
so i did before a MSD Radix Sort in place but i wanted to do one, with out the count, So i join together the quick sort and radix sort. Think as msd radix sort mod of 2.
Algorithm
i will explain this one directly with a table.
Code
start,finish,depth,mid are copy... |
I have a small bit of code and I wonder if I can make it more readable. I would appreciate it if some people could take a look at it and give me some feedback. I especially wonder if there is a beter way of doing this:
cv::Mat image = loadImage(path.string());
if (image.data == NULL) { continue; }
This is the bigger c... |
I'm trying to optimize the narrow phase of the contact detection in my code. I'm using OpenMP for multithreading.
That is the starting code:
// Narrow Phase
const unsigned int NbPairs = pair_manager_->get_n_pairs();
delete[] sum_rad_;
sum_rad_ = new double[NbPairs];
delete[] distance_vec... |
I am working my way through some code challenges — partly to improve my problem solving, but also to improve my code quality.
I think my current (fully-functional) solution to a challenge is pretty solid, and fairly understandable. I would love to know, however, if there is anything in my style which could be improved.... |
The following short program is a collection of routines for detecting the dependencies among a project’s component files. Dependencies serve as a rough measure of the complexity of a program. Minimizing inter-file dependencies is a worthy goal, since understanding and refactoring a complex program is often challengin... |
I am learning C++ by implementing small design problems. I have tried to implement LRU cache and the implementation that I have attached here works fine.
However, I am not sure whether my code is in line with C++ best practices. For eg. Unnecessary use of ref, pointers and const, or missing inline function, namespaces ... |
I have the method below, which generates backtesting results. However, it's highly unreadable. What could you possibly suggest to me in order to make it more readable?
public DataTable GenerateResultTable(List<BacktestResult> data)
{
var table = new DataTable();
table.Columns.Add("Pair");
table.Columns.Add... |
everyone!I have created a bit ugly looking Tic Tac Toe console game using Java. I'm learning how to code and I would love to hear some comments about my code. Because it's quite streatforward, I'm not using classes and objects ( my assignment was not to use any ). Thank you in advance!
package com.company;
import java... |
Given an array as input, we have to calculate the tree height. For example, input [4, -1, 4, 1, 1] means that there are 5 nodes with numbers from 0 to 4, node 0 is a child of node 4, node 1
is the root, node 2 is a child of node 4, node 3 is a child of node 1 and node 4 is a child of node 1.
I have a very low performin... |
I wrote a simple piping operator in c++. I just wanted to make sure that my code was robust, modern c++ code, and made correct use of perfect forwarding.
Here's the code:
#include <concepts>
#include <type_traits>
#include <utility>
#include <vector>
#include <iostream>
#include <deque>
//Accept an object on the left ... |
Okay, first things first:
Yes, I am aware of the logrotate tool, which would usually be used for something like this.
However, since the logfile i want to rotate already contains a timestamp in the filename, logrotate will never delete old logs.
This script is supposed to:
tell the application to create a new logfile ... |
I'm trying to make a simple code to upload an image directly from a url. However I have concerns about the safety of my code since a user can submit any url. How I can make it more safe?
All the good examples I found are always related to files uploaded via a form.
So I'm having difficulties in improving this code.
$im... |
This is a follow-up question for A Generic Two Dimensional Data Plane with SubPlane Method in C#. Thanks to aepot's answer.
I am trying to implement a series methods to enhance the ability and functionality of this two dimensional data plane.
Cast method in order to deal with casting between different types.
Some of ... |
Question
Recently I've written the following splitv() function, without using strtok. Any way to make it shorter and more efficient?
Descrption
The function calculates the index-th element of the string str split by delim. The element is written into buff and 0 is returned. When an index error is occurred, any non 0 va... |
Here is my memcpy algorithm I've been working on:
static void* memcpy(void* destination, const void* source, size_t size) {
char* dest = (char*)destination;
const char* src = (const char*)source;
//check if length is greater than 16 bytes
if ((size - 16) < 33) {
while (size ... |
This game is pretty common for beginner projects. I wrote a version of this before all in Main - so here I challenge myself to recreate it in a more OO style.
I wanted to take a more OO approach, so any feedback on where I could do better or am making some errors is appreciated. I also have some personal confusion if i... |
I'm an undergraduate student with little to no experience in formal computer science or coding, and I specialise in quantitative social science research. Our professor asked us to fabricate some network data to analyse because of the pandemic, and I asked permission to create a Python program that simulates social net... |
I made a small simple drawing app using HTML5 Canvas, learning how to use canvas.
You can right click to change color, scroll to change brush size, and click + drag to draw on the screen.
Any feedback is appreciated, but I am concerned about storing each move event circle that is created in an array may become quite me... |
Any suggestions on how to improve the Makefile, e.g. how to best replace the multiple uses of example1/example2, ex1_src/ex2_src, ex1_obj/ex2_obj with static pattern rules?
build := ./build
targets := $(build)/example1 $(build)/example2
src := ./src
srcfiles := $(shell find $(src) \( -name "*.cpp" -or -name "*.c" \) !... |
This code integrates with dweet and freeboard to produce a dashboard display of which occupants of a house are probably at home, based on the presence or absence of their phones' MAC addresses on the local network.
An important distinction to meke is between current and marked presence. For instance, with a 15 minute g... |
I am just getting a little more comfortable with Bash.
I wanted a super simple log function to write to a file and output to the console for messages and errors. I also wanted the terminal and the file to interpret newline characters rather than printing them out.
Here is what I came up with (it works fine):
#!/bin/bas... |
While experimenting with some of C++'s language features, I was able to successfully design an invokable nameless function call through the use of a lambda that generically creates an arbitrary class wrapper that returns a class object without having to have a direct implementation of that class within its own seperate... |
In my job, we often write functions that do some calculation and write the result to a database. Sometimes mistakes are made and wrong stuff ends up being saved, therefore we also want to supply an interface to clean up after the function. This is an attempt of solving that problem.
from functools import wraps
def rev... |
I've recently finished Chapter 8 of The Book and have started doing the exercises at the end of the chapter. This post pertains to the first exercise which involves writing a program to output the averages of a list of integers. I thought the instructions for this particular exercise was a bit vague, so I tried to make... |
I recently finished a high school project of mine for a class revolving around creating my own multithreaded implementation of the "cp" terminal command in UNIX systems.
I am seeking for help by experienced people in C to help me make my code better, offering constructive criticism all while improving myself at the sam... |
I'm learning JavaScript at the moment (still very much a beginner) and this is the first app I've designed on my own, without using any tutorials. It's an app which takes the user's gender, age, height, and weight and then calculates their BMR. It works, but I would really appreciate it if someone more knowledgeable ... |
I'm currently working on a project where I'm dealing with somewhat large data sets. I have a dataframe transactions and another users.
Iterating through the transactions dataframe is no problem. I used timeit and it takes just under a minute to do so. My second dataframe users has 1,000 rows. Both of these dataframes h... |
If you simply implement it with .push() to .enqueue() and .shift() to .dequeue() that's easy but the the time complexity of .enqueue() is O(1) and .dequeue() is O(n).
While still using arrays, I have come come up with a nice solution to make both .enqueue() and .dequeue() in O(1). I am using sparse arrays. It turns out... |
I have the following code:
items = set() # use a set to not have duplicate items
a = requests.get(f"{BASE_URL}?{BASE_QUERIES}&cursor=*")
amount = a.json()["totalResults"] # in the range of 30 million
items.update(item["guid"].split("?")[0] for item in a.json()["items"]) # we only want the url before the query stri... |
//Function-A
function duplicatesNumber(text) {
var counts = {};
let textLowered = text.toLowerCase();
textLowered.split("").forEach(function (x) {
counts[x] = (counts[x] || 0) + 1;
});
return Object.entries(counts).filter(arr ... |
In Haskell, I tried to implement a parser for expressions containing hyperoperations, and finally succeeded. Valid expressions shall contain:
Parentheses.
Nonnegative integers.
Addition represented by +. It has precedence of 6, and its associativity shall be exploited.
Multiplication represented by *. It has preced... |
I am a JavaScript programmer beginning with Go. I tried to replicate filter and map functions like JavaScript's, as an exercise.
Here is what I came up with.
The filter function:
func Filter(slice interface{}, cb func(i interface{}) bool) []interface{}{
sliceValues := reflect.ValueOf(slice)
newSlice := []interface{}{}... |
I have an array of dim 1000 x 150 where I have 1000 strings each of length 150. And the strings only contain ATCGN (these are DNA sequences).
I am converting the letters to one-hot vectors such that A is [1,0,0,0,0] and N is [0,0,0,0,1].
I wrote the following code but it takes way too long when there are about 20 mill... |
I am building a PowerShell class based tool that works with XML files of as much as a few hundred Kb size, and as many as a hundred of these files. I have extensive validation code that is time consuming, so I want to validate the XML and if it is valid hash it and write that hash as an attribute to the root element. M... |
The aim is to provide a generic functor class which makes references able to bind to r-values. The trick is to trick the compiler into thinking that the r-value is an l-value by using a forwarding references.
Here is the code:
#include <type_traits>
template <typename Functor>
struct Function {
Functor func;
te... |
So I have the following code, that takes an image and modifies the RGB channels one at a time. It then creates a list of 9 images with the various modified channels.
The Red channel is modified by 0.1, then by 0.5, then by 0.9. This is then applied to the Green channel then the Blue Channel.
Resulting in a list of 9 im... |
I'm looking for a way to speed this code up. It took about 4.5 hours to run on ~20k decks. I'm open to restructuring my SQL query, but feel adjusting the python would be more effective. The goal of this code is to see how many times a pair of cards occurs in all the decks. For example if ("card", "name") appears in 27/... |
NB: There's a bug with my iterator, apparently. I can't use const_iterator because I get some compiler errors. I know using const there is wrong, but I have to find a way to fix it first...
I finished implementing std::vector and decided to continue with std::forward_list.
This time, I did not take the time to make it ... |
I initially had a simple firebase cloud function that sent out a push notification to a topic when a new message child was created in my real-time database. But I wanted to add message filtering where notifications for messages from some filtered users would be sent only to admin users. For this, I have created user gr... |
This is the challenge:
You are given a sequence of N balls in 4 colors: red, green, yellow and blue. The sequence is full of colors if and only if all of the following conditions are true:
There are as many red balls as green balls.
There are as many yellow balls as blue balls.
Difference between the number of red ba... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.