« first day (371 days earlier)      last day (3638 days later) » 

12:09 AM
Welcome to Code Review! I've upvoted your question (+5!), but I think you should break this down into multiple questions - not because of the length (even more than that is still perfectly fine), but because it's really multiple unrelated pieces of code. The more questions you ask, the more upvotes you'll get, the more answers will appear, more votes, more happiness, joy! [cough] .. you'll like it here ;) — Mat's Mug 17 secs ago
first review:
1
A: My simple Javascript solutions

linstantnoodlesHere one way to sum a list of integers using ECMAScript 5's functional support // Sum all values in a list by reducing the list to a single value array.reduce(function(prev, curr) { return prev + curr; }); Not faster than your approach due to the repeated function calls, but definitely short...

 
12:31 AM
nice edit @Jamal!
 
:-)
It would be nice to see the solutions split up, but there are already answers.
 
my last close vote felt wrong.
There's a post on the meta site about technically off-topic but still reviewable code, you might want to chip in ;) — Mat's Mug 30 secs ago
I think that discussion should be , closing questions with non-working code is culturally firmly enrooted. The whole Community (with a big "C") needs to know this discussion is going on, especially with the current answers (where are the votes?)..
 
12:55 AM
CR unsummon
!! unsummon
 
@Malachi both work now?
 
not yet
I had to create an extension for the javascript code, but i am not sure that i did it right
 
perhaps CR could be the invocation for CR-related stuff (i.e. on-topic tools), and !! for entertainment (i.e. off-topic but toys)...
(reviewer in me can't help but say "yeah but tool: and toy: would more explicitly convey their nature")
 
lol
 
I guess we can take a level of abstraction ;)
 
1:10 AM
btw:
I like the two answers, but I think this is a major cultural shift, and it can have potentially astronomical impacts on this site, with possibilities ranging from hypothetical degradation of overall content quality to... possibly nothing less than site graduation through somehow managing to deal with a phenominal growth rate spike as we become The Best Thing Since Stack Overflow. — Mat's Mug 1 min ago
I think if this revolution goes through, the first blog post should be about it.
 
1:51 AM
Am I allowed to enter the post one contest or that would look suspicious?
meh. let democracy win!
0
A: Code Review Blog - Post One Contest

Mat's Mug There's something that's potentially major that's going on right here on meta (please vote!) that, if/when a conclusion is made, could make a tremendously impactful first blog post, if it's carefully crafted. It doesn't seem like the consensus will be that we should continue to close t...

 
0
Q: Java YAML Configuration file

Ryan PrintupI have recently started working on a server software in Java and wanted to add a configuration option to the program. I have gone through a few revisions of this class because I never liked what I came up with. I finally made something that I'm somewhat happy about and it works better than past...

 
2:40 AM
Damn it .... @Mat'sMug --- am I going to need to wait for the rest of the bloig to get the conclusion? meta.codereview.stackexchange.com/questions/1840/… ?
 
@Mat'sMug: That's also why I disagree with this. Even if we try to review the working parts, someone else may end up fixing the broken code. The close reason already mentions updating the post with working code, and I think that's good enough. I'm sure SO is full of reviewable code, but we should stick with working code. — Jamal ♦ 8 mins ago
Feel free to downvote this enntry in the Blog Post One contest. Also I think there should be at least one answer here that promotes status quo. — Mat's Mug 1 min ago
@rolfl there's no conclusion yet. I'll un-delete the post if the conclusion is that we go forward with that change. Makes no sense to have it if status quo prevails.
 
0
Q: How good/bad this Sudoku generator?

