This program takes a simple nucleotide sequence and finds the most common "k-mers" in the sequence, as determined by the supplied dataset (see below). The goal of the program is to find the origin of replication of a DNA sequence, as it is presumably the most common sequence, or in other words, t...
Last time I posted my code of Tant Fant Game. I got some really good advice and I have implemented all the suggested changes to my code. I was wondering if there were any other revisions that would be good to implement? Thanks! =)
class board:
def __init__(self) :
self.loc = ['B', '...
Here is a bit of context:
I am practicing TDD for a new application that will target .NET 3.5 CF and .NET 4.5.2 FF.
I might have some part of the code that use polymorphisme to decide at run-time a strategy (the design pattern) to use while running on a .NET 3.5 CF machine and an another runnin...
If this code works and you just want faster, give codereview.stackexchange.com a shot. More on topic. Make sure you read their how to ask page first to tune your question to their particular requirements. — user458130137 secs ago
package DungeonHack; import dungeonhackmonsterturn.*; import java.util.Scanner; public class DungeonHackRun { /** * The beginnings of a super cool dungeon hack simulator */ public static void main(String[] args) { System.out.println("Press 1 to play as Conan or Press any other Int to play as The Troll"); Scanner jesus = new Scanner(System.in); int…
I'm creating a C# application that produces unique lines of data.
The main purpose of the application is for me to learn C#.
The secondary purpose is to have available lines of (dummy) data when testing Database development.
For this particular question I'm concerned with the most efficient algo...
This is what I have so far and I am not sure how to prevent numbers from appearing again.
<script>
function Randomize() {
var myVariable = document.forms["pick"]["MaxValue"].value;
var max=myVariable;
var random = Math.floor((Math.random()*(max))+1);
document.getElementById("results").innerHTML...
I want to determine whether or not the selected element exists in the list. This is the current procedure that I'm using for finding the element exist in a list or array. Is there any fast procedure for finding an element with any of these?
int[] array = { 1,2,9,3,5,6,7,8,10};
boolean isFound =...
For the last couple of months I've been working on a python script that pulls data from a specific Trello list and sums up the numeric values by list (lists are split up into months). I've worked on making my code pythonic, basic functionality, separating functionality into distinct functions.
I...
For a homework assignment I've been given the task of parsing out information from an 32-bit MIPS instruction. (For more information on the instruction formats, see here: https://en.wikipedia.org/wiki/MIPS_instruction_set#MIPS_instruction_formats). The instructor has provided us with a header fil...
I have a problem that it is:
How we can move the horse on chess board so that it moves on all the points, but "it should move on each point just once"!
And at last,it should return to first point(starting point).
Since your code is working and you're just asking about potential refactoring, it's off topic for SO. You should post it in Code Review instead. — Magnus Eriksson5 secs ago
I'm workig on a shell script that basically re-implementing pgrep and pkill. The correct behavior should be like:
when -n option is set, kill all the child processes first, then kill the parent process
./script -n process_name
when -gn or -g -n (g stands for graceful) option is set, only try t...
The minimum cost algorithm is implemented in C++ set, Java TreeSet, no timeout. But, C# code using SortedSort has a timeout issue. C# SortedSet uses extension method, using LINQ to simulate TreeSet floor method. Need help on Java TreeSet analog in C#, how to avoid LINQ performance issue? Also, pl...
There are some repeated codes in switch case, how can I rewrite this code efficiently ?
$filterTypes = array(Filter::TYPE_ALLPAY, Filter::TYPE_TOP, Filter::TYPE_NEW, Filter::TYPE_SALEPRICE);
$date = Orm::getNow('Y-m-d');
foreach ($filterTypes as $type) {
switch ($type) {
...
Can please get some reviews and suggestions.
from flask import Flask, render_template, request, url_for, redirect, session, flash, g
from flask_security import Security, SQLAlchemyUserDatastore, UserMixin, RoleMixin, login_required
from flask_sqlalchemy import SQLAlchemy
from functools import w...
i have excel worksheet which has 9 columns in it, like Date, Website, Website_code, Part Numbers, Part number returned, Quantity, Lead time and Availability. Same part numbers have different pricing values in different websites, I want the Pricing values to be displayed website wise in seperate c...
When you start swearing at yourself in code you are either about to delete everything or you're really close to the solution. And the trick is knowing which is which.
I am trying to test my first functional test, I would like to know if it is my functional test is well done, or if the strucutre of it is not necessarily optimal.
Any advice will be useful to me, as I said, I start functional tests, so I have a major doubt about my test method which regroups all...
Is there a difference (of any sort) if concatenation is done in this way:
var html = [];
html.push("<div>");
html.push("<h1>Hi there!</h1>");
html.push("</div>");
document.getElementById("result").innerHTML = html.join("");
versus
var html = "";
html += "<div>";
html += "<h1>Hi there!</h1>";
...
I wish to select any other multiple records if it exists (not including the value 9999) - if NO other records exist except one with the value 9999 then only must that one be returned.
In other words, imagine the following:
| FIELD1 | FIELD2 | FIELD3 |
1.| AAA | BBB | 1234 |
2.| AAA ...
I had to do some maintenance programming on a legacy software recently.
Most of the system's logic is done with Java and PL SQL.
The Java creates some special kind of XML. These XML is then displayed in the browser. JavaScript is used as a link between does XML-views and the backend Java.
Th...
Even if it's stupidity, it's all we can offer you here. Stack Overflow is not a free coding service, nor a code review service. All we can do is to show you how to use mysqli. The rest is your job. — Your Common Sense35 secs ago
Explanation of code and hypothetical code is off-topic at Code Review. Please take a look at the help center. Code Review is about improving existing, working code. The example code that you have posted is not reviewable in this form because it leaves us guessing at your intentions. Unlike Stack Overflow, Code Review needs to look at concrete code in a real context. Please see Why is hypothetical example code off-topic for CR? — Mast8 secs ago
For all we know he's actually using some framework on the side which could do it in a more elegant way. Or he's building it server-side. Or <blanks here>.
@Vogel612 Which would be a good candidate for solution C which he didn't mention. We won't know whether it's acceptable in his case either, because we don't know anything.
This is my first foray into multithreading, and keen to know if I have fallen into any traps or room for optimisation/improvement.
example usage:
var success = new ConcurrentBag<CourseParticipant>();
var fail = new ConcurrentBag<CourseParticipant>();
using (var parallelEmails = new ParallelSmtp...
The problem is: Given two strings, write a method to decide if one is a permutation of the other. I wrote the following code in scala, may I know any other optimization one?
def checkpermutation(str1:String, str2:String): Boolean=(str1, str2) match {
case (a,b) if a==b => true
case (a,b) i...
I have these classes:
public class BaseSearchFilter
{
public int IssueCount { get; set; }
public bool IsSelected { get; set; }
public string FilterDescription { get; set; }
}
public class IssueTypeSearchFilter : BaseSearchFilter
{
public StandardIssueTypeDTO IssueType { get; set...
1. $(".container") shoud be closest .container, consider putting multiple on same page 2. if html is class="container active" you message is out of sync ... ask at codereview.stackexchange.com/ — cske45 secs ago
@Vogel612 Ah, right, we had SVN at a previous company, but since all those computers where behind a portal and massive firewall anyway, it didn't matter much.
@SimonForsberg How does that defend inconsistency with the rules?
> Every answer must make at least one insightful observation about the code in the question.
I see none.
0.
Nul.
Nada.
Next line:
> Answers that merely provide an alternate solution with no explanation or justification do not constitute valid Code Review answers and may be deleted.
@Mast I'd recommend not spending too much time on such missions. Find flaws for a reason, not for the sake of just finding flaws.
I have pinged the other moderators about it ( @200_success was the one that made it CW in the first place). I'd recommend leaving it alone for the moment.
I'm writing a communications library for a class. Part of the requirements is that semi-reliable communications, which leads me to this monstrosity:
unit UDP.Communicator;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, DateUtils, SyncObjs, blcksock, fgl, SimpleThread, Common.Types,...
I developed a simple deck shuffle and drawing system, as a test on how to use collections and learn from it.
However, I think my code is a bit wonky, and I think here is the best place to get new tips on what to improve.
Public deck As New Collection
Public face As New Collection
Public symbols...
I have some files I want to process, and I know how to do in sed/awk (for each one):
awk '{if (index($0,"#")!=1) {line++; if (line%3==1) {print $2,$3}}}' q.post > q
or
grep -v "#" q.post | awk '{if (NR%3==1) {print $2,$3}}'
It's one line, and rather beautiful and clear.
Now, my main pr...
You might want to look at the code review stackexchange instead; there are many errors in your code, ignoring method parameter values, unreachable statements etc. — Pete Kirkham15 secs ago
im just wondering if any one could help point me in the right direction please??
ive found this code on here and i cant seem to figure out how to call the post function passing through parameters for the dictionary.
ive searched all other the internet but no luck
please help i really need this...
@Mast That would be perfect, because I want to 1) understand how C++ works under the hood 2) Practice more C++ on a project that gives me all the time I want to think and design stuffs.
@skiwi I though that it could give me a general idea of what compilers do. But there might be some books out there that will bring me more than just that.
One example is integer increment... I heard that before Pentium 4 writing INC <register> in ASM was faster than ADD <register>, 1, then afterwards ADD <reg>, 1 was guaranteed to be always at least as fast as INC <reg>, because the INC instruction can cause a partial flag register stall and since a very recent Intel CPU generation there is no partial flag register stall possible anymore (at least not with INC), so INC <reg> is actually faster again
ASK
Consider any indexed sequence of natural numbers C, which define the concept of the present position.
Next, we introduce two operations on the elements of this sequence:
If amount of sequence of natural numbers is even number ->
R, remove the item 'c' on index POS + 1, then move the poi...
What are you asking is good or bad? The fact that you are faster your the way your code looks/behaves? If it is the latter do note that code review is off topic here as they have their own site. — NathanOliver22 secs ago
So I was always thinking about a mask like [3, -1^, 3] applied on a cell with value say 4, then the cells to the left and right need to add 4 * -3 = -12
Turns out I forgot there's cases where the cell under the pointer is not -1
Other case would be handling this in the Assembly code, not sure yet how
> Summary: There are plans by group of people to build a new racetrack in Almere (centre of the Netherlands). This racetrack should be suited for f1. The design has been made, the circuit should be around 5 km long, and able to host 178.000 people. Next to F1 they would like to host the CIK-FIA karting championship, MXGP Motocross, WRX rallycross and the IJSBA Jet Ski championship.
Having a working code and looking for improvements might be a candidate for codereview.stackexchange.com (though it's not to bad here either) — grek4056 secs ago
Time for the most original question of the year: writing a FizzBuzz in Haskell!
So here is what I came up with:
fizzBuzz :: [Int] -> [String]
fizzBuzz xs =
[fizz x | x <- xs]
fizz :: Int -> String
fizz x
| mod x 15 == 0 = "FizzBuzz"
| mod x 3 == 0 = "Fizz"
| mod x 5 == 0 =...
@Duga Well, actually it's correcting an earlier invalidation. It probably should've been handled differently, but the end result is OK. Just roll it back to the latest not-invalidating version if he does it again.
I have a problem where I need to replace every base part of URLs in a body of text. However, I only want to replace it in specific URLs. Only URLs that go to "resource.aspx" that have the "source" parameter need to get the replacement. Other URLs could have the target base part and we don't wa...
I have a method that takes a String and returns the phone number in certain format. It will return the numbers with dash ("-") in every 3 digits and at least keep 2 digits together. For example, it will return
Test: '00-44 48 5555 8361'
Expected: 004-448-555-583-61
Test:'0 - 22 1985--324'
...
This class has the responsibility of parsing a string to one of the primitive types: int, double, float, decimal...
While creating it, I have noticed that it'll be terribly ugly.
It basically should perform a TryParse of each primitive type and return the first that returns true, along with t...
I have a piece of code that works perfectly when I run it from it's own module.
When I call it from another module, however, I get the Argument not Optional error message. Can anyone spot what I'm doing wrong?
Sub DoSheets()
TrimUsedRange Sheets("Approved Closing Data Draw")
TrimUsedRange Shee...
I made an auto complete input box of every town,city,village in the UK...yes every single one the load times are painful to say the least is there a way to reduce that?
Yes it's in the fiddle I really don't think it would fit in here.
But here is a sample
<input type="text" id="location" n...
I have written a small program to query the Stack Exchange API, specifically for badges. The main idea of the program is to return the new list of Tumbleweed posts on Stack Overflow, every 10 minutes. The motivation for this bot was the Weed Eater hat.
The program queries the API every 10 mins....
I’m a junior developer and working every other three months in a software development company as part of my corporate studies.
Even though I’ve been programming for almost 1 year (3 x 3 months work experience + side projects) I quite often have to check the documentation and/or Stack Overflow du...
Exposing Inherited Members
I have a WPF Custom Control library (ContentToggleButton) and an app (spec) to test it. The Custom Controls, which derive from Presentation Framework elements, expose inherited properties as well as new properties to the consumer.
This means that the consuming app depe...
It is true that you could "have code reviews focus on code that uses this annotation." But what if you are just a caller and the warning is suppressed in someone else's code; then how would you search for those (potentially unsafe) calls in your code? — Patrick Parker22 secs ago