« first day (259 days earlier)      last day (3765 days later) » 

12:00 AM
0
Q: Ruby and cyclomatic complexity

Matthew ScharleyI'm currently writing a script and I decided to run cane over it to look for some issues, and the following method was highlighted. I've done my best to cut it back, and at this point I'm inclined to leave it as-is, however cane is still giving it a pretty high rating of 23 (15 is the point it st...

 
We can vote again!
 
Huzzah!
 
I had the same thought as @ChrisW.
… to ensure that the structure is packed without gaps.
 
Now givz my question votez:
4
Q: Recording audio in C

syb0rgThis is a program I wrote as a .wav audio recording library for Linux. It was developed on a Raspberry Pi, so that may affect the dependencies required.(1) Here is the header file (wav.h): #include <stdint.h> typedef struct { char RIFF_marker[4]; uint32_t file_size; char filetyp...

@200_success "Define the structure appropriately so that it is intrinsically packed. This is hard to do and requires an understanding of how the compiler behaves with respect to alignment on the target machine. Also it is hard to maintain."
 
you have 9400 rep dont break it man
 
12:05 AM
@200_success I don't have enough experience to do that myself yet.
 
@syb0rg It may be packable: the fields are aligned on 2-byte and 4-byte boundaries. Use something like stackoverflow.com/questions/807244/… to verify (i.e. to assert) that the sizeof(WaveHeader) is the size you expect (7 4-byte fields and 4 2-byte fields =) 36 bytes
 
@ChrisW @200_success Sounds good. Is this going to be a part of your guy's answers?
 
Now is too late at night, for me to answer.
 
12:26 AM
Meant to write a quick review since i'm (theoretically) working, but I think i got a bit carried away
0
A: Recording audio in C

CorbinA few things jump out at me immediately: Use sizeof whenever you need the size of something with non-dynamic allocation. In other words, all of your write calls on the WaveHeader struct members should be using sizeof, not hard coded sizes. Allocation and initialization should be separate concer...

 
@Corbin Looks nice, I'm going to make some quick formatting edits.
 
go for it
I'm pretty lazy with my formatting :)
 
Mostly minor stuff like adding spaced in between bullet points.
For some reason that makes a difference.
 
Ah, I should probably switch to horizontal lines instead of bullet points. I used bullet points because I originally thought it would only be 4 or 5 things
 
@Corbin I'll make that change.
Unless you want to.
 
12:29 AM
Go for it if you want. I hate formatting :)
 
gtg bye
 
Cya.
You should up-vote the answers on my question before you go!
 
0
Q: Improvements/suggestions for my CPU emulator

Lee AllanI am trying to emulate a basic CPU (Z80) as close as possible, currently it does not read real assembly code but that will be implemented so if you have any views on how that could be implemented I'd really appreciate. Instead of reading real assembly code I made up a simpler version with the kno...

 
@syb0rg It says on the page, you can ensure struct packing in one of two ways:
 
Gonna review that when I get a chance too :D
 
12:36 AM
a) Know how the compiler lays out the fields
b) Use __attribute__(packed) to force it to do what you mean.
So, it ought to work. Try including just your header, write a small program that prints sizeof(WavHeader) to verify that it's the right size.
 
@200_success I mean experience to know to do that.
 
(it's worth noting that both a and b are compiler-dependent)
 
@Corbin How does it look?
 
much better :)
 
I thought that formatting scheme would fit better than the horizontal rules.
 
12:40 AM
@Corbin True that it's compiler dependent. But on Linux, you probably only care about gcc and clang, both of which support that extension.
9
Q: pragma pack(1) nor __attribute__ ((aligned (1))) works

neoneyeMy code used to work in the past, but now the struct size suddenly is 16 bytes. It used to be 13 bytes. I recently upgraded from Xcode 4.2 to Xcode 4.3.1 (4E1019). #pragma pack(1) struct ChunkStruct { uint32_t width; uint32_t height; uint8_t bit_depth; uint8_t color_type; uin...

 
@syb0rg: Your question is on the front page of the (extended) hot questions list, and perhaps it may rise up.
 
@Jamal Good. More CR publicity.
 
