« first day (1491 days earlier)      last day (2822 days later) » 

00:00
RELOAD! There are 3927 unanswered questions (91.2034% answered)
00:15
0
Q: Variant optional to return error string or value

Stephen EckelsI needed a class with more information than optionals give, I need to know why the optional is not valid in error states. I used a Boost variant for this. Since this will be wrapping almost all of my return values, I need to know if it's as fast as possible (i.e. did I do move semantics and all t...

00:29
0
Q: Union-Find in C++

user140319A few days ago I start learning C++. This code is a simple Union-Find data structure. Questions: Why can't I use const union_find<T> &uf instead of union_find<T> &uf? Is it possible to replace union_find<T> with something like self<T> (self refers to current class)? Did I use references instea...

00:43
0
Q: Why is my insertion sort slower than bubble sort

TobiArray.prototype.insertionSort = function(){ for (var i=1, s,temp; i<this.length; i++){ temp = this[s=i]; while (s&&temp<this[s-1]) this[s] = this[--s]; this[s] = temp; } return this } Array.prototype.bubbleSort = function(){ var swapped = true; w...

01:13
@Andrea Deak Thank you so much for putting so much thought in your answer! You are an asset to this community. Your code seems to work great but it is slower than the vectorized version I made from Jaime's non-scipy answer. Since a close approximation is good enough and faster to compute i will use that instead. I posted my clumsy code on Code Review asking for help improving its performance. Your input would be greatly valued! — Fnord 52 secs ago
I'm voting to close this question as off-topic because it is asking for a code review - ask on Code ReviewDaniel A. White 54 secs ago
0
Q: Calculate the closest point to many hyperbolic paraboloids

FnordIn this question I asked for a way to compute the closest projected point to a hyperbolic paraboloid using python. Using the iterative approximation answer, I'm able to use the code below to calculate the closest point to multiple paraboloids. import numpy as np np.set_printoptions(suppress=Tru...

0
Q: I think my code is in a infinite loop. Code print combinations of air traffic control

Igor BragaMy code basically takes an int n that represents the number of flights, and then its destination given by 3 letter ABC, followed by the ETA in minutes, number of passangers to destination and number of passagengers on the way back. In my code I have to analyse all possible permutations between ...

02:03
monking
03:04
@Hosch250 Interesting. I wonder what kind of temperatures are produced by that reaction.
03:57
-1
Q: Shelllinthebox on domain - getting proxy error

RohitI am trying to put shell in the box on my domain but I get a proxy error. Error - Proxy Error The proxy server received an invalid response from an upstream server. The proxy server could not handle the request GET /shell. Reason: Error reading from remote server How do I solve. I am a noob at...

04:17
-3
Q: This is part of a code to enter the marks of some students for 3 subjects and to find the highest marks scored and the highest scorer

Susan/* (ii) for loop to list out the student's roll numbers who have secured the highest marks in each subject */ /* roll number who secured the highest marks */ for (j = 0; j < 3; j++) { max = 0; for (i = 0; i < n; i++) { if (max < st[i].sub[j]) { max = st[i...

These types of questions are better asked on the code review stackexchange :) — Keith M 45 secs ago
Welcome to Stackoverflow, Stackoverflow is one question and answer site in a network called stackexchange. There is another one called code review that's for questions about improvements on code. Stackoverflow is primarily intended for questions about programming errors and code that's not working :) codereview.stackexchange.comKeith M 29 secs ago
04:44
I'm voting to close this question as off-topic because it belongs on codereview.stackexchange.comAndreas 19 secs ago
 
2 hours later…
06:37
0
Q: A simple regex based lexer

Christian DeanRecently I've been interested in language design and text processing. And a common program needed in both of those fields is a lexer. And since I found myself writing a new, slightly different lexer for each project I was working on, I deiced I'd make a simple regex based lexer instead. I design...

 
1 hour later…
07:55
possible answer invalidation by Coal_ on question by Coal_: codereview.stackexchange.com/posts/164816/revisions
08:20
possible answer invalidation by Coal_ on question by Coal_: codereview.stackexchange.com/posts/164816/revisions
08:57
0
Q: read csv files and find the same values on the specific columns

Gujarat SantanaI created simple command line application to read csv files on specific folder and finding the same values on the specify column which exist on all files. Source Code Here is the snippet code which is the core of the logic : func csvReader(inputColumn, fileLocation string) { startTime := ...

09:10
My Factorio mod has reached 100 downloads!
 
2 hours later…
10:53
0
Q: Finding phrase in specified files v2 c++

Filip MirosławPlease provide constructive feedback so I can learn from my mistakes. Please tell me what I did right and where I came up with very good solution and where I should improve. Here is the code (Please pardon some indentation, formatting errors): #include <iostream> #include <string> #include <fstream

11:25
0
Q: get ProductFilters in hierarchy table

work questionI have two tables : Category and ProductFilter. Category table is hierarchy and I have depth in each row like it start at 1. Categories in level two have List<ProductFilter>. user clicked on category and I want to get ProductFilter to do this I have two code . which one is better : 1- var cat...

12:11
0
Q: Does my enqueue method look correct? (Javascript) Or am I missing something. Keep in mind I'm a newb

LoopyFootQueue.prototype.enqueue= function(data){ just a node that takes data and has prev and next props var newNode= new Node(data) empty queue case or do I do something with tail too? if(this.head===null){ this.tail= newNode newNode.prev= this.head this.head= this.tail return ...

12:26
0
Q: The real std::apply

IncomputableMotivation: std::apply takes single tuple like argument and unpacks the tuple into the function call. The limitation is that one has to know if the argument is tuple like or not, which makes its use cases severed. I found a way to solve the problem having 100% backwards compatibility (at least...

 
1 hour later…
13:33
1
Q: Is my use of pointers and references correct? (linked list)

HelloImJonI am trying to solve the travelling salesman problem. This function creates the first level in the form of a linked list. This is what the levels look like and this is the code that creates it: vector<pot> noviNivo; int tempInt = vozliscaG - 1; pot *head=NULL; pot *tail=NULL; ...

I'm voting to close this question as off-topic because it is asking for a code review (and this thus too broad / opinion based). It could probably be adjusted to be on topic for the code review stackexchange. — Quentin just now
0
Q: N-dim Barnes-Hut algorithm for data vizualization

AnkheI've recently written an implementation of Barnes-Hut Tree algorithm for n-dimensions. All python implementations I've found were working for 2 dimensions, while I needed on working for 3... So, while I might've just written one for 3 dimensions only, I've decided to write one that works for all ...

14:04
0
Q: How to sort array by divisor sum faster?

TimʘteiI am sorting an array by divisor sum in ascending order. If two or more numbers have the same sum of divisors they have to be sorted in ascending order. The problem I have is that my version is not fast enough. Here is my code: int divisorSum( double number ) { double sum = number + 1; f...

14:18
0
Q: Java code to find greatest number of one's in binary code.

Dhanasri DhanaWhich code is used for finding greatest number of one's in a binary code like eg:00101110011? Can Any one do it? If u can then plzzz tell me the code...

14:38
0
Q: How to find if a number is equal to it's sum of divisors faster?

TimʘteiA number is perfect if it is equal to the sum of all it's divisors smaller than it. For example divisors of 6 are 1, 2, 3. I want to read an array of numbers and for each number to print 1 if it is perfect and 0 if it's not perfect. Numbers are smaller than 10 ^ 19. How would I do it faster? My v...

14:52
0
Q: MVC structured REST API in PHP

Arslan.HThis approach might be wrong or right, if you have something to add please correct me since i want to learn! The past few weeks I'v been trying to build a MVC structure REST API in PHP.And this is my way of understanding how it works: So the User talks to the app thorough the Router. Accordin...

 
1 hour later…
15:52
-3
Q: Which Version of the Code Is Faster?

C plus equals 2This one: void functionOne(char input[], int data[]) { int index = 0; int val = 0; int inputIndex = 0; while (index < 10) { switch (input[inputIndex++]) { case '1': { val += 1; } case '2': { val += 2; } case ...

16:03
So what happens when you start having hundreds of rules ? Are you looking for code review ? — eliasah 58 secs ago
16:45
Don't use else after an error return. See Indent Error Flow, Go Code Review Comments. Write: f, err := p["price"].Float64(); if err != nil { return 0, err }; sum += f;. — peterSO 36 secs ago
0
Q: Does Performing Operations on a Temporary Variable Instead of On an Array Directly Lead to Faster Code Being Generated

C plus equals 2I am wondering whether it is more efficient to create a temporary variable, perform operations on the variable, and put the final value of the variable in a position of an array, or directly modify a position of an array. I am using Visual Studio 2015's compiler. The code I posted is a simplified...

17:08
Monking
17:22
0
Q: android emulator crashing due to problem with code.

GabrielI´m using Android Studio 2, and following the book "Learning Java by Building Android Games", the problem is at activity_game xml page, there´s a bug in answers buttons, when i click one of the three buttons to give the answer, the app crashes. I am emulating the android 5.1 (API 22). I don´t p...

17:36
0
Q: Adding columns in Spark dataframe based on rules

Varun ChadhaI have a dataframe df, which contains below data: **customers** **product** **Val_id** 1 A 1 2 B X 3 C 4 D Z i have been provided 2 rules, which are as below: **rule...

18:06
0
Q: Read date from a file and rename two files using the date

RaystafarianProblem I have image files that are RAW data and have the extension .NEF Whatever edits I make to these files produces what is called a sidecar file with the extension .xmp Given there are many photos and the photo numbering in the camera can only go up to 9999, there is a possibility that I ma...

18:36
Are you just asking for a code review? — melpomene 53 secs ago
0
Q: Can't link imagemagick on homebrew

memoI can't link imagemagick (Mac OS X) $ brew link -f imagemagick Linking /usr/local/Cellar/imagemagick/7.0.5-9... Error: Could not symlink include/ImageMagick-7/Magick++/Blob.h /usr/local/include/ImageMagick-7/Magick++ is not writable. but Magick++ seems writable when i go to the directory and ...

18:51
@CaptainObvious ????
0
Q: Finding number of divisors faster

Koshere is my code: triangle_numbers = [] number = 0 for i in range(0, 10000): number = number+i triangle_numbers.append(number) for number in triangle_numbers: number_of_divisors = 1 for i in range(1, int(number/2)+1): if number % i == 0: number_of_divisors = n...

1
Q: Parsing Title from any given website

SMth80I've created a very small script in vba to parse Title from almost any website. I've checked it with few websites and it is providing with the accurate results. I used split function on responsetext to achieve the result. Websites should be placed in column A and the results will be displayed in ...

19:36
Huh, what do you think about this statement?
arr[i] = i++;
20:08
0
Q: Commander Lamda Asks

user140363Problem Commander Lambda is all about efficiency, including using her bunny prisoners for manual labor. But no one's been properly monitoring the labor shifts for a while, and they've gotten quite mixed up. You've been given the task of fixing them, but after you wrote up new shifts, you realize...

@skiwi What about it?
This might get better answers on Code Review. You can flag your question and request migration. — Michael Kjörling 5 secs ago
20:29
1
Q: Fibonacci series-A different way (C++)

JittinI am a C++ student (1.5 months into it). Please give feedback to this different way I have thought of for Fibonacci series. If there are any improvements needed,please suggest them also. #include<iostream> using namespace std; void fibseries(long int n) { double x=0;double y=1; for (lon...

0
Q: Calculate prices of different days? How do I shorten Mon/Wed-Sat so the code isn't repeated?

Lavan Walter Smith S Children are admitted free on Sundays, and pay only $6 each, any other day Adults admission is $12 any day, except on Tuesdays, when it is only $8 Monday, Wednesday, Thursday, Friday, Saturday are same prices. include include using namespace std; int main() { int Children, Adults, ticke...

20:42
0
Q: Value semantic type eraser

BrentI've been using std::unique_ptr for cases where I want to store a derived-type value with type erasure, and felt that unique_ptr being nullable was an undesirable degree of freedom. From https://codereview.stackexchange.com/a/54954/62314 I understand Adobe poly and boost probably have similar fea...

0
Q: Combination of decimal and binary numbers using Dynamic Programming

yadav_viI was solving this problem on HackerRank and managed to make a working implementation. The question in brief can be described as follows - A binary implementation of a number - say 21 - is - 10101. The decbinary of the number 21 are [69, 149, 157, ....., 10021, 10101]. The decbinary ...

@skiwi Depends on the context. If that's all going on in that particular function, sure, go for it.
It usually goes wrong if you add more operations reading/modifying i near it.
21:16
@skiwi That is undefined behaviour (assuming that you are talking about C). See for example stackoverflow.com/questions/12203704/….
0
Q: FRP: Processing task lists

APlessnerI recently heard about functional reactive programming and thought it was rather interesting. Therefore, I started out with writing a simple program which processes a list of tasks. (In this example, the "tasks" are just some strings which need to be printed) So because I have no idea how to do...

@MartinR In C, yes. In C++ this is perfectly legal though, right?
C++ has fairly strict rules about pre-increment and post-increment IIRC.
@Mast: I think it is the same in C and C++ (and the referenced Q&A is about C++)
But from stackoverflow.com/a/44348568/1187415: "Note that this will change in C++17 ..."
21:32
@MartinR I don't understand how it would be undefined in C++.
@MartinR I actually got it from a different SO question :P
I just was thinking about it again and thought about how undefined arr[i] += i++; would be
@Mast If I understand it correctly, it is not guaranteed that the address of the LHS a[i] is evaluated before incrementing i. Here is another explanation: stackoverflow.com/a/367690/1187415.
@MartinR To the best of my knowledge, i++ increments after using while ++i increments before using. So it should be perfectly well defined.
Are you sure. That looks well defined. — Loki Astari Dec 15 '08 at 7:10
@LokiAstari I'm pretty sure you can tell us once and for all whether it's wrong or not.
5
There appears to be a difference between unspecified and undefined.
Loki changed his mind and later left this comment in the same thread:
OK. After reading n2521 Section 5.2.6 I think I have it. See me answer below. — Loki Astari Dec 15 '08 at 8:46
I've read the answer.
I'm not sure I parsed it correctly though.
21:47
0
Q: Scraping table data from websites

SMth80I've written a script in vba to parse table from any website if the html elements are not encrypted in javascript. There is a table index in my script in which inputting the right number it is possible to parse any preferable table. Any input on this will be highly appreciated. Sub TableData() D...

I'm pretty sure I've abused the difference between postfix and prefix before. If that was all based on UB...
It could also be well-defined for the compiler you're using and the test suite you have and the behavior you are experiencing, yet undefined behavior because the specs don't say so
Referencing uninitialized memory on the other hand is by definition undefined behavior
Of-course, there's also the matter of compiler optimizations. Who knows what the actual result is.
@Mast: Another Q&A about this issue: stackoverflow.com/questions/4176328/…. The case a[i] = i++ is explained at the end of stackoverflow.com/a/4176333/1187415.
Roughly speaking (as I understand it): Using both i and i++ in the same statement is UB.
22:12
@MartinR Looks like the problem I assumed being solved by differentiating between postfix and prefix isn't actually solved and therefore undefined. Yikes.
1
Q: Need to increase speed of image creation

wolf53135I'm trying to create an image with every possible color. It would start with a seed pixel and then place randomly-generated RGB pixels around it. Future placements would be based on whichever open spot had the average of the pixels surrounding it closest to the new color to be placed. from PIL i...

If your code work, it has nothing to do here, you should post it in codereview.stackexchange.com. — Stargateur 42 secs ago
22:47
Monking
My bounty expired before I got any new answers :|
23:18
0
Q: Given a date and a duration, calculate the future date

Jeniffer PanThe question is basically like this: Given year, month, day and duration, calculate the future date based on given data and duration. The given date guarantees to be after 1900-01-01, and the duration k is between [0, 10000]. For example: Input: 2016 10 1 100(meaning given 2016-10-1, what is the...


« first day (1491 days earlier)      last day (2822 days later) »