instruction
stringlengths
71
95.1k
I'm a beginner programmer and I came upon this problem which is to find the n​th number in the Fibonacci series. I used to solve the problem using a for loop; today I learned about recursion but there is a problem: when I pass 40 or 41 to the recursive function, it takes a bit of time to calculate it, while in the iter...
I am mapping a complex JSON response to two JPA Entity model classes using Jackson. The classes are CxExport and Mention, Mention has a Many to one relationship with CxExport I.e. Many mentions belong to one CxExport. The HTTP Response returns a List of mentions 2. The JPA model is a flattened instance of one of the li...
I have the following relationship in EF Core 3.1.1 (Many-To-Many): public partial class Movie { public Movie() { Directors = new HashSet<MovieDirector>(); } public int Id { get; set; } public string Title { get; set; } public virtual ICollection<MovieDirector> Directors { get; set; } }...
I've been studying Java for some days and I'm just now starting to make some simple programs, I'd like to know if there's any 'noob' mistakes or habits that I could avoid. In other words: how could my code be more streamlined to Java? My code: import java.util.Scanner; public class Main { private static String rev...
I am trying to implement a greedy zip method in Haskell where it does not drop the elements, instead, it will use some default value. I appreciate any feedback to make it more compact. zip' [-1] [] r = r zip' [] [-1] r = r zip' [] b r = zip' [-1] b r zip' a [] r = zip' a [-1] r zip' a b r = (xa, xb) : (zip' xsa xs...
I have a list [5,2,7,4,3,2,0,8, 9,100,99,98,97,93,92] i need out [100,99,98,97] but i am getting 4, 3, 2, 100, 99, 98, 97, 93, 92 `arr=[5,2,7,4,3,2,0,8, 9,100,99,98,97,93,92] z=[] l=[] for i in range(len(arr)-1): if(arr[i]==arr[i+1]+1): if(arr[i] not in z): z.append(arr[i]) ...
Below is code for handling events in SFML. It works by reading a text file containing a sequence of functions to be called when a given event is detected: EventManager.hpp #pragma once #include <SFML/Window.hpp> #include <SFML/Graphics.hpp> #include <vector> #include <unordered_map> #include <functional> #include <fst...
My solution to the LeetCode's Subtree of Another Tree passes all the test cases, but the code feels and looks ugly. Would appreciate an advice on how to improve it. The problem: Given two non-empty binary trees s and t, check whether tree t has exactly the same structure and node values with a subtree of s. A subtree ...
Is the code below safe to create unique ids for objects? I will create new yoga classes and need to have a unique id for each class. I made this small piece of code to generate the id numbers. Regarding specifically the uniqueIdCreatorHandler method, would this solution incur in bad performance, or is it just far from ...
So I have a method that, after validation, generates a random password based on the length and characters provided. The UI uses check boxes to select using between lowercase and/or uppercase letters, numbers and special characters to populate the characters parameter. as well as the length of the password and the spaci...
Why am I fighting the compiler? - Wrote this, which works, but I feel like I'm breaking every rule in the book: #[macro_use] extern crate lazy_static; use std::ffi::OsString; use std::path::PathBuf; use std::str::FromStr; use actix_rt; use actix_web::client::Client; use async_std::fs::File; use async_std::prelude::*...
Given the models below: class Structure(Model): ... class StructureComponent(Model): ... structure = ForeignKey(Structure) parent_component = ForeignKey('self', null=True, ...) Developer should synchronize with the database a list of trees: The sample of request data: { 'trees': [ { ...
I want to improve quality of this symfony rest endpoint (solid principle, Kiss, best practice...) Can you review my code please? Symfony controllController function that return json list of product /** * @Route("/api/products/my_list/{number}", methods={"GET"}) * @param Security $security * @param BeamyAPI $beamyAPI...
I'm trying to learn Javascript and I've set up a bill calculator. Most of the lines in the code are to deal with rounding. It has four main components: Allows you to enter the bill amount and tip percentage. Calculates the total bill divided by the number of guests. Calculates the total tip. Splits the bill by the num...
I have done a clustering algorithm and represented the results in a pie chart as shown below. fig, ax = plt.subplots(figsize=(20, 10), subplot_kw=dict(aspect="equal")) contents = [] for k,v in clusters.items(): indi= str(len(clusters[k])) + " users " + "Cluster_"+ str(k) contents.append(indi) #contents = ...
So I'm writing a game emulator and would like some advice after finishing the networking. It is designed to accept multiple connections, and process messages from all of them. Here is just a brief introduction to the packets and how they are structured. [lengthOfString:short][stringEncodedInUtf8:Byte[]] Let's start wit...
I'm working on a little endian machine and in my program I need to convert 2,3,4,5 or 8 bytes into network order before transmitting them over the network. I've written the following function which basically just reverses the bytes. I just wanted to make sure if it's logic is correct. void convertLittleToBig(const uin...
An abstract base class which derives from the ObservableObject (MvvmLight), implementing the INotifyDataErrorInfo interface. The model (exposed via the ViewModel) binds directly to the view, to avoid duplication of properties. A couple of notes: a) I chose the HashSet<string>> to avoid duplicate errors, e.g. "The numb...
Recently, I've received negative feedback of interview's test. They say that they need somebody with higher technical level, the quality of the task was not good enough. I upload it here, to request your knowledge and teach me how to improve it to improve my development skills around Google Maps and Marker placing. The...
I have two classes ExceptionLog and DebugLog public class ExceptionLog { public static String StackTrace {get; set;} public static String ClassName {get; set;} public static String MethodName {get; set;} public static String LogType {get;set;} public static Exception ex {get;set;} public Static...
I had a 50 GB text file (about 45 million lines) and needed to extract about 1500 lines from it. I knew their indices, that is, line numbers. Those 1500 lines were spread across the whole file up to the very end. To accomplish this, I wrote a simple Perl script. It worked and was quite fast: it finished in about 4-5 mi...
I'm looking to speed up an Rcpp function I have written. The function takes in a string called vcfield, which takes the format od x:y:z. This string has 3 fields if you separate it by the :. It takes an int DSfield which tells us the index (0 based) field from vcfield which is the dosage. Dosage is always one double v...
I have small (<250 bytes) chunk of binary data, where I know that almost always, the first nibble is going to be zero 0. For example, in hex: 01 02 03 04 0A 0B 0C 0D I want to do some simple compression on this data. What I've decided to do is run length encoding, but I first need to get the data such that all the e...
This is a project I started a while ago, and still going. It is a text-based RPG written in Python. There are two files: asathryne.py (the main file) and stuff.py (a file with some functions for programs that I make; the game imports a couple of functions from it.) Thanks for looking over it! asathryne.py: from random ...
I posted the first part of this game earlier, and now I finished the second part. From the first part we just had to have a random value to get the cards, and the bet always stayed at $25. For the second part the user could choose their bet, enter 0 to quit the game completely, and just hit enter to default to 25 on th...
I wrote a program that is able to perform calculations with matrices: main.cpp (Just for test purposes) #include <iostream> #include <vector> #include "matrix.hpp" int main() { std::cout << "Width (matrix 1):\n"; int width = getDimension(); std::cout << "Height (matrix 1):\n"; int height = getDimens...
For my programming class, at the start of the semester before we learned about object oriented coding, I was supposed to make a small program that searches through a bunch of files, being graded on useability. from os import walk from time import time SEPARATORS = (" ", "-", "_", ":", "|", "~") REMOVABLES = (".", ",",...
It's a web application. It should provide a service for entering data. Data is then evaluated and uses itself another service. It was part of an interview process where I was given that task to solve. The feedback was that it was not sufficient and I got rejected. But I don't know what exactly they don't like. Could yo...
I am trying to implement Deep Quaternion Networks. I was able to implement the batch normalization technique. But it requires a lot of GPU memory. Is there any way I can optimize the code provided below? class MyQuaternionBatchNorm2d(torch.nn.Module): def __init__(self, num_features, eps=1e-5, momentum=0.1, affine...
I'm doing some code review and I saw something like the following: std::ifstream dataFile(filename); if (dataFile.is_open()) { std::deque<std::string> lines; std::string line, line_batch; while (std::getline(dataFile, line)) { if (!line.empty()) lines.push_back(line); } dataF...
I am a beginner in programming, started about 2 months ago with Java, changing careers from law. I have recently applied for an internship but was denied because I failed to do the pre-interview test right. One of the tasks was to keep deleting 3 consecutive same integers from the array until the list is either empty o...
As I mentioned in my bio, I do not code for a living and too old to switch careers but I do enjoy it as a hobby and I am trying to get better. Also trying to get my teenage son more interested. Anyhow, the code below does want I want it to but I am looking for tips to improve it. Any advice would be much appreciated be...
I am currently trying to implement an extensible way to create commands that can be sent to some type of executor. In my case, there would be two of them (server and client). As I posted here, I had a hard time developping my idea, but it finally came through something usable, but a bit complex in my opinion. I am thus...
I'm working on an application that counts the number of employees in each department. Here's my code: SELECT count(case when (JS_TITLE = 'Accounting')then 1 end)as Accounting, count(case when (JS_TITLE = 'Management')then 1 end)as Management, count(case when(JS_TITLE = 'Marketing')then 1 end )as Marketing,...
The following script reads a set of SIDs inside firewall rules and uses them to set ACL rules in a folder. The question is: Is this syntax ok or is there better ways to write this script, considering powershell syntax features? (by the way, this code works) param([Parameter(Mandatory)]$foldername) $result="" (Get-Net...
I created a simple log-in system in Java for a project. Security isn't a concern here, hence the plaintext password, but I'm interested in how I can improve the quality of my code. Everything seems to work but it just feels like messy code. public boolean logIn(String name, String password) { if (getLoggedInUser() ...
I just recently got into c# and Unity coding, and would like to put this algorithm and code up for review to check how I'm doing. I've only been working by myself, so it would be interesting to hear how my code design and style could be improved. The task is like so: There's a 3D cubical grid (stateGrid) containing vox...
I just got started with Python. I created some code, and I want to know what more experienced devs think about it. What can I do better? What to avoid? #!/usr/bin/env python # -*- coding: utf-8 -*- """ Graphs - Calculate expression or draws a graph from given equation. This is a conversion of my old program created at...
I am just learning Vuejs and I am implementing it in a 'legacy' environment where jQuery, Bootstrap 3, among other libraries are loaded by default. In my implementation I try to keep it simple with certain functionality built in. My codepen is stripped of a few things such as some fetch calls and related things, so sta...
I am looking to optimise my solution of the 'SMS problem', i.e splitting a String into chunks of the same size without splitting words. I did a recursion and am looking for ways to optimise that code, or a more efficient algorithm. In my solution spaces are left at the beginning of each chunk, this is voluntary. Here i...
So I wrote this class template for a custom container. Basically, it stores elements and their occurences. When an element is pushed into the container, if it already exists, all it does is increment its counter. #pragma once #include <map> #include <string> // // Template class for a tocc, or Thing Occurence Counter...
I am writing a small application to get commits between two tags from different env (apple, banana) and write the result into a csv file. For security, I have to replace some sensitive information with alfa, beta and application banana key words. The application is running fine from my local machine. Please help me to ...
I know there is a better way to do the following but I havent had any luck trying to clean it up. This is for a table of messages where the user can click a row, message-head, which will display the message-body-hidden to the user as well as change the class of message-head to message-head-active. It will also change ...
My solution to LeetCode problem Most Frequent Subtree Sum works, but I have several questions regarding the code. I am also looking for an advice on how to improve the code. Problem: Given the root of a tree, you are asked to find the most frequent subtree sum. The subtree sum of a node is defined as the sum of all th...
I'm doing some code revision and I'm looking at this portion of my Worksheet_Change() event: If Target.Address = "$A$4" Or _ Target.Address = "$A$7" Or _ Target.Address = "$A$10" Or _ Target.Address = "$B$21" Or _ Target.Address = "$B$22" Or _ Target.Address = "$B$23" Or _ Targ...
Okay all you Linux/shell folks out there. This is my first shell script (2nd if you count "Hello World") and would appreciate some feedback. Basically, I need to test whether htop is installed; if it is, then move on; if it is not, then install it. If the user is root then just do it, and if not, sudo and install it. ...
This is my first ever Python program. It checks every frame of a video file with Tesseract then uses OCR to recognise numbers in that frame and prints it to the console. import pytesseract import os import cv2 import openpyxl from numpy import interp import numpy as np # Video URL TEST_VID = cv2.VideoCapture("VET2.mp4...
I am using the following code within the footer of my test site. I am using WordPress and Advanced Custom Fields The intention is: To display the HTML container .social-media--icons if any of the fields contain content within the CMS. Then, within the container .social-media--icons, display the relevant icon and href...
There has been ongoing concern about the question of awaiting a task that could possibly be null, as when using null-coalescing operators. Consider the following: var response = await turnContext?.SendActivityAsync("I am a bot"); That will throw a run-time exception when turnContext is null, as seen in questions like ...
A simple design for task scheduling using the following classes/interfaces. /// <summary> /// Represents an executable action. /// </summary> public interface IExecutableTask { Task ExecuteAsync(); } /// <summary> /// A task which can be planned for execution. /// </summary> public interface IPlannedTask :...
I created a small sample project using caliban, akka-persistence and ZIO. I'm not really happy with the wiring code: implicit val defaultRuntime: DefaultRuntime = new DefaultRuntime {} val counter = context.spawn(Counter("counter"), "counter") val service: CounterService = defaultRuntime.unsafeRun(CounterS...
Couple of items to make note of first: Some of the code is inherited the other has been refactored by me. The procedures that have an underscore in them I am still working on refactoring. I am still working through naming cells that I feel need to be named. This code below was re-factored once with help from @TinMan...
I have the following code in my project that installs linux sl on Windows using PowerShell. Is there anything you'd improve about this? param([String]$Profile, [Switch]$Help, [Switch]$Force) $ErrorMessages = @() $Payload = " # <Code inserted by Install-Steam-Locomotive> function Steam-Locomotive {wsl sl -e} function ...
I'm implementing a PAKE-protocol as a university project and one step of the protocol involves sending encrypted data from a key created via a hash function (I'm using SHA-256). I want to use AES/GCM but do not have an IV so I'm using HKDF to expand the key into an IV and key with the following implementation: import o...
I'm developing a small C# Unity application to display stereoscopic images as part of a wider research study. Since the experiment consists of unique stages (Start, during a trial, between trials, and End), I decided to use the State Design Pattern to make a State Machine for code readability. The program design is bas...
I would like some help on making my solution more functional. At present, I rely heavily on using indexes in my map functions. I am also seeking general feedback and advice, thanks. export const getMatrixColumns = (a: number[][]) => { return a[0].length; }; export const getMatrixRows = (a: number[][]) => { return ...
I always want to improve my code by refactoring but when I've to work with complicated function that have many thing to do . How can I refactoring them. Here is my data for example I get data from request My DB structure look like this DB id PK blog int date_end string date_start string employee_...
Purpose of the code: I have 3 Excel files to deal with. Those file have already been filtered or hidden because the content is very large. And I only need part of the content for every excel files. I don't want to open every file and worksheets in order to copy the desired range. I want to write a code to combine every...
After a lot of browsing and experimenting I have managed to achieve to read excel file as a Dataframe, apply some style to it and export it to html. My main concern is that the highlight_max function looks a bit redundant. The rows I want to highlight are already predetermined and are not just simply minimum or maximum...
For the question, I had a pretty messy solution so I would like some advice on how to better use Java to make the code a bit cleaner. Also, a semi-hack that I did that I'm not proud of is checking if words.length == 0 at the beginning and returning 0 if so, so that I can initialize int longestSeen = 1 (if there exist...
I made a BigInt class that supports almost all functions an int would. The code seems too bulky and there might be a few bugs lurking here and there. I would like to simplify my code as much as possible and increase performance. #include <iostream> #include <algorithm> class BigInt { public: bool neg = false; ...
I am working on an object detection API implemented in Tensorflow 1.14 and OpenCV 4.1, where my task is to recognize personal protection equipment (PPE) worn by workers at various construction site gates. We are using RTSP streams, where I am already using threading to minimize latency, but still some times the stream ...
I wrote the following code to generate a series of barcodes given a CSV with a list of ISBNs in the first column and titles in the second, using the python-barcode library (which itself requires pillow to generate PNGs and JPGs). I am fairly new with Python and have had little formal training, and so would be intereste...
I'm still a beginner so any pointers to make this code more professional/production ready are appreciated. The tokens and database connections have been anonymized. The script is working, its goal is to copy prices from one database and push them via api into another database. This data is monthly price data that usua...
I previously submitted my code for a HugeInt class here. That version lacked a long division implementation. I have now implemented (long) division using Donald Knuth's algorithm D, following the code that appeared in Hacker's Delight fairly closely. Since the algorithm relies on some a priori non-obvious facts and its...
After running my C-brute-forcer for two days on a 25x25 sudoku, I decided to re-write in Java so that it would solve it in an acceptable time frame. The idea: Make smart fields that contain all possible values for that field, and then let the bute-forcer only loop through these, hopefully reducing the time. After some ...
This part of my code is taking 30 minutes to multiple 300 RGB and Depth images pixel by pixel. How can I reduce this time? This is just a part of big code but this taking lot of time. def depth_to_xyz_and_rgb(uu, vv, dep): # t1.tic() # get z value in meters pcz = dep.getpixel((uu, vv)) if pcz == 60: ...
I have started programming a couple of months ago and have recently applied for an internship. One of the assignments was to create a console application, the assignment can be seen here - > HERE My implementation is this: I have created an abstract class called DiscountCard which holds all the info, getters and setter...
Here I already asked for tips, and I wrote another hangman game with the tips I got. My questions are: is int game() doing too many things that I should split further into smaller functions? And how to avoid those nested while-loops? Or are they ok for what I intend (to make it possible to replay the game without execu...
I am trying to identify and print pairs of 4 digit palindromes that sum up to a 5 digit palindrome. This is what I have so far def isPalindrome(x): return str(x)==str(x)[::-1] palindrome = [x for x in range(1000, 10000) if isPalindrome(x)] for x in palindrome: for y in palindrome: if (9999 < x+y < 10...
I wrote a simple bash script in order to batch convert Markdown files via pandoc and it is working for me. But I have the feeling the code is dirty. Could you help me improve it? #!/bin/bash rm -r out; mkdir out for f in src/*.md do filename=$(basename "$f") filename="${filename%.*}" echo "Processing $fil...
So i code stuff for my fx-cg50 calculator's micropython as I'm an a level student and a python beginner, and i need help pointing out the bugs and some programming tips to further improve my code, and i can't use sympy or numpy since they cant fit in my calculator's measly 16 MB so i have to make everything from scratc...
I have an Entry that I want to give a red outline when the entry is empty. I'm using SyncFusion's SFTextInputLayout for my Entry and it has a property HasError that once it's set to true, it'll automatically highlight my entire in Red. Here is the following XAML code for SFTextInputLayout <inputLayout:SfTextInputLayou...
Here's Alice and Strings, a programming challenge on hackerearth: Two strings \$A\$ and \$B\$ comprising of lower case English letters are compatible if they are equal or can be made equal by following this step any number of times: Select a prefix from the string \$A\$ (possibly empty), and increase the alphabet...
This is my A-Star implementation for a 2D space of nodes but allowing to specifically set connections between nodes because my usecase does not have points tied to a grid (however for clarification reasons, the sample data down there does form a 3x3 grid with non-diagonal connections). So basically it is A-Star on a gr...
I'm fairly new to programming and this is the 2nd thing I've done in python. This code creates a /Tiles directory in the folder where the script is ran, then it makes an X (8) number of folders inside of /Tiles. Inside of those 8 folders it makes a Y number of subfolders and downloads Z number of images per Y folder. ...
Purpose of the code: Let's say I have 3 excel files to deal with. Those file have already been filtered or hidden because the content is very large. And I only need part of the content for every excel files. I don't want to open every file and worksheets in order to copy the desired range. I want to write a code to co...
I am new to C. I tried to make a bank management console application. I want some one to review it for advice to enhance and develop my coding skills. This is what the program does with the inputs: 1 add an account 2 search for a specific account 3 modify a specific account 4 delete a specific account #include <st...
I have built a small roguelike in JS using minimal frameworks (Tho I am using one library for things like FOV, map generation and a few other small things) This is my first 'real' project that was done by only me without following any real tutorials, and because of this, I'm feeling like a lot of the things i'm doing ...
I've tried to implement parallel MergeSort in C++, that also tracks how many comparisons it's made and how many threads it uses: #include <cmath> #include <ctime> #include <mutex> #include <thread> #include <iostream> #include <algorithm> int *original_array,*auxiliary_array; std::mutex protector_of_the_global_counter...
I wrote a function in Python to call 7zip to compress a folder. The code works and is able to perform the task, however I do not know if this is the most optimal way. Are there any ways to improve the code, any redundant steps? def Compress_7z(Initial_path,Container_Name,File_List, compression_level = -1,DAC = False): ...
Not sure this is the right place, but I'll have a try. I'm trying to implement a mutex with capacity, which can be achieved easily with buffered channel like this: var ch = make(chan struct{}, 1000) func Enter(ctx context.Context) error { select { case ch<- struct{}{}: return nil case ...
#include <iostream> #include <cstdlib> #include <ctime> #include <string> using namespace std; void wrapUp() { cout << "-------------------------------------------------" << endl; system("CLS"); } int main() { srand(time(0)); string name; int player; int livesTracker = 5; int x = 1 + (r...
I have to prepare program that summing the digits of two given by user numbers and then give back the random number which is natural number the digit sum of this number is bigger then the digit sum of given by user numbers It's look like everything is ok but i dont know if it is just luck in random number generator ...
I have backend project in which there's own "parent-to-all exception" exists, something like this (also I have InvalidArgumentException derived from this exception): class CaliException extends \Exception { private $caliCode; public function __construct(string $message = "", string $caliCode = self::UNDEFINED_...
I am looking for assistance in optimizing a partition method I wrote for a class. It does its job correctly, but I only received half points on it, so I was wondering if there was a way to make it more efficient? private int runPartition(int lowIndex, int highIndex) { //Sets up pivot index and values int pi...
I created this calculation algorithm, unfortunately, it works a little hard for more combinations. How should it be improved for faster operation? Private Sub BttRemize_Click(sender As Object, e As EventArgs) Handles BttRemize.Click If CBRealTime.Checked = True Then Dim myProcess As System.Diagnos...
I made a HTML script to quickly make a Dnd5 sheet. This was a project done in two weeks, I don't know what to say else except I'm learning JS, CSS and HTML. I would love to learn how to make this better. <!DOCTYPE html> <html lang = "en-US"> <body> <h1> DND5 Quick Sheet </h1> <l><font size = "2"> this is for a quick...
I have a common List in mind which looks something like this: it has one remove button one input in which user can enter the name of element and on clicking insert the element will be added in the list. For this i have added HOC like this: function ListHOC(Component, data, listName, placeholder) { return class exte...
I'm trying to solve Wildcard Matching on Leetcode. I found a great solution using the Finite-state machine. The author builds an FSM and searches with BFS. I rewrite the solution with the same idea (FSM) but use DFS: class Solution: def isMatch(self, s: str, p: str) -> bool: # build the fsm fsm = {...
I am following a guide that specifies how to manage different configurations (DB_URI, LOGGER_NAME, etc...) per development environments. I create a config module that is structured like this \my_project\config\__init__.py import os import sys from . import settings # create settings object corresponding to specified e...
I have implemented a java class for minHeap but it is not working as fast as I want . I want some help to change it to work faster in insertion or deleting the minimum node. Here is my implementation: public class MinHeap { private static final int d = 2; private int heapSize; private long[] heap; MinH...
I have written this Rust code to implement the quick sort algorithm. Could you review it and tell me if it is idiomatic or not? Especially about my use of the slices? fn quick_sort<T: Ord>(array: &mut [T]) { let n = array.len(); if n > 0 { let mut i_pivot = 0; for i in 1..n { if &arr...
I've written some code that will take multiple stock tickers and calculate their returns over yearly, monthly, bi-weekly, and weekly holding periods. The results are written to an xlsx file. I'm seeking commentary on any general best-practices I've missed, or any possible simplifications. In particular, I feel like t...
Recently i added such generic list in github and i would like to get some feedback. Here is a link to the code in github: https://github.com/MartinChekurov/Generic-Linked-List GenericList.c #include "GenericList.h" typedef struct GenListNode_t { void* data; struct GenListNode_t* pNext; }GenListNode; struct ...
I am trying to learn to implement DSs in C++ and here is a simple implementation. Please review in terms of optimization, memory management, coding standards, etc #include <stdio.h> #include <iostream> class BstNode{ int data; BstNode* left; BstNode* right; public: BstNode(int data) { this->data = data; this-...
I want to put the worksheets from several (2-5) excel workbooks (files) into one single workbook. The names of the workbooks are not standardized and so I opted for a dialog box to select the workbooks. Here is the code. It meets the basic requirement that all the worksheets (sheets actually) from the selected files ar...
I am trying to implement DSs in C++ and this is BST insert and search functions. I tried in two different ways, please review and see if one is advantageous over other. With pointer to pointer #include <stdio.h> #include <iostream> struct BstNode{ int data; BstNode* left; BstNode* right; }; BstNode* NewNode(int da...
I was bored and sketched out this idea in pseudocode( I will try to turn it into C++ later) for taking a set of numeric data and manipulating it. I ran through it manually and it seems to put the data in a range [0, something] count = data[count] = { d_0, d_1, … , d_(count -1) } sigma = $Σ_{a∈ℕ} data_a$ avg = sum / cou...
I am wondering if there is any way to meaningfully shorten the chain of conditionals used here to compare two versions. struct VERSIONCODE represents a version number of the form major.minor.revision and CompareVersions returns EQUAL if they're equal; LHS_NEWER if vLHS is newer, and RHS_NEWER if vRHS is newer. typedef...