instruction
stringlengths
71
95.1k
I am currently processing some large time-series data with pandas, and I have a function that is intolerably slow, and I'm sure it could be done faster. The problem is: I'm studying a factory that produces things. It runs continuously throughout the week, but on weekends it shuts down. Before the end of the week, and a...
I have a need to store data retrieved my ASP.NET Web Api to stop making redundant API calls for the same data when I navigate through my Angular page. On my API I have a database which stores a list of printers known to the PC and stores some basic information about them. Here is the model: export class Printer { ...
A few days ago I learned about the dynamic programming approach to problem-solving; the thing is, I'm still not sure I am fully grasping the concept. I decided to write an algorithm that takes a single String of uppercase letters, s, and split it into substrings based on a dictionary I have provided. My algorithm works...
I'm trying to define parameters for my API. It's a super basic one and the first I've made. I'm trying to instantiate my class and set parameters but to me it seems super messy. Is this really the best way to set a bunch of properties on a class and check them? API Class: class Api { private $_fields; public $...
I'm currently working through an exercise of Chapter 4 from Automate the Boring Stuff, which reads as follows: "Say you have a list value like this: spam = ['apples', 'bananas', 'tofu', 'cats'] Write a function that takes a list value as an argument and returns a string with all the items separated by a comma and a sp...
This is a python program that automates skipping through users on a chat website called talkwithstrangers using the Selenium Webdriver and BeautifulSoup modules of python. The first part uses selenium to open the browser from selenium import webdriver driver = webdriver.Chrome('C:\SeleniumDrivers\chromedriver.exe') us...
Here is my solution to problem 11 on Project Euler. The goal was to find the largest product of any four numbers in consecutive line of any direction (vertical, horizontal, or diagonal). While my code achieved the solution it feels wrong to me in a way I cannot quite articulate. I attempted to implement a pseudo-mat...
I'm working on a project where I have products. Each product can either be a theme, plugin or a plan. Now my idea was to add different styles to each of the types. For instance, Theme is red, Plugin is blue etc... Now in my blade file I have handled this in the following way: @if($product->productable_type == "App\Them...
I've a list of tuples (comes in pairs only) a = [(1,2),(1,4),(3,5),(5,7)] which I'm trying to convert to a dictionary as below d = {1: [2, 4], 3: 5, 5: 7} Here's what I've come up with - a= [(1,2),(1,4),(3,5),(5,7)] d= {} for k, v in a: if k not in d: d[k] = v else: d[k] = [d[k]] d[k...
I have to check an uploaded file for anti-virus and if there is an exception, I have to give a message according to the exception to the users. e.g. if its a timeout, I would ask the user to try againg in a while. My first class, fileUpload is: public class FileUpload { //Message when no virus found. pri...
I tried to implement a simple container class using the copy-and-move idiom. I am learning the changes to C++ as of C++11 and later. Is the code exception safe? I chose to use a smart pointer. Is std::unique_ptr a safe choice? I read that it should not be copied, but since I am doing the copying of the content explici...
I'm learning Java with Head First Java. I've built a program that creates a 7x7 grid (A0 to G6) and places an object of 3 consecutive values inside it. The user has to guess the location and when the 3 values are found, the program will confirm that the object is destroyed. My problem right now is that I'm not satisf...
Appreciate your thoughts and feedback on my simple list implementation. I have the code on github with list and some googletests here (not sure why github changes the spacing to be so big) Some points to keep in mind.. I have chosen to have two separate functions for assignment and move operators. As oppose to one tha...
This R code separates the values in rData. They are classified according to the class in rClass. To do that, ClassifiedrData is a named list, where each element in the list (a class), should be a vector with all the elements in that class. It is slow, and I had read that I should not use for in R, but I have no clue on...
Question : Build a graph in python, given its edge representation. from collections import defaultdict graph = { '1' : ['2' ,'4','5'], '2' : ['3'] , '3' : ['5'] , '4' : ['2'] } def generate_edges(graph): edges = [] for node in graph: for next_node in graph[node...
My task was to implement this algorithm that uses memoization to calculate fibonnaci numbers: int fib(int n) { int f[n+2]; // 1 extra to handle case, n = 0 int i; /* 0th and 1st number of the series are 0 and 1*/ f[0] = 0; f[1] = 1; for (i = 2; i <= n; i++) { f[i] = f[i-1] + f[i-2]; } return...
So it's been a while. I present you with a somewhat basic PowerShell script that is designed to deploy our staging environment to production, on a nightly basis. I've designed this to be robust, and also log information relating to the deployment of staging to production. The idea where was to build it simple enough to...
I wrote a program in Python 3 to check all tuples of the form (s,t) where s and t are positive integers satisfying three conditions: The inequalities s <= t^2 and t <= s^2 hold, and the value s+t divides st(s+1)(t+1); The value of s+1 is prime; The inequalities both s * [math.ceil( math.ceil( (t^2)/(s+1) ) * ((s+1)/t)...
I'm using a linear search as a spell checker. I need to time my code to get averages as I'm using different searches and comparing them. However I don't believe the code I've used to time the code is accurate enough or the best method. If anyone has any suggestion that would be great. import re import time start_time ...
I have an array of date objects, which I want to group by year and month. The data structure I have chosen for my target is an array of arrays of Date objects. Two Date objects should be in the same array if year AND month match up. I'm supplying two extensions I added to Date and Formatter to easily extract year and m...
As a side toy project for my Genetic Algorithm, I decided to try to create a macro that lets you use maximize: ... subject to: ... linear problem notation to generate fitness functions. Those fitness functions can then be used in a genetic algorithm to solve linear problems through brute force. Yes, I'm aware genetic a...
I have a DataGridView whose Virtual Mode property is set to True. When values of the underlying list are updated, those updates are not occurring in the UI unless I scroll vertically. So I have created a timer which, every 1 second, calls DataGridView.Refresh(). Feels ineffective and overkill. Is there a better wa...
I've been working on a project in python, and I needed to represent a certain numeric type. I need to represent the concept of some or all. Then I need to be able to add these amounts. Coming to this juncture I found myself really wishing I was writing in Haskell. In Haskell I could build myself a nice little functo...
I was asked this question from online coding interview and I have provided my solution that passes all of the test cases. I wanted to see if someone can review my code. Array Index & Element Equality Given a sorted array arr of distinct integers, write a function indexEqualsValueSearch that returns the lowest index i ...
I decided to redo the first program I wrote (after the hello world thing). So, what it does is to convert a DNA sequence string to an array of strings that represent the amino acids that are made in a cell by ribosomes when that DNA sequence gets used (DNA codon table). #include <stdio.h> #include <stdlib.h> #include <...
I was asked this question from an online coding interview and I have provided my solution that passes all of the test cases. I wanted to see if someone can review my code. You can find my solution below using BFS. Here's also the link to the question that was asked at Pramp. Island Count Given a 2D array binaryMatrix ...
I have a table with ~900,000 records. I need to display a single record based on DocID using this query. The record is the latest record that got modified by another program. This piece of query run ~7 seconds: SELECT TOP 1 t.Register FROM PxStats AS s INNER JOIN Therapy AS t ON s.ID = t.ID WHERE ...
I'm trying to better understand flux-style architecture, so I wrote this snippet to clarify how a simple flux system can be designed. I was wondering if my implementation is valid, or if I've missed something. const application = () => { /* Init the model */ let model = { page: null }; /* redirects th...
I'm trying to introduce immutable types into our code base and I'm trying to determine a good pattern that is intuitive for our team. I was reading about the Popsicle pattern and that seemed complicated. I also saw a lot of builder patterns. But those seemed like overkill as well. In the example below I would like to m...
I have to implement a "user-friendly" URL for an employment website. The URL /jobs{parameters?} may be composed of up to three searching criteria separated by hyphens (i.e. -); each criterion is separated by a tilde (i.e. ~). The parameters string has the following structure: -keywords-employmentTypes-locations. keywor...
I have written a class that locates relative root project directory path from where I'm calling that class. E.g. I have structure: rootProjectDir |_sub |__subsub |___subsubfile.txt |_another_sub |__another_sub_file.py and what I'm doing is when I'm working within another_sub_file.py I'm calling my class GetRootPa...
I am a new Python programmer, and I am learning how to use the turtle import. I am making some projects, and now I am trying to do a Pong game using turtle. It is working but not really well; the hitbox and the collisions can be improved. Can you please look at my code and tell me how I can improve it? Code: import tur...
I have a code created and need your support to optimize it. VBA analyses spreadsheet for 6 dates located in columns (milestones) and defines the latest date, column name and status if there is any status next to date column. As a result VBA pastes this data to additional columns located in same sheet and called: Curre...
I tried for fun implementing a function that converts HTML input characters to asterisks after a given time. What do you think about my approach and how would you do it? const passwordEl = document.querySelector('#password'); const showPassEl = document.querySelector('#show-password'); const replaceAt = (string, ind...
I have a csv file with more than 700,000,000 records in this structure: product_id start_date end_date 1 19-Jan-2000 20-Mar-2000 1 20-Mar-2000 25-Apr-2000 1 20-May-2000 27-Jul-2000 1 27-Jul-2000 2 20-Mar-2000 25-A...
I have created a mini Android game. The aim is to catch aliens in space. You score points for each aliens, there is a pause function and you can change the level of difficulty and change spaceships. import android.app.Activity; import android.content.Context; import android.graphics.Bitmap; import android.graphics.Bi...
I am working on a Spring-MVC application in which we have note like functionality. Notes can have attachments, history, etc. There is a method to copy notes. When a note has a large number of attachments (big or small), it takes a heck load of time for it to copy (around 5 minutes for a note with 341 attachments). Yes...
Is this an efficient way to search for a specific object in an ArrayList? Product is the superclasS. Mobo, CPU, RAM, GPU... are the subclasses. ArrayList(called stock) stores Product objects. I consider that they key i am searching is found when class and the attribute "model"(you can see the getter of the attribute in...
Purpose of the question: learn more about ways to implement concurrency in Python / experimenting. Context: I want to count all of the words in all of the files that match a particular pattern. The idea is that I can invoke the function count_words('/foo/bar/*.txt') and all of the words (i.e., strings separated by one ...
I am learning exception handling in java. Every time I am writing a function, I wonder if I should put the entire function code in a try catch block. What the function does: In the below function, i am checking for file upload failures that could be caused by multiple issues.e.g. file too big, not a supported format an...
I'm a beginner at python, and this is my first major project. Inspired by this reddit post, I wrote a program that accepts a DNA sequence (in a FASTA file format) and generates a graphical representation Ebola Virus I've optimized it as much as I can, but I've hit a bottleneck with generating the actual image and rend...
Please review this code. #include <iostream> #include <vector> bool is_prime(int x) { int flag = 1; for (int i = 2; i <= x/2; i++) { if (x % i == 0) { flag = 0; break; } } if (flag == 1) { return true; } else if (flag == 0) { ...
I decided to write a 2D game with SFML, and for the beginning of the game I wrote classes to manage resources like sounds, musics, textures... I would like to get reviews of my code: how would you have write the program, how can I improve it? I also wrote a class "Logger" to make the debug of the game easier. I would l...
This is a very simple (no ability to flag tiles) mine sweeping game written in Python and designed for a terminal. Due to its limitations it is not recommended to change the board size as that will break the alignment of the visual indicators. It will display the game board as shown below and ask the user for input in ...
I'm trying to come up with a nice way of filtering a ListBox asynchronously, to keep the UI responsive. The filtering gets fired off asynchronously each time the filter text is changed. This needs to cancel all previous filtering operations, so the updates to the filtered list don't conflict. It seems that a list of Ca...
I'm beginning to work with VBA class modules more in Excel and want to make sure that no properties can be used if the class hasn't been initialized. Below is the class and my attempt to at doing so. Private Type helper Prop1 As Boolean Prop2 As Boolean Prop3 As String Prop4 As String End Type Private ...
I have written this code where per entity in feed.entity, if that entity has a field named trip_update and it has a matching route_id then I must iterate through each trip_update.stop_time_update in order to make sure the proper metra transit (using stop_id comparison) is selected. Then, I calculate some data; then ite...
I have a Character model that has a CharClass and ClassPerks child. Currently I am duplicating my logic a lot by manually assigning data. My Character index and create: def index @campaign = Campaign.find_by_id(params[:campaign_id]) @characters = @campaign.characters render json: { characters: @cha...
I am new to game development and took on the task to create a Pong replica due to my curiosity and interest in the field. I decided to write it in JavaScript because the game is not too labor intensive. I specially wrote it without any libraries for learning purposes. One of the biggest issues that I seem to run into i...
This is a getter in a class. It recursively generates a tree/hash to a certain level of depth. def children(depth: 4, article_children: self.root.child_links) get_children = lambda do |depth, article_children| article_children.map do |uri| if (depth == 0) Article.new(uri: uri) else ar...
In this game the pieces are trains and you move forward on the track (never backwards) in search of your goal. The players move based on a combination of resources (Soap and Water to make Bubbles) that are added each turn with a die roll. Players must choose a direction when faced with a branch. The game has not been f...
I can tell by looking at this code that I've gone about this in the wrong way. Provided the string is correctly formatted (each index ofCSVData[][], would the following generate a CSV file? There must be a more elegant way of taking my queries and building a CSV. Looking at this code kinda makes me sick in the stomac...
I have a Projects table, which I need to ORDER BY code column. But problem is code is not a simple INT, but a VARCHAR specifying multiple level (like 01-15_33/23). So I need to sort by first part, then next, and so on. One of the option I found is to replace order field everywhere with a complex array $orderAsc = ...
I've been working on this mostly for myself until now, but I am now thinking that it might be worth uploading for other people to use. But first I wanted to ask what other people think because I don't do much vimscript and have no idea about the dos and don'ts (aka. best practices) of the language. Description: A colle...
Created a shortest path finder that must pass via sets of intermediary edges (either one in each set counts as a pass) in order. Primarily I would like to know if there are logical fallacies in the ShortestPathViaFinder. I built it as a label-based breadth first search. Made for Java 7. Example: in the graph with vert...
I have an asp.net core app that sends emails with a link. When they click the link they can start taking an online test without logging in. The link contains a number that is validated by the controller who then returns their test. I log into my app and create a project. Here I enter a list of emails in a textbox separ...
Please review this code. How can I optimise this code? #include <iostream> #include <vector> #include <algorithm> // std::reverse #include <cmath> // pow() typedef unsigned long long int ulli; bool is_binary(ulli num) { bool status = true; while (true) { if (num == 0) { break; ...
Problem statement: Perform a depth first traversal on a BST and print the elements traversed. class Node(object): def __init__(self, value, left=None, right=None): self.value = value self.left = left self.right = right class BST(object): def __init__(self, value): self.root = No...
The below query is used to return a dataset for a SSRS report. It works fine and is quick enough but I am looking for any improvements that could be made. The client has asked to see all transfers between sites and the report should look like: Site1 Site 2 Site 3 Site2 Site 1 Site 3 Each row should also show the v...
In usual code if something goes wrong you throw an exception. However in some cases you need so that exceptions were processed and reported. Form validation is a good example. Error handling in this is realy easy. However I faced a problem when error handling is different from the previous example and that code does no...
I'm currently working on transcoding a large histogram so that the lessened file can be used within a viewer style GUI. The transcoding works by using Tokens to define runs of bins. For example, Token C (below) defines any number above 255 (or 8 bits) up to 16 bit) or 63535) of 0 height bins in a row. At the moment, m...
BSON is an extended JSON format. For example these documents are valid BSON documents, but invalid JSON documents: prettified documents: [ { "_id": ObjectId("5a934e000102030405000000"), "k": 10, "dt": ISODate("2018-10-10") }, { "_id": ObjectId("5a934e000102030405000001"), "k": { "field...
I tried again to implement the algorithm. Just need someone to check my work. I hope I didn't miss anything but my long work hours recently have been pretty taxing on my brain so I honestly wouldn't be surprised if I messed up somehow. def KMP_table(wrd): #example: B A A B D C B A A A C A B -> [-1, 0, 0, -1, 1, 2, ...
I need multiple CResourceUsers to share one instance of CResource. I want to instantiate the CResource only if at least one CResourceUser exists. CResource is not singleton by design, there may exist other users of CResource C++98 is used Windows only solution CResource methods are thread-safe I started with simple C...
What is it? It's a fairly simple logger which utilises a thread. How it works Note: this a pretty terrible explanation, perhaps it would be easier to look at the code. The logger class is a singleton, which contains the function log(). Upon logs()'s first use a static logger instance is created. The function then retur...
I am writing simple formatter for valid JSON. Is reads JSON data from stdin and writes formatted output to stdout. Goals: given valid input produce valid formatted JSON output constant memory usage minimal viable program (smallest program that solves a particular problem) feature free easy to read and understand be C9...
This is my attempt at an alphabet cypher in Rust. I'm unsure if iteration and pushing to a mutable is the best way to handle building the output; it seems like a good candidate for a map but I can't figure out how to do it. Can anyone help? use std::env; fn main() { let keyword = env::args().nth(1).unwrap(); l...
Anything that could be done better here? public class ShuffleBag<T> : IEnumerable<T> { private readonly int m_endIndex; private readonly FastRandom m_rng; private readonly T[] m_values; private int m_currentIndex; public ShuffleBag(T[] values, ulong state, ulong? stream = null) { m_current...
I am trying to implement and compare Floyd Warshall and Johnson Algorithm(for Sparse Graphs). I have written the following code which produces correct output values for the all pair shortest paths. However theoretically, Johnson's Algorithm should perform better than Floyd Warshall on sparse graphs. However, the run ti...
I am trying to create a data model where there are Document entities, which need to be in a defined order to each other. Think of an article that has sections which build up on one another. Example: Document1 -> Document3 -> Document2 -> Document6 -> Document5 -> Document4 I was trying to implement a linked list to ac...
I wrote this shell in C about a semester ago for a university assignment on operating systems. Even though I got a score of 10/10 in this assignment, I doubt it deserved it - The pipeline implementation could be written better. There were some cases (1%) where I got the pipeline to stuck while bash did not. Maybe so...
I was looking for optimizing a search method for an assignment where I had to search a file for employees, I should be able to search by having any of the four filters or even none; I've imagined it like a sample space Venn with 4 events where I'd be looking for intersections (no filters should return all,...). The pr...
After thinking for a long hard time, learning about algorithms to find substrings, and coming to really long and tedious code I decided against my solution and to look for help. The solution was much simpler and elegant. After determining that my code was too much for a simple task I came across an explanation of a sim...
I had a phone interview and we shared a screen to do a simple challenge. Instructions were ambiguous but I basically had to implement how an air conditioner would work in general. I wrote the following as I talked it out with the interviewer. So I made a class with a parameter that would be a room temp and then added t...
I'm pretty new to this but I coded a DDOS mechanism for educational purposes. I need to know if the thread safety can be improved (Right now I have none, but do I need any?) and if the loop speed can be improved (can data be sent any faster)? public class SessionWorker : ISessionWorker { private ISession _session; ...
This is a follow-up of: Rearrange page numbers for printing a book Input: Total pages of a book: int Pages per booklet: int (divisible by 4 evenly) Processing: Rearrange the pages in each booklet to follow a specific format, [n, f, f+1, n-1], where n is the last page of the booklet, and f is the first. Output: Print ...
This question is a direct follow-up #1 of my previous question: Lightshot Print Screen key linux handler There were too many errors which I didn't see at the moment and I tried hard to fix them up now. I would like someone else (than myself) to actually review the code this time. #!/bin/sh # treat unset variables as...
I don't mess around a lot with templates (or with GTK), but today I wrote something and would like to know how it can be improved, and hopefully clarify a few things in the process. So, Randolfi() is a function template which returns a random number. A range can be specified as arguments. It uses features new to C++11,...
I have implemented a dynamic array in C. I am a beginner in C so any constructive feedback about improving the implementation would be greatly appreciated. Header file for the implementation( dyn_array.h) #ifndef TYPE_H #define TYPE int #define TYPE_SIZE sizeof(int) #endif #ifndef STDDEF_H #include <stddef.h> #endif ...
I wrote a C++ plugin that retrieves screen pixel. It works on Windows and Android. I noticed that dllexport is only required on Windows but not on Android and causes error on other platform other than Windows. I fixed that by using #if macro to make it use dllexport only on Windows. Here is the fixed header code: #ifnd...
I'd appreciate advice regarding both the implementation detail and ways to improve usage/performance/generic. There are two parts: XDelegate, which is I got from here, and XEvent, which is the event implementation similar to C#. #pragma once #include <unordered_map> //hashing function //TODO: replace hashing with somet...
Two Sum Problem: Given an array of integers, return indices of the two numbers such that they add up to a specific target. You may assume that each input would have exactly one solution, and you may not use the same element twice. Example: Given nums = [2, 7, 11, 15], target = 9, Because nums[0] + nums[1] = 2 + 7 = 9,...
Can I get my program checked for efficiency? As in, see if there are better ways of writing my code, for example, making more efficient use of memory and/or security options like where to use constants? main.cpp // MAIN.CPP // #include "Force.h" #include "require.h" #include <iostream> #include <fstream> #include <vect...
I implemented median filter in Python in order to remove the salt & pepper noise from the images. It is working fine and all but I would love to hear your advice or opinions. def median_filter(data, filter_size): temp = [] indexer = filter_size // 2 for i in range(len(data)): for j in range(len(da...
City is represented by matrix M x N, where rows are enumerated from 1 to N, and columns are enumerated from 1 to M. Tramways always go straight along the row. Starting point of tramway is (r, c1) and ending point is (r, c2), where r is the number of row, c1 - starting column and c2 - ending column. We need to determine...
I have a cookie on my site with the following value: eyJGIjp0cnVlLCJBIjp0cnVlLCJUIjpmYWxzZSwiUyI6ZmFsc2UsIkciOmZhbHNlLCJYIjpmYWxzZX0%3D I use this function to retrieve the value from the site so I can use it in the applications my site uses to greenlight certain elements or to block them. function getCookieLawSetting...
Task: Perform Breadth first traversal on a Binary Search Tree and print the elements traversed. class Node(object): def __init__(self, value,left=None, right=None): self.value = value self.left = left self.right = right class BinarySearchTree(object): def __init__(self, value): ...
Let's assume we have an array that contains the following elements: -1, 0, 0, 1, 0, -1, 0, -1, 1 I would like to count the combinations of consecutive elements such that -1,0 & 0,0 & 0,1 & 1,0 & 0,-1 & -1,0 & 0,-1 & -1&1 In this case: The count of -1,0 = 2 The count of 0,1 = 1 The count of 1,0 = 1 and so on I imple...
This is my first Python program and while it's not quite finished I would like to know how I could improve in general as a programmer. This project has be a lot of fun but it has felt more like throwing stuff at the wall and seeing what sticks rather than well thought out programming. Could anyone point out things I'm ...
I am doing MarsRoverKata exercise just to train my coding skills and I came up with the following solution. A squad of robotic rovers are to be landed by NASA on a plateau on Mars. This plateau, which is curiously rectangular, must be navigated by the rovers so that their on board cameras can get a complete view ...
I'm looking for some enlightening, since I'm still learning to code in VBA. I'm running code to create a daily report. It has to compare dates and check certain values in those dates and based on that I get my info. The info is gathered from three worksheets that are on the same workbook. It's working since it does wha...
There are sometimes situations where you have a couple of related classes with static fields or properties but you cannot access them via T because you cannot define interfaces for static memebers. I thought I write a helper that by utilizing dynamic allows me to do that anyway. It is implemented by the generic DuckObj...
Motivation I typically try to avoid using ! in if-statements, because (to me) it seems easy to overlook. So, I'll usually just spell it out instead, ex: if (done == false) instead of if (!done). While that makes the intention more obvious, it doesn't read very fluidly. Macro code For those cases I wrote the following m...
I sometimes have to schedule some tasks and wanted to have my own reusable scheduler. Since I like the Rx, I build it on top of it. Follow-up There is a newer version of the Scheduler. The Scheduler class is really simple. It's backed by a newer implementation of my old CronExpression. There are currently only these ...
I am given an integer "n" as an input and must convert it to a binary representation. Then I have to find the maximum number if consecutive 1's in it. Can you please evaluate the implementation? Any advice on how to achieve better performance? using System; using System.Collections.Generic; using System.IO; using Syste...
The goal of the code below is to: Support authenticated encryption using AES in the CBC mode and using HMAC SHA. Support encryption and decryption of data of size larger than memory (potentially). Please criticize :) public class AesCbcThenHmacSha : IDisposable { private readonly Func<HMAC> hmacShaTransformFactor...
I would like to make (or improve my function) a function that returns an array of integers containing all the prime numbers from 2...n that can execute as quickly and efficiently as possible (ideally so that it will be able to execute n = 1,000,000,000 in a matter of seconds). I am using Swift 4.1 and Xcode 9.3. Where ...
Inspired by this reddit post, I have written a program that accepts a DNA sequence (in a FASTA file format) and generates a graphical representation. HIV virus and Ebola virus My program works like this: Accept and parse input file Break input file into array (using custom array class largearray.Array()) Iterate thr...
My exercise is to write the Fizz Buzz problem with the following in mind: Use the latest up-to-date style and best practices for a C++17 compiler. Don’t just show that I can write a loop. Rather, illustrate some good engineering concepts, as much as can be done without making the code not-so-trivial. The “good engin...
How can I improve and optimise this code? #include <iostream> #include <vector> std::vector<bool> sieve_of_eratosthenes(int n) { std::vector<bool> primes(n+1, true); primes[0] = false; primes[1] = false; for (int i = 2; i <= n; i++) { if (primes[i] == true) { for (int j...