« first day (330 days earlier)      last day (3681 days later) » 
00:00 - 20:0020:00 - 00:00

12:00 AM
Oh, this makes sense. I was wondering why I kept getting downvotes and negative comments all the time. Thanks for breaking it down for me. As you can see, I'm very new to this. — Pivo 1 min ago
I hope that means that he learns what belongs where.
 
@Sham Following up with your Python questions in another room...
in Room for Sham and 200_success, 1 min ago, by 200_success
@Sham How about this visualization?
 
RELOAD
And now that you all have votes:
1
A: Credit card verification: string conversion most optimal?

syb0rgThings you did well Readability - everything was well organized and spaced neatly. Initializing variables within your for loops/adhering to the C99 standard (which is the minimum you should abide by in my opinion). Marking your function arguments as void when you don't take in any parameters. U...

 
Your problem is that you should use { } or a ; after the else at the end of your code, btw (where the //do nothing comment is). Please fix that problem and ask instead for how you can improve the code, because I have a desire to really review your code. — Simon André Forsberg 1 min ago
 
@SimonAndréForsberg When he was little, his parents probably made a lot of idle threats, like "Clean up your room, or else"
5
And now he can't write code.
 
@200_success took me a while to get that one :) I thought at first "What does that have to do with my comment?" Now I understand :)
 
12:08 AM
@syb0rg I still don't understand why the OP's prod = prod%10 + prod/prod%10; and 200's prod / 10 + prod % 10 are the same.
 
@ChrisW The Luhn algorithm calls for finding the sum of digits of prod, which is itself a sum of two digits.
 
@ChrisW Take a look at this, it helps a bit: chriswareham.demon.co.uk/software/luhn.c
 
Napalm Strike!
5
Q: Blocktastic optimisation

MunkybunkyI have written the following code as the level rendering part of a game engine I am writing. I am very happy how it works but as it is the background / level graphics made up of individual blocks it needs to be quick. What it does it look take the graphics from a resource loaded elsewhere and sc...

 
Therefore, prod (the original) ranges from 0 to 18, inclusive.
prod % 10 is obviously the first digit.
prod/prod % 10 is just a fancy way of saying 1, when it's inside that if.
 
OK.
 
12:12 AM
I meant, prod % 10 is the last digit.
 
I understood your code; not the OP's. Now I understand the OP's: "just a fancy way of saying 1". Yuck.
 
What do you think mods, should this be re-opened now? He's asking for a review, but the else part hasn't been fixed (although I pointed out the solution in my comment). I'm voting to reopen
-2
Q: Read 10 numbers and display distinct numbers

PivoI'm within my first few weeks of programming and this is my 1st language. Should I be using different code than what I already chose to write? Problem: Write a program that reads 10 numbers and displays distinct numbers.(i.e. if a number appears multiple times, it is displayed only o...

 
I've edited anyway, and I'm not sure why he also didn't fix the error.
 
I might not be awake enough to review that one this evening though. I feel sleepy.
 
am in now
 
12:18 AM
Yeah, me go sleep. Night folks.
 
Goodnight!
 
Bye!
 
0
Q: Fading and Loader Jquery Improvement

azngunit81I'm not much of a jquery coder except to call a few get values out of class and id and ajax calls. (more of a php coder) however I need to make a checkout system work and one thing I would like to do is to put a loading wait while I send a form through Ajax and then when its finished it would red...

 
Those conditionals look like they could be refactored.
 
@syb0rg If it's true that people return negative to indicate an error, perhaps they shouldn't: IMO en.wikipedia.org/wiki/Exit_status#References says to return non-zero positive number.
 
12:20 AM
@200_success i got u with part(2)
how do i visualise modules beong pbject?
'import operator'
@200_success can u please answer at SO, so that i can accept your answer?
i mean the same answer
 
Also if you want to complain about using the wrong type of int as the return code from strlen, perhaps size_t would be better than unsigned long.
 
@ChrisW Are you referring to the EXIT_SUCCESS and EXIT_FAILURE? They have their place, but error indicators sometimes need more values in order to be more descriptive. I guess positive values could be used as well.
 
Someone commented ...
 
@ChrisW True, I'll edit that in.
 
I would also mention that returning -1 is normally a bad idea. The shell interprets negative numbers in weird ways — FDinoff Mar 26 at 18:50
 
12:23 AM
It does?
How does it cause it to act strange? I've been returning negative numbers for a long time.
 
... and when I looked it up, all recommended error codes for all O/Ses seem to be +ve.
@syb0rg Me too, but I won't recommend it any more.
 