PhoenixI have written this following Sudoku Generator. How good/bad is this? How can I improve this? import java.util.Random; public class SudokuUtility { static final int max = 8; static final int min = 0; static final int digitMax = 9; static final int digitMin = 0; static fin...

 
3:00 AM
0
A: Off-topic questions that are still reviewable

Mat's MugStatus Quo. We're doing great the way we have it. Why fix it if it ain't broke? Barometer answer for voting purposes. Does not necessarily reflect my own personal opinion.

 
line 794 of the bot @rolfl
> //nothing to see here, move along
 
TTGTB - good night @all!
 
what?
@Mat'sMug you are leaving me with this Javascript
maybe it's time to play some COD
I am definitely going fishing tomorrow
 
I'm falling asleep!
 
@Mat'sMug later
I am going to need a nice Rainy day to read through that JS for the bot. it's like 8k lines of code, and I don't know JavaScript that well.
if I didn't know C# I wouldn't know where to start on this beast
 
3:21 AM
-1
Q: C# Pseudo- code Improvement...Help Please

peterMain Module Declare PlayerOne as String Declare PlayerTwo as String Declare CardPlayerOne as Integer Declare CardPlayerTwo as Integer Declare PointsPlayerOne as Integer Declare PointsPlayerTwo as Integer Declare SuffleCard as Integer Call Welcome_Message Module Call Set Up Module Call Game Module...

0
Q: Python class for Facebook

Pranav RajGiven below is a code which I wrote to provide an easy access to facebook graph api. import simplejson as json import urllib class Facebook (): def __init__ (self, access_token): self.access_token = access_token self.id = None self.name = None def user_information (self, fbuser =...

 
@Mat'sMug - not yet:
0
A: Off-topic questions that are still reviewable

rolflAlmost Working code Code Review is for working code. Let's play a what-if game... (devil's advocate) ... what if it's OK to have a rule that says: "Almost Working Code is on-topic". That means: "I tried Poject Euler #3x and it is running really slow, and it gets the wrong prime factor for 654...

 
3:37 AM
@rolfl remind me to check this out on monday
oh yeah and I got the bot running in chrome. unfortunately all the commands that we entered were destroyed when the bot was moved
I need to make a list somewhere of these things, and the ideas I have on fixing them
CR info
oops wrong place
hopefully it will run better here
now I have all my stuff running on Chrome.. let's see what happens over the weekend.
this StackOverflow answer looks like it has all the info I need to implement a Javascript RSS reader.
63
A: How to parse a RSS feed using javascript?

haylemParsing the Feed With jQuery's jFeed (Don't really recommend that one, see the other options.) jQuery.getFeed({ url : FEED_URL, success : function (feed) { console.log(feed.title); // do more stuff here } }); With jQuery's Built-in XML Support $.get(FEED_URL, functi...

I just need to create a function that uses this and returns the url of the answers. (I need to find that RSS feed first....lol)
actually looks pretty simple, hope that I think that when I go to write the code for the bot....lol
later guys
 
 
3 hours later…
6:22 AM
0
Q: Extreme Newbie here - Looking for constructive criticism on my first C++ program

CamI am very (very) new to programming, and today I (semi-)successfully wrote my first program that performs very basic things. My hope is that I can receive some constructive criticism around how I structured it all and if I am doing things in the most efficient and proper way possible for what I ...

 
^ I'm not sure where to start with this one.
 
I just saw it and had similar thoughts. Not sure I can handle that one this night at night... lol
 
Me, neither. Too tired. :-/
 
6:57 AM
(early) Monking!
@Mat'sMug I guess you can put it like this.... Android likes C# about as much as you like the singleton pattern..
@Mat'sMug To be honest, theoretically there could be a way to write C# code and make it into Java. I doubt it would be a good one though. I'd recommend using Java to write Android code. Java and C# is after all quite similar.
 
 
2 hours later…
8:42 AM
Only me who's up and running?
 
8:53 AM
Good morning, @Simon. I'm here. ;)
Working on my site. Rework some parts, some things need fixes..
 
9:19 AM
morning
 
Hey. :)
 
I'm fascinated by the AI in Civilization V ^^
Only it takes somewhat long... With 22 players at some point (depending on what the enemy is doing) it takes like 1 sec per AI
Step one in winning Civilization V: Never, ever trust Sweden. They will always backdoor you some point in the game.
2
 
Phew. Sweden. One never knows.
 
9:34 AM
I told you... 10 minutes later they declare war on me
 
9:53 AM
lol, hi @skiwi and @kleinfreund.
@skiwi I just gotta star that ^^
 
10:05 AM
^^
 
When you visit a website, how important are URL's to you? Do you actively use them?
 
0
Q: How might we make this Python Merge Sort implementation more Pythonic?

doughgleI've implemented a (version of) Merge Sort algorithm in Python. My goal here is two-fold: Improve understanding of Merge Sort and recursion in a language agnostic way. Improve understanding of Python conventions and idioms. The implementation recursively splits the given sequence into left an...

 
@kleinfreund I loath “example.com/index.php?id=12345” type of URLs. Stack Exchange has generally quite good URLs, and I sometimes modify them manually – for example to get to the post timeline (here is an example of such a timeline on one of your questions)
 
10:20 AM
I'm rethinking quite a bit stuff I'm doing on my site. One thing which came to my mind are hackable URL's.
 
@kleinfreund Well, I'd rather have a readable URL such as example.com/somepage instead of example.com/page.php?id=334221 or example.com/3680238023gdffdg.html . So for me, I'd say they're quite important. If I actively use them? Probably not as much as I think I do.
 
For example if I have a page of example.com/en/portfolio/, removing /en should lead to the native language of the site.
 
@amon Has a good point there. Modifying URLs for navigation (especially on SE) I also do, although that can be seen as an indication that the site itself has bad navigation.
 
But then URL's for German and English (in my case) need to match. Not counting the /en here.
I kinda like to have hackable URL's, but then they're not all too useful for people who don't speak the language I write the URL's in.
That said, using English for the URL's is probably the way to go?
 
Hmm, yes, I think they should match. Or at least provide automatic redirection to the other language
And if they should match, I think English URLs is the way to go, yes.
 
10:30 AM
But then - let's assume I have kleinfreund.de/2014/05/post/ and kleinfreund.de/en/2014/05/post/ - manipulating URL's is only possible by removing /en.
The other way round? There is no indicator, unless I do kleinfreund.de/de/2014/05/post/.
 
But if I would manipulate the URL to become just kleinfreund.de/en/2014 I would expect to see a list of posts you wrote in 2014.
I think kleinfreund.de/2014/05/post/ should redirect you to kleinfreund.de/de/2014/05/post/
 
Yeah, I know. That's what Wordpress has in most themes.
 
The /en/ part in the path is fairly inelegant, as it suggests a kind of hierarchy. It actually just returns an English version of the resource – something that a ?lang=en query parameter could convey more clearly. However, I doubt that can be made to work with static pages.
 
I don't agree with that. That would mean redirecting all URL's without the language manually.
Yep, you'll need PHP for these things.
I'm really not happy how this bilingual thing works out in total.
1. I need to use plugins to get blog pages with working pagination for categories (categories = languages in this case)
2. Using plugins means that I can't host the uncompiled source on GitHub Pages and need to compile locally.
I have two ways I can choose from. 1) Use GitHub Pages (yes!) and live with a lot of restrictions for bilingual stuff (no paginated English blog page!) or 2) Compile locally everytime I change something (no!) and have the English blog page.
 