Yeah... I'm just wary of forcing a packed struct. It's fine when it's naturally aligned like it happens to be now (actually WAV might've planned that), but it's a dangerous road to go down in general.
Maybe I'm just being picky and pedantic though since syb0rg is likely already aware of the drawbacks
 
I'm not sure @retailcoder has voted on them yet.
Maybe he has, who know.
 
What was your intention with retrieveWAVHeader() anyway?
 
12:42 AM
I've already napalm'd.
 
@Jamal Thanks.
@200_success That is where this ties in:
5
Q: WAVE to FLAC encoder in C

syb0rgThis is a .wav to .flac encoder that I wrote a little while ago. The only method that is really called is encode(), which takes in a .wav file, converts it to FLAC, and stores it in the .flac file that is taken in as a parameter. I would prefer suggestions on how to improve the method, decrease...

 
I might want to add, the WAV header is designed for alignment along 32-bit boundaries.
 
@200_success It looks like I discontinued that method for some reason. I might need to add it back in at some point...
 
You could alternatively treat the char[4] fields as uint32_t magic numbers.
… but with endianness issues.
 
@200_success I'd like to avoid those if possible.
 
12:46 AM
Fair enough. I'm just saying that it has a strong chance of working.
 
@200_success what did you think of the memcpy for the strings into the char[4]? I saw you said to use a static struct as a template (which is probably the best way), but I'm curious if you'd prefer blah = memcpy(...) or blah = {'b', 'l', 'a', 'h'}. The memcpy struct me as odd, but I couldn't think of a pleasant way around it
 
Dunno. Like I said, I'd just memcpy() the whole struct at once.
 
Ah :)
 
I heard to use memmove instead of memcpy somewhere.
I think I read that in the C book I bought recently.
Haven't gotten far enough to figure out why though.
 
memmove is basically the exact same as memcpy except source and dest can overlap
 
12:51 AM
memmove() is just memcpy() that safely handles overlap. That's not going to happen in this case.
 
that added functionality makes memmove slower though, so prefer memcpy when you're sure source and destination are disjoint
 
It would be really awesome to have that question at the top of the hot questions list. @rolfl @retailcoder @Malachi , have you guys napalmed it yet?
 
@syb0rg yeah I already voted on everything earlier today
 
@syb0rg yup.
 
What do you think of the Welcome Intermediate Users query now?
 
1:01 AM
order by latest vote? that's awesome! :D
 
Not just that, but sort by the latest vote on any of the user's answers.
 
Very nice.
 
Very nice indeed. I'd add a tag parameter to filter, and a link to the users' profiles. Or is that intrusive?
 
I left off the user link on purpose, to discourage ad-hominem voting. However, when you see a cluster of the same User Rep scores in the right column, that's a hint that they're all answer from the same user.
As for tags, I want to encourage browsing and scrolling down the list for some serendipity.
 
> "I left off the user link on purpose, to discourage ad-hominem voting."
good call
lol
I mean I agree, I lol'd at how many edits it took me to get the quote thing right.
came across this answer:
2
A: Enum Design Pattern

canahariIn a case like this, you could consider writing classes to implement the functions you want your GUI to do. One per enum member, with a base class. Then you could do: GuiStateObject myState; in your GUI class; switch state any time you want with myState=new EasyGuiState(); and do th...

+1 for answering a CR question on your phone!! — retailcoder 1 min ago
well the question was migrated from SO, ...and that answer was posted on SO. Oh, well.
@200_success I like that you have Users.LastAccessDate in your order by
 
1:59 AM
0
Q: friend mapper on mobiles android application

praveenHow to create a java codings for friend mapper on mobiles? i've create the codings for getting the friend address for various location. but now how can i create the java codings for facebook friend tracking?.

 
2:09 AM
My question is almost on the upper part of the Hot Network Questions list!
 
I guess it'll need more votes.
 
It's getting views, but not attracting up-votes for some reason.
 
It might just take some time. I suppose most people just bother to look towards the very top.
 
One more napalm strike and it would be on the upper part.
 
2:42 AM
0
Q: Can this algorithm to print numbers in lexicographic order be improved?

KeithSmithI saw this problem posted as an interview question asked at Bloomberg. #!/usr/bin/env python import sys import traceback def printlexnum(i, tens, number): lexnum = i*tens for j in range(lexnum,min(number+1,lexnum+tens)): print j if number>=lexnum: printlexnum(i, tens...

 
Blerh. Doesn't seem like a Friday.
 
