« first day (1937 days earlier)      last day (2081 days later) » 

12:00 AM
RELOAD! There are 5520 unanswered questions (89.9421% answered)
 
@Feeds is that like the difference between C and C++?
@SamOnela ^
 
12:43 AM
0
Q: LRU Cache in python constant time

NinjaGI would like to ask for code review for my LRU Cache implementation from leetcode. Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations: get and put. get(key) - Get the value (will always be positive) of the key if the key exist...

0
Q: Async methods do not permit out parameter

Wildly StuntedI wrote a method like this: public static async Task<StuffAndError> GetAStuffAsync(string key) { return await GetTheStuffAsync(key).ConfigureAwait(false); } Which goes on to do something like this: await Task.WhenAll(tasks).ConfigureAwait(false); To return errors I c...

 
Second snippet definitely looks better to me, but "clean code" is somewhat opinion-based, you might try codereview instead (and probably post more of your code) — CertainPerformance 14 secs ago
 
12:58 AM
0
Q: Want to know which one is better javascript design & clean code as per javascript experts

GautamBelow are the 2 code snippets that I am working on and I just got confused which code is better approach. In javascript less number of lines of code is recommended so I like the second approach but first approach makes it more readable as well. Please help switch (cloudType) { ca...

 
You might want to checkout codereview.stackexchange.com — Rich 36 secs ago
 
1:13 AM
0
Q: Program to see how many points lie strictly inside a convex polygon

skr_roboThe program takes in a set of coordinates that defines the polygon. It then takes in a set of points. The idea is to find out how many of these points lie strictly inside the convex polygon (not on the edge or outside). First the program checks if the first set of points form a convex polygon or ...

 
 
1 hour later…
2:42 AM
@RobbyCornelissen That is very true, however I've checked and had the code reviewed as well, and at no point is the list or any of the keys ever modified — Mars 49 secs ago
 
3:29 AM
Thank you very much! It was a lot of help. I'll post it in the code review. — geunjae oh 32 secs ago
I'd suggest checking out codereview.stackexchange.com I thought for sure it would get flagged before I finished my answer. — ArtisticPhoenix 14 secs ago
 
3:44 AM
0
Q: Cell division Solving algorithm problems

geunjae ohWhen G cell divides, it is divided into two G + 1 cells. In order for the G cell to divide, energy as much as G is required. What is the minimum energy required to make the total number of cells x? Input Example (G for each of 2 cells, total number of cells) 1 3 4 Output Example (minimum en...

 
3:59 AM
0
Q: Hacker rank - Left rotation - PHP code feedback for Timeout

Ayman Elarianhere is the problem description : https://www.hackerrank.com/challenges/ctci-array-left-rotation my code pass all test cases but stuck on Hacker rank timeout , i want to know where is the part that take long execution to optimize my code <?php function rotateOnce($a){ if($a[0]>=1 && $a[0]<...

 
4:35 AM
Monking
 
0
Q: Python arrange sublist sequencing

Khái DuyParameters population_size = 20 job_count = 10 max_sublot = [3, 5, 7, 6, 4, 2, 7, 9, 3, 5] mc_op = [6, 14, 8, 5, 6, 9, 4, 6, 7, 2] sequence = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 2, 4, 9, 3, 1, 6, 5, 7, 8], [1, 0, 3, 2, 8, 5, 7, 6, 9, 4], [1, 2, 0, 4, 6, 8, 7, 3, 9, 5], [2, 0, 1, 5, 3, 4, 8...

 
5:00 AM
0
Q: Which approach is better for assigning conditionally

GautamBelow code is just initializing two variables, depending on cloudType passed, which can be assigned by either of approaches. In javascript less number of lines of code is recommended so I like the second approach but first approach makes it more readable as well. Please help Approach one gives m...

 
6:03 AM
Monking
 
 
1 hour later…
7:30 AM
0
Q: How does this function change the variablevalue out of the method's scope

guestI have Tried to Learn QuickSort and I got this code from GeeksForGeeks (And I edited it a little). I simply can't understand how this code changes the value of the variable. Here is the code: def partition(arr, low, high): i = low - 1 pivot = arr[high] for j in range(low, high): ...

 
possible answer invalidation by Mathematics on question by Mathematics: codereview.stackexchange.com/posts/202199/revisions
 
8:00 AM
0
Q: Calculate the difference between the elements in a list

plshm So I have two lists which have the same size. One is called roadS and the second one is called simTime. My aim is to calculate the difference between two indexes which lie next to each other and divide them with the difference of the other list. On the picture above you see what I mean. This ...

0
Q: Efficient Database design

A.MI have created ASP.NET Core WEB API service and I am using EF core for communication with Database. Now, I am looking for efficient design of my database. At this moment I have three tables Which are exactly the same. Below is shown their corresponding entity models. public class PurchaseDocume...

 
8:15 AM
0
Q: Simplifying calculation with min value in C#

JoeJoe87577We have to calculate a lot of different fixed factors with user input values. Every single calculation has a different min value. This block of code result.Calculation_VK = input.km_past_year * 0.040m; if (result.Calculation_VK <= 300) result.Calculation_VK = 300; result.Calculation_VK *= C...

 
Monking everyone!
 
Monking
 
8:53 AM
If you jave trouble getting your code to work, ask here with a MCVE (read help section). If you want to get feedback once your code works, check Codereview Stack Exchange site. — hyde 5 secs ago
 
0
Q: Design an elevator system

ShaneI saw this interview question and gave it a shot as I think I am probably lacking in OO/general design skills(I work for a JS/C# shop). Any feedback on the code would be greatly appreciated: // assumes that floors are normalized // to always start from zero const DIRECTION = { STOPPED: 0, U...

 
9:17 AM
2
Q: Binary Expression Tree

VincentCI implemented a binary expression tree, I've used my previous shunting-yard parser to provide it the post-fix expression. I have a few specific questions outside of just comments about making it more pythonic: Should I check the type when assigning left and right nodes? I read that type check...

 
9:40 AM
possible answer invalidation by Swift on question by Swift: codereview.stackexchange.com/posts/202158/revisions
 
-1
Q: Python Unittest Testsuite

Frank RentmeisterI have over 100 test cases and would like to use the Unittest Suit from Python now. Currently I have the following code. So far he does not work because he gives me an invalid syntax. But I have defined a class, and just do not understand why he makes me difficult at this point. Can only be an...

 
10:01 AM
@Duga seems ok
 
@CaptainObvious Hardly OO.
 
10:18 AM
0
Q: Validation in BLL, many ifs - Suggestions how to refactor what I think looks smelly

David C We have an MVC application, which performs actions on a referral. We are added the business logic, to ensure that we can't perform invalid actions on the referral due to it not being in the correct state. We have something that works, but it looks pretty smelly, however we are unsure how to im...

 
11:04 AM
0
Q: Derived class static

Carrot Cake#include <iostream> #include <string> /* make sure that none of your constructors or destructors call virtual functions on the object being created or destroyed and that all the functions they call obey the same constraint. */ class Transaction { // base cl...

 
I'm voting to close this question as off-topic because it belongs to Code Review site. Although I know, questions in that site will not get attention as much as here on SO. I wish there could be easier methods for moving question. — Mohammad Dehghan 52 secs ago
 
11:19 AM
0
Q: Count number of group for same element in given array?

Prashant GuptaI have a int array{2,3,4,2,3,4,2,1} So I want to make of all common element in one group like there are two group one{2,3,4} and {2,3,4} So I want the print total count of such group of Same Element for this output 2. I try with some code but it's not working.please help me out with correct logi...

 
11:33 AM
If it works then this is really not a question for SO.. you might try CodeReview.SE but check their guidelines first. — Paulie_D 22 secs ago
 
0
Q: Find SuburbName from latlong or location

Lalji DhameliyaI have create one class and interface for finding SuburbName based on Location or LatLong coordinates. i have written code below my interface. public interface IGeoCodeService { string GetSuburbName(double latitude, double longitude); string GetSuburbName(string location); ...

 
12:21 PM
0
Q: A simple linked list of arrays in Java

coderoddeIntroduction This simple data structure combines ArrayList with LinkedList. In other words, it is a linked list of arrays: Code package net.coderodde.util.experimental; /** * This class implements an experimental linked list data structure that * combines linked list with array-based lis...

0
Q: Hex Dump Utility in x86-64 Assembly: Version 1.1

case_2501I recently posted a code review and received some very useful feedback. I have spent some time implementing the suggested improvements/fixes, and wish to post a follow up review, with the new and improved version of the program. Changes Made: Comments Section(s): I have added an additional...

0
Q: JavaScript responsive menu

JohnDoeaI have the following frontend code for a responsive navigation menu which I thought using in my WordPress website. Code document.addEventListener('DOMContentLoaded', ()=>{ let clicks = 0; let menu = document.querySelector('.menu'); let menuButton = document.querySelector('.burge...

 
12:36 PM
0
Q: Generic function with same logic but different input structure

bugsI have a data structure that looks like this: interface Node { originalWeight: number; currentWeight: number; } where both properties are floats between 0 and 1. To check if a node has been modified, I wrote a simple isNodeModified function: isNodeModified(node: Node): boolean { return...

 
1:07 PM
0
Q: Node.js script to automatically increment version number on commit to specific branches

K48My goal is automatically increment the version number in package.json whenever anything is committed to the specific branches (development, testing or master). Strangely I couldn't find a ready-made solution, so I wrote this script which runs automatically as the pre-commit git hook using the g...

 
1:22 PM
0
Q: show/hide components

knot22The following code is used to show/hide components in an AngularJS app: var vm = this; var hideComponents = function() { vm.showRegions = false; vm.showAccounts = false; vm.showOrders = false; vm.showInvoices = false; vm.showWarehouses = false; } vm.showComponent = function(comp...

0
Q: Project Euler Problem #5 Solution in C++

Phenolso the problem is this:- "2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder. What is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20?" And I'm wondering if my code to solve this problem is good and...

 
2:00 PM
I believe that asking for ways to improve your code are better suited for Code Review. — Shepmaster 58 secs ago
 
2:14 PM
Greetings, Programs.
 
@Donald.McLean Monkafternoon
 
There's a huge push on for python where I work, and I'm hating it.
 
@Donald.McLean What don't you like? Python, or the fact that your coworkers really want to use it?
 
0
Q: Reading a text file, writing it in binary, then reading that back into a string on a different platform

Nimitz14I need to convert some text files into binary format on my (AMD) computer, and then I plan on reading them in and converting to strings (which can contain utf8) on Android. This is what I've currently got: int main(int argc, char* argv[]) { std::string inf(argv[1]); std::ifstream ifs(in...

 
@Mast your last two comments here sound like the beginnings of a good review for the code posted --> codereview.stackexchange.com/questions/202292/…
 
2:31 PM
@avazula There are four classes of languages that I find more difficult to think in: a) loosely typed languages, b) interpreted languages, c) scripting languages, d) assembly language.
 
@Donald.McLean Doesn't leave much choice ;)
But yeah, I saw in your bio that you were a Scala programmer? I don't see that often :)
 
Scala is just a better version of Java. Many people make way too much of the differences.
 
@Donald.McLean I actually happen to really dislike Java (but I'm originally a C++ girl, so that's not that surprising I guess ...)
 
Heck, I would switch from Java to Scala just for traits and the option stuff.
 
0
Q: React Native Props Issue

MonkeyTo start of, I wanted to make a code that involves the use of props. I tried to learn from many resources, but it still showed an error. Here is the code. import React, {Component} from 'react'; import { View, StyleSheet } from 'react-native'; const styles = StylesSheet.create({ container: { ...

 
2:38 PM
Monads - that's the word I was trying to think of.
@avazula I never minded C++, however I do appreciate that there are whole classes of fatal memory errors that just aren't possible in JVM languages, and probably python as well.
 
@Donald.McLean Meh. I prefer to risk having a SYSSEGV and knowing why that happened instead of letting some garbage collector do the job and have no idea what it's doing.
Although that's a nice feature for non-programmers and people who don't want to have to deal with that :)
 
Yeah, modern programming involves much more trust that the people who developed the stuff that you're building on didn't screw it up.
The technology stack for the system I work on is huge.
But that's a heck of a lot of code that I don't have to write myself.
 
2:54 PM
0
Q: API DESIGN: Store Table of function pointers in client or dynamically in service

NJ MercaldoCurrently I am developing an applications development framework. Unfortunately I am completely stuck on a specific design decision: (The following is a huge over simplification, but I believe it will be sufficient for the purposes of the question) Within the framework API there are clients a...

 
@Donald.McLean So you're lucky I guess :)
 
@CaptainObvious Not real code
 
3:20 PM
@Malachi Meh, that's just the structure I'm using on my 2 half-finished Elevator projects...
 
@Mast you interviewing for the same job as the OP? lol
 
@Malachi No, I'm an engineer and somebody wrote a challenge for it:
20
A: September 2015 Community Challenge

CarlAn Elevator Management System A building has \$x\$ number of floors and \$y\$ number of elevators. People create up/down requests to your system, and when they are inside an elevator, command it to go to a floor. Your job is to get them to the floor they want. If this interests people, we can...

The current version looks a heck of a lot better than the last attempt I wrote, but it's not even close to finished.
 
@Mast oh, haha. when I get moved into my rental house in a few weeks I will have to take a look at some of those challenges
 
The other program is in a PLC language and is getting atrociously monstrous.
I know a couple of things about elevators, building a decent one in software is hard.
 
lol
i need more coffee before this Webinar Mandatory meeting starts.
 
3:26 PM
If your code works but just needs to be optimized then it is better suit for Code Review. — dwirony just now
 
@Malachi Mandatory webinar? I hope it's a lot more interesting than it sounds.
 
probably not, that is why they have a food truck coming for lunch...so we all show up...lol
 
lol
 
4:10 PM
0
Q: Custom data type - "Binary" Float (0-1.0)

cupro PandaIn my current game I have the need for values ranging from 0 to 1, or from -1 to 1. The values should never exceed this threshold, so instead of constantly validating the values I made a custom data type which essentially clamps a float to that threshold. I have been researching various ways of m...

 
Apparently we're using Gerrit Code Review version 2.11.3, if that's important. But by this point we've taken care of the problem by just submitting a new code review from a manual merge of the changes. Again, thank you for trying to help. I'm sorry it didn't work for me. — phonetagger 43 secs ago
 
Monking
 
4:44 PM
I'm voting to close this question as off-topic because this question belongs to codereview.stackexchange.com — Nelson Teixeira 17 secs ago
@NelsonTeixeira The code, as it stands, is not a working example. So if it were moved to Codereview, it will most likely get closed, so it's not on topic for code review. — Taplar 9 secs ago
 
0
Q: Compensation Year-End Planning VBA Script?

bloomfieldhero9219I have a pre-planning file for year-end review that does a lot of index/match formulas and IF statement formulas based on certain parameters when referencing increases in various types of pay/incentive pay. Sub Update() 'File Paths Dim Preplan As String: Preplan = "M:\PrePlanning_Template.xlsm...

 
5:13 PM
@Mast turns out I had to appear in person...
 
@Malachi For a webinar? Were you the presenter by chance?
 
no. it wasn't really a webinar, it was a meeting where people could call in and listen to the C's talk to us about stuff
 
Ah.
 
5:42 PM
0
Q: Explain me how to create Binary Search Tree in C#

vijay pratapExplain me in detail how can I create the binary search tree in c#.

 
@CaptainObvious Lightning-fast moderation strikes again!
2
 
@CaptainObvious that's not how any of this works ....
 
5:58 PM
0
Q: python OOP design

Norbert BraunI decided to improve my OOP design knowledge and learn python at the same time so I started to write a simple program which will be a fight "simulator". For now, there are only 2 character types : Orc and Human. The CharacterFactory class is created so that I'll be able to handle Orc and Human c...

0
Q: SVM algorithm throws float instead of 'Yes or No' as output

Sushant Karandemy code is import pandas as pd import matplotlib.pyplot as plt import numpy as np from sklearn import cross_validation, svm,cross_validation,neighbors from sklearn.linear_model import LinearRegression df=pd.read_csv('train_loan_prediction.csv') dft=pd.read_csv('test_loan_prediction.csv') ...

 
6:13 PM
0
Q: Simple bank OOP structure in PHP

jetskiI don't have much experience using either OOP or PHP since this is probably my first thing ever written in this language. I've had some exposure to OOP but I'm not used to writing programs that way. I would greatly appreciate some feedback concerning OOP and PHP best practices, clean code, and ov...

 
Question might be a better fit on Code ReviewAmy 17 secs ago
 
0
Q: Adding ID to body tag from variable defined in URL

ShanePKI have written a small PHP script to get a variable from the URL and echo it in the body ID. An example of the url: http://www.example.com/?var=123 I have added this to the head of my HTML page: <?php if (isset($_GET['var'])) { $var = $_GET['var']; } else { $var = NULL; } ?> The bo...

0
Q: Cleaner approach to JSON deserialization?

HoserSo I have a bit of code where I am deserializing a bunch of Json to various different objects based on what query was used to generate the given json. Code below: foreach(QueryResult result in response.Result.Results) { var dataSet = (JArray)result.Data; //Object1 if (result.Quer...

 
6:29 PM
This seems like a better fit for codereview.stackexchange.comjonafato 1 min ago
 
6:54 PM
@sf_jeff: IMO, in idiomatic Java (and C#) you catch exceptions that you can't easily predict. Exceptions are also used for programming errors, e.g. passing in invalid inputs etc - but those exceptions shouldn't be "handled" so much as avoided. Catching NullPointerException is not idiomatic Java anywhere I've worked (and usually wouldn't get through code review). IIRC, Josh Bloch talks about this reasonably extensively in Effective Java. — Jon Skeet 21 secs ago
This is probably better suited for Code Review. — Sach just now
 
7:30 PM
0
Q: Double Linked List Using Smart Pointers

SnorrlaxxxI have decided to rewrite what I did here, following the suggestions to use smart pointers. I will rewrite the other data structures as well using smart pointers where appropriate. I just want to see how my code stands now, I am sure there are still areas I need to improve or fix. I again want t...

 
8:09 PM
Once you have corrected the errors. You should take the code to codereview.stackexchange.com (they review working code) but will tell you how to make the code better using best practices. — Martin York 57 secs ago
I'll mention though that I posted for review stripped down versions of all the threading macros here. They may be a good starting point to write your own. — Carcigenicate 29 secs ago
 
8:25 PM
possible answer invalidation by cupro Panda on question by cupro Panda: codereview.stackexchange.com/posts/202322/revisions
 
@Duga rolled back
 
0
Q: Sliding Window Spliterator in Java

Grzegorz PiwowarekI implemented a custom Sliding Window Spliterator in Java. Do you have any ideas how this could be improved? Thinking if replacing the buffer with a plain array could have a positive impact on the performance side of things if done correctly. I'm not going to use that code in any production sy...

 
8:46 PM
-1
Q: please help I keep getting stuck

anna heiderrage charges ​$ 1.58 1.58 for the first hour and ​$ 0.50 0.50 for each additional hour or part of an hour. What is the maximum length of time Tom can park in the garage if he wishes to pay no more than ​$ 4.58 4.58​? What is the maximum length of time in hours that Tom can​ park?

 
@CaptainObvious sigh
 
9:01 PM
This might be better-suited for Code Review Stack Exchange. And I'm just curious, would the second std::move(v) call always work? If the first std::move(v) call blanks v, wouldn't the second call try to move an empty vector? — frslm 13 secs ago
 
9:51 PM
So, you have working code that you wish to improve? That sounds like a better fit for code review. If you agree and move this post there, I'd be happy to point out ways to improve the existing code. — Shepmaster 40 secs ago
 
10:03 PM
1
Q: Read file to class

lizduadacA simple concept yet I seem to have written it in a complicated way. I have written some C++ source code that should: write what will be read in later (I do not need the writing, only for reading in later) read in a file parse it save the data to a class print out all the saved class data I ...

0
Q: Testing Excels RandBetween Function

learnAsWeGo INTRO I am using an excel worksheet as my "database." No headers so [F1] is assigned to column one by default. I filled the entire column, all 1,048,576 cells with RANDBETWEEN(1,20). I then hard set these values by copy/pasting as value. It is very slow. Much slower than using excel functio...

0
Q: A simple Vector implementation

DimChtzJust made a simple Vec class, nothing fancy but I am open to suggestions for improvements. Of course, this is not suppose to replace or used for the same tasks as std::vector. This is more like opencv's Vec and eventually I want to include this in a bigger project of mine. #include <cmath> #incl...

 
10:18 PM
0
Q: Simple interpreter written in Rust

wyer33I'd like to improve how ownership is handled within a simple interpreter written in Rust. The interpreter takes simple calculator like expressions and returns either a string of the AST or a number of the evaluation: // Simple expression for working on numbers enum Exp { Add { e1 : Box <Exp>...

 
10:46 PM
I'm voting to close this question as off-topic because it is seeking advice on working code. This question can be asked on Code Review, if you can produce a complete working example, but remember to check their FAQ first. — Bhargav Rao ♦ 29 secs ago
 
0
Q: Python Multi Choice Quiz

NjoodI am trying to make a multi choice quiz which contains 5 questions with a score to count. it says my code has an infinite loop and I tried to see where the problem is but couldn't find anything. Is my code wrong??

 
@CaptainObvious not working, screenshots of code
 
11:04 PM
0
Q: Java - Execution times and performance [Efficiency]

Mr Pro PopI am creating a simple bot that collects coins in-game. The code runs under a game-loop so there are 60 ticks p/s Here is the function that I use to check for the nearest coins to be collected: public GameObject getNearest(ID objectID) { LinkedList<GameObject> object = new LinkedList<GameO...

 
11:19 PM
0
Q: int to Roman numerals in Go / Golang

Christian HujerFor a new project, I've started learning Golang. This is one of my very first steps in Go. The objective that I've given myself is to convert int to a String representing the roman numeral of that int. The supported range shall start with 0, negative numbers can be ignored, and it's okay for now...

 
11:50 PM
0
Q: Python Functions with Docx

Brian G.I am a Python newbie. I would like to know advice please on reducing the following code to use Functions to reduce the repeated code. I will have up to 100 user inputs on an excel form. MySQL queries are done and text paragraphs is pulled out of a mysql database for title, content and picture. I ...

 

« first day (1937 days earlier)      last day (2081 days later) »