10:52 AM
@kleinfreund Is (2) not a superset of (1)? Using GH pages does not require your site to use Jekyll, you can upload any HTML and it'll work. Compiling the stuff yourself isn't that much of an issue, considering that you already have to do it for local preview.
 
0
Q: Android Gradle script in multi-module project

ben75I've a multi-module Android project build by gradle with the new android-plugin 0.10.+ All modules are mainly configured from the root project. I've enable the new code coverage feature. The major problem is that only some modules contains test code and when I enable code coverage on modules th...

 
@amon Yes, but I have to compile everytime I write a post. I can't just drop a markdown file in my _posts folder and have it published.
 
11:21 AM
0
Q: Problems writing a class for binary search tree

user3369309This is my first experience with OOP, I'm working on writing a code for Binary search tree, I have finished the first "draft" of it but I got many errors in it. Also I don't think I quit understand how to use an attribute from one class in another, I got this error in the insert function class ...

 
12:11 PM
@kleinfreund - woke up one morning, to a band in the sky.
Took a series of about 8 pictures. Stitched them together.
 
Woow, that's cool.
 
This photo covers more than 180 degrees
Monking All ;-)
Thanks FireFox:
meta.codereview.stackexchange.com uses an invalid security certificate.

The certificate is only valid for the following names:
       *.stackexchange.com , stackexchange.com , meta.stackexchange.com ,   stackoverflow.com ,
*.stackoverflow.com , stackauth.com , sstatic.net , *.sstatic.net , serverfault.com ,
meta.serverfault.com , superuser.com , meta.superuser.com ,   stackapps.com ,
    openid.stackauth.com , *.meta.stackexchange.com

(Error code: ssl_error_bad_cert_domain)
 
12:31 PM
wait what??
 
@rolfl don't worry, I've been having the same problem on chromium for months now. Apparently SE still hasn't figured out HTTPS completely.
 