Same here. Not quite sure why.
 
3:02 AM
Maybe the first week of class threw me off. Doesn't quite feel like school has started back, but doesn't quite feel like Christmas break.... lol
 
It did seem like a slow week to me.
 
Yeah.... The first week is always slow. I hate it. It's the strange ramp up period before any of the classes are actually doing anything, but I still have to wake up early :(
 
I still have much math homework to do this weekend.
 
Ah. That sucks. At least there's no class Monday I suppose
 
Yup. Three-day weekend.
 
3:20 AM
0
Q: Framework Design Review, making use of generics

Bruno CostaFirst and foremost I found this would be a better place to post this type of question rather then StackOverflow since it's about code modeling. In my framework development I came across a situation where I have a generic class however I don't know the concrete type that the generic would take at...

-1
Q: Help With Batch Startup

Coder11Is there a way to make a batch file add its self to start up while its in a folder. I want it to set in with all users to. I have tried many lines of code but I get an error saying it cannot find the file destination. Any help?

 
3:39 AM
1
Q: Framework Design Review, making use of generics

Bruno CostaFirst and foremost I found this would be a better place to post this type of question rather then StackOverflow since it's about code modeling. In my framework development I came across a situation where I have a generic class however I don't know the concrete type that the generic would take at...

^^ @Jamal what do you think?
 
It looks off-topic.
 
That's also my feeling. But closing this question is taking a firm stand, about the way CR should handle high-level overviews. This is a very nicely put question that must be migrated wherever it belongs, if it's off-topic.
 
Perhaps DB.SE?
 
IDK, it's about the code too, but it's more about the high-level architecture. I say Programmers.SE.
 
I'll go find out.
 
3:50 AM
@Jamal actually as it is, we can put it on hold because there's not enough code to review; he's asking feedback on code that's not in the post, too.
 
That's fine. It can always be migrated later if needed.
 
+1 but this question appears to be off-topic because questions must include the code you want reviewed. As it stands, there's only 1 method that's reviewable. Post your classes, don't just talk about 'em ;) — retailcoder 10 secs ago
@Jamal I would have refused that edit as too minor :p
 
Perhaps, but we are exempt from that. :-)
 
0
Q: Elixer Pipes and anonmous Funtions

OxinaboxI recently got started with Elixir, I'm used to F#'s pipes, and Seq.map and LINQ's .Select statements, Things are different in Elixir, and the code I have seems very ugly. Anon functions in anon functions. defrecord FileData, name: "", date: nil def filedetails() do files = File.ls! d...

 
With great power...
 
3:59 AM
...comes great edits. -Jamal
 
lol
 
lol
 
Jinx!
 
totally
 
@retailcoder: Is it Elixer or Elixir? The former is not a tag on SO.
 
4:03 AM
@Jamal it's Excalibur
 
Retagging. ;-)
 
I didn't know the latter was a tag on SO.
ah, now I know what it is!
 
It is, but the OP uses both names. The former is also a new tag and is awaiting review. I'm tempted to kill it and create the correct tag.
 
if both refer to the same thing, why not just synonimize?
 
The other tag would have to be created first.
 
4:07 AM
Oh, yes... Of course!
 
We're in luck!
1
Q: Roman numeral kata in Elixir

NhuI'm new to Elixir so I'm doing a roman numeral kata which converts a decimal number into roman numeral to learn the syntax. I would appreciate any feedback you have. Thank you :) defmodule RomanNumeral do @decimal_roman_numerals [[5, 'V'], [4, 'IV'], [1, 'I']] def converts(number) do ...

Now, I'm guessing Elixir should be the master.
 
Come to think about it, is probably a typo.
elixer
A drink that has been tainted by a roofie
Try this "elixer" itll knock your socks off...
lol a French link, didn't notice.
 
I had a feeling.
 
tonight was gonna be a good good night?
 
Yeah, this is why we need more SO people who know this stuff. Anyway, that tag can be killed and replaced.
 
4:19 AM
done
1
Q: Elixir pipes and anonymous functions

