The Three Laws of Robotics (often shortened to The Three Laws or Three Laws) are a set of rules devised by the science fiction author Isaac Asimov. The rules were introduced in his 1942 short story "Runaround", although they had been foreshadowed in a few earlier stories. The Three Laws are:
# A robot may not injure a human being or, through inaction, allow a human being to come to harm.
# A robot must obey the orders given to it by human beings, except where such orders would conflict with the First Law.
# A robot must protect its own existence as long as such protection does not confli...
Here is my attempt at the UTTT code-challenge (in response to the the Weekend-Challenge Reboot). Here is what I would like critiqued:
I tested the code a few times for bugs, but I may have missed some.
I feel like I have duplicated code in some places (with only minor changes being the differe...
I am having trouble with this graph method.
Ideally, I wish to print out the first and second occurrences of the CSC101 occurrences in my two dimensional integer array.
The input would look like this
2012 CSC101 20
2012 MTH223 30
2012 ENG105 15
2013 CSC101 25
2013 MTH223 10
2013 ENG105 4...
I am having trouble with this graph method.
Ideally, I wish to print out the first and second occurrences of the CSC101 occurrences in my two dimensional integer array.
The input would look like this
2012 CSC101 20
2012 MTH223 30
2012 ENG105 15
2013 CSC101 25
2013 MTH223 10
2013 ENG105 4...
@JerryCoffin Hmm, simplified logic that I was looking for. But say that you included that in a switch that couldn't be simplified down. Would you still not use it?
I'm trying to do a SPOJ problem called twosquares where you check whether the current number can be obtained by adding two squares together, however, I'm getting a a time limit exceeded. I'm creating a sieve of eratosthenes - if the number is prime and mod 4 is 1 then the number is a sum of two s...
@palacsint not sure I understand that comment/dig ...
> As an occasional interviewer I would appreciate a solution which shows that the candidate does not reinvent the wheel and can use (and know) the existing libraries.
He is not using the existing libraries correctly
(and does not know them - enough)
He barely understands the basic Java collections, thowing in that Java iterable stuff is not going to do much for him
If I interview someone for a Java position, I would not put them through the interview-challenge, but, if I did, and they did not use the generic type of a generically-typed class, I would blacklist the person
If they use a primitive/array instead of the Collection alternative, and they could justify it for even one valid reason (faster, smaller, whatever), then I would lift their name in the stack
I consider those to be 'differentiators', things to avoid, things to like... takes a person out of the 'average' category ...
I'm trying to do a SPOJ problem called twosquares where you check whether the current number can be obtained by adding two squares together. However, I'm getting a "time limit exceeded" message.
I'm creating a Sieve of Eratosthenes program. If the number is prime and mod 4 is 1 then the number...
As part of my java learning i tried solving part I of problem description in below link. The only issue that i see now is, i could not close the button of Frame.
http://www.cs.berkeley.edu/~jrs/61bf06/hw/pj1/readme
Please review and provide your comments on coding style/OOPS/.. aspect on below...
@rolfl it's super simple, I could have created the connection there in the using statement, I am trying to think of why I didn't do that in the first place.
i bet there is a reason
but when he commented that on your answer, it hit me that it might be keeping that connection open longer than i want it to be open
I'm fairly new to python and I'm curious how to improve the readability of my code.
This function does heavy lifting by obtaining information from a row on a dataframe and outputs specific information about a stock position, such as price, totalstocks, capital, status of that position (bought o...
Your stats are a bit messy: Compare CodeReview: http://data.stackexchange.com/codereview/query/161411/site-activity-and-votegraph#graph and AVP: http://data.stackexchange.com/avp/query/161411/site-activity-and-votegraph#graph
And you are very much the leading member there ... a solo effort?
you need to know a) what needs to happen and b) why someone wants that to be what happens even if they don't know it yet
if you understand those two things, you can guide people to being more productive and getting more from the site
and when people realize you can help them get more, they follow
because power comes from being beneficial to people
you can either convince them it is their interest when it isn't (manipulative, power hungry leaders), make them fear not following you (dictators) or actually make it so they are better off following you (serving the community)
but in all cases, the power comes from people viewing following you as in their own interest
When we do finally graduate, and if I do decide to run, I hope that I've indeed fulfilled the third category. I really love this site and have wanted it to succeed ever since I can remember.
In case there are any real-life obligations (probably unlikely), or if I end up feeling burned out. But if some people can mod for years, then I can certainly take it for a while.
@rolfl: That's what bothers me. There hasn't been much other mod activity, and I assume part of that is because there aren't too many flags when they're around. I've taken my own initiative to massively clean the site and keep it clean and growing.
Tim is already aware of it, so they'll do whatever needs to be done. That is, if it takes too long for us to graduate, otherwise elections will refresh the mod pool.
A few comments:
[ ... ]
for (; (x % 3) != 0; x--); // quickly set x to left bound of sub-board
for (; (y % 3) != 0; y--); // quickly set y to upper bound of sub-board
I think I'd move the code to round to a multiple of three into a function of its own. I think I'd implement that something lik...
I'm just thinking the 9 by 9 data structure is more confusing than it needs to be
if it can be broken in to a 3 by 3 structure of 3 by 3 structures, it might be more understandable
my C is a bit rusty though since it's been about 8 years since I wrote much in the way of C code
and then all the lookups become direct to the index
rather than needing the 0..2, 3..5, etc
and you can take the index of the sub-board selection and pass it directly to the overall board
since putting a move in space 1,3 means you play board 1,3 next
@JerryCoffin even worse was when I made the mistake of learning PHP and Perl at the same time
even when I was using them regularly, it threw off my ability to write in either without having to look for syntax and keyword errors for a good 2 years
The way I approached the problem may not have been the best way. It's just the way I thought of when I started off, and I could see myself working with it pretty easily to the end with it.
One quick observation I have is about the way you are storing the playable spaces. While a 9 by 9 grid is a simple way to do it, it isn't the most clear way to store and ends up requiring some complicated addressing logic to get each sub-board.
Your options to deal with it are a bit limited by ...
actually, I think I may have overcomplicated my own code
I think it can be done without the struct
I think you can simply do the typedef
I changed my code accordingly, though I'm not 100% confident in it being 100% correct syntax
@JerryCoffin or in the case of the real world, you come up with the best solution after it's already in production and being used by 40 other developers
@AJHenderson: Welcome to CR! :-) If you ever hunger to write a review but cannot find anything on the front page, feel free to help yourself to some zombies.
@AJHenderson In that case, you want to try Unicon, the unified Icon, which is a successor to Snobol, which was the progenitor of REs. Then again, you might want to play with Snobol, which was pretty cool in itself.
@AJHenderson F# is basically an ML dialect.
I'm almost tempted to post an answer to an SO question for code review, but I'm pretty sure it'd make most people some combination of sick and angry... :-)
@Yuushi Oops--sorry, was too busy typing to notice you'd beaten me to that.
I'm using this JS to sticky website footers at the bottom and I would like to know if is there anything to be optimised?
(function($, window, document){
//Screen_height = Header_height + Main_Content_height + Footer_height + alltoplvlContainersMarginTop_Bottom + alltoplvlContainersPaddingTop...
I've tried to write my Property Container design-pattern implementation.
Could anybody, please, tell me, if this code is really what I intended to write (follows the Property Container design-pattern rules)? Is there anything that can be improved?
<?php
class PropertyContainer
{
private $P...
personally, I like the guy on slashdot who has the signature "build a man a fire, he'll be warm for a day, set a man on fire and he'll be warm for the rest of his life"
@Yuushi Yeah, he's not exactly a shrinking violet--but he's been a moderator on comp.lang.c++.moderated ever since it was formed (I believe) and spent years on comp.lang.c++ and comp.lang.c before that, so he's seen far more than anybody's share of flame wars and such.
@Yuushi He's a smart guy, and knows a lot, but is also the sort who gave Usenet (and such) a bad name--just for one example, constantly picks up on some irrelevant detail, and tries to make it the main topic (e.g., once started a pretty serious flame thread over somebody using foo in sample code they posted).
I'm implementing a system where we are trying to keep things highly flexible. We have an abstract superclass called EmailTaskService which has two classes inheriting from it. One is EmailTaskServiceImpl (the concrete implementation class), and the other is another abstract class called ScheduledE...
@Yuushi I enjoy the Lounge quite a bit, but I'm another who spent years on Usenet, so I have a pretty thick skin. It's certainly not a place for the faint of heart.
@Yuushi I've spent little enough time on IRC that I can't really answer/guess (but quite few of the regulars in the lounge have apparently spent a fair amount of time on IRC).
Pretend that a LinkedList is not just a quick iterable structure in Java. Meaning you have your own personal implementation of a LinkedList, and you want to find the next value linked to it that is not null, how would you go about doing that?
I've tried this:
while(LinkedListObj.next != null){
...
Here are examples for fails (a brief history of one line fixes):
http://www.tedunangst.com/flak/post/a-brief-history-of-one-line-fixes
from the OP:
Does nobody use a compiler that warns about comparisons always being
false?
or:
Does nobody use a compiler that warns about unused p...
I am using knockout in my project. I have some models like EmployeeModel, ServiceModel etc which user can update. On UI i give user a Cancel control button by which he can revert the changes. On cancel i have to revert the model change back to its original state. For this i found these two good a...
I'm hoping this is the correct place for this, I'm struggling a little for wording as i'm not sure what you would call this.
Basically, i have a system in place where my datagrid marks cells that have changed with a new background colour, to do this i have a method in the object that contains th...
I want to iterate through the dictionary which is sorted with values. one method is to use ordered dictionary means initialize dictionary with sorted values.
from collections import OrderedDict
data = OrderedDict([('a',0), ('d',1), ('c',2), ('b',3)])
for mykey in data:
print mykey
How to mo...
I tried to make a weighted search function in JavaScript. I've been improving my JS lately but still not sure about some best practices, wondering if there's any improvements I could make, or if I've ended up doing it completely wrong.
The intention is to keep it quite flexible so it can take an...
I'm hoping this is the correct place for this, I'm struggling a little for wording as i'm not sure what you would call this.
Basically, i have a system in place where my datagrid marks cells that have changed with a new background colour, to do this i have a method in the object that contains th...
@apieceoffruit - seems to me like there should be an event generated when the user changes a value. Change the background then (when the event is triggered), instead of after the fact by going back through the cells looking for differences.... another mouthful about to happen.