@ChrisW Ditto. And the edit has been made.
 
Maybe it depends on the shell, and whether/how you run the program from a shell.
 
Maybe, but typing $? always worked fine for me.
 
Hello everyone.
 
12:29 AM
Hey @Malachi
 
found a program for doing my websites via FTP but it is doing the same thing that Eclipse was doing on my linux machine.
 
@200_success Your comment on my answer is supporting one of my points, right?
 
I think it is tightly linked to Eclipse. it's Aptana
@syb0rg how is it going
 
@Malachi Good, I'm back reviewing C stuff again: codereview.stackexchange.com/a/45714/27623
 
@syb0rg I have no clue about any of that C business...lol
 
12:32 AM
@Malachi Just take my word that it's right ;)
 
@syb0rg Yes and no. On one hand, you correctly say to "use strings to hold credit card numbers". But you also said that using a double instead of a float was one of the good things about the code.
 
@200_success Yeah, I thought about posting an exception there to clarify, but then I assumed he would read on and see that he shouldn't have used a floating-point type at all.
Maybe that is another edit I should make ;)
 
@syb0rg lol
6
Q: Some tips on a CodeIgniter Model I am building

o7th Web DesignCan I get some pointers/critique/comments on the following model? (p.s. performance seems great... tested all methods up to 10,000 records) <?php if (!defined('BASEPATH')) exit('No direct script access allowed'); class o7th_Model extends CI_Model { private $msg; private $last_id; ...

 
@Malachi Yeah, I took your word that what you said was right, and upvoted that a while ago ;)
 
12:44 AM
@syb0rg I upvoted you...lol
 
@rolfl You should clean up the comments and reopen this one:
1
Q: Read 10 numbers and display distinct numbers

PivoI'm within my first few weeks of programming and this is my 1st language. Should I be using different code than what I already chose to write? Problem: Write a program that reads 10 numbers and displays distinct numbers.(i.e. if a number appears multiple times, it is displayed only o...

 
@syb0rg you know I am going to bug the crap out of you when I get the Arduino IDE going on my new Computer right?
 
@Malachi I'm looking forward to it...
:P
TTED
 
I found a bunch of code that I did in class, simple stuff. maybe you can review some of it. isn't there an arduino site?
what is TTED
 
@syb0rg: Minor answer, but I think it's still good to mention.
0
A: Credit card verification: string conversion most optimal?

JamalThe other answers offer great advice, but I have a few minor things to add: This doesn't seem like a good input prompt: printf("Give me a number: \n"); Imagine, for a second, if the user briefly forgot what this program is for. If they see this prompt, they'll just input any number. Instea...

 
12:47 AM
@Jamal Nice, I accidentally glossed over those in my review.
@Malachi Time to eat dinner.
 
@syb0rg The same can be said for prod, but I think the OP gets the idea.
 
1:11 AM
@syb0rg :
Pivo . you should edit your code, remove the else //do nothing part, and I recommend you also make your indentation correct. When that is done this can be reopened. At the moment your code does not compile. (and you should jump though this hoop ;-) — rolfl ♦ 1 min ago
 
@rolfl Ahh, well now the comment section is clean!
5
Q: Why return a negative errno? (e.g. return -EIO)

exscapeAnother simple example: if (wpa_s->mlme.ssid_len == 0) return -EINVAL; Why the unary minus? Is this (usually) done for functions that return >0 on success and <(=)0 on failure, or is there some other reason?

So maybe negative return values are useful?
> Back in my old Unix days, there was something of a convention that 0 means success, a positive number meant minor problems, and a negative number meant some sort of failure.
 
1:28 AM
@syb0rg Maybe -ve is a useful convention for some function return codes, not so much for process (main) return codes.
 
@ChrisW Maybe. I think I'll just change my recommendation to be: "Error return codes should be unique non-zero values".
And let the OP decide. I don't think that is matters too much.
 
2:08 AM
@200_success You might want to delete the code at the end of your answer, because it's
 
