« first day (2816 days earlier)      last day (39 days later) » 

12:00 AM
RELOAD! There are 7272 unanswered questions (89.6363% answered)
Q: Generating a random directed graph

Gustaf LinderI wrote a function that returns a directed graph as an adjacency matrix. The function requires two arguments: the amount of nodes and the amount of edges. At first, nodes are placed and instantly connected to the graph. When all nodes are added, random edges are created until all edges are placed...

12:34 AM
Q: How important is using the "proper" tag & attribute?

ControlAltDelI have a fully working JavaScript library in use in a business production environment. Within this library I have a bunch of solutions that are "not proper" I am using a SPAN in place of a hidden checkbox / label / a tag combo to open and close content regions and scroll (animated) to them I am ...

12:47 AM
@Peilonrayz like @Edward said, weather + salt beat them up
2 hours later…
2:25 AM
If you want feedback on your code, try a site like Code Review instead. Stack Overflow is for specific programming questions and is not a place for general discussions. If you want a reference R implementation check out: rosettacode.org/wiki/Binary_search#RMrFlick 54 secs ago
2 hours later…
3:59 AM
Q: Who should I add methods to a controller in Laravel

Juan TopoWho should I declare method inside a controller method in laravel, first I think in add methods inside the controller class <?php namespace App\Http\Controllers; use App\Models\Sale; use Illuminate\Http\Request; class SaleController extends Controller { public function store(Request $reque...

4:25 AM
Q: Rainfall challenge: procedural implementation

Luca ArgentiThis evening I have seen the text of the Rainfall Challenge posted seven years ago by Hunter McMillen. I did not look at his solution (besides, I have no clue about perl), but I was intrigued by the problem, so I set out to solve it. In this case, it seems to me that OOP is a bit of an overkill, ...

4:53 AM
For future reference, SO has a sister-site at Stack Exchange, Code Review, which is a valuable resource for getting suggestions on improving working code. — Cary Swoveland 29 secs ago
I’m voting to close this question because it belongs on CodeReviewjwdonahue 59 secs ago
1 hour later…
6:58 AM
Q: Simplest possible Tic Tac Toe AI in Python

eligolfLast week I challenged myself to create the smallest possible code for a Tic Tac Toe game with an AI as opponent. Smallest possible in regards to say least number of characters used. The requirements on the game are as follows: A "nice" playing experience (ability to get user input and print the...

7:43 AM
Seems that you are rather looking for a Code Review of working code. This question as-is would be fine and on-topic on Code Review. — Lundin 1 min ago
8:35 AM
It's not able to get a tree query like: Tasks -> changesets -> code review requests. If you want to get all changesets with associated work items for the previous sprint. You could use Changesets - Get Changesets api to get the changesets for a range of dates. Then use Changesets - Get Changeset Work Items api to get the work items associated with a particular changeset. After that, filter the changesets that have "workItemType": "Code Review Request". — Cece Dong - MSFT 12 secs ago
8:59 AM
OMG -- and I wasted a hundred bounty points and a day on that!!! Sometimes working alone is the worst thing ever. Thanks so much for the code review. SO won't allow me to award the bounty for another 22 hours, but I'll send it asap. — Software Engineer 20 secs ago
Q: Checking the type and validity of a credit card with Luhn's algorithm in C (CS50)

xdxtI'm taking CS50 Intro to CS. In this assignment, we're asked to make a program that can identify what type of credit card (AMEX, Visa, MasterCard) is given in the input (and whether it is valid.) Validity is checked using Luhn's Algorithm. Here's how the algorithm works: Multiply every other dig...

2 hours later…
10:42 AM
If the code works but you are looking for something better, this belongs to codereviewJeremy Thille 13 secs ago
I’m voting to close this question because it belongs on codereview.stackexchange.com — Jeremy Thille 1 min ago
Welcome to Stack Overflow. Your question stays better on codereview.stackexchange.com. — axiac 48 secs ago
11:05 AM
I’m voting to close this question because you should ask it on codereview.stackexchange.com, rather than here. — Peter O. 42 secs ago
1 hour later…
12:07 PM
Q: Array To Matrix

MoonRedditso I made a method that takes an array and converts it to a matrix given that it is a valid conversion however there are some redundant code in the beginning and I thought maybe you could help me? I am new to programming so avoid complicated imports and such. private int[][] toMatrix(int[] ar...

Q: C++ Simple equation Parser

Thomas BriggsI am relatively new to C++ coming form languages such as Java and would like tips to make my code more C++ like and doing things in the C++ way. The header file #pragma once #include <string> #include <memory> class Expression { public: std::string symbol; std::shared_ptr<Expression> le...

12:33 PM
Q: even numbers from 1 to 100 using array in c++

Korramy code is this: #include using namespace std; int main() { int i; for(i = 1; i<100; i++){ { if(i%2==0) int a[100]={i}; cout<<a[i]<<" "; } } return 0; } it gives me output error as: prog.cpp: In function ‘int main()’: prog.cpp:10:15: error: ‘a’ was not declared in this ...

12:59 PM
Q: Rstructuring of code block in Javascript

NeshInitially I have a code in JavaScript which looks like - const createUsersInfo = obj => { const studentDetails = []; const teacherDetails = []; obj.forEach(x => { if (x.type) { if ( x.type === 'teacher' && x.group !== 'admin' ) { teacherDetails.push(x); ...

Here is my try (which works) ...if it works then you don't have a problem which we can solve. You could see if your question would be on-topic at the Code Review stackexchange site, which accepts questions seeking to get a peer review of their code. codereview.stackexchange.com/help/on-topicADyson 20 secs ago
1:25 PM
Q: Applying stacking penalty rule in Daily Fantasy Football

Konstantin KostanzhogloMy program applies stacking penalty rule in Daily Fantasy Football by choosing which players to be penalized by which amount of points. The rule is about penalizing teams with two or more defensive players when the team conceded no goals. Here is the description of the rule: For the 2019/20 foot...

possible answer invalidation by eligolf on question by eligolf: codereview.stackexchange.com/posts/254875/revisions
@Lurch Posted a warning, but did not roll back the edit because it wasn't necessary.
1:51 PM
Q: .Firstpage.Rightheader command with picture does not work

QuentinI want to set a different header and footer with VBA for the first page of an Excel sheet that should be printed. The right header should contain a picture and the left header another picture. Those should only be displayed on the first page. I have tried the below code but somehow the .Firstpage...

2:17 PM
Q: Summation of large inputs

Mohammad Ali NematollahiAssume we are given \$ n \$ natural numbers, \$a_{1}, a_{2}, \dots, a_{n} \$ and we are supposed to calculate the following summation: \$ \sum_{i = 1}^{n}\sum_{j = 1}^{n} \lfloor \dfrac{a_{i}}{a_{j}} \rfloor\$. This is a question from a challenge and in only one test, I get time-limit exceeded er...

2:32 PM
For feedback on working code, please post on codereview.stackexchange.comMathias R. Jessen 41 secs ago
Probably better suited for codereview.stackexchange.com — Wyck 38 secs ago
3:10 PM
Q: Applying random luck score to a instances people

ASWIN VENUI'm trying to do a simulation on the role of luck in human achievement. Here is what I intend to do with my code: Create 20000 instances of people with randomly generated scores for skill, experience and hard-work(0 to 99), and a luck value(0 to 100). Create a total score for each person, with...

Q: How to Simplify Different but Similar Functions?

Cassie Beanabsolute newbie here. I need help with simplifying my code. I want to create many more similar functions as shown below. Is there a simpler way where I can code without having to manually type in the same function every time I want to add a new function? function toggleItem1() { var myItem1 ...

Q: Messing around with Methods

the I just recently learned how to write Methods in C#. Here is one experiment I made. It calculates addition, subtraction, division, multiplication, and the square root of a number. fill free to give me suggestions on how I can improve the code. I also do know that I need to set up a system that pre...

3:22 PM
3:32 PM
I think this is better suited for the Code Review Stack Exchange. — Adrian 13 secs ago
Q: Could not create an instance of type Gym.Session. Type is an interface or abstract class and cannot be instantiated. Path '[0].ToStringCustom

George VasilakisI deserialize a JSON object using the JSON.net library and import it into a SortableBindingList. I declare my list like that: public SortableBindingList<Session> AllSessions = new SortableBindingList<Session>(); What I am trying to do now is when the program starts, load the JSON file, deserializ...

Q: Bookmarklet for selecting code snippets on StackExchange in 2021

konijnThe following code will add to each code block on https://codereview.stackexchange.com/ or https://stackoverflow.com/ a 'Select Code' button that will select the code belonging to that block. This was originally written in 2013, I adjusted it to the new CSS and exchanged var with let, otherwise I...

what happens if you run it? Asking for a code review might be better suited on Code Reviewmike 33 secs ago
4:28 PM
Q: Temperature converter in Rust

A.D.I've just started learning myself Rust. I am practicing with the exercises from the book available on the official website. Here is my attempt at the temperature converter exercise at the end of chapter 3. Could you tell me if my approach is correct? Is there something I could have done more effi...

Q: Non-ASCII characters in an identifier [Python, PyCharm]

VinzentI'm implementing an algorithm in python which makes use of a lot of linear algebra, and after struggling for a while to come up with a way to make the code readable I ended up doing the following; Example: class StateSpaceModel: def __init__(self, A=None, B=None, C=None, D=None): self...

5:11 PM
I’m voting to close this question because it should be on codereview.stackexchange.com — Max 11 secs ago
5:47 PM
Q: Improvements for a C getline implementation

truckI wrote a function in C that reads an entire line from a stream into a dynamically allocated buffer. What would you suggest I should do to improve its performance? Also, are there any errors that could occur and are not handled? This is the code: #define ERRALLOC(ptr) ...

Q: Applying 'Uncle Bob's Clean Code' on this small exercice

HappyI'm trying to apply Uncle Bob's Clean Code practices onto this exercise I'm helping someone with. (The exercice assignment is in a "docstring" comment above the Main. I'm unsure what the best naming convention would be for ReturnAllCombinationsOfInputtedList, although I suspect it doesn't involve...

6:13 PM
Q: Create an hash table from .txt file and counting the collusions

Mustafa YılmazI have homework about hash tables. Introduction of teacher and where did I stuck in below: Insert 1000 password list into a hash table with an appropriate hash function. It would be better if the number of collusion does not exceed 200. Search a password within 1000 password list using Hash Table...

6:39 PM
Q: Command-line Tic-Tac-Toc in Rust

stephenwadeI implemented Tic-Tac-Toe in Rust to learn the language. I split the implementation into two files: game.rs contains the actual game logic, and main.rs contains the main function and the command-line UI. I'm interested in any feedback. One particular question I have: I'm interested in trying to i...

7:03 PM
The type of question makes it more appropriate for codereview.stackexchange.comKamil.S 1 min ago
I’m voting to close this question because it asks for code review — idmean 39 secs ago
possible answer invalidation by Nesh on question by Nesh: codereview.stackexchange.com/posts/254886/revisions
7:38 PM
@dankSoirst Try to post it in Code ReviewFederico Baù 37 secs ago
8:18 PM
if you do not use design patterns, there are not design patterns. SO is not the right place for asking code reviews, go to code reviews stack exchange instead — quirimmo 1 min ago
Q: Handling Circular References Without Recursion

Kittoes0124Despite the many decent answers to this question, one was unable to find an iterative solution. Here's what I came up with: Code: type CircularReferenceHandler = (parentKey: IndexKey, parentValue: Dictionary<IndexKey, any>, childKey: IndexKey, childValue: Dictionary<IndexKey, any>) => void; type ...

8:34 PM
Might be better suited towards Code Review (read their guidelines and tour!), although perhaps you mean to return your recursive call? — Sayse 53 secs ago
This is a question that belongs on codereview.stackexchange.com instead. — FluxedScript 55 secs ago
possible answer invalidation by truck on question by truck: codereview.stackexchange.com/posts/254913/revisions
2 hours later…
10:21 PM
@Edward Purchased. Thx for the rec.
@brug That's great! I hope you enjoy it.
I can't wait to build things.
I love building things.
Me too! Software is nice, but there's something very satisfying about a physical thing.
When I was a kid I used to take my toys apart and then reassemble them and see what I could make. It was pretty much limited to splicing wires and electrical tape and duct tape.
We all start somewhere.
I remember getting in trouble as a kid for diassembling things I could not reassemble.
10:24 PM
I am indiscriminate about creation. I like writing. I like building physical things. I love woodwork too. I like software.
I was lucky. I didn't get in trouble for it.
Well, unless it was someone elses.
The time I took the remote apart my parents were less than happy.
Because I ruined their remote.
But I loved taking those tiny little motors out of things.
They amazed me.
Biggest trouble was when my mother came in to see the movement from her 100-year-old antique clock completely disassembled on the kitchen table.
THAT one I fixed and redeemed myself.
It hadn't run for 20 years.
What motors are in a remote?
Ohh not the remote.
I took apart a lot of toy cars and things like that.
Small electronics.
Ah, that makes sense.
My parents might have made me stop if they knew about the time I broke my alarm clock at the plug, from ripping it out of the wall. So I spliced another two-prong plug to it and taped it together. Then I was jumping on my bed one day and they got ripped apart. They made a huge spark and a loud pop. I was a bit scared to pull the live exposed wire out of the outlet.
So you learned something and didn't get electrocuted. That's a good day in my view!
10:34 PM
@brug You're doing better than @Mast with soldering irons.
I ordered one of those too.
:) I don't think you need one for that kit.
I don't. I will find other uses for it.
@Edward When I was reading that I was preparing to press f
10:45 PM
@Edward Was the 20 years before of after you disassembled it?
The clock was old (obviously) and hadn't been cleaned or lubricated for many, many decades.
I read a couple of books and studied the mechanism and figured I could fix it.
So I was almost finished when my mother came home a bit earlier than expected.
btw Edward. I haven't been on the main site in a while but I just started coming back and I saw a few good answers from you. I like the way you have taken to incorporating the C++ Core Guidelines into your answers.
Yes, I should do more of that than I do, but I think it helps.
@Edward If it magically started working again wouldn't she have wondered?
@pacmaninbw I'd likely have casually suggested that I might have added a few drops of oil.
10:52 PM
What is the oldest car engine you have worked on?
A '32 Model A.
Very simple, very easy to work on.
The only engine I've ever worked on was a Chevy 350 4 bolt main.
We used them in the trucks in my fathers business.
Q: how to optimize this pattern

horcle_buzzI have the following pattern showing up several times in my code, where I need to convert a pandas dataframe to named tuples for processing later. A profiling of my code shows that the majority of time is spent here. Of note, the number of docs is ~4.9 K and the size of each list, c is about ~2K,...

Q: Can you help me optimize this code that calculates a Simple Moving Average?

Grim87The below function takes in a dataframe consisting of an excel sheet with the Price column. It works correctly however it looks unnecessarily long for something quite simple. Basically calculating a Simple Moving Average based on Price : SMA = Sum of all prices in a period/period def SimpleMA(Tim...

Q: Vega lite plot rendering with Yew (rust + wasm)

villasvI wanted to render some Vega plots in a rust+wasm web application I've been building with Yew. I'm a bit new to Rust, so I'm looking for feedback on runtime safety and stylistic issues. I was specially skeptical of the spawn_local I copied from someone's GitHub and the amount of unwraps thrown ar...

11:18 PM

« first day (2816 days earlier)      last day (39 days later) »