OxinaboxI recently got started with Elixir. I'm used to F#'s pipes, and Seq.map and LINQ's .Select statements. Things are different in Elixir, and the code I have seems very ugly. Anon functions in anon functions. defrecord FileData, name: "", date: nil def filedetails() do files = File.ls! ...

 
And perhaps we can just use SO's wiki.
 
done
(there was no "comment" where I could enter "copied from SO's")
 
Well, that was fun.
 
yeah, I see how you get high on that shit. was nice :)
 
We must pursue the Elixir of Life!
 
4:25 AM
lol
I mean, you just held my hand into editing the title and retagging the question myself. Did you use the Force on me?
 
Yes, and good I've used it for! Fun, was that?
 
Yup. Asked 31 mins ago is ok. I think > 30 days we should hold back, but doing that for recent posts should be actively encouraged.
 
Also, you did get +4 rep. I would've gotten zip.
 
Hey I'm back to a _score.ToString().EndsWith("5"), and I didn't even have to downvote anyone! :D
 
Um... yay? :-P
 
4:32 AM
OCD
(@Malachi says COD)
 
I do prefer COD. Both the game and the fish.
 
Call of Duty
CDO
 
lol
if (_i.NeedToSleep())
{
    if (_i.GetSomeSleep())
   {
        _i.DreamInCodez();
    }
    else
    {
        _i.Zombify();
    }
}
2
 
I only got about five hours of it last night. I'm not sure why I stayed up so late.
 
@Jamal I did a bit of editing just now to the wiki.
 
4:40 AM
I'm dead out. Good night!
 
@syb0rg: Okay. I'll let others review it.
 
Good night @retailcoder
You probably won't see me for a while!
 
Goodnight!
 
@syb0rg remember this 'cause you won't see it again for a while then:
:p coming at you!
I need another 120 to beat you for the year. That's 3 days if you blackout this long.
 
@retailcoder I'll be gone for roughly a week and a half.
I'll still try to get on and vote for stuff though.
 
4:44 AM
cool!
 
^^^ Wishful thinking.
 
lol
visited 183 days, 98 consecutive
 
Ohh, so close!
 
You can do it!
 
I know! It's been so hard, I'm exhausted! A journey!
</sarcasm>
 
4:48 AM
63 more days, and I'll reach one consecutive year.
 
53 days for me!
If I can stay on during this trip of mine...
 
2013-04-04. I don't feel like computing the DATEDIFF.
 
@syb0rg I think "closely modelled on lambda" should be "closely modeled on lambda", but I can't edit (@StackExchange doesn't trust me for another 375 points), so I've skipped.
 
#typingtoofast
 
4:55 AM
I think you can edit your suggested edit while it's pending review
 
I got it.
 
Now my CR rep in nice and round :)
 
@syb0rg: Five more rep to the next privilege.
 