@ChrisW You're right. I've deleted it (though it's still in Rev 1).
Careless on my part, but not a huge deal, considering that he was aiming for a function call.
 
This OP is new and may not know how to view revisions.
(Doesn't know how to vote or accept answers: I was wondering about posting on meta-SO asking for an answer I/we could link to which tells people how and why to vote and accept, complete with pictures and hand-drawn circles: I haven't found such a single, complete answer in one place for new users).
 
^^^^ would get my upvote (if it struck the right balance of tactful but forceful)
 
2:31 AM
Hello @LokiAstari
@rolfl Can mods see who has voted on a post?
 
1
Q: Decoding big text input: potential concurrency bugs? And how to im prove the code

fgeThe code here will be directly pasted from this project. Quick summary: it is related to a StackOverflow question. So, basically, all the code below aims to implement CharSequence over a large text file, within the limitation of CharSequence itself (that is, up to Integer.MAX_VALUE chars). All t...

 
@rolfl Review this for tact:
**How does voting on answers work?**

How and why should users vote on answers?

This explains how to accept an answer: [How does accepting an answer work?](http://meta.stackoverflow.com/a/5235/139866)

---

If voting is important I would like a similar answer which includes a picture of how to vote, and explains why.

Sometimes people would like to be able to link to such an answer in a comment, for example when a new user says "thank you" in a comment but their profile shows they have never voted.
@syb0rg No
 
@nhgrif Can you try to explain how init works in [[ClassName alloc] init]?
I know that alloc sets up the memory and initializes everything to 0, so what is the point of init?
 
@ChrisW It is almost as if someone has thought about this before... ;-)
 
@rolfl Have you found an answer which explains voting?
 
2:42 AM
@syb0rg By memory, I don't know what NSObject's init does, which is what all objects initialize from, but in init, you're doing exactly what other languages would do in their constructor methods.
 
@ChrisW No, I was reading through that meta.so one.
 
You use this method to make sure all variables that need it have a set value so that if the value is never set explicitly, it won't be a problem.
 
That meta post does go in to why and how to vote on answers too, but not in much detail.
@syb0rg No.
 
For example, in a Rational Number class, I'd have a numerator property and a denominator property. Technically, the numerator could be any value, but the denominator cannot be 0. So in init, I'd set the denominator to 1 by default.
 
Ahhh.
 
2:44 AM
@rolfl So it does. So all that's needed is to add a picture to that, to illustrate an upvote.
 
But here's the pattern you really want in that example...
well, let's go to NSChat real quick
 
It was frozen, @rolfl could unfreeze it though.
 
@syb0rg As I understand it, +alloc allocates memory, and -init makes it a useful object. The responsibility is split, so theoretically you could use a different memory allocation strategy.
 
meh, don't unfreeze it.
 
So in some cases init doesn't have to do anything?
 
2:46 AM
Other than call [super init], correct.
Also, there's a method allocWithZone:
 
@syb0rg Mods don't see who voted, but we can see a report of suspicious voting patterns.
 
@nhgrif And do you prefer to use [ClassName new] or [[ClassName alloc] init]?
 
Oh... wow
allocWithZone: does the exact same thing as alloc.
 
@200_success The less said about that the better, probably. ;-)
 
The parameter is ignore and the method only exists for historical reasons.
I prefer neither syb0rg.
I prefer [ClassName className];
I don't like new (personal preference), so I write my own default factory method every time
 
2:50 AM
Can't you just do that by calling your own init: ?
 
Yeah.
+ (instancetype)className { return [[self alloc] init]; }
 
So why do you write you own if you are only doing that? ^^^
 
hang on
important space maneuvers
Okay, first of all, your factory methods really shouldn't do a lot besides alloc init.
But you could have initWithDelegate:
And then + (instancetype)classNameWithDelegate:(id<Protocol>)delegate { return [[self alloc] initWithDelegate:delegate]; }
But even if you're just going to do exactly what new already does, the reason I do it is for consistency with the Foundation classes.
[NSArray array]; is the exact same as [NSArray new]; and [[NSArray alloc] init];
 
@syb0rg Link?
 

 NSChat

Rules → spifftastic.net/nschat.rules — Discussion for iOS and...
 
2:55 AM
Done
 
Thanks.
 
3:25 AM
1
Q: How does voting on answers work?

ChrisWHow and why should users vote on answers? This explains how to accept an answer: How does accepting an answer work?

 
@ChrisW - just wondering whether you intended to post that to Meta StackOverflow, or Meta.CodeReview?
 
SO
I still think of it as meta-stackexchange
 
Hey @JerryCoffin
 
3:42 AM
@syb0rg Hello.
How are you today/tonight/this morning/this evening?
 
Decent. Finishing up some homework before I go to bed.
 
Strange. Both suggestions here have been downvoted, but no alternative provided.
7
Q: Rename [code-challenge] to something more site-specific

JamalIt seems that users are still using the code-challenge tag for challenge-oriented questions that do not correspond to the site's occasional voted-upon challenges. We already have the programming-challenge tag for off-site challenge programs, but it's understandable that the two tags sound simila...

 
@Jamal I downvoted them just because you're (now) both moderators. The Man been holdin' us down too long! :-)
 
