How to count the solutions of the equation xy + xz + y*z = n (0 <= n <= 10^4) with the constraint that x >= y >= z >= 0 ?
To solve this i've isolated the z value and brute-forced the values of x and y. If the values x,y,z satisfy the constraint and equation than its a valid solution.
#include <...
I recently had submitted my bashscript for building an OS for review and got valuable feed back .
So I rewrote the entire Script to a MakeFile
MakeFile
# Make File for Bulding Ultron
# Sets up the Assembler
AS := nasm
ASFLAGS := -f elf
ASFILES := $(wildcard kernel/boot/*.s kernel/arch/*.s...
Recently during an interview, an "interesting" criticism of
reviewed code came up regarding the SRP principle.
The code looked something like this:
interface IActionResult
Execute()
class JsonResult : IActionResult
Execute()
class HtmlResult : IActionResult
Execute()
Now the iss...
Anyone around who can see deleted posts? There was one late last night that may have been on-topic for programmers so I asked in their chat, but then OP deleted it. Was just hoping to get a screenshot, for learning purposes, as long as it's not a problem per site rules
I gotta get ready for a meeting.. I will see you all later
@Zak as far as getting the degree vs. experience, I am not doing one over the other. I hope to do both at the same time, Work and get a Bachelor's degree
Is it the most Pythonic? I'm not sure. Did you know there are multiple alternatives around for handling arguments?
One of them is in-build in sys. Arguments with sys work like this:
import sys
n = int(sys.argv[1])
x = sys.argv[2]
y = sys.argv[3]
However, an even better idea (thanks to @janos...
IMHO, if you took your code example, and actually applied it to the OP's use case I think it would be more valuable and easier to follow how to actually use the advice you are giving
@Mast Read the comments by OP. He is not talking about command line arguments, so unless you can transform/convince ArgumentParser to use kwargs you missed the mark on this one...
@Mast Hmm... It would have been a nice extension though... As you enforce types and default values, and various other stuff using it on kwargs in cases like the one presented by OP
This scares me a little bit... as in... shouldn't all this be logged in VCS, and not in a flipping SQL table?
IF OBJECT_ID(N'ReleaseChangescriptLog') IS NOT NULL BEGIN INSERT INTO ReleaseChangescriptLog (rcl_ScriptName) VALUES ('QA_R2_2015-12-02_170529_COMMON.sql') END
@Phrancis Profiling, praying, crying in a corner, giving up, profiling, wishing Javascript had mutable strings... I guess that is a good plan to speed up any code in Javascript.
@TopinFrassi Grabbing an unminified version of jQuery (~240kb), stripping whitespaces and comments, removing some repeated code with a static dictionary and then shoving it into a <canvas>
Then, it grabs that code, re-adds the removed repeated code and runs it
I wanted to post it today, now, but I can't with this speed.
There are several aspects to this question that make it a poor question to ask on Programmers.SE, and some that also make it counter productive to have planned out for an interview.
Too broad
The first aspect is that the question is too broad for Programmers.SE. The "How do you build Amazon" b...
> Stack Overflow would close it as too broad focus on fixing a specific issue; Programmers would just close it address high-level design (don't quote me on that), and Code Review would close it as broken code explain how to refactor the code so that it's more efficient, while pointing out bad naming and other things that get pointed out in a peer review.
@LoganHasbrouck This is not the right place to talk about this kind of business, but you can always visit Code Review (codereview.stackexchange.com). There, you can post your code and get tips on how to improve it in every single aspect you can imagine! (But before posting anything, please, read the faq at: codereview.stackexchange.com/help, stats by reading about what is on-topic and how to ask a question). The guys there are really friendly. You really should visit it. — Ismael Miguel12 secs ago
In theory, any question that could be an interview question. It's much like homework questions - the good ones don't need to say they are homework or interview.
@IsmaelMiguel Just post it. It's not like you'll be the first person to post a large amount of code. Just make sure the non-code part of your question gives plenty of context.
It will likely take somewhat longer to get an answer than your run-of-the-mill question, so just be patient, and maybe add a bounty as incentive if you have not received an answer within a few days
For a previous job interview I wrote a log cleanup / warning of something broken script in perl. If I was to post it to code review, writing the question well shouldn't need to say this was for an interview. Same here.
Sometimes, I need to change the color of <hr> elements in an email.
The only achieveable way is by using CSS. But not every email client supports CSS. Most clients delete separated stylesheets. And some even delete stylesheets altogether!
With a lot of trial, I came up with the following:
<...
It's proper to your scenario. You need to do whatever you can to support everything without using a css stylesheet. I think it's normal you have to do this!
If I add *.net* to my Favorite Tags list I can see all questions with a tag that contains the substring .net (as well as a summary list of tags matching *.net*)
If I add *C#* I am only shown the C# tag, no other matching tags such as C#-4.0, C#-5.0 are displayed in the page or matching tag summa...
On a side-note (as this is chat): Emails where never intended for html, and so having something which works across all different variations of implementations (with and without removing of styles and stylesheets), is a battle you're never going to win!
So far most of the solutions, including the solution by OP, will stop having list markers with more than 5 elements in the list, which is a show-stopper for me.
The ideal solution in my mind, would be to make the next color at a given percentage of previous color. But that requires programming, ...
I'm especially looking for a variant where one could change the formatting of previous element, so that one could set the color on first element, and let following elements be that color multiplied with 90% (or similar. Possibly ever increasing opacity)
@Phrancis There were things that I already knew (like HTML for email being arcaic, like Outlook 2007+ using the Word engine to render HTML ... Yeah, that's right...), but other than that, your answer is really great. You deserve a handshake! Thank you!
@holroy Sorry dude, but his answer is superior in content to yours. If he gets a different of 3-5 votes from you, I will give you a bounty of 50, to equalize it
I'm going to eat Lacasitos without sorting them by color and without eating from the group with less to the one that has more, in the shape of a square (or closest)
Translation: eating random colors, without picking
@holroy Actually I like your answer quite a bit. I can't think of a way to make the gradient opacity bullets scale better (adaptive to the number of bullets, for example) without using JavaScript though
@holroy Actually, I wrote multi-asserts but the whole purpose of the answer is to tell not to use multi-asserts :p But I know in some cases it's necessary. I'll take a look at the blog though! I do have quite an interest towards unit testing! Thanks
@TopinFrassi @Mat'sMug Does it make sense to make an interface for a Vector2 that takes a type parameter which indicates what type the X and Y values are?
@holroy That's quite interesting. I guess there's some value to a MultiAssert written this way. Though, when I have to do multiple asserts more than once I'll usually write a custom assert that joins the both of them
I think when doing actions which are heavy and influence loads of stuff, it can be quite valuable to do multi-asserts. Like if you're in a test environment borderlining on integration tests, it is interesting to verify that more than one parameter of your single method call is actually changed appropriately.
@Mat'sMug Is that a serious question? When doing dependency injections and factory stuff, and in some cases just something as simple as unit testing, interfaces can simplify the code tremendenously!
Well I like the interface because I use R and Theta fairly often, so it's nice to be able to just say, "Give me an IVector so that I can use the R and Theta to build my display."
I am using classes for the first time.In this program I want the object to run infinitely so that any change in the MongoDB will trigger the function and do the necessary processing.
I am little confused about the using of the self.Please give me a feedback on my code.Thanks!
class first_level:...
I am trying to write a function that will count the occurrences of a pattern in a string without overlap. This is what I have right now.
size_t count(char *string, char *pat) {
size_t patternLength = strlen(pat);
size_t stringLength = strlen(string);
size_t count = 0;
char *compa...
Just had an interesting idea about zombies and SEDE... I might write something up, I think a query that would find n random zombies in a user's most prolific tags might be cool
select t.name as [table], c.name as [column] from sys.tables as t join sys.columns as c on t.object_id = c.object_id
where 1=1
and t.name not like 'audit%'
and c.name like '%hhrg%'
@Phrancis Only reason for doing that would be when dynamically building the where query and it could be empty by default. But still you could avoid this using a decent sql builder interface
This is a rags-to-riches take on this question, specifically an improvement of my original answer there.
Copying my interpretation of the calculations involved from my answer:
Given a 70-character String, e.g.
"ABABABaABABABaABABABaABABABaABABABaABABABaABABABaABABABaABABABaABABABa"
Response...
I have a method which I use on occasion to convert strings (like enum and property names) to PascalCase for display.
It's fairly simple, so there's probably not much to comment on, but as usual I appreciate any advice on improving it.
/// <summary>
/// Converts a string of dash-separated, or un...
Which begs the question, why the hell has nobody made a library or whatever to handle SQL (MySQL in particular) more elegantly and in a more generic way, like Java Hibernate and things like that...
Hibernate looks very complicated to implement initially, but once that part is done it looks quite low-maintenance
One of the main advantages from my understanding (besides portability between DBMS) is that it encourages to write business logic with Hibernate instead of using countless stored procs and triggers and other stuff like that
public class Aston_Martin {
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println("Why couldn't the math professor's daughter buy her first car? Her parents wouldn't cosine on a loan.");
System.out.println("What happened to the pasty math tea...
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println("Why couldn't the math professor's daughter buy her first car? Her parents wouldn't cosine on a loan.");
System.out.println("What happened to the pasty math teacher who sunbathed too long? ...
I'm voting to close this question as it is on one hand too broad, and on other hands cannot fit in the scope of question that can be answered on SO. You can't get code review here. Sorry! — eliasah19 secs ago
Hey guys, don't forget to register for the Secret Santa!!!! :D Right now we're 6 participants. You still have 1 week and a half to register but the sooner the better!!
I suggest you edit your question into specifically asking about handling unseen labels, showing as little code as possible to make a MCVE. Then, when you get your code to work as intended, post the entire thing on Code Review to address the scalability and performance part. — Mat's Mug50 secs ago
To celebrate our first graduated Christmas (and because we feel like it), some regulars in The 2nd Monitor thought it would be a good idea to make a Secret Santa between members of Code Review!
The rules are quite simple :
You will send an email to secret-santa@lambdaexpression.io to register...
yeah, well, the only person that will have your shipping address will be your secret santa. and you don't have to have it shipped at your place - a P.O. box works just as well.
Below is the code I have for a RandomForest multiclass-classification model. I am reading from a CSV file and doing various transformations as seen in the code. I am planning to run this in a Spark cluster with lots of data(atleast 6 million rows of data with 50 features). I can get sufficient am...
@Mat'sMug Well, it's twice the budget, yeah :p But if you feel like it nothing stops you from giving a gift from a higher price range. Just don't expect your santa to do it or you might be disappointed :p
No wait, you don't have deletePoly() in the destructor, right? That's wrong, the destructor is the right place to call it, that's what destructors are designed to do. Anyway if you want to hear constructive critique, post code to codereview. stackexchange.com. — n.m.49 secs ago