mine has been ending in 4/9 for like 3 months now, and it drives me insane :(
 
Downvote coming! :D JK.
 
5:01 AM
:(
 
Nah, I'll see if I can find something I can vote for.
 
what's horrible, is that I'm far more likely to downvote someone's answer when I'm on a non-5 rep. When I'm on a 5 multiple, I have to reaaaaallllly have issues with an answer to DV it haha.
 
I prefer even numbers, so I wouldn't want a 5.
 
well, my idea is a multiple of 1000, but.... yeah....
 
5:13 AM
Pushing the limits of Fibonacci calculation:
8
A: Fibonacci sequence in C

syb0rgWhat you did well on: Your program is easy to read. You are allocating memory. You prepare for some corner cases. Things you could improve: You are returning 0 when your program runs into a problem (except in one spot where there are too many parameters being entered). return 0; 0 is t...

Just made an edit so that I can calculate numbers 8589934562 times larger than before.
 
@syb0rg: It looks like your audio question went up the list a bit.
 
@Jamal I know. Unfortunately it's not generating votes on the answers like I hoped it would.
 
5:29 AM
Hrmm, I wonder if it's showing up in the SO sidebar yet. That's when views/votes really take off. Although it seems like things that take off in the SO sidebar always have oddly intriguing titles.
 
@Corbin It has. It's on the upper part of the Hot Network Questions.
The views have taken off, but not the votes.
 
Ah. Maybe it's just a Friday night :)
 
Maybe.
Also, if you do get to 10 upvotes, I'll probably give the accept to you so you can have a shiny silver badge.
 
Hmmm 15 views/vote isn't too bad considering external traffic probably doesn't have an account on CR.
there's a badge for an accept on a question with >= 10 points?
didn't know that
and give the accept to whomever you think deserves it :)
 
@Corbin If you were the first to answer, your answer is accepted, and you have a score of 10 or more, you get the "Enlightened" badge.
 
5:34 AM
Ah... hrmmm... interesting.
So many badges. I can't keep track of what they all are :)
Ooo nifty, I've apparently gotten it 6 times on SO
Oh, and I've gotten it twice on CR. Do not remember getting that... lol
 
5:52 AM
Goodbye all!
I'll won't see you guys for a while!
 
Bye!
 
6:08 AM
Cya, syb0rg!
 
7:02 AM
@retailcoder that should be pinned
 
7:48 AM
0
Q: BMR program in C++

OrbitI am working on a simple program that calculates the BMR of either a man or a woman. I am writing it in C++ and compiling it (if it matters) with MinGW in Codeblocks under Windows 7 64-bit. The program asks the user whether they are male (m) or female (f) and then their weight, height and age. Th...

0
Q: Merging the results of two functions

Pedram BehrooziI have a class which extends another class and override one of its parent methods. See code below: class parentClass { public function methodA() { if (some_condition) return Array(); else return true; } } class myClass extends parentClass { pu...

 
 
1 hour later…
8:58 AM
0
Q: Code which to wake my app every day at 2pm and sense the location. But my service doesn't start at all. What am i missing?

Abbypublic class MyService extends Service implements LocationListener { private final Context mContext; boolean isGPSEnabled = false; boolean canGetLocation = false; Location location; // location double latitude; // latitude double longitude; // longitude // The minimum distance to change Updates...

 
9:35 AM
0
Q: Lesser load for my app

AdorableVBI don't know where to properly asked this question in the Stackexchange site. So I will ask it here. Let me know if this question is off topic and I will move it to what Stackexchange site it should properly be. I have an application (VB.NET), that is almost complete, and I want to know what s...

 
 
1 hour later…
10:37 AM
0
Q: Find all permutations of a string in C++

barak manosI need a review of the following code for finding all permutations of a string in C++: List Permute(String string) { if (string.length == 0) return EmptyStrings(1); List prevList = Permute(SubString(string,1,string.length)); List nextList = EmptyStrings(string.length*prevList...

 
11:22 AM
This answer deserves more up-votes: codereview.stackexchange.com/questions/3423/…
 
11:35 AM
^ So it does. But it's from 2011 and Jim Reed hasn't been seen since 2012: so why bother?
 
@ChrisW Hoping that he might come back? :)
 
He hasn't been seen on SO either. If you found that question using Data Explorer, looking for answerers to upvote, you might like to filter on 'active' (present-day) users somehow.
 
Nope, I found it through "Related" on the right hand side when looking at another question :)
 
12:10 PM
Well it is a helpful answer, so +1. I haven't trawled through old Q&As; except this one which was funny ("Can't tell if trolling...or just addicted to lambdas" posted over the Christmas holidays)
 
 
3 hours later…
3:28 PM
0
Q: Python Google Chrome bookmark deduplication script

JonSomeone wrote me this script to help me process the duplicates out of my bookmarks, but it lacked a feature that I needed, so I decided to add it myself. I don't really know python, so I'd appreciate feedback, both toward helping me improve python and toward making the script correct, though I'm...

 
 
1 hour later…
4:54 PM
0
Q: Alternative algorithm to solve maxMirror problem of Codingbat

PhoenixI request you to provide insightful suggestions to improve the following code as well as an alternative algorithm to solve it. Problem Specification: We'll say that a "mirror" section in an array is a group of contiguous elements such that somewhere in the array, the same group appears in rever...

 
 
2 hours later…
6:52 PM
0
Q: Node.js equivalent of cat -n or nl

Ray ToalTo add line numbers to a file (via stdin to stdout) we can use cat -n or nl. So given the file test.txt with: hello hello bye We can do $ cat -n < test.txt 1 hello 2 hello 3 bye In languages like AWK, Perl, and Ruby, we often get built-in constructs to process files line...

 
 
2 hours later…
8:25 PM
0
Q: Number of prime numbers between 1 and n in javascript

KingKongFrogI came up with following solution to find the number of prime numbers from 1 to n. Wondering if there is a more optimal way. var max = 10; var compositeNumbers = {}; mainLoop: for (var i=2; i<= max;i++) { smallLoop: for (var j=2; j<=Math.ceil(Math.sqrt(i));j++) { if (i % j == 0)...

 
8:56 PM
0
Q: Reading input from the console in F#

RadixeoIn the process of learning F# I wrote this code that reads lines of input from the console and stores them in a list. As far as I can tell the code works correctly, but since I'm new to functional programming I'm not sure if it is written as well as it could have been. Should I have read charact...

0
Q: Find the median of sorted equal sized arrays

JavaDeveloperLooking for code review, clever optimizations, adherence to best practices. etc. /** * Complexity: * O (logn) * * @author javadeveloper */ public final class MedianOfTwoSortedArrays { private MedianOfTwoSortedArrays() {} private static boolean isMedian (int[] a1, int[] a2, int po...

0
Q: Searching a 2D matrix for a consecutive sequence

Hopping MouseI've been solving problems on checkio (and trying to digest other's code) in order to improve my python. My main goals are to learn to write more idiomatic Python and to explore the language more fully ("batteries included" is no joke!). I'd like critiques on the following (working) code in ter...

 
9:33 PM
I'm almost out of votes again...
 
9:44 PM
I just read Call of Duty - We're on a mission ... and only now I realize why you think it's Stack Overflow important to vote: Grace Note helped to bring that obsession on, by complaining about "questions without any upvoted answers".
Stack Overflow so
 
0
Q: Making my own programming language?

Sam TubbOk, so this question is really to help me decide on something. I have started development of my own programming language that I am calling DeliciousWaffle (or maybe samscript). So far it looks pretty cool, I built a compiler in python, and associated .dw files with it, these files are like .py o...

 
My rep is exactly 8K at the moment ;-) Nice round number.
 
data.stackexchange.com/code%20review%20stack%20exchange/query/… shows many questions with accepted answers but no upvotes.
 
Although 8888 sounds good too ;-)
 
@rolfl: Nice, solid number. :-) Hope you reach 10K soon.
2
 
9:49 PM
In theory I can make it before February..... ;-)
That will take some serious effort though.
 
Maybe there's a chance I can reach 4K before I earn Yearling, which will be sometime in March.
 
Promise, not pimping an answer, I am genuinely interested in why a person chose such a weird way to find the mid-point of an array...... Why is this asker's code so convoluted?
0
Q: Find the mean of the medians of two equal sized sorted arrays

JavaDeveloperLooking for code review, clever optimizations, adherence to best practices. etc. As an example: a1[1, 3, 5, 7] a2[2, 4, 6, 8] The median for each array is the middle-element for odd-size arrays, or the average(mean) of the two middle-elements for even-sized arrays. The function should retu...

 
I cannot judge the Java specifics, but I wonder if there's any continued improvement with each of these new questions. Seems like the same stuff.
 
Yeah, I get the impression that the asker is going through a set of exercises, but never learns anything when they post the next solution to a problem.
The same broken code again and again... .and always the interest in 'complexity'.
 
Perhaps you can address that, if it could benefit that user. These are still decent questions and are all on-topic, but helping askers improve overall should be our top goal.
 
9:57 PM
ooohhh, I got a for-my-resume compliment ;-) ...
Really what I expected :)-. I didn't really like my approach. But, I want to learn. To code better like a 'Real Programmer(TM)', like you, one needs to start reading and understanding others programs and algorithms. Thank you once again. — Phoenix 4 mins ago
I am a real monkey, and a 'Real Programmer', apparently.... ;-)
 
