« first day (2252 days earlier)      last day (2062 days later) » 

00:00
RELOAD! There are 6198 unanswered questions (89.7716% answered)
If code is complete and working, it should be on Code Review. This site is primarily for fixing broken code. Note though, you should give some context as to what exactly the code is supposed to do. — Carcigenicate 19 secs ago
0
Q: string combinations of 0 and 1

user5447339I was asked this question in an interview: Given a string s consisting of 0, 1 and ?. The question mark can be either 0 or 1. Find all possible combinations for the string. I came up with below code but I wanted to know whether it is the best way to solve the problem? public static voi...

0
Q: New to Programming - Creating a random item generation system to be used in a later roguelike

AcidreignAs per subject line - New to programming with the goal being to create my own roguelike. I am mostly interested right now in creating my item generation system. I want the code to create a random item that can then be used, stored in an inventory etc. Want to know if the below is a smart way to b...

 
2 hours later…
03:30
0
Q: Non-alphanumeric characters to clarify test cases

ig-devIn a test I have many lines that look somewhat like this foo should equal(Seq(true, false, false, true, false, false)) bar should equal(Seq(false, true, false, true, false, false)) baz should equal(Seq(false, false, false, true, true, false)) I find the expectations hard to distinguish. So I ...

04:13
Monking
@Duga Uhoh
@SᴀᴍOnᴇᴌᴀ Your argument is flawed and confusing. Even if it's an improvement, alternative implementations are not justified without a review.
05:12
0
Q: Shorter and better way to write an if/elif/else in python

Ibrahim RahimiI just write a simple method which returns a string based on the number in accepts as a parameter. I used if/elif/esle here but I think for this simple scenario I wrote long code. I want to know is it possible to shorten this code in any way except using a lambda method. Also, I'm interested to k...

Monking
Monking
05:32
0
Q: Using another function on modified dictionary?

HemaThis is based upon an exercise in chapter 5 of Automating the boring stuff using Python. This code contains functions addToInventory which modifies a given inventory of items to add new items as well as update existing items and displayInventory which displays the items and their values. The mai...

-2
Q: interactive calculator

Rotaru Artiomcould you help me with this interactive calculator? I would like him to be able to add numbers not just digits, and I would like to be able to do more operations in a syntax (a + b-c) #include <iostream> #include <cstdlib> #include <conio.h> using namespace std; int main() { int a=-1,o=-1,b=-1...

06:12
-2
Q: Are calculations or checks made in the for loop lifecycle/breakpoint penalising?