Hmmm.... or I have not been using HTTPS to get to meta....
 
most inter-site links on SE use http, even when I'm currently using https. The HTTPS Everywhere extension minimizes this, although it doesn't work on meta sites due to the aforementioned cert problem. Manually adding "https://" to the URL, it is.
 
@rolfl Nice picture. I've saved a bunch of pics you and @kleinfreund have posted, planning to use some of them as desktop backgrounds. This marks the 10th saved picture.
 
heh ... thanks ;-)
THis one would make a lousy desktop though .... too wide.
 
12:39 PM
If you want a higher resolution of the files, just ask. ;)
 
I like the picture, but it is essentially useless.... can't frame it, etc.
 
@rolfl it has a slight air of fisheye lens..
 
12:54 PM
0
Q: Is coding to an interface with regards to PDO the right thing to do?

davethebraveAm I on the right lines for connecting to my Database? If not could somebody help me improve it or point me in the right direction? Index.php: use Acme\Foo\Database\Connector; use Acme\Foo\Database\MySQLConnector; $obj = new Connector(new MySQLConnector); echo $obj->db->connect(); DatabaseIn...

 
1:13 PM
another hot RTFM question on SO...
71
Q: Why does 1==1==1 return true, "1"=="1"=="1" return true, and "a"=="a"=="a" return false?

chris97ongfunction a() { return (1 == 1 == 1); } function b() { return ("1" == "1" == "1"); } function c() { return ("a" == "a" == "a"); } I tested the above code in Chrome's console and for some reason, a() returns true, b() returns true, and c() returns false. Why is this so?

not that I'd have known..
 
@rolfl Perhaps if I'd get a widescreen :P
@Vogel612 And people wonder why I don't like dynamic typing...
The idea of making the comparison true == "a" is completely nuts to me.
Compiler Errors FTW!
Or rather than "dynamic typing", perhaps it should say "implicit conversions"
But still, I don't like dynamic typing. Some implicit conversions are fine (Read: all the conversions that Java does)
 
1:38 PM
Object --> Boolean --> boolean..
in a single line
using reflection
in a unit test.
now that's what I call conversion
 
0
Q: PRNG - Algorithm: Performance vs Readability

gonidaI have a PRNG-Algorithm: /** * Generates an integer. Min: 0 | Max: total - 1 * @param total The number of possibilities. * @return The generated number.*/ public function generate_normal(total:int):int { _seed = (_seed * MULTIPLIER) % MODULUS; return (_seed * total / MODULUS); } The...

 
@SimonAndréForsberg rather than "dynamic typing", perhaps it should say "implicit conversions" – yes, you should. They are completely different things (note that any OOP systems is to some degree dynamically typed due to dynamic dispatch of methods). Btw, Python is an interesting example of a dynamically typed language with very few coercions (although objects are free to overload the "==" operator as they like).
 
1:55 PM
@amon Yeah, I realized that shortly after having written it. Seems like I should do more Python-coding some time.
 
2:21 PM
0
Q: Handling of memorystream with streamwriter efficiency

Mitulát bátiI hope you're doing well. So, my little program I'm working on generates charts (GUI) and (on another tab) lists the values my chart is fed from. 2011.01.01 0:00:00 456 2011.01.02 0:00:00 45 2011.01.03 0:00:00 46 2011.01.04 0:00:00 6 2011.01.05 0:00:00 1500 ... When I clic...

0
Q: Can the following Ruby/Rails code be simplified?

Can't Tellclass InvitationConfirmationValidator < ActiveModel::Validator def validate(record) invitation = Invitation.find_by_url_suffix(record.id) if invitation if invitation.materialized? record.erros.clear record.errors[:base] << "Invitation already materialized" en...

 
@skiwi I managed to reach a Nash equilibrium in two AIs fighting each other with RPS. They're smart enough to realize that "the best choice is to just pick randomly" :)
 
2:31 PM
I found some stuff on Javascript and RSS feeds so later I will see about creating a function that will work with the bot to provide us with an answer feed that can be turned on and off (hopefully)
but going fishing right now
 
@SimonAndréForsberg Sounds cool
 
@Malachi You should ask us if we have something, and then we can tell you: "Go fish".
@skiwi I have also started reading some in Artificial Intelligence: A Modern Approach.
 
cool
 