I assume you've downvoted the new moderator announcement as well? ;-)
(and technically, one's a monkey and the other a fish)
 
@Jamal We closet revolutionaries are not known for consistency (or logic)!
 
3:47 AM
Well, we monkeys are not known for our good looks, and I need my beauty sleep. Night all.
 
lol
Goodnight!
 
@rolfl G'night.
 
Monkout!
 
@JerryCoffin Does that include programs? :P
 
@rolfl Bye
 
3:51 AM
@Jamal Probably not--that would be too consistent.
 
So, all your code looks like a tornado has hit it.
 
@Jamal If all my code looked any one way, that would be a consistency in itself.
 
@_@
 
For that matter, if all of it were inconsistent, that would also be a consistent quality in itself, so obviously that's not the case either...
 
Did you also downvote all of the posts in this question?
20
Q: Please welcome your new moderators!

PopsI'm Pops, a Community Manager at Stack Exchange. Though it saddens me to say it, not just one but two of your existing moderators are stepping down for personal reasons. Over the past week and a half, I've been working on finding replacements, and I'm happy to announce that two avid Code Reviewer...

 
4:01 AM
@syb0rg Honestly? no. But for the sake of argument...I upvoted two, then created a sockpuppet account under which to upvote my own post (though you may have difficulty finding that...)
 
@JerryCoffin is your sockpuppet, and Pops is your real account?
 
I knew it!
(that Pops is the puppetmaster)
But wait... then why not make your sock(s) moderators?
 
@syb0rg Actually, I have about a million sockuppet accounts (but most of them are on SO, not here).
 
@JerryCoffin You are Jon Skeet as well? Whoa...
 
So that's why there are so many gimmetehcodez questions on SO. Wait until... damn, SE must be in on this, too. :-/
 
4:06 AM
in Lounge<Weirdos> on Stack Overflow Chat, Mar 4 '13 at 19:05, by Jerry Coffin
@TonyTheLion Yes -- with 1.6 million sock puppet accounts, I see all and know all.
 
@syb0rg No--my puppets got together and created that account on their own.
I'll be back in a bit. I spent most of the day hiking in the desert, and need to take a shower.
 
@Malachi FYI, I think you will be awarded that bounty unless someone else answers the question.
 
4:22 AM
Thanks Santa
 
Welcome to 10K. ;-)
2
 
Huh, chrome on my tablet is better than ff
Grats ChrisW
 
4:39 AM
@Jamal Members of the 10k club will do the welcoming. Until you earn 10k, you may congratulate. =)
@ChrisW Congratulations, and welcome to 10k!
 
@200_success walks away with head down
 
Double tap:
0
A: Genomic Range Query

syb0rgJust a few notes not mentioned in other answers: You can typedef your struct right away. typedef struct { int pre_1_idx; int pre_2_idx; int pre_3_idx; } PreMinIdx; Then initialize it with a more unique name. PreMinIdx UniqueName; Use else ifs in your mapping() method. And sinc...

 
@Jamal There, now. Only 1832 points to go for you.
 
Welp, time to break out the socks.
(kidding, of course)
 
Now I'm off to bed. Good night @all!
 
4:42 AM
Goodnight!
 
Good night!
 
If someone gives you something they're entitled to welcome you to it.
So thanks to Santa, and thank you all.
 
Simon is next in line with about 500 to go.
 
Assuming that any zombie needs one upvote to RIP:
0
A: How to implement 'cat' command using c?

ChrisWYou're initializing but not using local variables like bflag. Is the user allowed to specify more than one option? Source code for GNU's cat found here says "Yes, multiple options can be specified". So instead of calling a different routine for each option, you should call the same routine for a...

0
A: Selecting from a database into a DataGridView

ChrisWThree possible problems that I see. dbConnection = New SqlConnection("Data Source=connectionhere\sqlexpress;Initial Catalog=line_log;Integrated Security=True") You have a hard-coded connection string. If you want a different database location then you need to edit the code. Perhaps it's bett...

^ Let me know whether these can be improved.
And good night for now.
 
It's about time I tried to improve this title. This has Winston's highest-voted answer.
68
Q: Calculate SHA1 hash from binary and verify with a provided hash