Not your average code monkey. ;-)
Wait, why is a monkey teaching me how to code better?!?
2
 
10:09 PM
0
Q: Factorial class -> StackOverflowError

LXSoftHow to test factorial static method (recursive) with try-catch block, before throw Exception. Console print me only the StackOverflowError trace no aditional System.out.println(). I can test using JUnit but that does not help me, I need a alternative, to show the max k number before program fails...

0
Q: Three ways to do the same thing, functions that return a variable

ThomasReggiI'm simple looking for what the general preference is between the below options A) anon function directly to variable middleware.customer = function(req, res, next){ req.customer = function(){ var customer = false; if(req.method == "POST") customer = req.body; if(req...

 
The OP of the factorial question shortly found the error and just added it as a comment. Sigh
 
10:28 PM
@rolfl There's a pending edit to your answer which I don't understand.
 
The change doesn't match the description, either. Nothing was really correct, just removed.
The suggester also has commenting privileges, so a comment could've been better.
 
The editor is the poster of the question, so my guess is that he disagreed with it (maybe he thought the variables were used elsewhere?). I rejected it with a custom reason saying he should comment if he has an issue with the accuracy of an answer, not edit it.
 
10:44 PM
@Jamal I figured out what the factorial question was about, and answered it. Now that I understand the question doubt it was on topic.
 
