instruction_seed
stringlengths
71
95.1k
_source
stringclasses
1 value
I am attempting to, given two dimensions (width and height) which represent a quadrilateral, partition that quad in to N parts where each part is as proportionally similar to the other as possible. For example, imagine a sheet of paper. It consists of 4 points A, B, C, D. Now consider that the sheet of paper has the di...
stackexchange/codereview
I'm making an AI agent (blue entity) that pursues a target (green entity) while avoiding an obstacle (red entity). The code works as it should most of the times, but will fail if all the entities are aligned in either the X or Y axis or any direction diagonally. I suspect this is due to dividing by zero. I fixed the pr...
stackexchange/codereview
I'm taking this C++ program and am trying to replace some of the older structures like memset (which I don't completely understand) and struct with newer language optimized for C++11. The program works as is and I am just trying to further my understanding by playing with the code. "Hike on a Graph" is played on a bo...
stackexchange/codereview
I've started learning java. I've written a small program I've done in C before. It's simple input analysis. If there is number, program checks if number is prime. Then write number: (value of input variable) (prime) for example date in format DD/MM/YYYY, if does program will print date: DD/MM/YYYY Day (Day represents...
stackexchange/codereview
Problem: Given a set (let's say of integers), return the list of all of its subsets also known as the power set. It looks to be working, but I would like feedback on the algorithm and Python coding style and techniques as I am new to Python. def get_power_set(s): empty_set = set() power_set = [empty_set] ...
stackexchange/codereview
I find this script handy for preparing ad-hoc reporting. Using two sets of unique identifiers, it allows you to lookup multiple columns of data with the Index Match function. I welcome any feedback or suggestions for improvement. Sub MatchMaster_PRO() 'Peter Domanico (June 2018) 'this script helps simplify the use of ...
stackexchange/codereview
I was just wondering, is there a way to load these better and log the times they each took? It seems like a headache having to write about 90+ stopwatches, which is what I will have to do as I have about 100 of these to load. // PacketManager var packetManagerStopwatch = Stopwatch.StartNew(); _packetManager = new Packe...
stackexchange/codereview
I recently created a library in C, which creates and stores binary arrays. My library uses the standard fixed data types and allocates no more than 8 bytes for a binary array (8 bytes = 64-bit unsigned long long number). It also sets the binary equivalent at the bit level using the setBitsAt() method to make it quite e...
stackexchange/codereview
I am working on a library for algorithms for multiway number partitioning. One challenge I face is that some users need the entire partition, while other users need only the sums of the parts. For example, suppose the input is the following list: [1,2,3,3,5,9,9], and the goal is to partition them into two subsets. Then...
stackexchange/codereview
Which of these three methods is the most efficient? Also, what is the time & space complexity of each? public class Palindrome { public static boolean isStringBased(String word) { if (word == null || "".equals(word)) { return false; } String lowerCasedWord = word.toLowerCase(); ...
stackexchange/codereview
Requirement After a user draws two circles with their mouse successively, the program should draw all common tangents, if any, to them. Here is my implementation function InteractiveCommonTangent tolerance = 0.001; color = 'b'; style = '--'; width = 0.5; circleCount = 1; buttonDown = 0; x1 = [0 0]; y1 = [0 0]; x2 ...
stackexchange/codereview
class ShareModel constructor: -> questionaireView = new QuestionnaireView @previewImages = shareCurrent: -> ShareModel::getSingle(ModelView::getCurrentImage(),'current',questionaireView.weight(),questionaireView.weightUnits()) shareGoal: -> ShareModel::getSingle(ModelView::getGoalImage(),'goal',qu...
stackexchange/codereview
I asked this question yesterday: Entity and Value Object are not part of the Ubiqtious language. Should this stop me from using them?. I originally decided to introduce a ValueObject class as described here: Generic Value Object Equality, which contained equality methods for all value objects i.e. all Value Objects in...
stackexchange/codereview
I have coded the following C function for multiplying two NxN matrices and using AVX vectors to speed up the calculation. It works but the speedup is not what is to be expected(some scalar code is faster). What are my major mistakes when trying to use AVX? (I'm new to programming with it so I don't fully understand ho...
stackexchange/codereview
For digital electronic circuit simulation, i wanted to implement Three states. i.e High, Low and Undefined in C++. I saw Boost::tribool, and they implement it using enum Now for conserving some memory i have implemented it using 1 Byte Int #ifdef _WINDOWS typedef __int8 State; #elif typedef int8_t State; #endif const ...
stackexchange/codereview
Instructions for the 'is my friend cheating' kata in codewars are: A friend of mine takes the sequence of all numbers from 1 to n (where n > 0). Within that sequence, he chooses two numbers, a and b. He says that the product of a and b should be equal to the sum of all numbers in the sequence, excluding a and b. Given ...
stackexchange/codereview
I would like to get some code review for my recursive implementation of python flatten array method. Write a piece of functioning code that will flatten an array of arbitrarily nested arrays of integers into a flat array of integers. e.g. [[1,2,[3]],4] -> [1,2,3,4]. I'm particularly looking for some feedback ...
stackexchange/codereview
I want to make a graph from input from a text file in the format: vertex1 vertex2 cost time where vertex1 and vertex2 are strings that form an edge and cost and time are the properties of that edge. This information will be used to construct the Graph based on cost. I want to plan out the project before coding it so ...
stackexchange/codereview
This week's challenge is essentially about fetching Json data from the Web, and deserializing it into objects. I don't have much time to devote to this one, so what I have is very basic: it displays the names of all pokemons in a WPF ListView: Here's the code for the window: public partial class MainWindow : Window { ...
stackexchange/codereview
Here is my Piece class as part of implementation for the Tetris game. If possible, I want my code to face the same level of scrutiny as actual production code. Hereare some of the potential areas in which I feel my code could be improved, but due to my limited experience, was unable to do so. Please help me provide sug...
stackexchange/codereview
Please review my code/code quality. var textarea = document.getElementById("textarea"), inputFile = document.getElementById("input-file"), prtHelper = document.getElementById("prt-helper"), overlay = document.getElementById("overlay"), help = document.getElementById("help"), appname = " - ...
stackexchange/codereview
This is my third project for review; I would like feedback on: code readability code efficiency particularly good parts The project is called BirthdayBackup. It's a GUI app that allows you manage a list of everyone you know with their email, name and birthday date. It can send a random birthday blessing to people w...
stackexchange/codereview
I have implemented directed graph and Dijkstra algorithm using heap in Python. I first implemented an abstract base class WeightedGraph, of which DirectedGraph is a subclass. The DirectedGraph uses an adjacency map as its internal representation. I then implemented the method single_source_shortest_paths, which uses th...
stackexchange/codereview
I have image files consisting of black and white pixels encoded as RGB8. I want to count the number of blobs i.e. contiguous areas of white pixels. I rewrote this algorithm in haskell. The algorithm works as follows: The image is traversed and whenever a white pixel is encountered the counter is incremented and all acc...
stackexchange/codereview
I have an RPG-like program that uses a Character class to specify and return information about an individual player/character. I was curious about a way to best set and return an inventory of strings in terms of memory and performance for this purpose. I gave some thought to creating a struct or using something similar...
stackexchange/codereview
I'm a newbye in React. I created some simple Components to practice. For now, I'm using class Component (I want learn either class COmponent or function COmponent). I would know if I projected properly my Components or if I could have a better setting: My little application allow to increment a number of 1 by default, ...
stackexchange/codereview
I'm wondering how I can make this function better, more compact, even faster. char* DectoBin(int dec) { int counter = 0; int x =0; while (dec>=x) { counter++; x = pow(2, counter); } //counter is the # of bits in the converted binary number char* bin = new char[counter+1]; //...
stackexchange/codereview
Given an array A of integers, find the maximum of j - i subjected to the constraint of A[i] <= A[j]. If there is no solution possible, return 0. Example : A : [3 5 4 2] Output : 2 for the pair (3, 4) My Code : def maximumGap(self, A): if len(A)==1: return 0 a_list = sorted(([Val,indeX] for indeX,Val in enumer...
stackexchange/codereview
Today I had an interview, where I was asked to solve this problem: Generate nth prime number. Given a signature below, write python logic to generate the nth prime number: def nth_prime_number(n): # n = 1 => return 2 # n = 4 => return 7 # n = 10 => return 29 I wrote this code, but couldn't get through: def n...
stackexchange/codereview
The following code is making two asynchronous requests to obtain the desired data. The second request needs to access the data from the first request, hence I need to nest it. I know that it is better to chain promises, but this is a case where nesting seems necessary. However the lint raises a warning: avoid nesting p...
stackexchange/codereview
Attempting to jump into the Windows Server ServiceBus 1.1 code-base along with adopting the new TPL async methods. But I could not find an easy way to just spin up N number of handlers for message sessions (might have 100 or so concurrent sessions). So it would be great to get some feedback on the following code, any s...
stackexchange/codereview
For class, I was asked to write a (linear probing) hash table in Java. (I was also asked to write a linear-chaining hash table, which is why I named this one HashtableB as opposed to just Hashtable.) I'm think my code is correct, but please tell me if I've messed up. Primarily, though, my questions are: Is my style (e...
stackexchange/codereview
I have implemented my first program in JavaScript, Rock-Paper-Scissors. I would like JavaScript developers to help me make this program more JavaScript-like by following the idioms of the language. I am also open to any suggestions related to simplification of logic and code readability. The following is the complete l...
stackexchange/codereview
I have a bunch of processes that are being executed on different virtual machines. All of those processes have a StartDate, EndDate and Resource properties. Resource is a specific virtual machine it was ran on. I generated the actual timeline for items and found out that all of those resources have "holes" in timeline ...
stackexchange/codereview
I wrote a program to gradually lower the volume of my computer when I go to sleep so I can fall asleep with TV or music on. This was my first time using argparse and I feel like there should be a cleaner way to deal with default values of optional arguments. Any other feedback of course also welcomed. import vol from...
stackexchange/codereview
I am receiving the JSON from WebService and populating ExpandoObject from this one: var converter = new ExpandoObjectConverter(); var jsonObject = JsonConvert.DeserializeObject<ExpandoObject>(json, converter); The JSON object is quite complex and in order to find the value I am doing this spaghetti code: KeyValuePai...
stackexchange/codereview
I do programing with core php & i don't want to like use any cms or mvc framework. if any handy ideas then welcome it. index.php file <?php /** INCLUDE BSIC CONFIGURATION FILE */ strip_php_extension(); /** GET REQUEST NAME */ $request_uri = trim(filter_input(INPUT_GET, 'uri_req'),'/'); /** CALL REQUESTED PAGE *...
stackexchange/codereview
Hi I am pretty new to programming and I would like you to give me some feedback about my code, how does it look, what could be better. Thank you. A = [] B = [] C = [] PegDict = {'A': A,'B': B,'C': C} #Would it be better to use a two dimensional array? discs = int(input("Podaj ilość dysków: ")) for i in range(discs, 0...
stackexchange/codereview
As part of my journey in learning the Rust programming language, I decided to make a miniature cat clone (catty) in it. The following is my code, which depends on clap for argument parsing (see below). It currently only supports concatenating 1 file with possibly numbered lines (-n/--number). I tried to be as close as ...
stackexchange/codereview
All of this does just one thing. Move my player by finding the first finger that was used to touch the ship and drag it. I have a few questions: The first thing is I have an embedded class of MotionState. At first glance it makes a lot of sense to start with that. I latter ended up not using it. How do I go about ref...
stackexchange/codereview
I'be been learning c++ recently and as an exercise I wanted to write a program to find numbers up to n using sieve of Eratosthenes. I'm new to c++ and programming in general so I'm not sure if this is wildly inefficient or not. I would love some feedback for my code performance wise or better programming practices in ...
stackexchange/codereview
I need to speed up the function below: import numpy as np import itertools def combcol(myarr): ndims = myarr.shape[0] solutions = [] for idx1, idx2, idx3, idx4, idx5, idx6 in itertools.combinations(np.arange(ndims), 6): c1, c2, c3, c4, c5, c6 = myarr[idx1,1], myarr[idx2,2], myarr[idx3,1], myarr[idx...
stackexchange/codereview
I am wondering if someone can do a code re"vue" specifically for my star rating component ([complete code available on github). I am looking for feedback on best practices, any glaring code crimes I might have committed and bad code. The code is also deployed to #Heroku here Problems I saw with the code previous code a...
stackexchange/codereview
I just got into Object Oriented Programming, and it made me think about certain code how I can make them as efficient as possible. Right now I am just including my header and footer like the following: PHP require_once 'core/init.php'; require_once 'includes/header.php'; //Big block of content goes here require_once...
stackexchange/codereview
For context, I wrote a function, get_servers, for the game Bitburner which is usually played by writing JavaScript code. Instead, I used PureScript to write the function which is an implementation of something like the breadth-first search algorithm to get a list of all the servers in the game: module Main (main) where...
stackexchange/codereview
I'm switching my code to promises - mostly as delivered by Mongoose. I use Hapi though I think something similar would apply to Express. In my models/services I perform queries such as: var sampleMethod = function(id, status) { return Model.findById(id).exec().then(function(item) { if(!item) return Boom.notFound...
stackexchange/codereview
Ram was busy calculating the factorials of some numbers. He saw a pattern in the number of zeros in the end of the factorial. Let \$n\$ be the number and \$Z(n)\$ be the number of zeros in the end of the factorial of n then for \$x < y\$ \$Z (x) \leq Z(y)\$ i.e. the function never decreases. He is solving a pro...
stackexchange/codereview
var root = this; root.node = function(path, type) { root.type = type; this.type = type; this.parents = []; this.children = []; var components = path.split('/'); this.parents = parseParents(components); this.name = components[components.length - 1]; this.addChild = function(path, type){ ...
stackexchange/codereview
I'm looking for any and all feedback on quality, style and efficacy of the code. If there's a simple way to get the header put in, I'd love to hear that. The code is used to take zip codes from a csv file and and spit back out the city and state where available. import sys import os import csv from bs4 import Beautiful...
stackexchange/codereview
Would you consider this to be idiomatic Scala? If not, what would you do to improve it? def fibonaccis(max: Int): List[Int] = { fibonaccis(max, 2, 1) } private def fibonaccis(max: Int, prev: Int, prevPrev: Int): List[Int] = prev >= max match { case true => List[Int](prevPrev) case false => prevPrev :: fibonaccis(ma...
stackexchange/codereview
For a research analysis, I'm writing a small bash script that serves as a frontend to Singularity. The reason is that I want to save in this script which options are needed for singularity. For example, I want the working directory to appear at a fixed path in the container, regardless of the actual working directory p...
stackexchange/codereview
The Problem I have a cursor that I am trying to replace (perhaps unnecessarily) in an attempt to clean up a stored procedure. Essentially what it is doing is counting each note for each member in a temp table and then assigning each of those notes a sequential value into the field NOTE_COUNTER (int) of the temp table. ...
stackexchange/codereview
I have a form built with react, formik and yup, and this form has some async validations. Apparently, some users were able to bypass these validations, and to prevent some errors, I wanted to disable the submit button when there's a pending http request. Many years ago, I used to handle this very easily with jQuery, bu...
stackexchange/codereview
Problem Statement Write a HTML page holding a form and a text field. Using JavaScript make the text field to accept numbers only. When a non-number character is entered through the keyboard (or by any other way), make the field red for a while and do not accept the change (preserve the previous value of the field). Ex...
stackexchange/codereview
The javascript method Math.random() returns a (pseudo-)random float between 0 (inclusive) and 1 (exclusive). In some use cases, I need both limits to be excluded, a random float between 0 (exclusive) and 1 (exclusive). This is what I currently use to generate said random float: do { var random = Math.random(); } wh...
stackexchange/codereview
I'm writing a method to insert objects into a MySQL database and while everything runs fine I feel my code is bulky and inefficient. What steps would you take to make this code more pleasant to look at and more efficient? public void addAuthorization(Authorization authorization) { try { // Builds the query...
stackexchange/codereview
I have a question concerning the correctness of the reading and displaying the image in ASP.NET Core MVC web application. This is the way I am reading image names from a specific folder (I am using IHostingEnvironment _hostingEnvironment to get the rootPath): public class GetRandomImageForGalleryView : IGetRandomIma...
stackexchange/codereview
I'm just getting into Clojure, and I wanted to make sure I am writing code the "Clojure way". The challenge I took on is Zeckendorf numbers (fairly trivial). (defn fibs-until ([n] (vec (if (< n 3) (range 1 (inc n)) (concat [1 2] (fibs-until n 1 2))))) ([n a b] (let [fib (+ a b)] (if (> fib...
stackexchange/codereview
I am trying to solve the following problem: Given three numbers, a, b, and c, return their product, but if one of the numbers is the same as another, it does not count. If two numbers are similar, return the lonely number. If all numbers are same, return 1. I have the following solution: def solve(a, b, c): produ...
stackexchange/codereview
I want to write a function that merges two sorted lists in Python 3. For example: >> merge_lists([2, 5, 9], [1, 6, 8, 10]) [1, 2, 5, 6, 8, 9, 10] My implementation is as follows: def merge_lists(L1, L2): Outlist = [] while (L1 and L2): if (L1[0] <= L2[0]): item = L1.pop(0) Outl...
stackexchange/codereview
I have a Cache Helper Class. using System; using System.Web; public static class CacheHelper { /// <summary> /// Insert value into the cache using /// appropriate name/value pairs /// </summary> /// <typeparam name="T">Type of cached item</typeparam> /// <param name="o">Item to be cached</param...
stackexchange/codereview
The code works and I get the results I want. Please comment about complexity, a shorter way of implementing the solution, and advice for better unit tests. using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApplication2 { public clas...
stackexchange/codereview
I'm teaching myself programming, using Python as my initial weapon of choice. I have learnt a few basics and decided to set myself the challenge of asking the user for a list of names, adding the names to a list and then finally writing the names to a .csv file. What would you do differently, i.e. how could this code b...
stackexchange/codereview
I'm trying to implement a generic Sudoku solver (with n x n puzzles). The puzzle itself is contained in the class Feld with: typedef size_t Point; class Feld { public: // containing all the possible values in binary, eg: 7 means this could be 0,1,2 std::vector<Point> pos; Point L0; // length of t...
stackexchange/codereview
I have a Table that I store All setting in that , it is like below : public class Setting:IEntity { public string Key { get; set; } public string Value { get; set; } } and I have a service like this to update and read Setting Table : public class SettingService : ISettingService { #region Fields ...
stackexchange/codereview
Now I have this d-ary heap data structure. Note that for d = 2 this is a binary heap. The client programmer specifies the value of d when constructing the heap. See what I have: heap.h: #ifndef HEAP_H #define HEAP_H #include <stdbool.h> #include <stdlib.h> #ifdef __cplusplus extern "C" { #endif typedef struct h...
stackexchange/codereview
I want to create a circular queue using a linked list. I also want to create many instances of that data structure (queue) without repeating the code. This is what I came up with: #include <stdio.h> #include <stdlib.h> struct queue { int info; struct queue *next; struct queue *front; struct queue *rear...
stackexchange/codereview
I'm a freshman in Python world, I used to program in C. I wrote a function/method that returns the power of a number: def pow(x, y): powered = x if y == 0: return 1 while y > 1: powered *= x y -= 1 return powered Mine is a logic question (correctly): if I set y = 0 then it ...
stackexchange/codereview
How could I improve this working Perl script, which changes my desktop background to the next available one, without opening a terminal? Specifically, how could I iterate over my .fehbg and walls/ lazily, without reading them into arrays? I couldn't find a way to do that; I need the for loops. Other than that, are t...
stackexchange/codereview
I'm trying to check in my meteor app for a defined timeout (idle user) to show a modal. But the way I did it seems a bit too complicated to me. I'm doing a setInterval for 1 minute. Then a counter - which is stored in a Session var (maybe a local reactive var would be smarter?) - will be incremented by one. If there is...
stackexchange/codereview
Again, out of fun on Saturday night, I decided to solve the following problem from CodeEval. The challenge is finding the index of the lowest unique number. There is a game where each player picks a number from 1 to 9, writes it on a paper and gives to a guide. A player wins if his number is the lowest unique. We ...
stackexchange/codereview
I am creating styles for the comment posts for a projects using BootStrap. I am wondering if this is good HTML markup and the extending of BootStrap's CSS. Using HTML5 markup recommendations the HTML for the comment posts is as follows. <div class="container"> <div class="row"> <div class="col-md-8"> <h2 class="...
stackexchange/codereview
Problem In the famous eight queens puzzle, one must place eight queens on a chessboard without letting any queen threaten any other queen. There are 92 (or 12, depending on how you count) solutions to the original puzzle, but it can also be generalized to smaller or larger boards. Solution My strategy is pretty similar...
stackexchange/codereview
This is the JavaScript file that i use for my editor that allows people to edit questions from a form. I'm wondering if this sort of approach to use JavaScript objects is good or that I kind of miss the point here? $(document).ready(function() { manager = new Customerformquestionmanager(); manager.formId = firs...
stackexchange/codereview
In a case like this: object A1 = null; Decimal? B = Convert.ToDecimal(A1); object A2 = null; int? C = Convert.ToInt32(A2); Note that in case where A1 or A2 have values, they appear to be of type double. B and C will be 0 instead of null. A1 actually comes from Excel via the interop and (Decimal?)A1 throws an error: Sp...
stackexchange/codereview
The parameters list contain the array that is passed to and the size of the array respectively. Is there anywhere I could improve my code? void bubbleSort(int a[], int s) { for (int i = 1; i < s; i++) { for (int j = 0; j < s - i; j++) { if (a[j] > a[j + 1]) { int temp = a[j]; ...
stackexchange/codereview
I'm just wondering how my model looks. And by this I mean did I perform the correct tests with the results on each function and use the return at the right points. If you can check all functions. I'm curious to know about if I did the sendMessage function correctly. <?php if ( ! defined('BASEPATH')) exit('No direct scr...
stackexchange/codereview
I just went through a very easy online example creating a Rock-Paper-Scissors game, but it seemed like it was not a great use of computing power. It seemed like I was writing out results for every possible outcome instead of declaring properties or attributes for variables that will dictate the results depending on the...
stackexchange/codereview
This is my attempt at the Problem Euler #4 in Haskell ("Find the largest palindrome made from the product of two 3-digit numbers.") import Data.List isPalindrome :: Show a => a -> Bool isPalindrome n = l == reverse l where l = show n maxPalindrome :: (Integral a, Show a) => a maxPalindrome = maximum $ head . transp...
stackexchange/codereview
I just made my first pygame program, ChickenDodger, and I would like to know how I could make my code better. I think I did pretty good for my first time, except the way I added the 2nd egg. I do not like the way I added it. Any advice? (I made a lot of comments for my younger brother, so he understands it easier, I th...
stackexchange/codereview
I have written a double linked list in Scala. The list should be fixed in size and items are always added to the head. if the list reaches max size then the tail is dropped. This is my code. I want to review this for brevity and functional approach. sealed trait List { var prev : List var next : List } case ob...
stackexchange/codereview
I am writing possibly my first real C project, and it is almost finished. But as I was coming to a close I noticed something. This is a simple operation to split a cookie string into a ~2D array. I don't expect you to read all of the code if you don't want to. It works, but that is not my current worry. #include <stdi...
stackexchange/codereview
So I have been told that my code is not good and needs refactoring. I'm struggling to see what I need to do. How do I specify the success and failure conditions for lambda? Also don't get what the method process_lines should contain. Any help is greatly appreciated! These are the comments I was given: Let's create a f...
stackexchange/codereview
I'm a beginner programmer and I came upon this problem which is to find the n​th number in the Fibonacci series. I used to solve the problem using a for loop; today I learned about recursion but there is a problem: when I pass 40 or 41 to the recursive function, it takes a bit of time to calculate it, while in the iter...
stackexchange/codereview
Our business intelligence suite outputs data as an indented hierarchy, as below: Level 1 1000 Level 2a 600 Level 3a 500 Level 3b 100 Level 2b 400 Level 3c 400 I've written a macro that converts this into a 'database' format, where only rows with the base (mo...
stackexchange/codereview
Question Say you have an array for which the ith element is the price of a given stock on day i. If you were only permitted to complete at most one transaction (i.e., buy one and sell one share of the stock), design an algorithm to find the maximum profit. Note that you cannot sell a stock before you buy one. E...
stackexchange/codereview
I expecting the response of an API to be a array of objects like this: [ { "code": "X", "name": "Product A", "pricings": [] }, { "code": "Y", "name": "Product B", "pricings": [] }, { "code": "Z", "name": "Product C", "pricings":...
stackexchange/codereview
I have an Entry that I want to give a red outline when the entry is empty. I'm using SyncFusion's SFTextInputLayout for my Entry and it has a property HasError that once it's set to true, it'll automatically highlight my entire in Red. Here is the following XAML code for SFTextInputLayout <inputLayout:SfTextInputLayou...
stackexchange/codereview
I'm trying to set up a system where I can have an arbitrary number of parallel tasks, all of which wait for a go signal, do their work, and then stop while a manager collects the results, prepares for the next batch of work, and so on. The easy way I know to do this is to launch a packaged_task for each job, for each i...
stackexchange/codereview
I've never had a serious attempt at writing an encryption algorithm before, and haven't read much on the subject. I have tried to write an encryption algorithm (of sorts), I would just like to see if anyone thinks it's any good. (Obviously, it's not going to be comparable to those actually used, given that it's a first...
stackexchange/codereview
I believe this set of code is very repetitive in a way where every method does almost the same task but it is repeated multiple times. This is what the code looks like and its main purpose is to display the intended design on the simulator: private void configStart() { button1 = new JButton("start"); button1.se...
stackexchange/codereview
My first program using Classes, it should allow you to set the price of three different pumps, times how long you pump, then calculates what you owe, and updates the amount of gas left in the pump. Working on an associates degree and my teacher doesn't give any critique so anything you all could point out would be help...
stackexchange/codereview
Ram was busy calculating the factorials of some numbers. He saw a pattern in the number of zeros in the end of the factorial. Let \$n\$ be the number and \$Z(n)\$ be the number of zeros in the end of the factorial of n then for \$x < y\$ \$Z (x) \leq Z(y)\$ i.e. the function never decreases. He is solving a pro...
stackexchange/codereview
Everything works, i just want to know if i can change the way the xml tags are retreived. This way seems a bit bulky - but i could be wrong. Thoughts? var d = 0 $(".timeline").children().eq(d).addClass("active") // default traverse function to buttons, inject node prev.data("node", array.length-1) ...
stackexchange/codereview
Output should be an object ({cal: val}), with soonest possible time throughout all calendars recommended times from the data. My question is: is this approach over complicated and if so, what should be the proper way to solve that task? Incoming data is an object: let data = [ { name: "A", calendars: { ...
stackexchange/codereview
The following is used to create a masonry effect with varying height rectangles. How can I simplify and make this more elegant in Unity? private float startX = 0.0f; private float startY = 0.0f; private float posX = 0.0f; private float posY = 0.0f; private float prevWidth = 0; private float prevHeight = 0; private int ...
stackexchange/codereview
I decided to write a pathfinding algorithm in order to expose myself to the world of pathfinding and for me to further understand more advanced algorithms such as A*. I chose C# due to its flexibility compared to other languages such as Java. I will start with the basic objects and work up to the more complex ones. vec...
stackexchange/codereview
Given an infinite stream with the property, such that after all 0's there are only all 1's, find the index of the last 0. I'm looking for code review, best practices, optimizations etc. Verifying complexity to be O (log n) where n is the first 1 encountered in the search (not the first 1 in the stream). /** * An inf...
stackexchange/codereview
This is "my" version of a basic C++ calculator, that requires a single line input (like 1+1) to calculate the result. I have been (self)learning the language for 2 months now. I don't pretend to have invented this code, but I haven't taken the time to search for this variation. The functions included are: Addition: 1 ...
stackexchange/codereview
I'm using the haversine formula to count distance from selected post-code to desired destination. I have the following scope in App\Models\Business.php: public function scopeDistance($query, $latitude, $longitude, $radius) { $query->getQuery()->orders = []; return $query->select('*') ->selectRa...
stackexchange/codereview