« first day (333 days earlier)      last day (3909 days later) » 

00:05
RELOAD!
Anonymous
Take my hand and reload
This is free love
That’s what we are made of
Yes we are, are, are.
@Corbin It's because the way std::sort works would make it quadratic complexity if used with std::list iterators
Right, it's just the thought of sorting a std::list at all is gross :/
Personally the API for std::string is uglier I think
so much crap that just...doesn't need to be there
Side note: it seems that a template<typename Container> sort(Container& container); should exist in the standard library. I suppose those much much wiser than I though think differently.
Yeah... And a few things that would be nice to have are missing.
00:13
@Yuushi @Corbin Have you seen my latest question yet?
I have not. Will take a look now.
@Jamal add uses std::size_t but remove uses unsigned int? :)
Darn...
Darn ... the new lol ;-)
Well, I was unsure if I should even use std::size_t here. I was about to have a size typedef, but nah.
00:18
hrm, what to listen to, what to listen to...
@SimonAndréForsberg - Congrats, you GURU!!!!
No code included...
0
Q: JQuery: slide-out navigation bar (fiddle)

oceanic815http://crystalcleanhomes.com/slide/ There are countless scripts that perform this simple slide-out navigation menu but they are all so bloated and the styles are so convoluted that I decided to make my own and it seems almost too simple and too basic so I've come here for criticism. From my test...

0
Q: Slide-out navigation bar

oceanic815http://crystalcleanhomes.com/slide/ There are countless scripts that perform this simple slide-out navigation menu but they are all so bloated and the styles are so convoluted that I decided to make my own and it seems almost too simple and too basic so I've come here for criticism. From my test...

00:34
@Jamal I had a go at your latest question:
0
A: Singly-linked grocery list

CorbinRather than having the user pass in name and quantity, have the user pass in a Grocery. You complete throw away any sense of encapsulation by having the user provide the components rather than the object. Rather than displayGroceries, I would overload operator>> for ostreams. Give Grocery a...

@Corbin to be fair, a list is almost never the right data structure, so it kind of goes without saying :P
Hah. Especially in C++. There's a particular interesting talk (if you're into cache-y type things) by Stroustrup where he compares a vector to a list and basically concludes that lists suck even when logically/algorithmically a list is what you think you need.
yeah, I haven't seen it, but I can guess some of what he talks about
removes any opportunity for SIMD, has to jump around the heap so loses any kind of locality of reference...probably a lot of extra stuff I don't know about as well :)
Nope, that pretty much covers it.
@Corbin Do keep in mind that this is still a toy program. :-) I'm going with the "Not Another Linked List" for April Fool's that Jerry Coffin already started.
00:42
@Jamal Yeah, I thought about prefixing my post with a note about how I knew you probably knew a lot of what I was going to say. I tend to review all programs as if they were real programs though. Otherwise, everything really comes down to "tl;dr: it doesn't matter in a one off, toy program." :D
I might post my list, but it's a bit less toy-ish and more... massive. It's only about 75% finished and I'm afraid it's already probably too long for CR. github.com/nibroc/containerpp/tree/dev. I will likely post it at some point after I go through and refactor it heavily. I've never posted anything before, and I'm a bit curious what bad habits/design pitfalls/etc I have.
I am glad you've pointed out how I've messed up add(). I was mostly in "while not at the end of the list" mode the whole time. :-/
@Corbin looks about right
(length wise)
@Corbin: For the first point, should I make the struct public, or have it in the driver as well?
@Yuushi Hrmm, perhaps when I get a chance in a few days, I'll clean it up and post it.
@Jamal well, ideally an container should have no idea (nor care) what it's storing, so it would be completely separate from the container. In this case though, since the list is special purpose, that doesn't really apply. I would have the list keep using Grocery (rather than going the templated route), and just pull Grocery out into its own header (e.g. Grocery.h) and maybe implementation file if you give it methods.
It just feels icky to use a string/number pair since it's both vague and prone to break when changes are made (Like what if you wanted to add a cost field to Grocery? Then you would have to update all of your methods).
00:53
Okay, I can go the header route.
01:13
1
Q: Auto-Format GPA while typing

James Anderson Jr.I'm looking for a more cleaner and simpler solution to auto-format a text-box field intended only for the user to enter their college Grade Point Average (GPA). Here is my code: <label for="collegeGPA">GPA:</label> <input type="text" name="collegeGPA" id="collegeGPA" maxlength="4" style="width:4...