2:54 PM
Scores is: 31 vs. 37 (32 drawed games), 100 total <--- Computer: 31, Me: 37.
 
0
Q: Python Barcode Generator

Pong WizardI was asked to provide some example code [for a job interview] and didn't have anything to offer, so I wrote the following function. A barcode generator may seem a bit basic, but there's some logic behind the choice. It's something I recently needed, so it's not entirely contrived. It's simple ...

 
3:13 PM
@skiwi Unfortunately, this AI can't exploit the fact that the opponent chooses Rock, Paper, Scissors in that sequential order.
In fact, picking in sequence seems to be a quite good strategy against this bot:
332385 vs. 333105 (334510 drawed games), 1000000 total
AI: 332385
Picking in sequence: 333105
 
4:01 PM
0
A: What is the faster way to conver BigInteger to array of int?

SSpokeUse EditPadPro Record Macro do first 2 numbers then auto macro to very end. I did it for you. BigInteger i = new BigInteger("5876934265987526278534978564378568734564937563487564327564376534875483753475"); All you must do is select this below paste into EditPadPro 5876934265987526278534978564...

answers getting creative
 
4:13 PM
@JeroenVannevel Reminds me of an answer I provided a while back. stackoverflow.com/a/370135/14065
2
 
4:47 PM
0
Q: Project Euler 39: Integer right triangles

jshuafI just finished Project Euler 39 and I'm pretty satisfied with my solution. I derive the formula for the hypotenuse as follows: a + b + c = perimeter b + c = perimeter - a a^2 + b^2 = c^2 a^2 = c^2 - b^2 a^2 = (c - b)(b + c) a^2 / (perimeter - a) = (c - b) (c - b) + (c + b) = (a^2 / (perimeter -...

1
Q: A small text adventure in Python

user42239I've been teaching myself programming in Python for about three months now using How To Think Like a Computer Scientist and a bit of the internet with the intention of being able to create video games someday (nothing huge, but something/stuff worth playing). What I'm looking for is an assessment...

0
Q: C++ Student Class

Deepak SinghIs this a good approach of designing a class or is there some other way that I am not aware of? Student.h specification file #ifndef STUDENT_H #define STUDENT_H #include <string> using namespace std; class Student { private: int ID; string name; double GPA; ...

 
@SimonAndréForsberg Pretty fair numbers there
 
5:13 PM
0
Q: Small, embedded full-stack web server

LiavKI thought it might be interesting to post this for review. I did this project last year, under some interesting constraints: it's a thin webserver which lives in a raspberry Pi, which is networked to an embedded system in an industrial sign which is running a proprietary and heavily modified vers...

0
Q: determining if you can generate an answer

bazanghow can I improve my code below, for the following question. While it works, I am not satisfied with how it looks; I was hoping I can somehow keep it recursive, and have the ans filled up inside the function, and reduce the number of return statements that I have. treat this like an interview pro...

 
5:25 PM
0
Q: Follow up: Python class for facebook

Pranav RajThis is a follow-up post I have taken some of the suggestions there and have made some changes from my side too. I think it looks better, but please look at it and lemme know if you think any more changes needs to be done. It follows PEP8 standards. __author = "Pranav Raj" __email = "pranav090...

 
a lot of questions today
 
0
Q: Optimizing a recursion code over lists

user3369309I'm writing three functions which iterate over lists, I want do this recursively, but I think this code is not as efficient as it could be. def flatten(lst): if type(lst)==int: return [lst] elif lst==[]: return lst else: return sum([flatten(sub) for sub in ls...

 
@janos apparently, saturday is personal project day
2
 
:)
with a little luck, I can turn it into "rep cap day" ;-)
 
that's the spirit!
 
5:39 PM
@amon Yes, personal project day. :~)
 
I was too tired to review anything yesterday, but today I was able to whip out this beefy review.
 
5:53 PM
nice one @Jamal, +1
 
:-)
I know I've missed some things, but I wasn't trying to get everything. The second answerer picked up on some stuff.
 
several beefy reviews there
 
@janos: Hm... almost to 4K. Let's see if Santa can help with that.
 
haha
I think I'll keep going today until I cap
 
6:06 PM
@SimonAndréForsberg is that a feature request for the bot???
 
@Malachi Not really
 
@SimonAndréForsberg because that would be funny.
CR do you have any new C# questions?
 