user26614I applied for a job and they asked me to write code with the following requirements: Get a "toolbar offer" description from http..update.utorrent.com/installoffer.php?offer=conduit. Parse the bencoded (see http://en.wikipedia.org/wiki/Bencode) response and extract the URL of the binary...

 
5:36 AM
0
Q: Is there any issue if ternary operator is used in super?

nigel thomasWhile reviewing a code the reviewer replied to the coder that, "Strictly do not use ternary operators in super calls " Is there any rule of thumb like ternary operators should not be used in super calls ?

 
6:13 AM
0
Q: Ford-Fulkerson algorithm

JavaDeveloperSolved the ford-fulkerson algorithm, which is too vast to explain it comprehensively here. Check Wikipedia for Ford-Fulkerson and Princeton lecture on Ford-Fulkerson. Looking for code review, optimizations and best practices. Also I request you avoid mentioning renaming GraphFordFuklerson and u...

 
^^^ I like this typo: "Fuklerson".
 
How did I not notice that...
Oh wait, it is used in the code.
 
@ChrisW Your reputation graph has the most beautiful linear trajectory. Impressive!
 
6:41 AM
And we have invalidation:
5
Q: Determine total number of ways of reaching a destination

user3476387 Question: One of Scotland Yard’s most wanted criminal (Mister X) is on the run and needs to reach a certain destination safely. There are three modes of transport available for him - By air, by train or by cab. With air travel, he can go from station i to station i+3. Using a trai...

And based on that edit, it appears that the ^ was supposed to be for pow.
 
0
Q: openmp loop parallel for loop with function calls and stl vector c++

priyankaI have a function initialize_path_statistics(). I have used openMP to make it parallel. I am not sure where certain lines such as float length_enclosed = Nodes::get_length_enclosed(i); need additional pragma like #pragma omp atomic. void Path_Statistics :: initialize_Path_statistics() { ...

0
Q: VBA Excel 2010 Code Check

webheadI have written a small program with VBA in excel 2010. It is a self service concession stand where a user enters their ID numbers, log what they bought, and add it to a balance or pay. I would appreciate a code review. Everything seems to be working, but I would like to ensure my code is as eff...

0
Q: Use up all characters to form words

mchangunTask: Given a dictionary of words, and a set of characters, judge if all the characters can form the words from the dictionary, without any characters left. For example, given the dictionary {hello, world, is, my, first, program}, if the characters set is "iiifrssst", you should retu...

 
7:12 AM
Ha. Someone wanted to be disassociated from this post.
3
A: Eratosthene sieve and MPI

anonMy advice: split up that main function.

 
7:22 AM
0
Q: Calculator for Mass

WoodyI've been trying to create a calculator to find mass using any and all known equations, the program will also return the steps used to find mass so the user can cheat... er... 'check their work' on physics assignments. My biggest problem so far (and was solved by much copy-pasta) is the equation...

 
 
1 hour later…
8:27 AM
any python programmer her?
here*
 
@Sham I've written a couple of Python scripts, but I don't have a deep knowledge of the language. Why?
 
9:14 AM
0
Q: OpenMP parallel for critical section and use of flush

priyankaThe following is my code. I am not sure about the place where flush should be used(if it is used at all here) int Window_Shift :: get_window_shift() { int window_shift = INFINITE; #pragma omp parallel for for(unsigned int node_id = 0;node_id< no_of_valid_nodes ;node_id++) {...

0
Q: Can my C program get more efficient, more portable or faster?

909 NiklasHow can I test this C program for "efficiency"? The most interesting usage is that it returns negative output for large enough input, otherwise the behavior is about expected e.g. the usage is when compiled: $ ./a.out 19011 19011 => 19013 Will you suggest how to improve it for portability (uni...

 
 
2 hours later…
11:10 AM
Morning
 
11:43 AM
@Jamal I know something you all can do to help me reach 10K faster...
 
12:37 PM
 
Finally, @rolfl's there!
morning for you
Do you still remember oru discussion about Collectors and that they need to be associative, and not commuative?
Take a look at the default Collectors.toList()
public static <T>
Collector<T, ?, List<T>> toList() {
    return new CollectorImpl<>((Supplier<List<T>>) ArrayList::new, List::add,
                               (left, right) -> { left.addAll(right); return left; },
                               CH_ID);
}
Here the combiner is not commuative either, because it adds the right elements to the left elements
If the combiner would've been called in the different order occasionally, then it would break aswell
 
0
Q: Switch like context manager in Python

canniThis is self explaining example with usage in doctests: class Switch(object): """ >>> with Switch(1) as case: ... if case(1, fall_through=True): ... print 1 ... if case(2): ... print 2 ... if case.default: ... print 'default' ... 1 2 ...

 
12:57 PM
1
A: Genomic Range Query

syb0rgJust a few notes not mentioned in other answers: You can typedef your struct right away. typedef struct { int pre_1_idx; int pre_2_idx; int pre_3_idx; } PreMinIdx; Then initialize it with a more unique name. PreMinIdx UniqueName; Use else ifs in your mapping() method. And sinc...

 
1:11 PM
0
Q: beginners clojure reverse function

dagda1I am just starting out in my clojure journey and I wonder if anybody can point out my beginners mistakes in my function below that simply reverses a list. I know that there is already a reverse function so this is purely for learning. (defn rev ([l] (if (= (count l) 1) l (rev '() l))) ([...

 
Monking all
 
@skiwi - I thought we concluded that it did not need to be commutative?
Hey @Vogel612
 
Hey @rolfl<>
gz from my side too, maybe a tad late, but better late than never ;)
 
Thanks ;-)
 
1:26 PM
Monking @rolfl and @Vogel612
 
Monking @Simon.
 
0
A: First prime number larger than given integer

syb0rgThings you did well Proper use of goto to break out of an inner loop. Things you could improve Portability If you want your program to be as portable as possible, take a look into the AutoTools suite. Standards You don't have to return 0 at the end of main(), just like you wouldn't bot...

 
@syb0rg Is it really recommended to use goto there? Why not break?
 
1:43 PM
@syb0rg - yeah, why use goto when a break will work better .... huh?
Wrong dinging
 
And why not use a while instead of that for (found = PRIME_FALSE; found != PRIME_TRUE; perhapsprime += 2) { ?
 
Yeah, why? !
 
@rolfl Well we did it by a very thorough anylasis, but I it could also be easily shown with the toList() collector appereantly ;)
 
@rolfl Nope, break would only get you out of the innermost loop.
goto's use is proper here.
 
Isn't that exactly the point in this case?
As the goto seems to be used, it only breaks out of one loop
 
1:49 PM
Ouch, that code hurts to read :(
What hapened to principle that code hsould be self-explenatory
 
There is even a comment that says /* This label is used to break the inner loop. */
 
@SimonAndréForsberg Oh shoot, somehow missed that.
 
I might be stupid, but where's the check_next_prime label
 
Eh, I'll have to fix it later.
 
@skiwi - just below the inner loop
 
1:50 PM
Ah, I was searching above... thanks
 
@skiwi - I have not found a good document/reference as to why the collector does not need to be commutative.
Empirically, it does not.
The documentation does say it has to be associative..... so maybe the lack of documentation on commutative implies it is OK.
I would prefer a positive assertion of that fact though.
We also discovered that there are ways to break the logic by messing with the Collector capabilities and the stream characteristics.
I think that is the real 'key' to the problem, understanding what the characteristics and capabilities imply, and what combinations are compatible.
I don't, yet
 
And the javadoc doesn't suggest all of them, either
 
No, OK, people, time for an opinion poll (Java folk especially):
1
Q: Read 10 numbers and display distinct numbers

PivoI'm within my first few weeks of programming and this is my 1st language. Should I be using different code than what I already chose to write? Problem: Write a program that reads 10 numbers and displays distinct numbers.(i.e. if a number appears multiple times, it is displayed only o...

This question is still not producing the right results.... after numerous attempts....
He made the changes I asked and I indicated I would reopen the question after he did.....
Now, there is still a bunch to review, but his distinct-list calculations are broken in his second-attempt.
(he never actually sets any values in the finallist array
Currently there are two re-open votes....
ahh, Thanks Ducks. I know what to ddo ;-)
Hi again Pivo - it is apparent that the code is still not working. Your own comment that it is 'getting close to the solution', and looking at the code, indicates that there is a real problem.... for example, you are never actually setting any values in finalList, so how can it possibly have the distinct values? Why don't you join us in The 2nd Monitor (CodeReview chat room) and we can work through some issues. — rolfl ♦ 11 secs ago
 
2:06 PM
0
Q: Increasing readability of Project euler problem 18 solution

Aseem BansalI had written a solution for project euler problem 18 in Python 3. It is good in its efficiency but the problem is the readability and I think reuse. The algorithm used is that at every iteration the maximum for all numbers in a row is calculated starting from the top and going down to find the...

 
@rolfl Good choice.
 
takes a bow ... why, thank you ;-)
Thanks Santa ... Necro!
 
2:37 PM
0
Q: Sound manager for android

FR073NI created a singleton class for managing sound effects on Android. This class will only be instancied and loaded once at the begining, and each activity will use the loaded songs. I don't know either if this is the good approach for Singleton, nor if this is the good way to play sounds in Androi...

 
3:01 PM
0
Q: Wrapping my head around generators

Aseem BansalI am going on with refactoring my code base while migrating from Python 2 to Python 3. I am using generators to make reusable components this time as I am more comfortable with them this time then last time. But there are times when I am stuck at their use. Like below example. These two are essen...

 
3:27 PM
0
Q: Implementation of the Atoi function

user3294082I implemented the Atoi function! Here is my code : int my_atoi(char* pointer) { int result=0; char* pointer1; multiplier=1; char sign=1; if(*pointer=='-') sign=-1; pointer1=pointer; while(*pointer!='\0') { if(*pointer>='0' && *pointer<='9') multiplier=multiplier*10; pointer=poi...

 
4:00 PM
how is the problem "string to int: 232-19" connected with the code at hand? — Vogel612 1 min ago
that Atoi question is strange..
also these edits don't look so nice to me...
 
@syb0rg - Competing/replacing answer:
0
A: First prime number larger than given integer

rolflLet's review the context of this function. If this function will be called often with a wide range of inputs, then it makes sense to pre-compute a bunch of prime numbers and then just find where the input value is in amongst the pre-coumputed set. When pre-computing the primes the most common wa...

Actually, am going to edit.
With the function extraction, there is no need for do-while.
 
@rolfl I was going to fix my answer up and undelete it.
 
4:17 PM
@syb0rg You can still fix your answer and delete it
I'm sure there's room enough in the question for both a monkey and a robot :)
 
I figured pretty much everything I was saying was different to your's ... ;-)
 
Tried to not step on your toes too much @rolfl
0
A: First prime number larger than given integer

syb0rgThings you could improve Efficiency As @rolfl stated, you want to use a Sieve of Eratosthenes. I can't see if you are doing this already, but you should be compiling with your compiler's highest optimization level. With GCC, this would be -O3. Portability If you want your program to be as...

 
You did well, and I tried not to step on yours either .... we point out different things and, a lot of what you say is good criticism for my answer too....
You are criticising style and standards, I focussed on the function extraction and loop structures.
@syb0rg - unfortunately, as a mod .....
.... I still only have 1 vote per answer.... :(
otherwise I would upvote for the answer, and another for the velociraptor
2
 
4:35 PM
@rolfl We worked to our strengths. You are really good with optimizing the code, I am good at focusing on the standards.
4
Hello @Speakwithsystem
 
0
Q: Combine jquery.history.js with another script which includes the html content of $file.php to div#include… now with JSFiddle

mandar1neFor about five hours now I'm trying to combine the use of jquery.history.js with another script which includes html content from a file $file.php to div#include. Would be great if I would get some feedback, if there are better ways of doing what I tried, and maybe even someone knows, why my exam...

 
Hey SpeaksWithSystem - how's your Error/Exception handling coming along?
Anyone here an XML expert ?
(like deep-in-the-guts-of-the-specifications expert)?
 
5:17 PM
@rolfl Didn't you mentain a library about it? If so, then that person must be a real badass expert.
 
@rolfl Hi @rolfl! Waiting until tomorrow to write to the preservation of hibernate, and intercept the main exceptions :)
 
@skiwi - I am struggling on whether my library is supporting the following XML document correctly:
 <xMl:xml xmlns:xMl="MyURI" xml="1"/>
See, I know that some libraries will process that OK, but JDOM does not, currently do it.
The XML specification has the following to say about that:
http://www.w3.org/TR/REC-xml-names/#xmlReserved
and, someone opened a bug against JDOM, and I am trying to decide exactly what the right system will be.
 
SE's latest question there seems to be off-topic, and the OP has implied that it was cross-posted (which it was).
 
Morning!
 
5:29 PM
Were you really up to like 5am ?
Hey 200_success too.
 
Yes...
 
0
Q: Voting Algorithm

JavaDeveloperFind the element the occurs more than n/2 times in an input array, where n is input array length. Looking for code review, optimizations and best practices. public final class VotingAlgorithm { // non-instantiable. private VotingAlgorithm() {} /** * Returns the number which...

 
@rolfl Interesting to read that bug report though
dang @syb0rg I know this comment, only not from where...
"Yes, there are some rare situations where you may find it necessary to use it. This is not one of them."
(about goto statements)
 
5:46 PM
Is this the "General discussion about Code Review" room or is it "The place where all the moderators of Code Review hang out"?
 
This is some deep stuff...
1
Q: class inherits unrelated defaults for spliterator() from types java.util.Set and java.util.List

JayanI have class that implements Set and List. Programs works fine in Java6 and Java7 public class SetList<V> implements Set<V>, List<V> { .... } With Java 8 , this does not compile. Error is java: class trials.SetList inherits unrelated defaults for spliterator() from types java.util.Se...

 
Good to see that our moderators are visiting chat often :)
 
Moderators and chat shall become one.
 
@skiwi That's not very deep stuff at all, the OP just needs to override the spliterator method
 
How in earth can you define a datastructure that is both a set (unordered) and a list (ordered) at the same time?!
That is the deep stuff I mean @SimonAndréForsberg
Technically it's overriding the spliterator indeed
 
5:48 PM
There are ordered sets as well. TreeSet for example
 
LinkedHashSet
 
The OP's class SetList<V> needs to provide its own implementation of it.
 
hmm, but a set does not allow duplicates, whereas a list does
How could that be fixed?
 
Even if it could be fixed, it shouldn't be. The OP probably wants to do something entirely different. XY-problem.
I'm suspecting that a LinkedHashSet is precicely what he is looking for
Possibly he just wants the ordered functionality of a List, while only retaining one of each unique element. LinkedHashSet is perfect then
 
@rolfl Why not remove all mention of do-while?
and rename checkprime to is_prime().
@syb0rg I disagree with all three of your portability points.
Autotools add a lot of complexity for questionable gain. They are good for defining macros that change which function you call, depending on what's available on your system. That's not even a concern for this question.
"Adhere to standards" is too vague to be helpful.
unsigned int is available everywhere, and is no more portable than size_t. However, size_t has the connotation that it represents an array size or something similar, which is not the case here.
A valid portability concern is that a signed int is only guaranteed to hold up to 32767, which may be smaller than the author expects.
 
6:16 PM
Maybe someone know where to share with code, i wrote SaveUtils with some popular methods and maybe someone have something to add in utility...
 
@200_success I'll fix the last two, but you really disagree with AutoTools?
 
Yes. How would autotools improve the code, specifically?
 
It doesn't really affect the code at all.
It's more of a packaging tool.
 
At best, you would insert some #ifdefs.
Even as a packaging tool, it hardly helps.
autotools would be useful for code that has a lot of system dependencies.
 
Maybe I'll link to that in my answer.
 
6:25 PM
All those examples relate to the size of some chunk of memory.
The code isn't allocating any memory or using any array. It's just doing trial division.
 
@200_success Revised the answer.
 
@200_success - because ... it was a progression of refactoring that made the do-qhile become a while.
And the is_prime, is_good_idea.
 
I just don't see how it was ever an intermediate step in the first place, and it just confused me.
 
Without the function-extraction the do-while loop is the best system... do the work to set found == PRIME_TRUE and then check the condition afterwards in the while part of the do-while.
The function-extraction is a better solution, and thus... well, never mind, let me refresh my thoughts....
 
6:41 PM
@Vogel612 jingle jingle
 
@200_success edited the answer with the is_prime change, and also mde the logic-progression a bit clearer from the do-while to the while.
 
You might want to update ideone as well. I just don't understand how your perhapsprime -= 2 got introduced in the first place, since it was never in the original code.
 
7:03 PM
@skiwi So you're basically telling me to leave chat (since I have no plan to become a moderator)?
 
@syb0rg jingle
Hey half robot.. i see you didn't roll back, but edited again...
 
@Vogel612 Where?
 
@JerryCoffin Then I'd have to leave aswell ;)
 
Let me know if you guys see anything wrong:
0
A: Implementation of atoi()

syb0rgThings you could improve Variable/Initialization Where do you declare multiplier? I assume that since it is not declared within the method, it is declared as a global variable. Try to avoid global variables. The problem with global variables is that since every function has access to these,...

 
7:28 PM
0
Q: Is this the right way to implement a hashmap?

NewbieIs this the right way? Any comments on the hash functions? If asked a question like this in an interview, do I need to follow all OOP concepts(because I am using Java)? Like encapsulating the variables by writing getter and setter functions? import java.lang.reflect.Array; import java.util.Arra...

 
@syb0rg Still fails for a maximally negative number on a 2's complement system, but fixing that can be somewhat non-trivial and probably outside the scope the OP contemplates.
 
Yeah. The easiest way to fix that would be to have the function not handle numbers like that at all.
 
@syb0rg That certainly makes it easier. Not so sure whether it qualifies as a fix though. :-)
 
"The Lazy Developer Fix"
 
@syb0rg return false; /* Implementation of anything */
4
 
7:43 PM
@syb0rg exactly there... the question code was heavily edited in rev2
 
@Vogel612 In my most recent answer? I added the Documentation section.
 
7:59 PM
Thanks, Santa! 2 more rep until 8200.
 
00:00 - 20:0020:00 - 00:00

« first day (330 days earlier)      last day (3681 days later) »