Tagged Questions
3
votes
1answer
141 views
Why divide and conquer algorithm inefficient?
I was solving one of the problem in USACO 2007 Open Silver. The problem is as follows:
Description
Farmer John has taken his cows on a trip to the city! As the sun sets, the cows gaze at the city ...
1
vote
2answers
39 views
Best way to animate with tkinter
I am trying to learn how to animate with tkinter. The code below is an example I was able to build. I creates a small 5x5 map of cubes then one of them randomly moves around the screen(preferably on ...
4
votes
2answers
156 views
Trying to get better at Ruby and programming in general- here's a simple TopCoder question in Ruby
I want to get general feedback and feedback about if I can make this more Ruby-like, if there are any obvious inefficiencies, and if I need to organize my class differently. The topcoder question is ...
1
vote
2answers
127 views
Email report generation from database
I have written a small batch job which will collect data from db and send mail to user. Can you please do a review of the code with design prinicples in mind and also with best practices for Db and ...
0
votes
1answer
72 views
I've finally found a satisfactory way to create classes on JavaScript. Are there any cons to it?
Depending on external OO libraries is really bad, using prototypes/new has some limitations, using only hashes has others. Dealing with classes was always a pain in JavaScript and it didn't help that ...
3
votes
1answer
284 views
Which is better: the short, clever way, or the long, ctrl+c way?
The code below is equivalent. I can see pros and cons for both versions. Which one is better?
Short version:
character.on("key",function(key){
var action = ({
...
1
vote
1answer
113 views
Playing Card Class - is this right?
The Art and Science of Java, a course book that uses the ACM library has an exercise that reads like this.
Implement a new class called Card that includes the following entries:
• Named ...
1
vote
1answer
132 views
Which code is better? And why?
I found two ways of writing the same program (one that only uses local variables, but no methods other than the main one) and other that uses one instance variable that is used in two methods.
This ...
2
votes
2answers
120 views
How can I improve this coin flipping code?
I am doing exercises for the Art and Science of Java textbook. I had an exercise that required me to program the simulation of flipping a coin until 3 consecutive "Heads" result appeared.
I did it, ...
2
votes
1answer
120 views
Simple and efficient code for finding factors and prime factorization?
I've modified this program many times, but I want to know if this is a good way to perform this task. My first algorithm for finding the factors of a number was pretty slow and horrible (started at ...
1
vote
3answers
94 views
Improving Javascript code of a failed test
I just failed in a JavaScript test and I would really appreciate some comments of how I can improve so I can keep learning.
The test was about making a form interactive, where the code should do ...
3
votes
3answers
187 views
Advice on program which calculates scores for predictions of Football scores
I am writing a program which calculates the scores for participants of a small "Football Score Prediction" game.
rules are:
if the match result(win/loss/draw) is predicted correctly: 1 point
if the ...
0
votes
0answers
57 views
T-SQL BFS center node of undirected graph
I am trying to answer this question by using a breadth-first search from each node of the graph represented by the tables mapSolarSystems and mapSolarSystemJumps in the data dump at ...
3
votes
3answers
135 views
How can I clean up this python code?
I am very new to programming and this is my first functional code. It works fine but I'm sure that I could use a lot of optimization. If you see any blunders or would be able to help condense the ...
2
votes
1answer
37 views
Power utility for starting processes
I was looking for a way to start elevated (i.e. administrator permissions) and/or invisible processes via batch in Windows. It turns out that this is kind of impossible with batch only, so I googled ...