and, after a while, probably a bit annoying
@Malachi Go fish.
 
hm, upvote on a pretty old post, pushing it to 10 upvotes... Santa is that you?
 
or CR do you have any new Answers to Question 12345 i think I could do that
you can create an RSS feed on a question, so it should post all activity to it, I think I could figure out a way to make that happen
but I am going to eat and then go back out fishing right now
catch you all later.....LOL
 
6:14 PM
your new trusted user is coming anytime now
6
drumrolls....
tada!
 
:D
 
(I imagine the crowd is cheering)
*me opening a bottle of champagne now
 
@janos ||: clap clap clap :||
 
*me naked happy dance
ok I've gone too far
 
@janos Go fish.
Oh, sorry. Not you :)
Congratulations, @janos :)
 
6:22 PM
haha, thanks!
 
0
Q: Python- Counting DateTime frequencies

user3378649I am working to do a study, and apply statistical model. I generated all the possible dates "Hourly" from datetime import date from dateutil.rrule import rrule, HOURLY a = date(2009, 5, 28) b = date(2009, 5, 29) gl_list=[] for dt in rrule(HOURLY, dtstart=a, until=b): gl_list.append(dt.s...

 
@janos about time....JK Congratulations
time to go catch some fish
 
"JK"? that's short for what?
 
@janos “just kidding”. See also urbandictionary.com/define.php?term=jk
 
in BlueCheese Monster's Home, 27 secs ago, by BlueCheeseMonster
@Malachi jk Just Kidding!
 
6:35 PM
:)
 
oh joy I made it to the first page
 
0
Q: Java program to shutdown computer after a certain time

AbdulI'm trying to make a program that will shutdown my computer after a certain time that I will input via GUI. I'm wondering if I did it the correct way. Also will this slow down my computer while it waits to shut off? Do you guys see anything wrong with the code? import java.io.IOException; impor...

0
Q: Is regex a better solution for this algorithm?

909 NiklasI want to find the lowest decimal number for a given integer in multiple data structures. I found that this batch processing looking code seem to respond the [expected result][1], but could it be done with a regex or more efficient, more readable, or other design improvement? def get(self): ...

 
7:33 PM
1
Q: Python script for generating C code

user3502847I'm writing a Python script to randomly generate C functions. This is my first time using classes in Python and I'm basically doing my best to pretend I'm using Java. I'm looking for a review of my OOP, Python style, and in general whether or not I'm doing things in the "Pythonic" way, whatever ...

0
Q: Filling two angular $scope variables with data

gearsdigitalI'm unsure about how to simplify this method properly. The method is basically responsible for filling two angular $scope variables with data. The response object is a collection of objects. Each object contains an attribute called order and i have to distinguish between visible and invisible el...

 
7:43 PM
Hey, @JerryCoffin! By the way, I've just raised a bounty on Loki's last unanswered question:
3
Q: JSON Serializer

Loki AstariCarrying on from: Yet another C++ Json Parser Yet another C++ Json Parser (Recursive) All the code is available from git hub: ThorsSerializer but only reviewing a small section here. The idea is that using this library it should be easy to define how a class is serialized without writing any...