@ChrisW: Yes, the OP just posted non-working code and shortly "casually" gave the solution. Since it was already solved, it can just stay here, and Community will eventually delete it.
 
11:07 PM
I took a moment to understand the edits-sugestion, and was on the fence about it. Nothing significant was changed other than some whitepace and camel-casing of variable names (I have a non-standard preference for all-lower-case variable names) One section/paragraph was entirely removed, which was minimal in content anyway. I pressed approve on the edit though, and discovered you all had rejected it already ;-)
That works for me too....
 
I reject basically any edit that changes content or meaning in a non-formatting way. It's just not fair to the poster of the comment. Feels weird to change someone's content in a meaningful way without at least discussing it with them. After all, if my name is going to be next to something, I want to be sure it wasn't bastardized from what I originally wrote. Perhaps I'm just picky though.
(The one exception is that I sometimes [and only just sometimes] will accept an edit in a language that I am very familiar with that fixes an obvious, small typo in code.)
 
@Jamal - need some help/suggestions here.... How do I dig myself out of the hole I have with the question here.....
The original question gave no hint on what the actual purpose of the function was, other than the code itself. I probed for some details, and everything I was told suggested the purpose was a certain operation. I edited the question to match my understanding, and answered the question as such. Now the actual requirement is completely different ... so all the probing I did was for nought, and my answer is wrong too ..... What are the options?
0
Q: Find the mean of the medians of two equal sized sorted arrays

JavaDeveloperLooking for code review, clever optimizations, adherence to best practices. etc. As an example: a1[1, 3, 5, 7] a2[2, 4, 6, 8] The median for each array is the middle-element for odd-size arrays, or the average(mean) of the two middle-elements for even-sized arrays. The function should retu...

@Corbin - I agree.... and I would do the same thing for edits to other people's code/answers. It just is different when it's your own ... ;-)
 
Yeah, definitely. Just explaining why I jumped on the reject button lol
 
... continued ... note the last edit to the question provided the contradictory example.
and after the answer.
 
@rolfl: Hmmmmmmm. It would probably be better to hear from the OP in chat. Other than that, if your answer really did reflect the original version, then it should stay. But I too am confused at what the OP really is getting at. As a last resort, the answer may need to be deleted, but don't do that just yet.
 
11:17 PM
What the OP actually wants is 'find the median of two arrays after merging their contents' ALL the examples he gave, by coincidence, give the same answer for 'find the average of the medians of two arrays' as well.
 
Wow... at first that question seemed simple enough, but now... What the hell? Why is he finding the median of two sorted arrays?
I think what he actually wants is array_median(a1, a2) = avg(median(a1), median(a2)) with median(a) = is_odd(len(a)) ? a[len / 2] : avg(a[len/2], a[len/2 + 1]).
But... it could be a lot clearer.
 
Should I close as Unclear?
 
@Corbin to be clear, what he wants is median ( arrayA union arrayB ) with the special input conditions that the arrays are initially sorted, and same length (in other words, possibility for smarter algorithms)
 
I wouldn't close it yet. Some clarity might still come out of it.
 
Yes, IMO he wants to merge the arrays, and return the median (or average median) of the merged array.
 
11:22 PM
Ah, you're right. His examples, his post, and his comments do not match up.
You're both right. Looks like he wants to sortedly merge the arrays and then find the median.
But his text contradicts that:

