See Problem - 151B - Codeforces for details. I think I have been very messy with using the Streams. Can you review for a good and better implementation with Streams? Any other improvements?
public void solve(InputReader in, PrintWriter out) {
int n = in.nextInt();
List<Person> ps = new A...
Yep, all reasonable suggestions and time permitting, I would have done a much stricter code review. Sigh.... such is life. Live and learn... — cplusplusrat38 secs ago
@CaptainObvious I'm tempted to close that question as not reviewable because of the variables names, but that's probably the wrong way to look at it, right?
I would like feedback on the class I've written. The purpose is to dynamically create and interact with SQLite3 databases, accepting lists of complete or incomplete statements.
import sqlite3
class DB(object):
"""DB initializes and manipulates SQLite3 databases."""
def __init__(se...
I'm a beginner Python (2.7) programmer, and I've just started solving basic problems on SPOJ. I correctly solved the ADDREV problem (http://www.spoj.com/problems/ADDREV/), however my code takes 0.06s time and 8.8M memory to run. The top Python 2.7 rankers for the problem take <0.005s and 4.00M. S...
I need to complete one task in VBA and after looking on the INTERNET for the past months, I think I'm too noob to make it.
I have a word file - standard INDEX file.
I need to copy the data from this file to another (excel) based on some logic:
Logic:
dps_so - DPS number (In INDEX: Header DPS ....
@syb0rg, my mistake. I was under the impression that if your code works and you are simply looking for improvements (i.e. performance) then Code Review was the place to go. I'm still (and always) learning. — Joseph Wood36 secs ago
As you can see in the example below, I partially refactored the code so okFields use the extracted function checkStringLength.
Now I also want problemFields() to use the same refactored function, but there is difference between how okFields and problemFields use the function: you see that the p...
Suppose I have an object which has a point denoting it's location and shape.
type Point = (Double, Double)
data Object =
Object { location :: Point
, shape :: Shape }
where a shape might be like
data Shape
= Circle { radius :: Double }
| Rectangle { height :: Double...
I'm implementing a simple merge sort to practice with Python's Threads. I've tried to split the job into two threads, that sort normally, then I can join them and merge the result. However, it takes almost twice as long with two threads than it does with the "normal" algorithm. Did I do something...
If you were to design a skip iterator, that is an iterator that skips values according to some predicate, would you design it in terms of: 1. Skip values for which predicate( value ) == false 2. Skip values for which predicate( value ) == true
It's not a function, it's a type that basically wraps around some other iterator and then operator++ skips values according to a predicate until the next match is found
@user2296177 skip the ones where the predicate evaluates to true
Just like any method in LINQ: Where(predicate) gets the values where the predicate is true. First(predicate) the first where the predicate is true. etc
And SkipWhile(predicate) skips those where it's true
Here is my request :
Select a, b, c, d,
price *(select p.value1 From Params as p where p.PAR_Field = 'Taxe' and p.PAR_KEY = 'TVA')/100 as RealTVA,
price+price*(select p.value1 From Params as p where p.PAR_Field = 'Taxe' and p.PAR_KEY = 'TVA')/100 as RealPuTTc,
Qte*(price+pri...
@user2296177, copy_if, remove_if, replace_if and many more in <algorithm>
@user2296177, also, if it would be possible, I would return dummy type with operators doing nothing on dereferencing if value should be skipped and provide different function to get the value without any restrictions. On increment, I'd still keep to increment it only once, not search for the next value that shouldn't be skipped
it may sound very bad, but I would like to control the algorithmic complexity of my algorithm
I have an AngularJS application where I have services that calls $http resource and returns a promise that I resolve in my controller. Here's a sample of what I'm doing:
app.service('Blog', function($http, $q) {
var deferred = $q.defer();
$http.get('http://blog.com/sampleblog')
.then(fun...
@Vogel612, my bad English reveals itself from time to time xD
@user2296177, yeah, the types should support constant time swap and noexcept. But anyway, if one would like to apply algorithm, I think they would first search for _if, and usually it is there
@OlzhasZhumabek but essentially since there are disparate people giving warnings, and down voting, anyone can down vote a dud question. The question hasn't even had an edit yet. @syb0rg I'd even suggest on a new user you are abusing them. If I went into a hockey match with a new player, and didn't allow them a foul or 2 on their first game, or did a full tackle, I'd basically be sent off by my team mates. It's just rude really. The experience lead through doing, not through whipping. RANT
@user2296177, there is apply_if in boost, so I think it is better to write apply_if than skip iterator, it makes the nature of the algorithm more concise and concrete. In my opinion, simple iteration is no op, so applied function should be integral part of the algorithm
@Gareth, I think it is because people are taking downvotes too serious. It is just a downvote, it is reversible and it doesn't affect things on the bigger scale
@Gareth My perspective is to avoid a negative first impression at all costs. Others (can rightly) argue that people should read the Help Center before posting. And that by downvoting (to -4), the post will be removed from the front page and hence keep our site landing page better-maintained for new arrivals. Plus, sending strong signal that the post needs changing/improving etc.
@OlzhasZhumabek how seriously would a new user look at a downvote if they didn't have a perspective of it's context? @Zak which is what @Vogel612 and another did on that occasion. Code Review for a new person is highly personal, for those with more experience they understand the nature of reviews.
Welcome to Code Review! This question is incomplete. To help reviewers give you better answers, please add sufficient context to your question. The more you tell us about what your code does and what the purpose of doing that is, the easier it will be for reviewers to help you. Questions should include a description of what the code does — Vogel61226 mins ago
when downvoting, there is a popup saying to leave comment about reason of the downvote, and those who have the rights to it and care about voting usually do
@Gareth Like I said, I agree with you in that I think new-users should be spared downvotes initially, but I can also appreciate the arguments for why they're useful, and I don't presume to know which option is the "better" one.
@Zak nor I. Perhaps part of the FAQ should be, any user with a score of say 5 or less should not be downvoted. Any user downvoting such a user shall within 12 hours of the downvote receive 1 negative point in the Code Review forum. Any user found not un-down-voting after a further 24 hours shall receive 2 negative points in 2 forums. The un-down-voting rule shall be recursively applied until the user has -1024 points
this would encourage those who purport to maintain the rules to bare their own rules in mind, and the nature and meaning of real code review. Compassionate and praise
@Mast I disagree. Yes, technically correct. But what matters (in terms of impact) is how the OP perceives it. And it probably feels like they're being voted on. Especially if new to the site / to SE in general.
I had exactly one question downvoted (not my first, it was after a year I think), but that was my own stupid mistake. I deleted the question, fixed it up, went HNQ. Now it's one of my highest scoring questions ever.
As a new user, you have to realize this website wants quality. If you don't put time and effort, you shouldn't expect an answer with time and effort behind it
Maybe. I like to give new users as much help and support as I can (at least initially). I still remember when I first came here and completely screwed up my first question.
There's a StackExchange site devoted to code reviews: codereview.stackexchange.com. You'll probably have better luck there, since your question doesn't really fit StackOverflow. — Adam V7 secs ago
@Vogel612 some of us aren't geniouses getting high grades, or who thoroughly enjoy our university experience. We are struggling older people in a world that changes too fast for us, where just getting our mortgage paid, and keeping our jobs is a struggle. Trying to get help would be nice, if only the world would be gentler when we first try.
in C# if I do a try catch and specify an exception type in the catch parameters, then it only catches those exceptions and lets the rest fall through the catch right?
@mikeTheLiar There's no such thing as "Too Broad" on Code Review*. If the code works, and they can embed it while staying within the ~65k character limit, then we'll review it. *Assuming the code relates to a singular entity (Method, Class, Project, App, Database etc.) — Zak34 secs ago
@Gareth If you want to try to change the social attitudes of the CR communiy then feel free to put a Meta post up on the subject. I've had this argument before and eventually concluded that people are entitled to their opinions and can vote however they see fit, and I can't change that.
I am not sure if Code Review is the right spot for this question but I'll ask anyways. I have a small application that reads from a folder tree. Each folder under a year folder will be targeted to a specific user (EG 2016 --> Joe Smith's Folder --> Work...
Is there a better naming convention f...
@syb0rg @Zak totally agree. I'm venting. It's sad to see especially given this response. Maybe they didn't bother coming back. Who knows. Social responsibility. Code Review. Ethical dilemmas.
@Gareth I've been doing this for some time, if the users care enough they will respond and work with us to fix up their question. We mentor them as best as we can
See Problem - 151B - Codeforces for details. I think I have been very messy with using the Streams. Can you review for a good and better implementation with Streams? Any other improvements?
public void solve(InputReader in, PrintWriter out) {
int n = in.nextInt();
List<Person> ps = new A...
I personally feel it's a waste of everybody's time and perhaps needs to be closed, but there's no rule that states it as such and hence no reason to close it
We're supposed to be reviewing code, I know, but if I cannot figure out what the question is about because apparently characters for variables are very expensive to type, then I'm not even going to bother
@throck95 Why? If that's the code then that's the code. Telling them how to improve it so they can post a (better) version for review is what CR answers are for, no?
I have spotted too many simple issues in order to review this code in-depth, therefore I will point out what simple issues I am seeing and I encourage you to post a follow-up question such that the code can be properly reviewed:
Your variables names are way too short, last time I have checked t...
This is kind of off topic for this channel, I know, but does anybody happen to know offhand where I can find information about what kind of security-related bugs can come up when a web browser is embedded in an application? I'm still trying to understand why this is happening superuser.com/questions/1062259/…
@jrh you might want to clean up the question, I don't know I don't spend enough time on SuperUser, but that question doesn't look like it needs to be moved. don't know why it is downvoted, but they are sometimes harsh on SU too
@Malachi I was thinking that there might be too much information in the question, though A) I wanted to mention what I tried (there's a ton of different causes apparently), and B) I wanted to make sure those reading it knew that I did my homework
I figured the downvote was due to it possibly being too localized? Is it?
@user2296177, man that article is talking about crazy stuff. Will reread it later, cause after a night with directx 11 depth and stencil buffers I'm running out of attention span :)
LOLCODE is an esoteric programming language inspired by lolspeak, the language expressed in examples of the lolcat Internet meme. The language was created in 2007 by Adam Lindsay, researcher at the Computing Department of Lancaster University.
The language is not clearly defined in terms of operator priorities and correct syntax, but several functioning interpreters and compilers exist. One interpretation of the language has been proven Turing-complete.
== Language structure and examples ==
LOLCODE's keywords are drawn from the heavily compressed (shortened) patois of the lolcat Internet meme....
I can't find it right now, but there's a basic script out there that opens 100s of the Cat Clock widget on a machine. So many that it lags out when opening. The kicker, since it's a widget you can't force close them. You have to manually exit out of every single clock.
Here comes the next round. I've implemented some of the suggestions from the previous review. That being said, though, there are a few things that I have on the horizons but haven't yet put in that were suggested. I am currently working on implementing dependency injection so that the database ob...
I'm voting to close this question as off-topic because it fits to Code Review Stackexchange site, but I don't see that option in 'this question belongs on another site...', — icebat54 secs ago
I was asked to complete a coding challenge for an interview. The challenge being to write a test function to check whether or not a string was a broken record. A broken record is defined as a string that contains a sequential repeated substrings. For example:
# These are broken records
"This is ...
I'm in the process of adapting the simple thread pool described here:
https://blog.engineyard.com/2014/ruby-thread-pool
...to my application. I'm new to concurrency in Ruby, but here is what I have so far:
queue = Queue.new
data.each { |datum| queue.push datum }
mutex = Mutex.new
results = []...
@Mast - yup. In a sense it was never about "overtaking" people, it was about adding vote-worthy content. I took a big step back in my involvement in the site almost a year ago, and it's resulted in less vote-worthy contributions, as a consequence, I can't complain if I don't make #1, or keep #2.
@syb0rg It's coming quite well. I've had to look up other online resources other than CMake's tutorial, and I think I'm starting to get a better understanding of how it should be used.
I'm currently writing a Javascript plugin to provide a very simple way to allow elements to animate in as they appear in the viewport.
It uses data-* attributes to determine which animation should take place when an element is scrolled in to view.
See the working example here:
http://codepen.io...