My very first bounty, too. Bye bye fake Internet points. :-(
 
7:56 PM
Can somebody help me determine the time complexity of this one?
0
Q: Determining if an answer can be generated

bazangHow can I improve my code below for the following question? While it works, I am not satisfied with how it looks; I was hoping I can somehow keep it recursive, and have the ans filled up inside the function, and reduce the number of return statements that I have. Treat this like an interview pr...

 
This place is a dump!
 
Don't litter your banana peels on the ground!
3
 
@Jamal hello. I've looked at that question, but it's yet another that's far enough outside what I typically work on that I'm not sure I really have a lot to add. I'll take another look though.
 
Alright! I hope someone provides a decent answer, even if it's a self-answer.
 
@rolfl Go fish.
 
8:02 PM
@SimonAndréForsberg oh dear, do we have a new meme?
 
I mean .... I am literally at the dump. Car full of crap. It looks like half the town has had the same idea
 
@amon I'm starting to realize that it might work as a new meme actually, but we'll see :P
@rolfl Half the town throws crap in your car?
 
Party at monkey's car!
 
Sweden's up in the Eurovision Song Contest Final now, but I don't really like our song much....
On the other hand, there's quite many songs this year that I don't really like much...
 
8:16 PM
@rolfl good you're here, can you teach me about calculating the time complexity of this one?
0
A: Determining if an answer can be generated

janosIt's fairly straightforward to turn your implementation into pure recursive: public boolean ablehelper(int a, int b, int c, int d) { if (a != c && (b + a) > c) { return false; } if (b != d && (b + a) > d) { return false; } if (a == c && b == d) { retur...

(or anybody else, for that matter)
 
I'm not quite sure. Recursion is not one of my strong points.
 
@janos I believe it's 2^n, as each method call does 2 more method calls. Some method calls ends early of course but I don't think that changes the complexity.
 
thanks @SimonAndréForsberg. That seems to make sense
 
@janos I should add though that I'm completely self-taught regarding complexities, I have nothing to back me up other than my own intuition :)
 
what say you @rolfl to that?
 
8:29 PM
Now though I'm starting to believe that there's gotta be a different way... Once one of the numbers are correct, you could just use subtraction and modulo to determine whether or not the other number can reach it's target.
I wish more examples were included in the question
 
yeah
 
I asked WolframAlpha for four random integers, I got {750, 146, 862, 825}, I doubt those will return a positive result.
 
looks like a false
 
anything else would surprise me :)
 
:)
 
8:36 PM
@SimonAndréForsberg I don't think even that's needed. Looks to me like the real question can be boiled down to: "are there positive integer values m and n, such that C = mA + nB" (and likewise for D). I haven't thought through things really carefully, so it might be a little more restrictive than that, but it's at least in the ball park.
 
@JerryCoffin You may be right there actually... I'm also starting to think more mathematics than programming. If that's true, the complexity is suddenly reduced to O(1) :)
 
@SimonAndréForsberg Exactly.
 
@JerryCoffin Then the question is: Is it that easy? Or does the rule of (a, a+b) or (a+b, b) complicate things?
 
@SimonAndréForsberg That's an excellent question. I don't see where it adds much complexity, but I'm feeling too lazy today to think about it hard enough to be sure... :-)
 
But your idea would be a good first step I think, and if that one returns true, then it might be possible to reduce it at least to O(n) I think. (Haven't finished this thought)
How about a=1, b=1, c=11, d=11 ?
@JerryCoffin I think I just proved that it's not that easy ^^
But your thought might still be useful
 
8:51 PM
Now someone tells me Herb Sutter uses using namespace std?
 
@SimonAndréForsberg I'm not sure. Specifically, I'm not sure what the b, or a part of the problem means in: "you are only allowed to do a+b, b, or a, b+a at any given transformation". I took it to mean I can do (for example): find(A+B, B, C, D) 10 times, followed by: "find(A, A, C, D)", but I'm not sure whether that's supposed to be allowed or not. If not, then yes, that makes it harder.
 
@JerryCoffin According to how the code actually works, it means that you can modify a or b by adding the other variable to it, that's why recursion is being used with (a, b+a) and (a+b, b)
 
@SimonAndréForsberg Right--but I'm uncertain whether the OP has read a restriction into the problem that wasn't intended.
 
Yeah, that I cannot answer :)
 
9:07 PM
0
Q: JavaScript Cross Platform Efficiency

Francisco AguileraI wanted to get some feedback on this js I am working on. http://www.dapper-apps.com http://www.dapper-apps.com/kamibreeze/kamibreeze.js It works wonderfully on my desktop, but on my and my friends laptops (expecially safari) it is very slow. I need some pointers on improving the efficiency so ...

 
Right .... Immmmmm BBbbaaaaacccckkkkKKKK!
@janos - I was offloading a bunch of crap (and no, it was not half-the-towns ....).
 
hey @rolfl
 
And grats on being a T - U
Now, with great power .....
 
with great power what?
 
.... comes a requirement to monitor the Review Queues, etc.
And, as much as you enjoy the feeling now, i hope you don't have it for long.
 
9:19 PM
thanks :p
 
You wanted to talk complexity?
 
yup
 
I hope it's not 2^n ....
I am going to have to read that question.... give me 5.
 
@rolfl Consider the case when a and b are small (1) and c and d is big. I think it's pretty much O(2^n) at the moment, but there's gotta be a better way of solving it (I'm working on it, but haven't come to a conclusion)
Aha! Progress!
 