0
Q: How to make the Javascript code more efficient?

user3376708Here is another example of a moving ball I would like to see how to make a more efficient and better Javascript program. I think that moving the variables to the top of the function would be better but then I tried this and it would not work as good as it did. Question: How to make the Javascrip...

01:51
Catching up some ZZZZssss TTGTB
hai guys
hai
hello
'night rolfl
hai mat
02:01
mat? yesterday i was discussing on sustenance/maintenance market in software industry trend in my office
do u think it is diminishing? shrinking?
not market sector*
how do u see this trend in future?
I think the day the average upper management no longer sees code quality, peer reviews, refactorings, readability, extensibility and all of SOLID as something that costs more and delays delivery, but rather as something that reduces total costs and only adds positiveness in every single possible aspect of a project, that day, ...pigs will fly.
I don't see how maintaining code could be diminishing overall.
But I'm slightly biased. I work with legacy VB6 crap code
i worked for IBM AS400 event mgmt product, NSK tandem event mgmt product so jack of all, but i see these maintenance work getting diminished
customers are getting on new platforms
updating their infra
well of course if you're talking about overall maintenance in specific languages or technologies, ...thing is, maintenance doesn't diminish overall - the only thing that changes is the language of the code being maintained..
ok
if anything that demand will (hopefully) increase over time; more time, more programmers; more programmers, more code; the more code there is, the more there's code to maintain - the more jobs we have ;)
02:20
@Edward OK, that took longer than I expected, but the world can rest easy tonight: we have an assembly language linked list implementation.
ok
@Edward you're kidding
:D
As they say in Ukraine, "nyet!"
@Mat'sMug what about people mgmt career?
@Edward wow you're evil! putting it up for review?
02:21
@Mat'sMug :D
after agile?
people management, as in HR?
mgr in software maintenance team
2
Q: assembly language linked list implementation

EdwardInspired by all of the lovely linked lists lately, I decided to implement one in assembly language. This code maintains two linked lists - one is a free store and the other is the active linked list. Rather than allocating memory whenever a new node is needed, the Node is pulled from the free l...

her in our country still people mgrs work for software maintenance team
they run the teams
what about there
?
02:23
Beat me by 10 minutes.
@Bob65536 You can critique mine.
@Bob65536 are you competing with @Edward?
No, I had no idea he was doing something similar.
Nothing like a little bourbon on the rocks and assembly language after dinner.
@Sham I think that's specific to how each company runs their stuff.. you can find a job where you land in a team of 3 devs that each work in their own "silos", or you can land in a team of 3 devs that work as a team, and have a team lead that reports to some IT director. The maintenance team is often the dev team and the test team.
02:28
so dev team does fixing bugs as well in maintenance team?
fix*
Hmmm. The stackexchange syntax highlighter doesn't seem to understand assembly very well.
@Edward Surprisingly, gedit doesn't have a build-in syntax highlighter for assembly.
@Sham there's only 1 team, "the IT department" in many cases.
(generally split in two - "dev" and "network")
3
Q: Stack Implemented Using Linked List

Bob65536I wrote a stack implementation using a singly linked list in x86_64 assembly. This stack supports the usual push/pop operations as well as first/next for iterating over each element. I'm looking for general feedback. Here are the stack subroutines. ; Stack Structure ; Pointer Head ; Pointe...

@Mat'sMug need to leave now, office time! will continue tomo
02:31
see ya!
@StackExchange THAT is what the world needed.
@Corbin: I have made some massive changes to the code, including removing some member functions. I've probably rushed my implementation a bit, and you have pointed out some of the biggest things, so I may accept your answer soon.
...unless @JerryCoffin has something else to add. ;-)
02:46
:D
...and then the next answer mentioned the Rule of Three. :-/ I have forgotten about that.
It was mentioned that I can also remove them in C++11.
@Corbin: Here's a glance of what I have so far: ideone.com/mKNkh7
03:01
@Jamal I apparently forgot it too. What do you mean about removing them in C++11? If there's some kind of resource management going on, they're still very much required (and it becomes the rule of 4 or 5 in some circumstances if moving is involved).
3
A: Singly-linked grocery list

