instruction
stringlengths
71
95.1k
This is my solution to the ECOO 2015 contest, problem 1, Fractorials. I'd appreciate any advice to improve readability, style, organization, etc. def main(): number = int(input()) fractorial = {} for i in range(2, number + 1): prime_factorization = prime_factor(i) update_fractorial(prime_fa...
I created a ContactsList class in Java that holds Person objects. I consider this is a side project for my GitHub profile. Any kind of suggestion is appreciated. Person Class package contactsList; public class Person { private static final String FAVOURITE = "★"; private String firstName; private String la...
I have written a Reddit bot in Python (code below). Open to any improvements, especially on efficiency, as I am using PythonAnywhere to run it. The main function is to scan posts in reddit and when certain phrases are found in the text private message the reddit user. Furthermore, the reddit user shouldn't be messaged ...
I just started learning Elixir and stumbled upon this challenge over on Programming Puzzles & Code Golf. It is a well-suited task for beginners, so I chose to give it a go (to be clear, give it a go means solve it normally, not golfing it). To keep this question self-contained, here is the task – citing the linked post...
Can anyone point me in the direction of a C# or pseudocode implementation of A* optimised for relatively sparsely connected graphs (average < 3 edges per node)? The implementation below that I have currently runs in 100-200ms for a graph of ~3500 nodes. I need this to be as low as absolutely possible. According to the ...
When you're working with trees one of the most useful methods to implement is a clear way to print them, the following is my solution to print a tree in Java: class BlackRedBST{ public static final NodeRB NILL = null; public static final boolean RED = true; public static final boolean BLACK = false; N...
I am computing a random weighted classifier based on the rates at which 3 labels appear in a "train" set. I want to use this RWC as a baseline for other classifiers. I'm doing this over 1000 iterations and then computing the mean of F1, Precision and Recall of each class besides the overall kappa. Can this code run fas...
#!/bin/bash #extractApacheResolutionName GrepAndFilter="ServerName|ServerAlias" RemoveBadMatch="s/^\s*($GrepAndFilter)\s+//gI" RemoveTrailingWhitespaces="s/\s*$//" RemoveComas="s/,//g" ReplaceSpacesWithNewLines="s/ +/\s/g" grep --line-buffered -Ei "$GrepAndFilter" /dev/stdin \ | sed -E "$RemoveBadMatch; $RemoveTr...
The following code implements the logic for moving tiles in the game 2048. The "move"(GameBoard::moveRight(), GameBoard::moveUp(), etc.) methods appear to be duplicating implementation. Any ideas for removing the duplication from the "move" methods? I would prefer that the time complexity for each "move" method be equi...
I did the following two exercises in Programming: Principles and Practice Using C++ (2nd Edition), by Stroustrup, which build upon each other: From Chapter 22 (Ideals and History), Write a program that given a file of (name,year) pairs, such as (Algol,1960) and (C,1974), graphs the names on a timeline. Modify the pro...
I wrote a solution to the leetcode problem Sort characters by frequency and the solution passes 34/35 test cases. On the last test case, there is a "time limit exceeded" error with an input string of 100000+ "a" and "b" characters. How can the following code be optimized to handle an input of that size? def frequencyS...
I wrote a JavaScript and XHTML webpage. I think the format of the output is not better or the validation process is not as it is supposed to be. How can I improve the code? How can I make it more efficient? There are two text boxes. First, it takes a sentence and returns the length. Second, it takes an integer and retu...
I'm trying to write a simple 'n' layered ANN in haskell for supervised learning, it will eventually have back prop and you'll be able to use it in a step by step fashion through a GUI which will graph the error function. This is for learning (so I'm not looking for suggestions on libraries that already solve this probl...
I was working on the following interview question: Given an array of integers, return a new array such that each element at index i of the new array is the product of all the numbers in the original array except the one at i. For example, if our input was [1, 2, 3, 4, 5], the expected output would be [120, 60, 4...
Implement an algorithm to find the kth to last element of a singly linked list. Any comments or feedback regarding this? I came up with another algorithm that uses HashMap to find the kth to the last element in a LinkedList. public static int getKthToLastElement(LinkedListNode head, int k){ LinkedListNode n = hea...
I would like to only allow lists where the first n elements are True and then all of the remaining elements are False. I want lists like these examples to return True: [] [True] [False] [False, False] [True, False] [True, False, False] [True, True, True, False] And lists like these to return False: [False, True] [Tr...
I have written a simple Caesar Cipher in Python in my efforts to learn a language that isn't C. It works much like any other Caesar implementation and takes various command line arguments to specify options such as the spacing of the output, whether to encrypt or decrypt the input, and whether or not to try and brutefo...
Given a directed graph G of 20+ million edges and approximately 2 million unique nodes, can this function/process be made faster on a dataset of 40k edges? The current speed is at ~1.8 seconds per edge. import pandas as pd import networkx as nx # main feature calculator def jacard_inbound(u,v): preds = G.predece...
This script is run directly after a fresh install of Debian, to do: sets up syntax highlighting in nano, sets up iptables, sets up ssh, sets up custom bashrc files and ls colors, creates users on the system if needed, checks if user has a password set and sets it if not, installs non-free firmware and sets up apt with...
I have made this custom image carousel, using HTML5, jQuery and CSS. My aim was to make it really lightweight but with (just) enough features: "bullets", auto-advance, responsiveness. var $elm = $('.slider'), $slidesContainer = $elm.find('.slides-container'), slides = $slidesContainer.children('a'), slidesCount...
While learning Rust for the past couple of weeks, I set out to use the type-system to build a static State Machine implementation in Rust. The goals: program in idiomatic Rust no runtime overhead use traits for flexibility optionally use macro's for ease of use keep it simple I believe I managed to achieve all, excep...
I have made a small application that displays a posts JSON in the form of cards, with the help of AngularJS and Twitter Bootstrap 4. The application has an interface for pagination and there are about 100 posts displayed on each page. var root = 'https://jsonplaceholder.typicode.com'; // Create an Angular module nam...
For some time now I have maintained (and written) IdGen. It's inspired by Twitter's Snowflake project and it's intended use is to generate (roughly) incremental id's in a distributed scenario with multiple machines/processes/threads guaranteeing unique id's (no collisions). The way IdGen works is described in the READM...
Due to another module coupled to my function, I can only receive the input to my part in the form of a JSON object structured roughly like this: [{'id':0, 'y':4, 'value':25},{'id':0, 'y':2, 'value':254}] Note that I do know that the data will arrive in exactly that format. Now, I need to cast this to lists such that I...
I am not very experienced in Entity Framework, I previously used ADO.Net and Dapper for data persistence. For now, I only read Microsoft docs and watched a few video tutorials. I tried to stick to well accepted advice and have built a generic repository infrastructure with the help of from here and there. IEntity publ...
I have 2 geoPandas frames and want to calculate the distance and the nearest point (see functions below) from the geoSeries geometry from dataframe 1 (containing 156055 rows with unique POINT geometries) as to a geoSeries geometry in dataframe 2 (75 rows POINTS). Question: How can the following code be optimized so as...
This is actually a hackerrank interview question I have already solved but I need guidance on how to optimize it for the Time Space Given an array of integers, your task is to count the number of duplicate array elements. Duplicate is defined as two or more identical elements. For example, in the array [1, 2, 2, 3,...
I want to find a more efficient solution to the following problem: My dataset is about online games. Each player may have multiple plays (rows in the df). Each play has its corresponding timestamp. However, some events are lacking their id (session identifier). I need an efficient method to fill the NaN of the id colu...
I was wondering if there was a better way to implement my cli parser. For context: I need to pass to my script either a file in one of two formats or two files in a specific format. It may be easier to understand like this: file.ext1 OR file.ext2 OR (file_1.ext2 AND file_2.ext2) I've used python argparse add_mutually_...
I'm using angular 6 and ngx-translate. This is my switch language function switchLanguage(language: string) { this.translate.use(language); if (language !== 'ar' && document.getElementsByTagName('html')[0].hasAttribute('dir')) { document.getElementsByTagName('html')[0].removeAttribute('dir'); } else...
The title is a bit of a mouthful, so here's a quick example: You've got an array, maybe just the digits 1-3, and you want to get the sum of product of all size-2 combinations of the array. Those combinations are (1,2), (1,3), and (2,3), so the answer I'm looking for is this: $$1\cdot2+1\cdot3+2\cdot3=11$$ Except now, t...
This code builds on the code in the previous iteration. All of the following tests should work: let myTree = Tree.from({a:{b:{k:2}}}); myTree.a.b; // { k: 2 } myTree.a === myTree.a.b.__parent__; // true // adding properties myTree.c = {d:{l:5}}; // {d: {l: 5}} myTree.c.__parent__ =...
Basically, this code splits a string into substrings based on a token. The printf call is just a placeholder for something useful for each substring and can be substituted for something else, like a spell checker, profanity checker, etc... With the input ("The quick brown fox jumps over the lazy dog", 44, ' ') the outp...
EDIT: Link to the github, https://github.com/Evanml2030/Excel-SpaceInvader THE README (APPLIES HERE TOO): VBA version of a classic game Yes, I know that "Missile" is repeatedly written as "Missle". It will not run unless you change the pathways to images that will be uploaded into form controls. You can find these ins...
I'm trying to figure out a way to make my code more readable and maintainable. While rewriting some ugly spaghetti code, I stumbled across this: if($header !== null && $fieldValue === null) { $errorMessage = $message . ': row ' . $row . ', header "' . $header . "\"\n"; } elseif($header === null && $fieldValue !== ...
I did this Codepen to combine all the columns from one matrix in JS. const matrix = [ ['a', 'a', 'a'], ['b', 'b', 'b'], ['c', 'c', 'c'] ]; const combineMatrixColumns = (matrix) => { const biggest = matrix.reduce((acc, arr) => acc.length < arr.length ? arr : acc, []); return biggest.reduce((acc, item, inde...
A long time ago I implemented some code to walk the git commit graph. I recently updated the accompanying analytics part of the code base to follow file moves/renames in order to get a more accurate count of the number of times a particular file was committed. Here's the original implementation of the commit count func...
In a recent project I worked on we faced some issues due to an excess of parallelization (thousands of threads were created and the overall result was a degradation of performance and several spikes in CPU usage). What we needed to solve this problem was a way to apply an asynchronous operation to each item of a sequen...
Does what it says in the title. I just finished this and wanted to share with someone. Looking for possible optimizations, bugs (most of it is tested to work) or any constructive criticism. template<typename P> struct alignas(P) [[gnu::packed, gnu::may_alias]] pixel : public P { template<typename> friend struct pix...
The goal of this code is to seat students in a classroom based on a single test score. We want students to be evenly distributed across the class such that every student is positioned next to the greatest amount of peer-assistance they can, avoiding clustering of low or high scores. The following method seems...
I have written a simple program to read file that contains record spread between multiple lines. There is requirement to read file from source that is dirty and contains line breaks which are unexpected. I would like to tune this if there is any suggestions. I am very new to Java programming. This is just to demonstrat...
I recently had the chance to try Codility's algorithm training, and the very first one in the list is finding the longest binary gap of a given integer. I tried to implement this in Swift, and after finishing it up, I looked at answers all over the internet. My approach is a bit different from what I have seen from oth...
I have function which returns a vector or strings (values from an sqlite3 table). For each of those strings I need to generate a Qt Checkbox, if it does not exist yet. My first version looks like this: const auto results = queryStrings(QStringLiteral("select ...")); const auto pred = [this](const QString& name) { ...
Requirement is to monitor the changes in a List<T>, possible changes are Add / Remove / Update, which are registered in an Audit log, which I do in the code underneath using a Dictionary. Now user can take an action to revert each of the operations, using an integrated Action delegate. Each operation runs its respectiv...
In an attempt to learn more with Java, I decided to challenge myself by creating a GUI-based, multi-threaded chat room. Currently, you run the Client and it prompts you to either create or join a server based on an IP. Port used is 9000. Any suggestions on how I can improve? Server.java: import java.io.BufferedReader; ...
First off I'm quite new to Python, there will be a lot of messy/overcomplicated code, that's why I'm posting on this site. This code is written in Python (2.7) using the Tkinter library. Questions To allow for viewing/editing large files, I am loading the file and saving it to a variable, then displaying only the text ...
I have found the following interesting challenge on the web: Deficient Numbers A number is considered deficient if the sum of its factors is less than twice that number. For example: 10 is a deficient number because its factors are 1, 2, 5, 10 and their sum is 1 + 2 + 5 + 10 = 18 which is less than 10 * 2 = 20...
I have been programming with Python on-and-off for about 2 years now, even now I still find that when I look at other applications I struggle to follow along with their classes/objects. Please help me improve upon my own OOP experience. Here is one of my more recent projects for a Django Website. pokemon.py # pylint: d...
I'm trying to solve the OpenAI BipedalWalker-v2 by using a one-step actor-critic agent. I'm implementing the solution using python and tensorflow. My question is whether the code is slow because of the nature of the task or because the code is inefficient, or both. I'm following this pseudo-code taken from the Book Rei...
I'm about to post quite a bit of code. Hopefully, someone is willing to put some time into reviewing it all. I know linked lists have been done a lot on here, but I wanted to improve the basic C++ skills I learned in college by learning more about templates, inheritance, move semantics, smart pointers, SFINAE, etc. My ...
I have the following Java code used to retry a certain actions/methods package helpers; import java.time.Duration; import java.util.ArrayList; import java.util.List; import java.util.concurrent.*; public final class Retry { public static <V> V execute(Callable<V> action, Duration retryInterval, int retryCount) ...
This is a random frequency audio generator made with the Web Audio API by Mozilla. The end-goal is an audio frequency trainer: the website plays an audio frequency and the user tries to guess which frequency it is. The frequencies will be limited to those found on 31 band graphical equalisers, and I'll include multiple...
I'm trying to build an Excel workbook to automate and aid in the creation of a weekly work schedule. My current workbook is functional, but it's slow - especially on one task where I have a list of people with an annual schedule that I'm searching two sheets at the same time. I think there's a better and more efficient...
I'm interested in some feedback for a custom TaskScheduler implementation I wrote today for use on a game server - I wanted to be able to have a single-threaded scheduler for tasks since the game is relatively lightweight and its logic doesn't need to be multi-threaded. However, I wanted to handle networking/IO concurr...
For a project I'm working on I have a set of number sets, and I need all unique permutations of them. I want to return only one copy of each unique number set, and I'm struggling to figure out how without some really funky design patterns. Maybe I had a moment of genius, but I doubt it, it really seems like there's a b...
I'm new to React.js and this code came from 30 Days of React - Day 7. However the given code example wasn't working so I rewrote it myself. My biggest issue here is how to make the component work without function getTime() using both setState and return. Any other suggestions are appreciated. class Clock extends Reac...
I came across the following code snippet: static private volatile ConfigUserCredentails maintenanceUserCred = null; static private Object maintenanceUserLock = new Object(); /** * This method is slower. Recommend use the one from cache. * * @return The username/password credentials of the maintenance user. * @t...
Is it my queue mechanism thread safe? I just wonder if I need concurrent collections. Need I lock Enqueue method? Console displays queue count in incorrect order, Does it affect on maxQueueCount at Load method? Can I improve it in some way? using System; using System.Collections.Concurrent; using System.Collections.Gen...
Stuck with the issue with memory consumption - after running joblib's Parallel, deleting results and gc.collect() -ing I still have increased memory (checking by htop for process line). Found no way to free memory back. To broaden yangqch answer I use such code to isolate memory for parallel computations: Imports - imp...
Environment details Python 3.6.5 Django 2.0 (which is not necessarily needed for this review) Class details I have a small class which holds 3 staticmethods (I know they should be avoided and use simple functions instead, but I decided to have them all together under the same class). Each of these methods generates ...
I apologise if the title is not very descriptive. If someone can recommend a clearer one I'll edit it. I have an exercise question as: The language L={anbn} where n ≥ 1, is a language of all words with the following properties: The words consist of strings of a’s followed by b’s. The number of b’s is equal the numb...
I created a function that checks to see if a particular set of data has been added to a listbox and returns a boolean to indicate if the value was found or not. I am asking for critiques on my code. EDIT: I just noticed the BasicInclude.DebugMode variable, I use that so that users see a standard messagebox, where when ...
I have an image cropper that crops the uploaded image, Before sending it to the server using PHP and AJAX. Here is a live fiddle to preview a working cropping example. Here is the code: // Create cropped part. function getRoundedCanvas(sourceCanvas) { var canvas = document.createElement('canvas'); var context = c...
I've found myself today really struggling with this subject and I'm pretty sure that there must be a better way to do this. First of all my arrays have the same layout, I need to merge them and sum every value by domain. Let me give you an example: $array[0]['X1']['Y1'] = 1; $array[0]['X1']['Y2'] = 2; $array[0]['INFO'...
After a long break I took the suggestions from Console based Vocabulary Trainer and reworked the Trainer. It contains of the following parts Vocabulary.h/cpp: Save and read vocabulary from/to text file Settings.h/cpp: Save and read some basic settings like color and languages from / to text file Menu.h/cpp: The Te...
I'm just trying to get the common values from two distinct files called file1.txt and file2.txt where I'm using Python's set method to get the results and this works. However, I'm looking forward to see if there is better way to do this. #!/grid/common/pkgs/python/v3.6.1/bin/python3 def common_member(): a_set = dat...
I wrote this Powershell script years ago for updating AD from a CSV file. I'd like to try to optimize to run quicker and be more efficient... but I'm not sure where to start / what could improve it. Any suggestions are welcome. EDIT: I've updated my original script to this: $users = Import-Csv C:\Scripts\Employees.cs...
This is an OOP question and probably answerable even if you don’t have PHP knowledge. (A side note – we are learning PHP OOP and decided to create a github to hopefully help others learn this and other best practices a bit easier, https://github.com/nizamani/PHPBestPractices1-OOP if you are interested. PRs, issues etc ...
I wrote this algorithm but i was wondering if there was any way i can make it less 'expensive'. The algorithm needs to transform this data structure: const deliveryHours = { monday: [ { start: { hour: 3, minute: 0, }, end: { hour: 6, minute: 0, }, }, ]...
I am trying to find the longest Collatz Sequence: Which starting number, ≤ N, produces the longest chain? If many possible such numbers are there print the maximum one. (1 ≤ N ≤ 5×106) I tried optimizing the code to include memoization still getting Time Limit Exceeded, for these solutions. Wanted some help to under...
Going to take a look at Rasta's comment below tonight and just realized I am using byref to pass everything again - DUHOH - Old habits die hard I have revamped with some of Comintern's improvements particularly re naming, interfaces, how to reference game pieces, etc. I still need time re his presenter class. EDIT: Th...
As per the instructions on this Tape Equlibrium-Codility I've written the code import java.util.Arrays; public class TapeEqulibrium { int main(int[] array) { int minimumDiff = 100000; for (int i = 1; i < array.length; i++) { int differnce = Math.abs(Arrays.stream(array, 0, i).sum() - Arrays.stream(arr...
I need to validate the fields of user sent by an API. All works fine but the only one problem is that I don't like the solution is not an OOP solution. In the controller I call the service created by me: $userValidatorService = $this->get(UserValidatorService::class); And the service: class UserValidatorService { /**...
I wanted to explore how I can associate routes with "controllers" with Sanic as a base. It works fine but "feels" a bit clunky but I can't put my finger on why/how. routes.py - Returning controller methods from a given route from .index import IndexRoutes from .clients import ClientRoutes from Controllers.IndexControll...
I asked a similar question here which is: The language L={anbn} where n ≥ 1, is a language of all words with the following properties: The words consist of strings of a’s followed by b’s. The number of b’s is equal the number of a’s. Examples of words that belong to L are: ab, where n=1; aabb, where n=2; aaabbb, ...
This program is supposed to find and slice any cell within a CSV file which contains more than a defined number of characters. The files can be pretty large, so being a beginner I would like to know if it is written correctly, and if I could make it more efficient. One of the lines is also more than 80 characters long,...
I have an ordered array of integer values: 10, 11, 12, 13, 15, 16, 19 and I need to write a dash between first and last consecutive values when there are more than two consecutive values (10-13). Between other values I need to write a comma and whitespace. Output for this input must be 10-13, 15, 16, 19. I wrote a meth...
The following is my attempt at creating a Boggle board solver in Ruby. It's not especially fast. I would love to have input on how the solution can either be sped up, or whether a different algorithm might be applied that is faster. The solution corresponds to my answer on a related question on the Math Stack Exchange ...
I created a function that generates all the combinations of 1 digit, 2 equal letters and 2 different letters. I reduced the numbers and letters to make it more easy to calculate: letters = "bcdfghjklmnpqrstvwxz" digits = "2456789" There are 1,436,400 possibilities because $${5\choose1}{7\choose1}{4\choose2}{20...
I've implemented a console ToDo application. I would like to hear some opinions about it, what should I change etc. About project: It is intended to manage everyday tasks. Application contains: adding users to database adding tasks to database getting list of user's tasks It's my second project in which I use mocki...
I am trying to solve a programming challange that involves converting reverse polish notation to infix notation. For example: 1 3 + 2 4 5 - + / would be: ((1+3)/(2+(4-5))) My solution so far does work, but it's not fast enough. So I am looking for any optimization advice. public class betteralgo { public static voi...
I am solving another problem in leetcode. Given a set, generate all the subsets of the set. Input: [1,2,3] Output: [ [3],[1],[2],[1,2,3],[1,3],[2,3],[1,2],[]] The solution is accepted but I would like to improve on my C coding style. I have created a node_t type to encapsulate the data related each subset. There co...
My requirement is, I need to load the existing xml file from the given path by passing through command line arguments and need to update the xml file from C# code. First time I am working on the C# project. I have done given requirement but need few clarifications and optimization techniques in my code snippet. namespa...
I have the following radix sort implementation: #include <iostream> #include <vector> #include <string> #include <sstream> #include <cstddef> #include <algorithm> void radix_sort(std::vector<int>& arr) { int radix = 1; // Largest element in unsorted array int max = *(std::max_element(arr.begin(), arr.end()...
Graph Coloring Algorithm (Greedy/ Welsh Powell) I am trying to learn graphs, and I couldn't find a Python implementation of the Welsh Powell algorithm online, so I tried to write my own. Here are the steps. Order the nodes in descending degree. (Most neighbors ... Least neighbors) For each node, check the colors of ne...
I'm relatively new to PHP and one of the things I miss from other languages are enums. After looking around for some samples on how can I have somewhat similar to them, I came up with this implementation. I want to know how good is it, how can it be improved or any other flaws you can find in it. It's writen in PHP 7. ...
For programming practice, I created a chess program in PHP (my most comfortable language). The program reads a FEN (a string with the location of all the pieces on the board) from the URL, generates a board, then generates all the legal moves for that position. Then when you click the move, it loads the same file but w...
I am learning C++ and I attempted to do one exercise I found: Dungeon Crawl. The goal of this game is to reach the treasure by moving your character along the board. The exercise asks not to use classes so I have tried to achieve some level of abstraction with structs and arrays. I have followed my university's style f...
I'm trying to improve my dirty data wrangling code into something nice, readable & reliable. I believe I've done fairly well here, although maybe I should have some docstrings on my functions. Still, I believe it's fairly readable without them. I'd love some feedback on ways to improve! This script parses raw data from...
Disclaimer: The following question is not related to any malicious activity. Only performance testing we are doing. I am working on querying an internal server with lots of requests (~20 million). I need it to be as fast as possible. How the algorithm works: 30 Threads (because I found that more can slow it down) ...
I have solved the following problem using dynamic programming: Little Deepu and his Girlfriend 1. To paraphrase, We have two players Little Deepu and Kate and M items in the bag B, also we have a game set S with N elements, each element of game set is an integer. The game is played as follows, each player takes t...
In some components and services I need the window and document. So I created a small service, that provides these two objects. windowAndDocument.service.ts: import { Inject, Injectable } from '@angular/core'; import { DOCUMENT } from '@angular/common'; function getWindow (): any { return window; } @Injectable({ ...
A while ago a tricky C++ interview question came across to me, and ever since I could not tell what I did wrong. Create a base class named “Shape” with a method to return the area of the shape. Create a class named “Triangle” derived from the base class “Shape”. Class “Triangle” must have two constructors. One receive...
The task is for training go-lang. The idea is to extract unique words sorted and grouped by length. Might be useful in learning new words. The program uses command line argument assuming it's a file to read; reads from stdin if no arguments were given. package main import ( "bufio" "fmt" "os" "regexp...
I wrote a program for solving the Attribute Parser challenge on HackerRank. The challenge is to read some specified number of lines of HTML-like markup (each line no more than 200 characters; for any attributes, the = sign will be preceded and followed by a space), and perform some specified number of attribute queries...
I'm working on a nice approximation for the Bilateral Filter. I have a working code which runs pretty fast yet still I think much can be improved. The code (C Code, compiles with C99) is given by (See code on Compiler Explorer): #define _USE_MATH_DEFINES #include <stdio.h> #include <stdlib.h> #include <math.h> #includ...
I've just started with F# (I'm coming from a mostly OO background) and I'm looking for feedback on the code, particularly: is this the way F# code should be written like? have I overlooked an existing library function which would make this easier or could replace it completely? The goal is: Take an input list and s...
I have an implementation of Linked List with push, pop, size, print and search functionalities. This is also an attempt to learn smart pointers. I have only used shared_pointers in this implementation. #include <iostream> #include <memory> #include <cstddef> // Class for individual nodes in the list template<typename ...
I tried to implement a traffic light system using state pattern, please comment on the OOP/design pattern use. using System; using Microsoft.VisualStudio.TestTools.UnitTesting; namespace DesignPatternsQuestions { /// <summary> /// implement a traffic light system /// </summary> [TestClass] public ...
I have this code to save data into some records. It is a little slow, so how can I make it faster? To the first record (sheet MOV MERCADERIA) it copies 23 columns and from 1 to 29 rows. The problem is when the dispatch note is complete (when the 29 rows are full). And to the second record (sheet CONCAT) it copies 4 col...