instruction
stringlengths
71
71.9k
I was about to use the awful enum+map trick to switch on std::strings when I thought to see if I could let some variadic templates do the job for me and I started to play... #include <string> #include <iostream> #include <functional> #include <unordered_map> template<typename Key = std::string, typename Fun = std::fun...
I have a method that uses a bunch of if-else statements, and I am thinking how I could simplify it. public static CardNumber decode(String s) { if(s == null) { return null; } else if(s.equalsIgnoreCase(ACE.toString())) { return ACE; } else if(s.equalsIgnoreCase(TWO.toString())) { ret...
String.prototype.replaceAll = function(find, replace) { if (typeof find == 'string') return this.split(find).join(replace); var t = this, i, j; while (typeof(i = find.shift()) == 'string' && typeof(j = replace.shift()) == 'string') t = t.replaceAll(i || '', j || ''); return t; }; function html(input) {...
I'm looking for a review on the following classes and the comments I applied (class assignment): package assignment1; /** * Returns a GeneralEmployee object * Sets the name, id for the object when called. * It increments the id that is assigned to a new employee object so that each employee gets a unique id * It c...
I am trying to implement an iterative version of flood fill in C: #include<stdio.h> int m,n; void flood_fill(int [][n],int,int,int); void print_wall(int [][n]); int main(void) { int i,j; scanf("%d%d",&m,&n); int arr[m][n]; for(i=0;i<m;i++) { for(j=0;j<n;j++) { scanf("%d",...
I wrote this program a while back that would allow me to set a delay, say 3 hours, and when the delay had expired, my PC would turn off. The purpose of it was so I didn't have to leave my PC on all night whilst downloading games. I recently tinkered with it to allow me to have my PC shutdown at a specific time. It work...
I decided to write my own implementation of merge sort. Here is the code: public static int[] mergeSort(int[] array) { if (array.length <= 1) { return array; } int half = array.length / 2; return merge(mergeSort(Arrays.copyOfRange(array, 0, half)), mergeSort(Arrays.copyOfRange(array,...
This is a homework assignment, but it's already done and it's not for a grade; it's meant as a refresher for the rest of the course. I've never done anything with dynamic memory allocation in C before, so I'm assuming I've done at least something wrong. The goal is to write a program that takes a string from a user and...
I've ported some standard library facilities like vector, algorithm, etc. to my kernel so I can code in C++ instead of C. This is one of them. I'm looking for concerns regarding: Performance Safety Friendly interface Perhaps there are more idiomatic ways to accomplish what I'm going for? #ifndef _LIBCPP_STRING_H_ #de...
I am writing a CMS type application and I am trying to restrict how the server gets accessed. Any content (in js/, css/ or images/ directories) should be served as is, as long as there is an index.php file at the same level as the content directory All other paths should run through index.php to determine what conten...
This script of mine merges columns 1 and 2 from one input file and sees if these merged combinations exist in the other infile (and vice versa). I know I get stuck in appending. It did not get past that while running all night. The infiles are 13,000,000 lines long. #!/usr/bin/env python infile1=open('/path/to/tab/de...
I am trying to write a program which will count the occurrence of words in a paragraph. The logic I am following : I am using a linked list for the purpose. And I am searching sequentially - if new word encountered adding the word in the list, but if word already exist in the list increase its count flag. Code: //...
Casting, instanceof, and @SuppressWarnings("unchecked") are noisy. It would be nice to stuff them down into a method where they won't need to be looked at. CheckedCast.castToMapOf() is an attempt to do that. castToMapOf() is making some assumptions: (1) The map can't be trusted to be homogeneous (2) Redesigning to a...
I've subclassed UI button and used it in my View Controller's viewDidLoad method, like so: PLOTDefaultButton *createAccountBtn = [[PLOTDefaultButton alloc] init]; CGRect createAccountBtnFrame = createAccountBtn.frame; createAccountBtnFrame.origin.x = 20; createAccountBtnFrame.origin.y = self.view.bounds.size.height - 1...
I've made a (service) class to handle all form validation of my application. It contains a set of frequently used validation callables extracted into private methods that I use to build each is[FormName]Valid(); method. It would probably end up containing validation logic for about 5 or 6 forms of which it contains 2 a...
How would you simplify/improve the readability of this code? Because even after my attempt to improve the readability I think it still looks messy. private bool INTOP = false; private bool INLEFT = false; private bool INRIGHT = false; private bool INBOTTOM = false; private bool BEYOND = false; ...
I need to optimize the following stored proc. Please let me know of any techniques or modifications that I can make to optimize this piece of code. The procedure is for a report that needs to run and span a couple of months' worth of data. ALTER PROCEDURE [dbo].[UP_Report_OverallSales_SP] @DateType INT = 1, --defau...
I'm looking for some feedback on my first Javascript app. I've built an app that calculates tax for Australian tax payers. Specific feedback on areas that could be object orientated and any errors I have made would be great. //Inputs var income = 250000; var superAnnuationPercentage = 9.25; var superAnnuationTaxRate = ...
The problem is, in summary: A set of values will be given. Whenever the input is -1, the largest number from the values inputted until then needs to be printed, and is then deleted. Here is the code that I wrote for it: #include<iostream> #include<vector> #include<algorithm> using namespace std; int main() { int v...
I have some dropdownlist in my aspx page and I am using the choices from them in my SQL query: query = ""; DataTable taskData = new DataTable(); connString = @""; //connection string strClause = ""; if (!blOnLoad) { if (ddlTaskName.SelectedIndex > 0) //dropdownlist { strClause += " AND CT.ATTR2739 LIKE...
(From Project Euler) The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17. Find the sum of all the primes below two million. Can someone please help me improve this code? import math def main(): lim = 2000000 i = 2 now = [] total = 0 for i in range(2,lim+1): for x in range(1,int(math.sqrt...
Basically I want to create a concurrent LinkedHashSet which returns proper size too. I am mainly concerned about adding and removing iterations. Suggestions relating to implementation of set modification during iteration are also welcomed. import java.util.Collection; import java.util.LinkedHashSet; //TODO still not ...
I'm creating tool to add new virtualhost on UNIX-box. One of tasks is to add a new user and database to MariaDB (aka MySQL) server. In fact - this my first 'real' attempt to use OOP. Here is class, which I created for it: class mysqlUserDb: warnings.filterwarnings('error') def __init__(self): ...
I have just started to play around with C++ and I want to make my code efficient and clutter free. Please critique this code constructively and give feedback that will help me in my programming career. #include <iostream> #include <iomanip> #include <limits> using namespace std; /* This structure will hold my initia...
I need to process a bunch of completed orders (thousands). To make it faster, I'm using a SemaphoreSlim to schedule a number of orders to be processed in parallel. Every order goes through multiple web service calls to various APIs (SOAP, REST). Then I need to take the returned data and process it into a PDF. Here is w...
I'm developing an iOS app, and I have a file, WebService.m, that is now 2300 lines long. My file contains all the web service calls on my app, with their parsing if successful, like: - (void)searchSettingsWithSuccess:(void (^)(UserSettings *settings))success failure:(void (^)(WKWebServiceErro...
The purpose of this code is to centralize all error / status messages to present to the user. For example, registering an account and the user email address is already registered. A status code is set then sent off to get a friendly error message to present to the user. All services will have its own set of status code...
I have a quite simple loop that draws an 8px by 8px image many times in a canvas in a tiling fashion. Currently it's drawing 7500 images each loop. See the jsfiddle. var img = new Image(); img.src = 'http://i.imgur.com/3dzaMlv.png'; var W = 8; var H = 8; var R = 800/W; var C = 600/H var canvas = document.getElementBy...
I have written some jQuery code for AJAX form submission: jQuery(function() { jQuery('#message').click(function() { var btn = jQuery(this) var Name = jQuery("#Name").val(); var Email = jQuery("#Email").val(); var Sub = jQuery("#Sub").val(); var Message = jQuery("#Message").va...
What this query does: Gets multiple users with the first select in the union; those are the active users. But when a user is not in that list, but there is a @userid, it should get that user as well and set active to 0 there; that is what the second select does. If a user is in the first select, and in the second se...
Some background info: I'm working at a shipping company and the company's web developer has been fired a week ago. My boss knew that I had some knowledge in web development, so until we get a new programmer, I'm developing the navigation web application. What the application has to do: Well it basically has to be able...
Working on my first "big" project using the mighty Xamarin. Likewise my first venture in XAML so I suppose most focus will be going towards these new areas. Performance- and user-experience related remarks are welcome as well though. Or you know, just any issue you can see. The solution consists of 3 actively used proj...
I've been learning Java for the past 6 months online and haven't had anyone review my code before. I'm worried that I may be making lots of beginner mistakes and was wondering if anyone could point out any ideas on how to make the code more OO. The class is instantiated from the main and all relevant code is here exce...
This is my first angular code. I've been working with jQuery for a while, so I don't have the same approach. I'm looking for advice and code improvement. The following code has 3 directives: ceBoxCreator: Will create a div that will be draggable and resizable on a click. ceDrag: The element binded to this directive ...
Let's say I have a plain text string that I want to split into a string array, using an integer array containing the indexes of this string where I want it to be cut. Example: Input string: "001ABCD2T" Indexes array: {3, 7, 8} Expected resulting string array: {"001", "ABCD", "2", "T"} Here's how I do it for now: string...
I'm trying to make an XML editor. So far, I got the results I wanted, but a lot of code is repeated. How can I reuse more effectively? import java.io.File; import java.io.IOException; import javafx.collections.FXCollections; import javafx.collections.ObservableList; import javax.xml.parsers.DocumentBuilder; import ja...
I've written this to accomplish a specific problem, but it's too long. I've sure that it can be reduce too fit it. I have the following model: public class ColumnChart { public virtual string type { get; set; } public virtual string name { get; set; } public virtual List<double> data { get; set; } }...
This is my implementation of 1024bit(can be changed) RSA. Is there anything I'm doing wrong? public class Rsa:IEncryption { public AsymmetricCipherKeyPair Keys { get;private set; } private readonly Pkcs1Encoding _engine; public Rsa() { Keys = GenerateKeys(); _engine = new Pkcs1Encoding...
Is there any way to improve this simple addition to the textbox control: appending a new line? class CustomTextBox : TextBox { public void AppendLine(string textData) { if (this.Text.EndsWith(Environment.NewLine) || this.Text == "") { this.AppendText(textData); } else...
I'm new to OO PHP and I'm trying to create a simple properly-designed user authentication system. What am I doing right and what not? Is this right according to the MVC model? Connection.class.php <?php class Connection { private $host = 'host'; private $name = 'name'; private $user = 'user'; private...
My encryption algorithm I'm using this algorithm in order to encrypt notes users save on my site: function CasualPassword($lenght=527){ $available_chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890"; $password = ""; for($i = 0; $i<$lenght; $i++){ $password .= substr($availab...
I've come up with the following T-SQL to compare similar same length strings. Example usage would be: OCR returns a value which is expected to be in the database. PATINDEX is used to check the value's in the database, including matching for common errors (e.g. 0/O, I/1/l). If multiple values are found, each match is s...
I am a PHP newbie and this is part of a gallery code. I recently read about SQL injection and cross site scripting attack, I am trying to avoid that by html escaping on dynamically produced data. I am not sure if I am heading in the right direction here. I created an array with URL parameters then a function for HTML e...
I am currently developing a small tool intended to help me keep track of the myriad of characters in my Stories. The tool does the following: Load the characters which are currently stored as json on the disk and stores them in a list, which is presented in the Shell via a ListBox. If the user then opens a character t...
What I'm trying to do is very straightforward and easy, but I am wondering whether there is a more elegant solution. Basically I have a game and I want the difficulty to increase the moment the score gets between 100 - 500, then increase once again when the score is between 500 - 1500, then again when the score is bet...
I have the following function. It can be passed a candidate_string such as the following examples: "device1 device2" "device1" "device.*" "device.region" "device[123] Assume that target_list contains at least the following: ['device1', 'device2', 'device3', 'device4'] I want the output of calling the function to retu...
I have been working on a cronjob that runs a few checks across different tables in my database. The issue is that although it works, I feel like I am doing something horribly wrong in terms of the standards set out by others and also in the future for any adjustments I make. The code below DOES work perfectly, but a fo...
I wrote a program that simulates many instances of trying the martingale betting system with roulette in Haskell. At the answerer's suggestion I opted to leave the IO monad in main and ensure that the functions martingale and martingale', which handled the actual testing, were entirely pure, but the answerer also sugge...
I have a Java project that copies files and folders to a user's space on the cloud service using a RESTful API. The login design is getting very complicated, and I wanted advice on how to simplify/re-write it. I wrote this flow to gain an access token from the API and set the destination workspace (directory) through l...
I've been into algorithms lately, so I wanted to apply a simple algorithm using a language of my choice, which was C in this case. I've implemented the bubblesort algorithm (for strings) in a simple program: #include <stdio.h> #include <stdbool.h> #include <string.h> #define NUM_NAMES (5) void sort(char ** sorted, ch...
I have a situation in my Node (express) controller where I need to check whether a particular language has a parent language, if it does, I need to do a new DB (SQL) call to retrieve the parent language details. The problem is that this is encouraging a pyramid style (not too far from callback-hell). What if next I nee...
The following JS code handles when the form is submitted and some little extra stuff. I'd like to have it reviewed on the following aspects: Readability Efficiency Usability OOP It works exactly as intended. I have commented the code to possibly clarify some things and also added the form's HTML code, just in case. I...
I've written a function that generates a report, and then sends it as an attachment to an email. I don't want to clutter the function with a lot of calls to close up the filesystem, if there was an error along the way. What do you all think? // attempt to generate the report, any error will be wrapped in Failure(ex) ...
This is a reference implementation of a summation unit. The algorithm used is a most straightforward carry-propagation. If necessary, a test driving code could be provided. Few notes for the reviewers: The code does compile and works indeed. Test harness is available on demand. I am a steadfast proponent of descriptiv...
I have the following class: public final class ViewUtils { public static void setSize(View view, int width, int height) { ViewGroup.LayoutParams layoutParams = (ViewGroup.LayoutParams) view.getLayoutParams(); layoutParams.width = width; layoutParams.height = height; view.requestLayo...
An implementation of a simple compression algorithm that's featured in a programming practice book. My goals: Robust: All error conditions must be handled properly. The specification indicated in the self-documenting comment must be met exactly. Secure: No opportunities for buffer overflow in the program. Efficient: T...
The below idea seemed to look clean, to allow the object itself to validate its values for different scenarios. For eg: While creating the object, the value of Object1 and Object2 in SelfValidator object should be validated for not null. At one scenario like inserting the SelfValidator object to Database, validation...
I've been reading about wrapping JS files in functions to call them on load, etc. I also was looking at namespaces and how to avoid collisions with functions/objects/variables of the same name. What improvements can be made? I know the code works, I'm more concerned with best practices for wrapping JS files and using n...
A small program I use as my "hello world" of streaming libraries is the following: For each line of stdin Interpret the line as a file-name If the file represented by the file-name has changed ... (including the possibility of being removed or added) ... Then output the file-name This works well because you can draw ...
I am building a command-line .exe that can apply several operations on a PDF file (add text, images, resize, crop, etc). Currently, my Program.cs looks a bit like this (it uses CommandLineParser): switch (invokedVerb) { case "barcode": Operations.BarcodeOperations.AddBarCode(options.AddBarcodeVerb); ...
I have an array of a instances of an enum type. A random double variable is initialized with a value between 0.... to 1, and should be used to get the closest value's enum instance to that randomly set double value. The enum looks like this: public enum TargetScope { CLEAN(1, 5040), FIRST(.888, 5046), SECO...
I've made this extension method. Its purpose is to trigger the disposal of a value, stored in a Nito.AsyncEx AsyncLazy, as authored by @StephenCleary. Is this an approach that makes sense? Is the code good? using System; using System.Threading.Tasks; using Nito.AsyncEx; /// <summary> /// Extensions to types in the <...
I have this simple class where I load an object from the database and store it into the RouteContext.DataTokens because I need to access it through out the request. In this example the RouteContext is injected via the constructor but I'm not sure that's the right thing to do here, maybe the RouteContextshould be a meth...
I've read lots about getters and setters being evil, unless there is good call for one, but I cannot figure out how to implement that knowledge into my Model layer. Say in my Model layer I have a class that has services like: findStudentsByID($searchCriteria) findStudentsByLastName($searchCriteria) ... Do I require a ...
Mostly due to readability, I am using the following code to find a specific csv file on a drive read that CSV file using a streamReader parse it into a List<string[]> to be able to use LINQ and/or PLINQ later on However, the process takes about 4-5 seconds, which is simply put too long. Any suggestions on how to impr...
In this dummy structure, we have a race car manager class. this class contains a method named execute(). There is a List which contains all participating racing cars. This is the Car class, the List's type is based off: public Car { private boolean driverBeltOn; private boolean engineOn; public boolean e...
I was inspired to write a query that produced a graph mapping the perceived quality of your Stack Exchange answers over time.... in other words, "Are your answers getting better, or worse?" Because answer scores are very 'spiky', it seems natural to calculate a sliding average with a configurable window, to show trends...
Looking at Learn You a Haskell, I implemented a function that, given a binary tree, i.e. left and right branches, give a list of Directions and give the element at that location. Here's the Tree: data Tree a = Empty | Node a (Tree a) (Tree a) deriving (Show) And then the functions: elemAt :: Directions -> Tree a -> a ...
I wanted to try FizzBuzz, but to do it in the most efficient way. I think this method employs most of the concepts I learned here. Is there anything unaccounted for? A sprinkle of Swing since that's what I've been focusing on lately. import javax.swing.JOptionPane; public class FizzBuzzCounter { public sta...
I need a "little" help with an SQL query (MySQL). I have the following tables: COURIERS table: +------------+ | COURIER_ID | +------------+ DELIVERIES table: +-------------+------------+------------+ | DELIVERY_ID | COURIER_ID | START_DATE | +-------------+------------+------------+ ORDERS table: +----------+---...
I'm pretty new to AngularJS and have made my first directive. Is this a good or a bad way to do this? It works, but can't figure out if this is clever or not. .directive('showWithDelay', function($timeout){ return { restrict: 'A', link: function($scope, $element, attrs){ $element.addCla...
I put together an asynchronous map function for Swift's Array using Grand Central Dispatch. It's called with a transform closure, a dispatch_queue_t (optional), and a completion closure. The transform closure is passed an item from the array and a callback closure which should be called with the result of the transform...
I was browsing Stack Overflow recently and saw a PHP question about rearranging an array of arrays for printing. The initial data structure looked like this: $array1 = array( array("type01",1995), array("type03",1996), array("type01",1995), array("type09",1998), array("type09",1995), array("type...
I have a helper class that does HTTP operations on Android. Every method uses a client field. I think it's a good idea to make this client a singleton since every method in the class uses it. The problem is that I don't know 100% what's the best way to implement this singleton since it's only a field in my helper class...
I'm doing an Objective-C project and I need to do some prime factorization and so I came up with the following algorithm which is 99% C, except for the array part which was easiest to implement in Objective-C because it dynamically allocates new memory for the elements as they are simply added. The Objective-C part is ...
I want to create multi parameter search using JDBC prepared statement so as to prevent SQL injection attack and improve performance. As I couldn't find the best way to do it on the net. I've tried to implement on my own as follow. In this program I want to allow the user to search an employee by either first name, la...
Is this a good way to prevent two sequential numbers from repeating, or is there a better, more efficient way of doing this? By efficient, I mean a less CPU and memory consuming process. while (random === lastrandom) { random = Math.floor(Math.random() * 3) + 1; } lastrandom = random;
I'm building a Java method to sum arithmetically two time periods, using the JodaTime library. My code works fine, but I think that it's possible optimize to reduce the time execution. import org.joda.time.Period; import org.joda.time.PeriodType; import org.joda.time.format.PeriodFormatter; import org.joda.time.format....
I have written this code for UVa Challenge 100: #include<iostream> using namespace std; int main(){ int i,j,a,b,k,tot,gtot; while(cin>>i>>j){ gtot=0; a=i<j?i:j; b=i<j?j:i; for(int l=a;l<=b;l++){ tot=1;k=l; while(k!=1){ tot++; if((k%2)==0)k=k/2; else k=(3*k)+1; } if(tot>gtot) gtot=tot; } cout<<i<<" "<<j<<" "<<gtot<<end...
This particular problem has already been posted here before, but the community is ok with me to post it again, so I can have feedback on my own implementation. I tried to keep things simple, with each function having its own responsibility so they can be reused in other contexts. Here it is: (ns marcofiset.euler.proble...
Will this code qualify for a truly thread-safe list? It is using the Lock object. using System; using System.Collections.Generic; using System.Threading; public class ThreadSafeListWithLock<T> : IList<T> { private List<T> internalList; private readonly object lockList = new object(); private ThreadSafeL...
I have this simple function here because I am too lazy to write out a state dropdown every time I need one. I already have an array with all the states set up, abbreviations as keys and names as values. It works just fine, but I like to write concise, clean, legible code, and I am still very unseasoned, so I find I mis...
I have the following query which brings back a list of items which fall into a particular category: SELECT i.id, ir.range_name, it.item_type, i.item_value FROM items i LEFT JOIN item_types it ON it.id = i.item_type LEFT JOIN item_ranges ir ON ir.id = i.item_name LEFT JOIN menu m ON m.id = it.menu_link WHERE m.menu_titl...
I have this code: try { Console.WriteLine("Input number {0}", i + 1); int number = ReadNumber(start, end); } catch (Exception ex) { if (ex is ArgumentException) { Console.WriteLine("The input number wasn't in the alowed range. Please try again."); } else if (ex is FormatException) { ...
I have an array and I need to make one function which has two parameters, array and K. I need to return a new array with only K elements reversed, the rest becoming the same as in array. I am able to get correct results but I think its performance is too slow. Is there any better solution to get the same results? var a...
The first part of the code (above the in-code comment in the middle) looks messy. I know I could use variables to make it cleaner, I just don't exactly know yet how can I effectively apply those when dealing with jQuery objects. So I'd appreciate a review on that. As for the if-statements, I think they're okay but if t...
I'm looking to collect form input and pass it to a file called processing.php with AJAX JS: $(document).ready(function () { var serializedSubmission; var responseObj; $('#myForm').on('submit', function (e) { e.preventDefault(); serializedSubmission = $('#myForm').serialize(); // get input ...
This is a responsive navigation menu (pure css), that highlights the page with a short JavaScript I found online. I have it all working, but the CSS is totally a mess. The menu is actually a PHP .inc file, so that it can be used site wide. $(document).ready(function(){ var str=location.href.toLowerCase(); ...
I have implemented a HashMap which supports insertions of integer key value pairs. The approach uses an array for simplicity and uses a standard hash function. Please give a review on the coding approach used in the program. import junit.framework.Assert; import org.junit.Test; public class HashMapImpl { class HashMap...
I'm using data from a database from the IMDB website. The database consists of five relevant tables. Actor (id, fname, lname, gender) Movie (id, name, year, rank) Director (id, fname, lname) Cast (pid, mid, role) Movie_Director (did, mid) It's worth noting that the id column in Actor, Movie & Director tables is a key...
Background I'm using Lua with luaglut to do some OpenGL stuff. The luaglut API is almost identical to the gl/glut C APIs. Sometimes, gl functions want a pointer to some data, for example: glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, oh_crap_a_pointer) In these cases, the lua...
I'm attempting to apply multiple filters and maps to a list and attempted to refactor into something i believe is more readable. In my code, I am reading a file to create a list of terms, then munging it into something I will feed into another script. Please note my terminology in the title might be wrong, but please ...
I've been working in C# for a while, but I'm just recently starting to force myself to use better abstracted and generic code. I recently encountered a situation where I was juggling a lot of session values on a page, so I made a wrapper class for the session to enable easy and safe get/sets of session values. I'm not ...
Can you please help me in reducing the complexity of the below code? The problem statement can be found here. You are given an array A of N integers. You are to fulfill M queries. Each query has one of the following three types: C d : Rotate the array A clockwise by d units. A d : Rotate the array A anticlockwise...
I'm working on the communication module of an ecommerce application. This module takes care of handling messages that come from other apps over the wire. The awful switch case is never an option so I decided to look for some pattern. While reading about this topic found that Message Factory and Double Dispatch patterns...
I'm using data from a database from the IMDB website. The database consists of five relevant tables. Actor (id, fname, lname, gender) Movie (id, name, year, rank) Director (id, fname, lname) Cast (pid, mid, role) Movie_Director(did, mid) It's worth noting that the id column in Actor, Movie & Director tables is a key...
What this code tries to do is find possible combinations of three numbers. For example, let's say I have the following numbers: 1, 2, 3, 4, 5, 6, 7 Some possible combinations of three numbers would be: 1,2,3 1,2,4 2,3,4 2,3,5 2,3,6 I do get the desired outcome but my code looks ugly. Are there any remarks or ...
I'm learning C and I've got to a point learning about different sorting algorithms. Before seeing how it was done, I wanted to try doing it myself based on what I read on how it's working. int temp; for(int i = 0; i < SIZE - 1; i++) { for(int j = 0; j < SIZE - 1 - i; j++) { if (arr[...
I am making my first web scraper in Python. It works great but it runs extremely slow. The website loads in about 10ms but it only does like 1 every couple of seconds. There are about 4-6 million records I need to scrape through. Any ideas? from bs4 import BeautifulSoup import requests import json import re import u...
This clock mux is meant to allow glitch-free muxing between asynchronous clocks clk_a and clk_b via a (also asynchronous to both clocks) sel signal. I'm looking for any feedback, but in particular I'm looking for confirmation that there can be no output glitches or metastability issues assuming synchronous/related path...