« first day (3133 days earlier)      last day (877 days later) » 

12:00 AM
REFRESH! There are 7942 unanswered questions (89.2562 answered)
It's OK to ask a question on Stack Overflow about working code if you have one specific question which can have a definite, non-opinion-based answer. It's just that your question here asks for a "best", "pythonic way" to improve your code, which is open-ended and subjective; so it should be asked at Code Review because that is the right place for requesting open-ended, general feedback on working code. — kaya3 18 secs ago
 
12:35 AM
Should my question be moved to the code review board? This answer could be useful to others, so I'm torn. — Daniel Kaplan 45 secs ago
If the code works but needs improvement, then yes, it sounds like a better fit for Code Review. — jmoerdyk 17 secs ago
posted it here: codereview.stackexchange.com/questions/270558/… Dunno what to do with this question? Delete? Close? — Daniel Kaplan 22 secs ago
@DanielKaplan When posting across the network, it's generally accepted etiquette that you would leave only one instance on the more relevant site. You should be able to delete this one and leave the other question on Code Review. — esqew 17 secs ago
 
0
Q: best way to get data from dict

Maria MoulinkaI have a function general_statistics that takes a dict as input and get the wanted information. the function is working without any problem, but I want to know if I can do it with a pythonic way because I'm trying to improve my skills. def general_statistics(input_data: dict): result = {}...

0
Q: Map chaining vs execute on first map