insidesinConsider the following segment of code: for (let i = 0; i < (maxResults || currentResults.length); i += 1) { const item = currentResults[i]; if (results.has(item)) { // do something } } Does the i < (maxResults || currentResults.length) piece of code get opti...

0
Q: Updating field in Temporary table

J MI have a more massive sp, in which I use some temporary tables, below is a part of the sp where I am updating a field in a temporary table two times. Update #BalSheet set OBCr = OBDr + isnull(trialDeb.amount,0) from ( Select v.AccountId, v.CompanyId, Sum(isnull(v.Amount,0)...

@Fuseques use git and pull requests and code reviews. explain and educate. you will never be able to solve this only in code. you can bypass a lot of other supposedly safe secure mechanisms via reflection so don't even try to hide information. again, perform code reviews and educate. — UrbanEsc 14 secs ago
06:45
possible answer invalidation by greybeard on question by nz_21: codereview.stackexchange.com/posts/223381/revisions
 
1 hour later…
07:51
Monking
08:08
SO is a Q&A for people seeking help to make code work/debug... This kind of questions should be asked at the CR site. — dbl 33 secs ago
08:25
possible answer invalidation by Nicolas Raoul on question by Nicolas Raoul: codereview.stackexchange.com/posts/223484/revisions
1
Q: MySQL GROUP BY id, then show name

Nicolas RaoulI have a users table where some users have the same name: +----+------+ | id | name | +----+------+ | 1 | Joe | | 2 | Joey | | 3 | Joe | +----+------+ ... and a purchases table: +-------...

0
Q: "Is there a way to combine these function into one?"

SylerBy these functions I mean the (call, hide, removeListener, addListener, observer.subscribe) functions, i feel like going to write them over and over again, is there a better way to do this? export class UIStateService { authForm: UIAuthForm = { show: false, type: 'login', observer...

If you have working code and just need someone to read it, then codereview.stackexchange.com is the good place to post it. — Yksisarvinen 25 secs ago
09:32
0
Q: Enhancing if statements, timer and general code in this Drinking Water App?

DjaboneI would like to know how I might improve my code? I just started coding and liking it a few days ago so I am quite new to this whole world... So basically what this app does or is supposed to do is to calculate the amount of water one has drunk in a day. Depending on the user's input, the app te...

10:03
This is tedious, so I'm out, but if you have working code (and more than just a snippet of it) see Code Review. — jonrsharpe 43 secs ago
0
Q: c++ linux simple io completion ports in user mode

dev65This is a simple io completion ports for Linux implemented in user mode In windows io completion ports work like this : There is a global queue for issuing io requests There are some worker kernel threads that pop from this queue and operate on each request There are a queue associated with each ...

0
Q: I made simple connect 4 game in c++. Is my code good?

Dalibor TrampotaI made this easy game because I couldn't make tetris(I couldn't place piece into game field correctly) and I'd like someone to analyze my code and tell me if I'm bad cuz I really can't make more complicated game. The functions like NoFlicker and ShowCursor I copied from internet but the AlignStr...

10:32
0
Q: removing the properties based on another object - better way

DILEEP THOMASBased on userAccessData Object i need to filter the properties so what ever properties inside the fields are there they will be exist in the updatedValue, i am able to do it. also one more thing if the ouput is an empty object then there is no need to have that object want to remove that also i...

11:13
0
Q: Cube root in Python 3 using Bisection Search: Numbers in -1 to 0

arya_starkHere is my code, which doesn't seem to work for numbers in between -1 and 0 (works perfectly fine otherwise) I think the code enters an infinite loop, somehow, hence I get no result after entering the number. Please have a look and let me know what changes should be made. I am a beginner at prog...

0
Q: First project using SCSS

SabathaonI recently completed my first website using SCSS and thoroughly enjoyed using it over plain old CSS even though I didn't get use any of the advanced features of SCSS. I figured before I delve into making my next website I should get my code reviewed so I will be able to adapt these changes into m...

11:24
@CaptainObvious This c++ program calls main() from main(), there is no exit and it will cause a stack overflow.
 
1 hour later…
12:53
0
Q: SPOJ problem: BUGLIFE . Keep getting WA even though it works on all testcases I have tried

Yash SinghI am trying to solve the BUGLIFE problem on SPOJ using bfs + checking for bipartite graph. Even though my code runs on the example input and testcases from spojtoolkit.com , I keep getting WA while submitting on SPOJ. The code is as follows #include <bits/stdc++.h> using namespace std; vector< ...

0
Q: Compute binary sum with Python 3

Roberta BelladonnaI tried to make a function able to compute the binary sum. Binary numbers are passed as list composed by 1 and 0, like [1,1,0,1], [0,0,1], etc. It seems to work. I tried to improve the code, but I don't think this is the best way to make it work. How can I correct it? def check(value): if v...

0
Q: return array with subsets of objects

Question3rI have an array of objects. An example could be maskInfo: [{ fieldId: 1, values: ['My invoice'], fieldTitle: 'Invoice name', dataType: 'String', isRequired: true, valueAmount: '1', masterFieldId: null }, { fieldId: 2, values: ['08/15'], fieldTitle: 'In...

0
Q: Row and column major order for matrix multiplication in C

NPPI wrote a program for matrix multiplication in C language, but there is no way to check the data stored type of matrix A and B. I hope to have matrix A with Row-major order and matrix B with Column-major order, and I would appreciate if you could teach me the following two things: whether matr...

13:11
@Mast IDK, I think I've written an answer very much like that one.
13:33
0
Q: MYSQL database is not updated

Divyanshu''' Specifications: A multi-Threaded Web Spider that: Takes website and depth of spidering as input Downloads the HTML files only Inserts the HTML into a MYSQL database It also parses the forms on each page and inserts into db with form details ''' import mechanize import sys...

0
Q: Drawing a line in any direction with pixels

GuestI am doing an image drawing and rendering library, and would like some feedback on this code, it simply draws a line in any direction. The equation for that is: m = (y2 - y1) / (x2 - x1) b = y1 - m * x1 y = mx + b It works but all these if statements are bothering me, and I am not sure if it...

13:53
0
Q: Helper to convert arbitrary function into a custom deleter

HenrikSIf you want to use a custom deleter in unique_ptr you either have to pass a functor or the signature of a delete function as template argument. If you have a freestanding delete function (often from a C API) you have to pass the actual address of the function to every instance of your unique_ptr....

14:35
@CaptainObvious @TobySpeight I answered the question and removed the VTC.
15:04
I came across this while doing code reviews and I noticed that the accepted answer is no longer true. As of python 2.7.15 assertEqual behaves the same as assertDictEqual when the inputs are dictionaries. Which ever method I used, I got the same detailed output. — ivange94 50 secs ago
0
Q: KenKen solver - Python

EMLHere is my code for the KenKen puzzle. The user must fill in each embolded regions with numbers in the range 1-n where n is the board dimensions (e.g: 4*4, n=4) such that the total of that region equals the target number in the corner using the designated symbol. Each row and column MUST co...

15:33
0
Q: Import function vs turning it into custom hook

cbdev420I have this ProductSearchContainer.js file that it's getting too long to handle and maintain. What it's responsible for: Doing network requests to get a list of products Filter that list with filters values it gets from URL query string and update state with the new filteredList It also holds ...

15:53
1
Q: Finding Wikipedia articles with specific types of user page links

RetroSELECT pl_from, NS, page_title, L_NS, L_titles, num_L, SB, IU, WP FROM ( SELECT pl_from, -- pl_from_namespace does not appear to be consistently reliable; -- it might be better to select from the page table and join the pagelinks table to it. CASE -- This fails on pages missing from t...

Monking
16:08
@another-dave agreed on race to the bottom. I can't get a ?: through code review... :( — Baldrickk 23 secs ago
16:33
0
Q: Association Rules Generation is implementin in java(ecplice)

candy layyI found the following java code for association rules generation and I replace my own dataset in this. But I have uncorrect output but no error in code.Please explain me where the part of code is misused and changed in this code. details of code Demo.java package net.coderodde.mining.associati...

16:49
Please delete this now that it's been posted over on Code Review. — Carcigenicate 46 secs ago
 
1 hour later…
17:54
0
Q: Updating a object properties based on another nested object

DILEEP THOMASI have two nested objects where one object decides to remove or keep the other object properties. So based on the userAccessData object I am doing this operation on allData and I have one more conditions that if form has an action with read access, then the fields which are required will be updat...

18:05
You should let me do your code reviews... I often suggest replacing if-else statements by a single unconditional statement containing a conditional expression; this is IMO "easier to read" if the longer form contains much repeated text. In any case, pretty much all "easier to read" positions are opinions, not empirical facts. My position is "be concise, don't waffle in your code". — another-dave 49 secs ago
As your code is working, this question might better fit over at codereview.stackexchange.comPeter Sutton 24 secs ago
-1
Q: Need VBA code to be optimized so operations run faster

rikin bhavsarI have prepared a macro in VBA to create a pivot table and do some other cleaning up tasks. But obviously this has made my file heavy and it slows down the operation. Please can someone help to shorten my code and make it more professional. Or if anyone can share a good link on how to prepare...

I should also point out the entire code base for PCL was written by many people and at the very beginning there was no code review process. The ml module, where KMeans is from, is one of the more experimental ones of the library, so don't be surprised if you find situations breaking the convention established in the tutorials. — Sérgio Agostinho 55 secs ago
 
2 hours later…
20:14
0
Q: Django Rest Framework - function

Dawid I have a question about function get_data (). Is the logic of the function in the correct place? That work but I think it is no good practice but I no have an idea how to make it better class AlbionItemFilter(django_filters.FilterSet): item_data = django_filters.CharFilter(method='get_data',f...

20:34
0
Q: Is this code open to SQL injections?

ColeI'm working on prepared statements for my website and I'm wondering if it's possible to have multiple prepared statements one after another. In this example I have 2 select statements, I'm hoping that the question marks I have as place holders won't be overwriting one another. After that's been...

 
1 hour later…
21:34
0
Q: ways to optimiza this code (or modernize)

pythonoobI started to learn python not long a ago to automate certain tasks I work on. So this is not a problem i'm trying to solve per se but instead I want to optimize a script I wrote that takes a line in an Excel file and prints a pattern of text based on this line's content, here's an output example ...

0
Q: Is this a valid Kruskal MST algorithm? If yes, what is Big-O complexity of this algorithm?

Bhanuprakash DI came up with the following code by following Prof. Sedgewick's lecture on Coursera. Please review this code and let me know if there is anything that I got wrong here. private class WeightedEdge { public int from, to, weight; public WeightedEdge(int from,...

21:46
I like the way you think XD but I feel like that might not go over too well at my code reviews. — Lordbug 4 mins ago
22:43
I'm voting to close this question as off-topic because it belongs on codereview.stackexchange.comEyeslandic 37 secs ago
23:14
0
Q: Create User Class

RamaMCreate a user class with id, name, age. Write a function to get users older than age 20. Group all users with same age and increment users age by 3 Is there a cleaner way to write this? Any comments are appreciated. const userList=[]; const userAboveTwenty= []; class User { constructor(name,...


« first day (2252 days earlier)      last day (2062 days later) »