KeithYou need to consider the Rule of Three. That is: the default copy and assignment implementations will not handle the head as you'd like. You need to define them correctly, or hide them (or remove them in C++ 11). For example: class LinkedGroceryList { private: LinkedGroceryList(const Linke...

And, right now, I do have a tail.
napalm'd
@Jamal I'll take a look after I'm done helping my son with his homework.
Alright
03:18
Good day to you all!
03:33
0
Q: Print all combinations of balanced parentheses

JavaDeveloper Given ( and ) and length of 4, generate the following combinations - ()() and (()). Looking for code review, optimizations and best practices. Also verifying complexity to be O(2(n+1) - 1), where n is half the 'input length'. public final class BraceCombinations { private BraceCombin...

@Jamal I don't think he meant remove them as in "or you can just not have them." I think he meant it in the sense of "if you want to disable copying and assigning, you can T(const T& t) = delete; them." You do either need to implement them or delete them though.
Yeah, that's what I meant. Is that even possible in Visual Studio 2012?
@WurdNerd hi! welcome to The 2nd Monitor!
0
Q: Does this simple memory pool use too much memory?

2013AskerI just wrote this pool to avoid calling malloc and free when I have some code that frequently allocates and deallocates chunks of same-sized memory. I would like to know if there are any bugs I didn't notice and what would be the best solution to achieve this goal. I'm using some small functions...

03:51
now that is a much better answer than the quick crap I put together in 3 minutes before leaving work!
0
A: Async and Error Handling

Mat's Mug I need to delete a file when an error occurs during loading it. In other words: Happy path: Load a file Move on Unhappy path: Load a file, exception is thrown Delete the file Move on Exceptional path: Load a file, exception is thrown Delete the file, exception is thrown Handle exc...

You've been listening to Eric Meijer too much when you start using "Happy Path" :P
pure coincidence ;)
Oh well. I'll define the copy constructor and assignment operator later.
just realized the "Body" part/section of my answer contradicted the approach I researched just after writing that part. wow. removed, and TTGTB! 'night @all!
04:34
@Mat'sMug that was me voting and unvoting your answer, I was watching the Unicorns do their thing....lol
05:09
@JerryCoffin: I haven't used smart pointers before, but I'm trying them now. I am experiencing some problems.
What sort of problems?
It looks like I'm able to assign unique pointers with std::move, but I'm not sure how to successfully assign tail->next to a unique pointer (tail being of the same type).
05:25
tail->next is a nullptr I assume?
hai guys
i have a query in python
it is following query for an existing in SO.
can i ask?
@Yuushi tail does originally point to nullptr.
@Sham Is it about reviewing working code? If so, it probably belongs on the actual CR web site, not in chat.
ok
@Jamal Contains, not points to (for what little that's worth).
05:28
Ah
I have this in the add function now:

std::unique_ptr<Grocery> newGrocery(new Grocery(grocery));

newGrocery->next = nullptr;

if (empty())
{
head = std::move(newGrocery);
tail = std::move(newGrocery);
}
else
{
tail->next = std::move(newGrocery); // error line
tail = std::move(newGrocery);
}
gotta be careful when moving things
(yes, I know it's obviously wrong, but it was what I was attempting before)
once something is moved from, you can't move from it again
head = std::move(newGrocery);
tail = std::move(newGrocery);
I see. In that case, would I just need a copy?
well, you can't copy a unique_ptr, so in this case, you'd need to think about the design a bit more
05:36
True. I'm still trying to find sufficient information online.
so as some advice, it's easier to use an rvalue instead of explicitly moving stuff
so head = std::unique_ptr<Grocery>(new Grocery(grocery));
and set up your Grocery copy constructor to initialise the next pointer to nullptr automatically
Okay. Do I do the same above with tail?
I suppose you could, but is there any reason that tail needs to contain the same element here?
I thought both of them are supposed to point to the same node if there's only one node in the list.
that's often how it's implemented, but it's not going to work so well with unique_ptrs
given that they're unique and all :)
05:48
@Jamal That creates a circular list--but with a unique_ptr, you really don't want to do that. You probably want to set the tail to nullptr to indicate the end of the list.
@JerryCoffin Okay
Meanwhile, this looks like a great question to try out our new close reasons:
0
Q: Designing Architecture for Activation and licensing of a product in JAVA

KRCI want to develope a module from scratch for activation and licensing of my product.The architecture needs to be generic so that it can be used for any product to activate and license.Also the module will require to communicate with my server to get license information for a product periodically,...

Just as someone here observed, JAVA questions tend to be crappy.
0
Q: Designing Architecture for Activation and licensing of a product in JAVA

KRCI want to develope a module from scratch for activation and licensing of my product.The architecture needs to be generic so that it can be used for any product to activate and license.Also the module will require to communicate with my server to get license information for a product periodically,...

@JerryCoffin I have done that now, and I'm trying to figure out what to do with tail->next.
if tail is now a nullptr, you don't need to worry about tail->next :)
because dereferencing tail === dereferencing a nullptr, so no applying -> to tail
@Jamal If you're inserting before some existing item in the list, you'll move the pointer to that existing item into your new items' next pointer. If you're adding to the end of the list, its next pointer will be a nullptr.
05:53
@Yuushi I had a feeling. Here's what I have now:
std::unique_ptr<Grocery> newGrocery(new Grocery(grocery));

newGrocery->next = nullptr;

if (empty())
{
head = std::move(newGrocery);
tail = nullptr;
}
else
{
tail = nullptr;
}
Keep in mind that unique_ptr's are unique. They own the underlying object. tail is (apparently) intended to refer to the last item in your list. If so, it can't be a unique_ptr (that would imply its owning the last item in the list, which is already owned by the unique_ptr in the previous node). As such, tail should be a normal pointer, and should just point to the last item in the list. When you insert into an empty list, both head and tail will refer to the one node in the list.
When you add more nodes, head will still refer to the first, and tail to the last.
Ah, okay. Somehow I was under the impression that all raw pointers would need to become unique.
No--a unique_ptr is specifically intended to own the item...uniquely. Something like tail is just supposed to see the item rather than owning it, so unique_ptr doesn't fit.
That makes sense.
Now I'm in the remove function. For the first case in which the single node is to be removed, would I just release the pointer and set head to nullprt? I know I no longer use delete here.
06:16
Sounds about right.
I have this for the `head` case:

if (head->name == grocery.name)
{
groceryPtr = head->next;
head = groceryPtr->next;

quantitySum -= grocery.quantity;
if (grocery.quantity == groceryPtr->quantity)
numGroceries--;
else
{
groceryPtr->quantity -= grocery.quantity;
return;
}

//delete groceryPtr;
}
Where groceryPtr is a raw pointer.
If memory serves, I'd done deleting by swapping to a local variable (that goes out of scope and deletes the item). So, to delete the first item in the list, you point your local variable to the second node in the list, then swap it with the head of the list. That gives the head of the list ownership of the remainder, and it ownership of the first element. Then when the function exits, it automatically deletes that first element.
For something other than the head of the list, you're swapping with the pointer in the previous node that points to the node you want to delete.
06:32
I might have to look at this again tomorrow. I might need a clearer mind before I start thinking more about smart pointers.
0
Q: Get remaining days in date range

user1647667I wonder if there are some possible ways to simplify my code. startDate = '04/02/2014' endDate = '04/06/2014' mondayTag = 0 tuesdayTag = 0 wednesdayTag = 1 thursdayTag = 0 fridayTag = 1 saturdayTag = 0 sundayTag = 0 public int GetRemainingDays(DateTime startDate, DateTime endDate, bool monday...

0
Q: How can I optimize this very simple piece of “Game of Life” code by taking advantage of NumPy's functionality?

user89It was suggested to me that I should post this Stack Overflow post over here. Here is the code as it stands right now: import numpy as np from matplotlib import pyplot as plt from matplotlib import animation from random import randint arraySize = 50 Z = np.array([[randint(0, 1) for x in range(...

Morning
07:14
re
somebody had asked same type of question on stakeoverflow.com and than he was suggested by some expert that he needs to ask such question on codereview.stackexchange.com. So I asked this question here . May I know what is wrong in it ? — KRC 47 mins ago
Whomever said that this kind of question belongs here is absolutely wrong. If the question contains no code, it's automatically off-topic. We cannot review code that doesn't exist. — Jamal ♦ 1 min ago
Thanks!
What saddened me the most is when he mentioned that someone thinks a question with no code can be reviewed.
Monking everybody^^
@Jamal I'm afraid that we can't solve that. There always be users who suggest another sites where the question is off-topic.
07:29
if (question.containsNoCode()) { rejectQuestion(); }
@palacsint And yet some of that lacks common sense. At least the OP now knows.
0
Q: Handling packets in nodejs for MMORPG

majimbooWriting a MMORPG server in nodejs, I have to handle packets. These packets have a structure of <length> <id> <data> So what I did was use a node package called packet And first get the packet id: client.on('data', function(data) { parser.extract("l16 => length, l16 => id", function (packe...

07:43
Off-topic:
0
Q: Primes and multi-threading

SamothI use to compute primes using linear code which took a long time. As I've an 8 cores processor I thought about multi-threading. At first I use to put a huge number of int in a vector then share the vector between the threads which takeout each number which is not a prime. The first thread proce...

0
Q: Primes and multi-threading

SamothI use to compute primes using linear code which took a long time. As I've an 8 cores processor I thought about multi-threading. At first I use to put a huge number of int in a vector then share the vector between the threads which takeout each number which is not a prime. The first thread proce...

0
Q: ToString() and AddString() method without using .Net Collections

user2480288I was asked to answer the following question before setting up a phone interview, but they said my code wasn't detailed enough. Question : Without using any of the .NET Collection or Linq libraries (i.e. without using List), implement a ListOfStrings object that contains a set of strings. This o...

0
Q: Linked List reversal

Loki AstariRecursive version #include <iostream> #include <memory> struct List { struct Node { int val; std::unique_ptr<Node> next; Node(){} Node(int v, Node* oldTail) : val(v) , next(nullptr) { oldTail->next.reset(th...

08:04
8 pages of questions for ...
Seriously, we could ask to open LinkedList.SE
5
Morning @SimonAndréForsberg
@Morwenn Mine is still incoming
Current problem is that this refuses to work
    List<Integer> list2 = new LinkedList<>();
    System.out.println("list2 = " + list2);
    ListIterator<Integer> li2 = list2.listIterator();
    li2.add(20);
    System.out.println("list2 = " + list2);
@skiwi Let me guess: Java 8?
@StackExchange quite smart solution, really surprising
@Morwenn yep
08:40
Self note: collector.supplier() and collector.supplier().get() IS NOT THE SAME THING!
08:57
Huh?
I'm going to check that out
0
Q: How to avoid converting HTML tags elements into JSON Object during XML to JSON conversion using X2JS?

Ram Babu SI am using X2JS for converting XML file into JSON Object. Some XML Tags contains HTML Tags inside it. <xmltag>I am the data <strong>available</strong> for sale now</xmltag> Now I dont want the html tag "strong" to get converted into a JSON Object. When I use the variable "JsonObj.xmltag" it s...

@skiwi It's just me being completely stupid apparently. Of course they're not the same thing...
I should add a warning to this code: Kids, don't try this at home
I am so putting up this code for review some time...
hehe
After a nice snack of tea and salsa (so random), it's time to go to bed. :-)
@Jamal Either that, or the fact that it's about 4/5 in the morning for you...
09:05
It'd be four. :-P
@Morwenn real links help...
stuff is bigger then ;)
I didn't know that the image would be directly inlined.
it's done with all xkcd comics...
though i guess it's hard with the current
You mean that the SE chat has specific support for xkcd?
09:16
yea..-.
Wow :o
just like it supports wikipedia ^^
as well as wikipedia, amazon, YT and some other things..
xkcd, sometimes stylized as XKCD, is a webcomic created by Randall Munroe. The comic's tagline describes it as "a webcomic of romance, sarcasm, math, and language." Munroe mentions on the comic's website that the name of the comic is not an acronym but "just a word with no phonetic pronunciation". The subject matter of the comic varies from statements on life and love to mathematical and scientific in-jokes. Some strips feature simple humor or pop-culture references. Although it has a cast of stick figures, the comic occasionally features landscapes, intricate mathematical patterns su...
that image is the actual current XKCD strip.
09:18
confused the shit out of me
Meh, no support for Bandcamp.
meta.so incoming?
Not really. There isn't any website on the network whose purpose is to listen to obscure bands.
Hmm, if I add an element via a ListIterator, then it should add it to the real list, right?
09:35
@skiwi Yes, that sounds reasonable.
09:50
@SimonAndréForsberg Then my LinkedList is not reasonable yet
10:27
0
Q: What can be improved on this Matlab code?

ALJI MohamedI implemented K-Nearest Neighbours algorithm, but my experience using matlab is very few. I need you to check the small portion of code and tell me what can be improved or modified ? and hope it is a correct implementation of the algorithm ? function test_data = knn(test_data, tr_data,k) numof...

10:52
0
Q: Largest Palindrome checking program

user3296744import java.util.ArrayList; public class LargestPalindrome { //Write a java program to find the biggest palindrome of the string entered by the user. //Ex:: User input is ABABABAAAB //This string has following palindromes, ABA, BAB, BAAAB //Our program should return the biggest string of these ...

11:02
@StackExchange That "palindrome" question is not ready for review in my opinion. The code doesn't have anything to do with palindromes at all.
@SimonAndréForsberg Something new in Java 8 :o
7
Q: How to serialize a lambda?

assyliasHow can I elegantly serialize a lambda? For example, the code below (expectedly) throws a NotSerializableException. How can I fix it without creating a SerializableRunnable "dummy" interface? public static void main(String[] args) throws Exception { File file = Files.createTempFile("lambda"...

Monking all
@rolfl Monking!
Monking @rolfl!
How's the guru and the list-breaker?
11:08
    List<Integer> list2 = new LinkedList<>();
    System.out.println("list2 = " + list2);
    ListIterator<Integer> li2 = list2.listIterator();
    li2.add(20);
    System.out.println("list2 = " + list2);
Is unfortunately still broken
But haven't had time at the moment, working on android app for university project
It is an app that has something to do with walking form one point ot another and being on time, got the current speed, etc. distance covered and eta working :D
Monking @rolfl..
what happened???
I was doing break for 1h+ and there's only 13 messages?
@rolfl The guru's happy that his code works, and feels confident that the remaining features should be implementable as well. How's the monkey?
And oh, the guru's also quite confident he'll reach 10K today.
@Vogel612 Would you rather have 100 messages?
@Simon naaah... it just kinda surprises me, when I get a coffee and there's 65 messages....
and now I am out for an hour... and nothing happens.
Well, what can I say ... it has lulls
Have you ever checked out the chat activity graphs?
OK, I down-voted an answe.... now i have to hit re-max today ;0
I really love how you, simon, Jamal and the Mug are there twice in the "frequently in this room"
11:19
The bottom left are because we are room owners
hum... makes sense...
they should really make the difference more clear.
You don't think the 'Owners of this room' gives it away?
it should....
but on the first glance it doesn't....
@Vogel612 I actually agree that it's not very clear, it should be a line between them. Right now it's a bit hard to know if the folks in the bottom-right are visitors or room owners.
I would upvote a MSO request about it
alright, I'll ask one.
11:23
@rolfl I have checked it out a few times but haven't looked so much at the stats. We have quite many messages per week here..
13
Q: Chat room information screen is confusing

PearsonArtPhotoI wanted to see who the owners were of a certain chat room today, and here's what I saw: My first thought was, did I somehow become a room owner without knowing it? Upon more careful consideration, I realized that there are actually 2 columns of users, the left two are room owners, the right t...

found one..
Yeah, it is one of the more active rooms
@skiwi I'm not sure I find serializing lambdas that useful?
But the syntax/feature seems userful
TTGTW ... BBIAB
@SimonAndréForsberg I was trying to imagine a real use case too.
11:27
@rolfl I still think BBIAB means "Be back in a banana"
0
Q: Should I put python3 argparse filetype objects in a contextlib stack?

tommy.carstensenI just read the Lib/argparse.py code (class FileType) on http://hg.python.org/cpython/file/default/Lib/argparse.py. File objects are opened without the with statement. For safe file opening/closing, should I instead encapsulate my argparse.ArgumentParser() in a contextlib stack like below? I feel...

0
Q: Class for printing class hierarchy as text

bobbelI'm coding a little class hierarchy printing tool for easy show hierarchies of java classes. This is my current code: import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.PrintStream; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; i...

Type safety: Unchecked cast from Serializable & Indexer<Fight<TTAI,TTController>> to Serializable & Indexer<Fight<TTAI,TTController>> - How on earth can that be unchecked?
3
wait what?
0
Q: Sudoku Checker in java

user3296744public class SudokuChecker{ static int[][] sMatrix={ {5,3,4,6,7,8,9,1,2}, {6,7,2,1,9,5,3,4,8}, {1,9,8,3,4,2,5,6,7}, {8,5,9,7,6,1,4,2,3}, {4,2,6,8,5,3,7,9,1}, {7,1,3,9,2,4,8,5...

I wanna take that one.
11:44
0
Q: Collatz Sequence

NiallSzalkaiI'm a beginner and I only know limited amounts such as IF, While, Do While. So I'm here to check if I'm coding with best practise and the most effective methods to my current knowledge. Any feedback really is greatly appreciated! :) import java.util.Scanner; public class SixtyTwo { public...

@Vogel612 You want to answer that Sudoku one? Go ahead. I just scanned through it quickly and found several things I could say about it.
@Simon I'll stay completely with the algorithm, the rest is yours ;)
@Vogel612 Why do you get to take the fun stuff? :P
Alright, I'll take Collatz then.
dig in
@Vogel612 I'm done, how's yours going? :)
11:58
almost done, adding some explanationr right now.
0
A: Sudoku Checker in java

Vogel612You have waaaay too many sums you are checking. KISS --> Keep it Simple Stupid: private boolean checkSudokuStatus(int[][] grid) { for (int columnIterator = 0; columnIterator < 9; columnIterator++) { int[] row = new int[9]; int[] square = new int[9]; int[] column = gr...

@Vogel612 I think you should add a (No offense) to that KISS :)
And perhaps add a link to wikipedia
would be an idea...
I am really proud of my square generation tho ;)
I used that code as a golfed version in a company-internal challenge.
220
Q: Why can't my program compile under Windows 7 in French?

Lightness Races in OrbitI'm running Windows 7 French and I'm trying to compile this really basic program, but Visual Studio is being stubborn and refuses to comply. I also tried compiling it with both GCC 4.7 and Clang trunk on Coliru and I get more or less the same errors (output is below the code), though I think Coli...

This got shared by isocpp.org. That's awesome.
int i=0,x,y;for(int[]a=new int[27];i<81&&!(a[grid[y=i/9][x=i%9]+8]++>y|(a[y/3*3+x/3]+=x=grid[x][y])>45|a[x+17]++>y);i++);return i>80;
this was the shortest solution, with 131 characters.
12:23
@Morwenn I was aware of that one yesterday, but admit, I don't understand it.
@Simon I had my shot at the Collatz question too...
0
A: Collatz Sequence

Vogel612You can greatly reduce the complexity of your code, by using the ternary operator: while (n != 1){ counter++; stepsTaken++; n = (n % 2 == 0) ? n / 2 : n * 3 + n; System.out.print(n); //Your largest number and the linebreaks go here; }

@rolfl Too bad. There are some really good - and sometimes slightly offensive - comments in there :p
sometimes he says
slightly he says.
@Vogel612 I'm actually considering taking a shot at the sudoku question :)
@Simon feel free, there's still stuff to improve ;)
12:26
Two up-votes to 10K!
@Vogel612 Generally speaking, I'm quite used to be offended :p
@Simon you just got an accept too..
Done
Nooo, that was 5 rep too much!
Mouahahaha.
12:27
Whoo hooo!
Nevermind, 35 rep to much
And the winner is .... Simon (take that, Mat's) .... ;-)
Yay! I'm 10K!
6
Congratz
20K now
^^^ Not sure whether I should say ... half way... ?
12:28
it takes a while ;)
Basically, to earn points on CR, you have to know either C#, Java or C++.
Or be a regular in chat
@Morwenn There is this one guy who got 11K out of JavaScript :D
3
^^^ that
^^^^ and that
Or, be a good voter, I vote more for voters
2
12:30
@konijn Well, Javascript and C are 4th on the list.
And, it looks like there will be a new #2 today: codereview.stackexchange.com/…
I should learn to use Java and C#. It will get me points in the long run.
@Morwenn or you learn to review LinkedLists.
Pick one .... Java.
@rolfl don't be so negative against poor Microsoft folks..
12:34
Actually, I am happy with fewer people harvesting Java rep ... pick C#.
they were definitely faster with Lambda's and I really hate checked Exceptions.
@rolfl Too many of you guys reviewing Java in less than 2 minutes.
@Vogel612 I know, it is not fair, they have it so rough already
before i'm talking nonsense... Ternary Operator is only for assignments right?
no
12:36
fck.
but it can only contain one statement, right?
(please)
if (x == y ? a == b : c == d) { ...}:
@rolfl that counts as assignment to temporary var.
With correct parenthesis, it can do pretty much anything.
if ({temp =} (x==y) ? a == b : c == d){...}
How about:
majorerror ? System.exit(1) : throw new IllegalStateException();
12:40
bleargh.
Or even better:
3
Q: `std::common_type` implementation

MorwennJust to see how it worked, looked at the g++ implementation of the structure std::common_type in the header type_traits and I must admit that I can't get how it really works. Here it is: /// common_type template<typename... _Tp> struct common_type; template<typename _Tp> struct common_...

this should definitely be an if in my eyes...
That's probably one of the trickiest uses of ?: I can think of. I didn't understand how it worked at first, hence my question.
@Vogel612 That ternary expression does not work... hang on.
@rolfl which one?
does your majorerror have a major error?
12:43
@Vogel612 Now that it's 2 April, there may be less need for linked-list reviews...
@Edward not that it mattered to me..
@Vogel612 yes.
well, BTW.Work
@Vogel612 - ternary operators in Java apparenlty have to be part of a condition or assignment.
YES, I beat the guru in his own domain
12:50
@Vogel612 That's because GURUs only know about good practices.
When you avoid bad practices, you don't know how they work :o
Sometimes, people ask me "why doesn't my C++ code work", and I can only answer "I've no fucking idea, but if you rewrite it like that, it'll surely work".
*hilarity ensues*
I'm often wrong though.
*even more hilarity ensues*
@Morwenn yes, I usually use the phrase "bad looking code probably doesn't run well either."
12:57
@Vogel612 - reference is complicated, but this answer does better than most:
4
A: What am I doing wrong with conditional operators?

Stephen CThere are actually two errors in this statement. isTrue ? System.out.println("true"): System.out.println("false"); As @Slaks points out, the ternary '?' operator requires that the second and third operand expressions have a non-void type. That explains the message "Type mismatch: cannot ...

@rolfl that answer should have more upvotes.
I just discovered that Matplotlib can draw xkcd-style plots :o
Why is this downvoted without much explanation?
-2
Q: Efficiency of moving ball

user3376708Here is another example of a moving ball. I would like to see how to make it more efficient and better. I think that moving the variables to the top of the function would be better but then I tried this and it would not work as good as it did. <!doctype html> <html lang="en"> <head> <meta chars...

I rejected the suggested edit on the question btw
13:14
some people misunderstood OP due to dumb formulation...
i guess OP has performance issues, and thus it "works not as good as it did"
Voting just isn't the same without animated unicorns. <sigh>
3
@SimonAndréForsberg - the Castle Wars link .... it is now a redirect, is it what you intended?
15
A: Code-Challenge #2

Simon André Forsberg2-player card fighting game This is not about playing cards as in "Hearts, Diamonds, Clubs and Spades". This is a game where 2-players (or more if you are really enthusiastic) can play/use cards or spells to do some effect against themselves or their opponent(s). Minimum requirement: Two pla...

@Edward - people are not the same without bobbleheads
2
@rolfl Well, the end result seems to work at least. I'll edit the link with the redirect target.
Sorry, actually, check castle wars 2.
13:22
Hmm...
Ah, right. MochiMedia has shut down!
I'll see if I can find the game somewhere
Cha-Ching! Found it.
0
Q: Is there an in-built way to calculate a month later than current month (without rolling over to next month)

Keir LavelleI needed a script for working out billing dates over a period of time, the date should be the same day every month however if the billing date starts on a date that doesn't exist in another monhth, then it should be on the last day of that month. This rules out the DateTimeInterval Object, becaus...

Someone took away all my Rep!!!
@Malachi Don't you have any unicoins left?
no more unicoins
the fun and games are over I guess
13:43
@Malachi At least you have stars.
4
13:57
0
Q: inplementation of stack using pointers

shubham#include<iostream> using namespace std; class node { private: int data; public: node *next; node(int element) { data=element; next=NULL; ...


« first day (333 days earlier)      last day (3909 days later) »