async awaitI have two large arrays of objects, which look something like: [ { key: "prop", Email: "someEmail@email.com" }, //... ] and [ { key: "prop", "AN EMAIL": "SomeEmail@emailcom" }, //... ] To compare the array of objects by email, I first map the arrays to only grab the emails, then I forma...

0
Q: How do you get the next 9am/pm from now as a datetime in Python?

Daniel KaplanI have some code that needs to return a datetime of the next 9am or 9pm, UTC. I've figured out some code to do this, but it feels unnecessarily complex to me. Is there a way to simplify this? from datetime import datetime, timezone, timedelta class NineOClockTimes: @staticmethod def get_...

 
 
1 hour later…
2:04 AM
0
Q: Absolute Permutation | Hacker Rank: Any way to make this python code faster without changing it's whole logic?

Mysterious Shadowhttps://www.hackerrank.com/challenges/absolute-permutation/problem I know that if you work out the math and logic first, the algorithm can be simplified greatly (shifting indices), but is that the only way to solve this and pass all test cases? Checking if a value is in a list can be slow, but I ...

 
 
3 hours later…
5:15 AM
If your code works and you're looking for open-ended critiques consider posting on Code Review instead. — John Kugelman 51 secs ago
 
5:27 AM
0
Q: Identifying code smells in the classes which represent a protoype for a facebook

yemenConsider the following two classes: public class Person<P extends Comparable<P>> { private List<Person<P>> following = new ArrayList<Person<P>>(); private List<Person<P>> friends = new ArrayList<Person<P>>(); private P id; public Person(P id) { this.id = id; } ...

 
5:40 AM
Monking
 
 
1 hour later…
6:54 AM
If your code works, please use codereview.stackexchange.com for asking for code reviews. — 9769953 37 secs ago
Fair point :D. And thank you for directing me to codereview. Will post the question there! — Syed Ali Ahmed Islam 43 secs ago
 
7:35 AM
0
Q: Fastest string search algorithm invented by me. It is called ""Choudhary String Search Algorithm""

AmitI have invented the fastest string search algorithm. It is called ""Choudhary String Search Algorithm (choudharyStringSearchAlgorithm)"". I have compared my algorithm with Brute Force Algorithm, Boyer Moore Algorithm, Rabin Karp Algorithm, and Knuth Morris Pratt Algorithm and my algorithm is the ...

 
8:00 AM
1
Q: Magic ball 8 program

vlados155I was doing the Magic Ball 8 project (its task is to read a user's question and output a prediction) on Python and wrote the following code: from random import choice from time import sleep list_of_predictions = [ "Undoubtedly", "It seems to me - yes", "It is not clear yet, try again", "...

0
Q: Python sorting function. Feedback required. Beginner

Syed Ali Ahmed Islam I am learning python and for practice I have written the below function for sorting a list. Can you please provide feedback on how I have structured it and what better ways could be there to write it for optimization/structuring? a=[5, 4, 0, 3, 2,1] y=int() c=a[:] d=a[:] e=[] while len(a)>0: # ...

 
8:26 AM
0
Q: How to remove boilderplate code from the methods

username112233I have a methods like. public function getReceiptGames(Request $request):JsonResponse{ $result = []; $page = $request->get('page') ? (int)$request->get('page') : null; if ($page) { $pagination = $this->receiptGameRepository->paginateAll($page); $games = $pagination->items(); $this->r...

 
What improvements I see are in the way the solution is denoted. — greybeard 17 secs ago
 
8:51 AM
0
Q: How to get rid of TryParse in this code?

renathyusing (CustomerDataReader reader = customCommand.ExecuteReader()) { while (reader.Read()) { var person = new Organization { Name = reader["Name"].ToString(), Country = reader["Country"].ToString() // much more string he...

 
9:43 AM
0
Q: Is relying on exception handling a good way to ensure that the app's work is done correctly?

OrtundContextually, I'm evaluating if a member exists with the supplied information. This, ostensibly, is intended to prevent the addition of new members with the same details. The user will be provided with a list of members having the same details as the new member they're trying to add. I set this u...

 
10:16 AM
This question belongs to codereview.stackexchange.comGoion 39 secs ago
 
 
1 hour later…
11:27 AM
0
Q: Quick sort in c# using multithreading

Filip ResceanuI'm trying to implement quick sort algorithm in c# using multi threading . I want to learn multi-threading . I implement the algorithm but there is a problem .I sort each thread and i don't know how to merge the sorted threads public const int count = 180; static List<int> numbers = new List<int

 
11:53 AM
0
Q: group computed properties in vue component

PeteI have the following vue component which all works fine <template> <div class="sales-agreements"> <nav class="sales-agreements__navigation"> <ul class="sales-agreements__navigation-list"> <li class="sales-agreements__navigation-item"> <router-link :to="{ path: '/...

 
 
1 hour later…
1:11 PM
0
Q: Long switch statement. Can it be reduced?

Žiga ZajcI have a long switch statement and it would be great if someone know how to make it cleaner. Code is available on Github: https://github.com/Rabbit-Company/Passky-Server/blob/main/php/index.php And for those who don't want to visit Github here is the code: switch($_GET['action']){ case "getInfo":...

 
1:36 PM
Better suited for codereview as the code in itself does produce the desired result — DarkBee 14 secs ago
 
2:11 PM
Juan M on December 01, 2021
While millions of people come to Stack Overflow to find answers to their programming questions, there are well over a hundred sites within the Stack Exchange network, covering all kinds of topics from movies & tv to academia to global languages. We found that our question and answer format, along with a strong community focus,…
 
If your code hasn't any issue and you just want some advices about making it "better", maybe codereview.stackexchange.com/tour is a better fit for this question. — Bob__ 26 secs ago
 
2:56 PM
0
Q: How can I make this command-line sentence-by-sentence EPUB reader follow a more standard design pattern?

peterelbertThis is a command line application which displays the text of an EPUB one sentence at a time. I am going to make it more robust, including: make the segmentation more accurate, because it currently groups together unrelated text sometimes make it faster, so that the segmentation occurs a first t...

 
Ryan Donovan on December 01, 2021
How Aiven moved from storing metrics in one giant InfluxDB to using horizontally-scalable M3.
 
 
1 hour later…
4:10 PM
Monking
 
If you have working code that you want feedback on, you might want to check if your question could be made on-topic for codereview.stackexchange.com. — khelwood 32 secs ago
I would suggest re-titling to avoid asking for opinions. "Optimal" in what sense? Why keep two lists for points? PointsStatistics conflates display with calculation, IMO they should be separate concerns. This post may be a better candidate for the code review stack exchange. — Dave Newton 25 secs ago
 
0
Q: Is this example from AndroidX violating LSP (Liskov Substitution Principle)?

frumleToday i had decided to look at what is under the hood of androidx.lifecycle components and found this (here): /** * Implementations of `Factory` interface are responsible to instantiate ViewModels. */ public interface Factory { public fun <T : ViewModel> create(modelClass: Class<T>): T } ...

 
Thanks for sharing your code. It's still unclear what your issue is, or why you can't save content to a file. Perhaps it's related to creating an enormous in-memory string instead of writing incrementally to a file? Anyway... this is fairly broad, and not really something that can be covered here, as I believe you're looking for advice on improving your code? If that's indeed the case, you might consider posting instead to codereview.stackexchange.com (just make sure you're very specific when re-posting there). — David Makogon 48 secs ago
yes, you are right. I am just looking for the idea to optimize when all the solution we have taken in a string. Thanks for suggesting the codereview.stackexchange.com. :) — Gautam Jangid 22 secs ago
This might be better suited for Code Review if your code already works and you're looking to improve it. However, that depends whether your goal is actually to improve it or really just to make it shorter (see above). Things like replacing the inner loop with std::count fall directly into advice you might find there, but other advice might end up leading to more lines. — chris 17 secs ago
If you've got working code, the place to ask about improving it is Code Review.SE. — Andrew Morton 34 secs ago
 
4:54 PM
Monking
 
5:06 PM
0
Q: what are you think about my solution?

srxxxi m learning java mooc right now and this is my solution for exercise grade statistics. this is exercise: In this exercise we create a program for printing statistics for points in course. The program receives points (integers from zero to one hundred) as input, based on which it prints statistic...

 
5:29 PM
This is not a code review site. There is a specific Code Review Stack Exchange site. — Random Davis 1 min ago
 
5:58 PM
It seems that your code currently works, and you are looking to improve it. Generally these questions are too opinionated for this site, but you might find better luck at CodeReview.SE. Remember to read their requirements as they are a bit more strict than this site. — gunr2171 57 secs ago
 
 
1 hour later…
7:16 PM
0
Q: Python function for finding if all substrings exist in a string in sequence

JeffUKI want to find if all of a list of substrings exist in a string, in the correct order (with or without spaces between them), it seems to be a good use for regex. I think I need to build a regex filter of "a.*b.*c" and use search to find that anywhere in my string. Are there any other approaches ...

0
Q: Rust Pig Latin Translator - Idiomatic suggestions

Samuel PageThis is the code I came up with for the Rust pig latin exercise. I am looking for suggestions on how to make it more idiomatic. I think working with iterators instead of chars and Strings would be a step in the right direction? I was unable to figure out how to use .map to reach the same result. ...

 
8:08 PM
0
Q: Producer/Consumer Multi-Thread implementation - Is the solution correct?

ng.newbieI recently faced this following question in a Java coding round, needless to say I did not get a callback. So I want to know where I am going wrong in my solution and also what can be done to improve it. The Problem statement was as follows: Create a java program, with two components, a supplier...

 
8:23 PM
Stack Overflow is not a free code review and debugging site. Please see minimal reproducible example and How to Ask for instructions. — Mad Physicist 13 secs ago
 
8:34 PM
0
Q: Create trigger that updates Table3 from an insert into Table1 that multiplied by a value in Table 2 in MySQL

Ramen EnthusiastI know this is probably more complicated than it needs to be, however, I would really appreciate some help. I'm trying to create a trigger in MySQL that will update the value in the Costs table when a value is inserted into the Assignments table. HOWEVER, it can't just be that value, it has to be...

 
This might be better to ask on Code ReviewPred 19 secs ago
 
9:33 PM
This sounds like code review input you received. In general, calling a method on a null object would be an error. But, I found this related SO post: stackoverflow.com/questions/16837423/…. The ViewBag is not normally null so you can .Clear() it with impunity. — Doug Dawson 23 secs ago
 
10:18 PM
0
Q: Euler Project Problem 2 JavaScript

fabinfabinfabinJust solved Euler Project Problem 2 using JavaScript and I would like to know how I could improve my code, I do think it looks good, but you never know. function fibonacci() { var a = 0, b = 1, count = 0; for(var sum = 0; sum < 4000000;){ sum = a + b; a = b; //...

 
10:29 PM
If you're not aware of a specific problem, and just want the code assessed, try codereview.stackexchange.comPasserby 1 min ago
 
10:44 PM
0
Q: Achieving same abstraction by replacing JObject's implementation with System.Text.Json alternative

nopI'm trying to improve the following Binance Web Socket API wrapper. I like it because it uses System.Reactive and it takes advantage of the combined web socket streams. With the combined stream, you could subscribe to multiple streams and use only one socket/TCP connection. Here is a working exam...

 
@Passerby In the current form the post above seems off-topic for CR because the OP isn't sure if it works and asks about an error. Please read What topics can I ask about here?. — Sᴀᴍ Onᴇᴌᴀ 20 secs ago
 

« first day (3133 days earlier)      last day (877 days later) »