On the downside, using Variable Length Arrays are a great way to overrun the stack and introduce mystery bugs. Finally, the lack of descriptive names in int t,i,j,k,n,m; makes your program much harder to read than it needs to be. I'd fix that up before heading to CodeReview or you'll get some sarcastic nagging. — user458130136 secs ago
I was initially skeptical of @Jean-FrançoisFabre's close vote, but skimming the code and seeing the sheer number of improvements to be made, I agree that this question is much better suited for Code Review. The issues go far beyond the single question that's been focused on, and the code would benefit greatly from a full review. — jpmc2653 secs ago
I am trying to get a powerset (all subsets of a set) in Java. So my logic for that is:
A given set is one subset, so add so it as it is to result.
Remove each element of set from given set and we will get all the combinations for 1 element less. Add these results to final result.
Recursively fi...
I have a matrix and I want to make each of its element equal to the maximum of its neighbouring element and each time I increase number of counts till all the elements in the matrix becomes equal to the maximum element of the initial matrix. Note that this increase in element will happen simultan...
There are some light house's placed on a field can be rectangular.Each light house has base luminous intensity L.
Now the intensity diminishes as the light moves further away from the respective light house. In the Figure below light source is 2 and has intensity at light house 2 and then dimin...
im working on a go game in javascript and drawing the board is important to be efficiant because it gets ran multiple times a second, as when the user moves their mouse it will simulate where their game peice is going to go so the board must rebuild lots of times.
It looks ok at the moment, abi...
it's my first time on code review.
So I'm parsing a raw text file with my parser and a defined template (basically an array) to create a formatted array out of it.
The idea is that each line can have different templates and can be identified with the first characters of the lines. A template me...
I would like to make this function more efficient. Currently, its performance is lacking.
From my understanding, for large list that is being kept locally- I may might be better doing display:none on the hidden ones rather than removing them from the DOM. This could dramatically cut down on int...
imagine a game of checkers but you can move left right up down instead of diagonally. I have made an array to store liberties(avaliable moves) and use if statement to update if a checker can move there. checkers can share liberties, ill include a picture below so you can see what i mean
So the...
I am implementing json parser in c++,
i have written some code and i wanted to share it on stack overflow,
While writing this program i have assumed as the json will have only objects and array are of string.
Also i have used stack to find corresponding closing ']' or '}'
Also i have used ...
I wrote the following code for this program. It seems to work well,...then, my friend, you should change your way to Code Review — Sourav Ghosh7 secs ago
I am interested in DP problems from the past couple of days and am trying to solve various problems on topcoder. To be very frank could not even solve a single one till now. I went through https://community.topcoder.com/stat?c=problem_statement&pm=14408 question and thought to try this. I could c...
This is a very simple weather app where you can get weather details based on search and location services. Weather info: Humidity Pressure Wind Speed etc.
Check it out on GitHub (There is a lot of code so I uploaded it on GitHub)
T
The Weather ForeCast
Any:
Suggestions, Fixes?
Is it possible to get rid of the BehaviourSubject to have an Observable with an initial value? Another thing I don't like is that I'm using getValue() and then modify this value and push it with next back to the Observable. Maybe there is a more elegant way to get the same thing?
import { Inject...
im trying to check 4 things, 1 of them things might happen, maybe 2 or 3 or 4 but if none of them occur, i want to run some code. I cant do an else statment because that only applies to 1 and i cant do else if because more than 1 can happen. at the moment ive resorted to this:
function checkChai...
I'm voting to close this question as off-topic because this is really much too broad for Stack Overflow, which deals with more focused coding problems than this. For advice on improving working code, consider Code Review instead - but do read A guide to Code Review for Stack Overflow users first, as some things are done differently over there!. — Toby Speight57 secs ago
My android java ide can't find the main member,the setview code is R.layout.main.This issue appeared after i had fixed the "unknown entity R" issue by import it.How can i fix this?isn't main mean MAIN.XML?
I am attempting to code a basic Jumble game in Python utilizing the web-based environment CodeSkulptor and I could not quite find solutions to problems I encountered.
1- I don’t understand why the first word repeats itself upon pressing “new word” and why displayed scrambled words are offset wi...
I implemented, somewhat closely based on this implementation, a blocking queue with emphasis on filling up first. So if one producer and one consumer thread are using the queue, the producing queue gets prioritized.
Code
// BQueue.hpp
//#pragma once
#ifndef _BQUEUE_HPP
#define _BQUEUE_HPP
#inc...
I would answer if I would understand the problem. The question is too broadly worded and contain many parts which can be answered individually. Again, PropertyGrid can replace settings form, it's dynamic and very flexible. But database? MVP? Concerns like "another programmer may find it difficult to understand" only adding uncertainty. It's not possible to answer unless you clarify better your requirements, show what you have now and why it doesn't work for you (though that's rather code-review question). — Sinatr1 min ago
Normally I would use data reader with column index to get data from database but now, i wanted to integrate attribute and use reflection so that i can just loop the properties, as opposed to updating every single connection whenever there are changes on the database. I also thought about using OR...
Please have a look at the following class, it works but I'm not too happy with it:
template<typename T, typename Container = std::vector<T> >
class SortedVector {
public:
...
class insert_iterator {
public:
class assignable {
private:
SortedVector<T> &v_;...
I wrote a short class which allocates objects on the stack and aligns them to a specific memory address. Alignment makes sense for some objects (i.e. some SIMD intrinsics require aligned data). I wrote this mostly as an exercise. Tests are included. If someone has time to skim over this: thanks i...
Program Specifications: Use the following guidelines to write your program.
Find the EPA miles per gallon (MPG) for two vehicles you want to compare.
Estimate the number of miles you or your family drive a car each month.
Determine the current cost of gas where you live.
Name the class Vehicl...
@Hosch250 I think it supports Java. I was at a Java meetup not long ago where someone from Microsoft talked about Azure. Then the biggest question is if I can get an open port and have it work as a Minesweeper Flags game server the way I want to, for a reasonable price.
> You may not reuse any previous community challenge suggestions as normally required, but you may suggest challenges that are somewhat large in scope.
@EBrown I don't think I can, ones a question anyway. Under 'How does one win?' How does the split work? 1 winner get 500, 2 250 each, 3 500 each, 4 500 each, ...?
Of course other community members have indicated they wish to contribute reputation, so if @Vogel612 (and you even) contribute then we can give all winners 500 rep bounties
@Peilonrayz Ah yes, typo. :) Fixed
@SimonForsberg I edited that verbiage, I meant to say 'you cannot use any previously selected challenges', you can resuggest losers like normal.
@EBrown I think there's there's definitely 1500 rep people are happy to give, you, Vogel612, and me, I don't know the upper limit from Kaz. So I think that's definitely a possibility. Currently we can support a 6+ way tie at 250, :)
@EBrown I think that should be somewhat discretionary based on how much rep goes into the pool, and how many entries we get and how we feel about them.
@scripter Yes and no. The rule is that the relevant code must be embedded in the question itself, but you are free to also link to the repo for wider/fuller context.
@scripter Then you should embed all the code in the question, however in the case you simply want a 'does this project structure/architecture make sense', then this may not be the place for that.
I believeSoftware Engineering does project-level questions, though you should be certain to check their help centre and ask in their chat if you like just to make sure.
I would suggest to move this over to codereview.stackexchange.com , as this will not turn into a good format for this site, but you could do a lot of things (e.g. use serverside sessions instead of just this id in the cookie). — Nanne40 secs ago
Each input line should consist of
- A type name, which must be one of the following: char, int, short, long, float, or double.
- One or more individual declaration specifications separated by commas.
- A semicolon marking the end of line.
I wrote the following code for this program. It seems t...
This might be off topic for SO - since you seem to have managed to write some code, but want a better wya to do it. Try the code review site? Also, don't be shy about looking at open source implementations to see how they do this kind of thing — doctorlove30 secs ago
@MartinDreher I worked in a place where it was deemed normal for a SSRS report to take 30 minutes to process... People have varying standards I guess. Still, I would recommend you put your SQL up for review on Code Review if you can - you never know, maybe there's a chance it can be tweaked to run in under 10 seconds =) — Mat's Mug52 secs ago
Good afternoon, i have a dataset of 112 images (80x24x1 --> greyscale)(Jaffe dataset) that i want to use as training for a CNN. The code i am using is this:
def vgg16(num_class, placeholderX=None):
x = tflearn.input_data(shape=[None, 24, 80, 1], name='input', placeholder=placeholderX)
x...
I have recovered a project in ASP.NET MVC 5 uses a SQL database SERVER 2016 and Entity Framwork 6. In this code we will create a new instance of the DataContext whenever he wants to use an entity. Which is not optimal ... please tell me what you should not do. And that you proposed as correction ...
I'm doing a code review on PHP and i've found this kind of code:
$charset or $charset = 'utf8'
Which i believe is equal to:
if (empty($charset)) {
$charset = 'utf8';
}
For me the first one looks not clear and not a good practice.
What do you think?
See the help topic for What topics can I ask about here?. Since you have working code, and are asking for potential improvements, that is a more appropriate question to ask on the Code Review site. — CoryKramer45 secs ago
Please see the code options below:
Clent App - this is the same for both options
LetterCounter lc = new LetterCounter("HeLLo");
Option 1
class LetterCounter
{
string _Word;
List<LetterQuantities> letterQuantities;
//Other functions will be here.
public L...
Welcome to Stackoverflow, while this is a programming question it is somewhat outside of the scope of the questions we usually help with. Questions about code syntax and best practices are better asked on codereview.stackexchange.com — Keith M58 secs ago
According to code, as you can see, my problem is this: type struct bar init depends on data in type struct foo.
I want to avoid to use too many arguments in init method newBar, so I have to use a globVal. I have to say, this method is not that elegant.
If in Java, I will use static block in fo...
For starters, some variable names that actually means something normally helps. That said this really sounds like a question for CodeReview.SE, not Stack Overflow. — NathanOliver42 secs ago
I have 3 models: Import, Product, Values.
An import has_many products.
A product has_many values.
I want to find the product with the highest values count and the sum of all values for all those products. My current method is very expensive.
@import = Import.find(params[:id])
@products = @impor...
Based on the reply on my previous question, I have tried to shape my model so that it could fit the MVC pattern structure(thanks to @Mike Brant).
This this project is the Model part only and views and controllers are not yet added to it.I have planed to use Simple for the routing....
I use YAML...
I have been working on a 2-player battleship game and have finally got it working, bug free.
I'm posting this here to ask you what you think of it. Are there any changes that could be made to improve the performance/general layout of the code?
If you come across any issues with the code itself,...
What do you think of my Brainf*ck interpreter?
What else can be done to increase speed?
#!/usr/bin/env python3
class InfiniteArray:
def __init__(self):
self.pstack, self.nstack = [], []
def __getitem__(self, index):
s = self.pstack if index >= 0 else self.nstack
...
I wrote this as an attempt to create a non-recursive solution to project euler 60 which is basically finding a specific n choose k combination. The difference is that partial combinations can be invalid so this algorithm can reject whole swaths of combinations if the first part of the combination...
I know Gorilla and others have packages that accomplish this, but I'm trying to learn Go by making stuff. In the router below, the first route / is for all http methods, the second route /hello is only for GET, and the third route hello/:name has one parameter for all http methods.
func main() {...
I am not sure if this is possible, but I am wondering if you can pass a variable expression as a parameter that does not get evaluated until the function.
For Example:
construct_corner_tile([0, (1/3), (2/3)], xCoordinate + 1 - j, yCoordinate + 1 - i])
def construct_corner_tile(jList, x1, y1):
...
I am building a little game in using Unity, and recently made an algorithm to get the closest Entity to the player on the battlefield. I made a working sample in RexTester (it is not the real code, but the algorithm is exactly the same).
I am interested in the GetCloserEntityFromPlayer function....
I have been working on a 2-player battleship game and have finally got it working, bug free.
I'm posting this here to ask you what you think of it. Are there any changes that could be made to improve the performance/general layout of the code?
If you come across any issues with the code itself,...
The problem is from codechef challenge and this challenge is over now.
This is the link of problem : https://www.codechef.com/SNCKPB17/problems/SNELECT/
My code for this problem is :
package kk;
import java.util.Scanner;
public class Mongo {
public static void main(String[] args) {
Scanner in ...
The Unit of Work:
public class UnitOfWork : IUnitOfWork
{
private IDbConnection _connection;
private IDbTransaction _transaction;
private bool _disposed;
private _repository;
private UnitOfWork(string connectionString)
{
_connection = new SqlConnectio...
Your question is too broad to be a good fit for this site's Q&A format. Please read the linked documentation, try something, implement it - and if/when you get stuck on a specific issue, then you'll have a better SO question. Or, if you get it to work as intended and then wonder if there'd be a better way, head over to Code Review to get a peer review of your working code. — Mat's Mug19 secs ago
I have written a program that reads simple data declarations and responds with the amount of memory that would be allocated to that variable.
Each input line should consist of - A type name, which must be one of the following: char, int, short, long, float, or double. - One or more individual de...
God day!
I have wrote a django app that would get and some data to input and give you an image to output, image have 3 layers:
google map image
rosreestr(russian docs layer)
data from geojson layer
I ever listen that I'm junior, pls help me fix it.
I think so hard find a job, sometime I wanna l...
For the purposes of an app I work on I have created a separate framework that abstracts away the mechanism of making atomic changes to the complex object structures.
Each class that has to participate in transactional changes of state is supposed to implement Transactable protocol where it has t...
I have a simple application which shows film recommendations to see with rest api which provides data from file. I would like to ask if something is missing in this app, maybe something can be do better?
GitHub
Regards
our process on github is: 1) create pull request, 2) wait for code review, 3) merge into master (or release branch). Direct merge into master would lack code review. Am I missing anything? — user234966134 secs ago
As a beginner I was writing a code which asks the burger buyer what they want in their burger. I did this by creating a burger object and modify its attributes by the user using a switch case method. Most of the attributes were Boolean variables. At the end of the order, what I want to do is to d...
Just a little palindromic game.
that searches all palindromic numbers in ur random generated list.
I am new at python coding it's actually super fun, rate my code and feel free to give me some advice. Thank you i hope u like it.
import random
numbers = []
total = []
dice = random.randint(1000...
Can you improve?
rc = []
for i, j in zip(A_response, B_response):
rc.append(i)
rc.append(j)
I use zip and append, but But it's to use list comprehension?
You need to learn your data structures... You are using lists, or numpy arrays, in ways that defeat their strenghts. I think this question belongs in Code Review, not here. And you are more likely to get actionable help there than here. — Jaime37 secs ago
I was playing with JS and wanted to create an isEven(n) function that returns true if it is even and false otherwise.
Here is what I did:
function isEven(n){
return n % 2 ? false : true;
}
print(isEven(6));
//-> true
print(isEven(-3));
//-> false
My question is:
Is this good code? How i...
my name is Brian, I am new to Stack Exchange also new to coding, obly have been doing it a short while now. I would like to ask questions about coding in C++ about an issue I'm having with some code I have written.
Basically I have included all of the code I have written up until now, Apologies f...
I need to write a program to print the line numbers, in ascending order, of a particular word in a file. Example output of the program would be:
Hello 1, 3, 5-6, 8, 10-15.
// 5-6 represents 5, 6 (consecutive numbers)
The line numbers are stored in a sorted vector<int> with no duplicates. I ha...
I am currently converting a project from Java to kotlin and re-writing the code in the process to make the most out of kotlin's capabilities. The project contains a Battle System which uses elements to establish inferiority/superiority or neutrality of attacks based on the attacker's and defender...