> The median for each array is the middle-element for odd-size arrays, or the average(mean) of the two middle-elements for even-sized arrays.
> The function should return the average (mean) of these two medians.
Blerh idk. I should be working anyway :)
 
Be careful .... I added that comment based on his comments ... ;p
What a mess....
I'll fix this... have a plan.
 
@rolfl You could keep your old answer, edit it, add --- and a second answer for the revised question.
 
indeed.
The only losers are potentially the people who upvoted my answer and I may make a mess of it now ;-)
 
Don't worry. We'll all make sure to downvote it :p
 
@rolfl I hadn't upvoted it yet (I wasn't sure whether it answered the question, because it so didn't match the code in the OP).
And/or (perhaps before you edit your answer) we can edit the question to make it unambiguous, and ask the OP whether that's the question they want to ask.
@rolfl ^
 
11:30 PM
Just edited the question ..... I think it matches now... will ask asker.
 
I don't know if we should put word in the asker's mouth. At the same time though... the words that are already coming out are useless.
 
Can someone be sure of what the the question is, by reverse-engineering what the code in the OP is doing (assuming that code is doing what it's supposed to)?
 
Ah, looks like you're correct. His original edit makes sense:

> As an example:
> a1[1, 3, 5, 7] and a2[2, 4, 6, 8] then the return value should be 4.5, (ie average of 2 middle elements) 4 and 5.

4 and 5 are only the middle elements if you merge the two lists into 1, 2, 3, *4, 5*, 6, 7, 8
 
@Corbin 4 and 5 are the middle elements ( 3 + 5) / 2 == 4, and (4 + 6) / 2 == 5
 
But he said the middle elements, not the arithmetic mean of the middle elements :)
 
11:34 PM
He described the median ..... as the average of the middle elements !!! He Did!
 
That's how median is almost always defined on an even-sized sequence. That's the median he defined like that though, not "element."
Although.... Gah his first edit is pretty ambiguous. He could mean that 4 and 5 came from averaging the 2 middle elements from each list, or he could mean that 4 and 5 were the two middle elements of the combined list and were thus averaged. Gah!!! I hate ambiguity :(
 
@Corbin - I fell in to what I consider to be an innocent trap....
I saw the system one way, and everything he said/added still matched my perspective.
 
Yeah. Quite an unpleasant situation you've found yourself in :/. Maybe we can think of an unambiguous example to have him give us the answer for?
 
I produced the expected results in all cases.
He has suppied an example where it is clear... his last edit.
 
Ah you're right.
Didn't realize he had edited that in.
 
11:39 PM
I think his code is searching for (discovering) the two medians (one in each array), without merging the arrays.
 
Dinner time for me .... it's called 'code-and-dash' .... leave it for you poor souls for clean up ;-)
(dinner and a movie!)
 
I think that if the two arrays contain [1,1,10,10] and [5,5,5,5] then his code would not return 5
so he doesn't want "medians of the union of the arrays", if his code is correct
i don't know what he does want, though.
 
0
Q: Binary search in TypeScript, is the presented code correct?

bonomoI need your help to see if the following code that does the binary search is correct. I did my best covering the corner cases, I wonder if I missed anything. Thank you. The code as it is with tests (you can play with it online here): function binarySearch<a, r>( hay: a[], needle: a, ...

 
@ChrisW ideone.com/g3eR1Q You're right. The output is 7.5. I was expecting 5.... Perhaps his code is bugged and 5 is his intention though? Blarh... I don't know. I'm completely lost now.
 
I posted a comment to the OP to ask for the correct answer.
 
11:46 PM
Great. Should hopefully clarify significantly.
 
OP has posted a hyperlink to the spec.
Thanks for the ideone link
 
Bleh gross. The source of the problem could use a code review of it's own... And an article review.

Anyway, http://ideone.com/RSCGFG 5 is the correct answer.
 
you copied that from the article (it's a 'reference' implementation and correct answer)?
if so, then apparently the OP's implementation is different from the article's (I don't know why); and, it's buggy.
 
Correct. It's a near exact copy/paste of the "reference" implementation. I just removed a getchar() call.
 

« first day (259 days earlier)      last day (3765 days later) »