The complexity discussion on that question is BS.
For a start, what is 'n' ?
 
9:28 PM
An arbitrary number :)
 
Exactly.
And, the problem does not scale .... i.e. there is nothing that 'grows'. The inputs are fixed at 4 values.
Thus, there is no meaningful way to debate how the solution scales as the input size changes.
 
Wait a minute! The current approach is crazy! I think I've solved it in a much better way
I just gotta create an algorithm for it
I think the solution is O(n), again, where n is an arbitrary number :) (Don't know how else to put it)
 
Judging by part of the discussion, I'd say it is O(c), where c is some constant, so it resolves to O(1) (if the input is really fixed) That's the theoretical analysis I think
gotta go though
O(n) etc. only applies if n scales, everything non-scanling is treated as a constant
Yes. order-derivations are not neccessarilly a good tool for speed
 
Now I'm excited, gotta keep myself calm here. Working on an answer!
brb, gotta watch some ESC :)
 
0
Q: How random is this algorithm?

FrigidDevThis code's sole purpose is to create a very random password, using letters and numbers. I think that it fulfills its purpose, but I wonder, could it be done better? I'm not talking about efficiency, but security. In your eyes, how secure is this method for generating passwords, and if it is b...

 
9:43 PM
@rolfl In this case, n would be some combination of the magnitudes of C and D.
 
"First 12 points goes to.... Russia!" everyone's booing
Do you non-europeans know what Eurovision Song Contest is? :)
 
The fact that Russia is in Europe .... is odd.
 
thanks for the answer @rolfl
 
No problem.
@JerryCoffin - I would partially agree.... but, you can't have a complexity discussion on two independent variables.... and it is also dependent on A and B (because if they are close to C and D) then it's different.
 
gotta go, have a nice evening you all
 
9:53 PM
A 'good' solution to this would, I guess, have a complxity close to log(n) where n is (max(c,d) - min(a,b))
 
An extremely faster solution and different approach:
0
A: Determining if an answer can be generated

Simon André ForsbergThis is an interesting problem! Your approach has one big flaw: You're starting from the wrong direction! Instead of starting from a and b, start from c and d. What are the ways to reach that number? Consider this problem: (I will use the notation a, b --> c, d) 4, 5 --> 15, 19 What has to...

^^ No idea what the complexity is
@rolfl Technically, it's not. It's in the ESC though, but then again, so is Israel. And Israel is even less in Europe than Russia...
 
@rolfl Yes, that's why I said "some combination of"--but you're right, it also needs to take A and B into account.
 
10:13 PM
@rolfl Any idea about the time complexity of my answer?
 
10:36 PM
And the winner of Eurovision Song Contest 2014 is: Austria!
Did my answer to the math problem kill the chatroom?
 
10:53 PM
lol
2
 
@SimonAndréForsberg The chatroom is dead. Long live the Second Monitor.
 
@JerryCoffin My second monitor is still alive, and therefore the chatroom must also be alive.
 
@SimonAndréForsberg My second monitor is currently playing an old episode of "House M.D."
 
House FTW
 
11:13 PM
45 minutes to reload, 31 reputation to rep-max.
 
11:44 PM
For those with a vote left: this user is one away from 2K!
 
Makes sense with the avatar, too. :-)
 
2k and [badge:nice-answer]
 
Helping a friend with a Java game he's doing as school project, he had a method named getInteractiveObjects, inside that method he's creating new objects and adding them to the list that is returned! The importance of naming methods correctly! It might make sense in some cases, but this was not one of those cases!
Santa fixed two votes. The beauty of up-voting other people's random answers is that you learn something in the process, and find quite interesting questions you've never seen before.
 
11:53 PM
And sometimes crappy titles to fix.
 
lol, yeah, that too of course :)
 
I'm doing it slowly so that I don't flood the front page too much. We're already accumulating more zombies.
 
@SimonAndréForsberg - I believe your answer is O(log n) ... where n is the difference between min(a,b) and max(c,d).
If this rings a bell ...... ;-)
 
@rolfl Nice! Significant improvement, then. I believe it can't get any faster than that.
 
2 hours ago, by rolfl
A 'good' solution to this would, I guess, have a complxity close to log(n) where n is (max(c,d) - min(a,b))
Each time you double-the-difference between the limits, you only really add 1 computation....
 

« first day (371 days earlier)      last day (3638 days later) »