I'm just looking for feedback on how I could improve this simple program. Whether it be comments for better understanding or better variable names. I try not to focus on memory consumption because I'm honestly not that knowledgable as of yet. My main focus is getting a written solution on paper a...
I recently took a class on Angular 2+ at Code School.
I then rebuilt my homepage using Angular 4.
I would greatly appreciate any developer experienced with Angular 2+ can check out my code on git and offer constructive feedback.
I'm hoping this website will help me land a new job using Angula...
My code is working well and uses a lot of mechanics in c++, however, i want to know if there are any ways to make my code better, some possible problems in use. this is a simple program and I started yesterday. What other mechanics could i implement to make the code better? and where can i find m...
I know there are other structures which are better than the linked list, but I want to implement a singly linked list which has a remove function for study.
After struggling for a few hours, I wrote this code.
use std::rc::Rc;
use std::cell::RefCell;
type Link<T> = Option<Rc<RefCell<Node<T>>>>...
I was just copying the example from the book The C Programming Language by Kernighan and Ritchie. The code taken from the book appears below.
#include <ctype.h>
/* atof: convert string s to a double */
double atof(char s[])
{
double val, power;
int i, sign;
for (i = 0; isspace (s[i]); i++); ...
hope someone can help. I am assigning a macro to run when the user clicks the cell. this works fine:
Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
If Target.Column = Range("V3").Column Then
Range("U2") = Range("V3")
End If
End Sub
But then I want to be ...
I tried to implement singly linked list in java for adding and displaying the elements in standard output and uploaded it in "techgig" for practice. However my code is scoring only 20 out of 100. I know there might be numerous issues with it but am not able to figure out what and how to correct i...
This is one of the puzzle I was trying to solve, where the question is to validate the credit card with following characteristics :
-It must contain exactly 16 digits.
-It must start with a 4,5 or 6
-It must only consist of digits (0-9).
-It may have digits in groups of 4...
I am currently working on a function that should return true of false based on a condition written in string by a user. The condition will look something like this: "((dog OR cat) AND Horse)"
The () grouping objects and word making the search case insensitive.
How I approached the problem was t...
Used another algorithm which failed near the center of the complex polygon. This method sure works! — Vignesh55 secs ago
It depends on the code/algorithm behind "lots of big divergent control structures". You wrote that the CPU version needed about 98% processing time. What's the ratio of the (partially) GPU version? And how long does prereq_stuff run in comparison to do_work on_gpu. I am not sure if there is a good general answer and this question might be better asked on Code Review. — Shadowjust now
I'm voting to close this question as off-topic because Stackoverflow is not the place for questions about code which is working correctly. Please post your question on Code Review instead :) — Michael40 secs ago
@Zeta Correctly parenthesized expressions are not a regular language. Parsing them with regex always involves shenanigans. Most early flavors of Regex have no chance to even do it.
and since the structure is probably defined inductively, a regex cannot be used.
what's necessary is at least a Type 2 grammar, so... EBNF?
I'm a node.js beginner.
At first i thought this was going to be easy, but the asynchronus node.js rly made things difficult for me. Currently my tracker only features one coin and the address is hardcoded.
I plan to put this on a server with a far greater selection of coins and ohter user input. ...
I've written some code in vba for the purpose of scraping names and urls from several links found in the left sided bar in a webpage and populate the data in several sheets in a workbook so that things do not get messy and the data can be located separately. I tried to do the whole thing accurate...
I have written a solution to Memorise me problem on Hacker Earth but it takes a lot of memory space and time limit exceeds in the last test case.
The first line of input will contain N, an integer, which is the total number of numbers shown to your team.
The second line of input contains N spac...
Why do you think this is inefficient? The number of elements you add to your new array is exactly the number of times it must happen... you cannot reduce that. Anyway this question is out of scope for StackOverflow. You could try CodeReview, but I would consider dropping the question all together. — trincot39 secs ago
I asked this question in Stack Overflow but was suggested to come here since the code works and I'm just asking for improvement.
I have this VBA code that works perfectly fine but it's quite slow and I get the impression it could be improved. I'm rather new to VBA and it took me a small while t...
The problem is presented here as follows:
You are given a sequence A[1], A[2], ..., A[N] . ( |A[i]| ≤ 15007 , 1
≤ N ≤ 50000 ). A query is defined as follows: Query(x,y) = Max {
a[i]+a[i+1]+...+a[j] ; x ≤ i ≤ j ≤ y }. Given \$M\$ queries, your program
must output the results of these q...
This is the second pass on this.
pass one
A single player versus a dealer. It does not perform bets - it only track wins and losses and has no splitting. Other than that I tried to get it all in.
I take it most people know Blackjack. Number are the number, face cards are 10, and ace is 1 or 11....
I have the following javascript that switches the different views. All works fine however it is extremely repetitive.
I would like to clean it up to be optimally usable, but not to sure how I would go about it.
Any help with this would be highly appreciated.
Below is my code that i wrote in o...
I have attempted to solve the Boogle game by creating this string checker in Javascript. The instructions are as below:
Write a function that determines whether a string is a valid guess in a Boggle board, as per the rules of Boggle. A Boggle board is a 2D array of individual characters, e.g.:
...
I have written a Fortran95 function that will be called many times in a loop. A much reduced version of it, called myFunction, is below. Examples of its use is the fitting of data points to this function, or numerical integration of this function. This function is part of a small module myFunc...
I have a c++ dll I am calling (PInvoking) from C# which corrects barrel and pincushion distortion. Basically I call a method which generates a set of look up arrays and I adjust the pixels of the input image accordingly. However this is causing some serious performance issues with 50% of my appli...
I spent the better part of the last two days getting this to work, but it finally is working, but it feels extremely redundant.
I am following a belongs_to method for a table called 'authorizations' - I want a user to be able to sign up via Email, or any Omniauth channel I implement that has an ...
@ThunderFrame I just wanted to show the error and how to overcome it. As to making it better, meh... I will leave that to you guys who frequent CodeReview. :) — Scott Craner38 secs ago
Sorry, but to clarify - does this work, just take lots of time? If so, you may want to ask this over at CodeReview instead. — BruceWayne17 secs ago
"Making things faster" is not the greatest question in the world here, since it's likely to only apply to your code and not be helpful to others. If you want a review of your entire code, and provide example data, this might be okay on Code Review, but read their help center before asking. — Mike McCaughan56 secs ago
I have been writing this code for a few weeks now and it used to work, it took 2 hours to compile through the 49 worksheets I am comparing but for some reason it now just says not responding. I really want to try switching to use arrays so that if I can get it to work again it will go a lot faste...
I'm refreshening my c++ by working thru different problems and I decided to attempt a solution to the 24 Game. Basically given 4 numbers, try to use the operators +, -, *, /, ^ to reach 24. However, for my solution I wanted to use a generic target number, operators, and number of input.
The spe...
For educational purposes, I wrote the a selection algorithm based on a Merge sort. I would like to improve performance.
public static IEnumerable<T> MergeSort<T>(List<T> list, int left, int right, Comparer<T> comparer)
{
if (left == right)
{
yield return list[left];
yield...
I just started learning C++, and I'm taking an algorithms course on MIT Open Course Ware to get a better understanding of basic CS and the best practices in C++. Any comments on the structure of the algorithm (optimizations, etc) or best practices in C++ would be greatly appreciated!
#include <i...
I'm voting to close this question as off-topic because this is working code that needs a review. Thus it should go to codereview.stackexchange.com — HimBromBeere52 secs ago
I'm voting to close this question as off-topic because this is working code that needs a review. Thus it should go to codereview.stackexchange.com — Yahya37 secs ago
I'm attempting to write an implementation of a red-black tree for my own learning and I've been staring at this for a few days now.
I believe I'm implementing the Left-Left and Right-Right cases correctly. I'm just having trouble with the Left-Right or Right-Left cases where two rotations are r...
Here is the link to the assignment: http://web.cerritos.edu/pnguyen/SitePages/cis180/labs/cis180lab03sum17.htm
Is there extra code I could have avoided using? Currently learning c++ so i am limited to my resources, but i do feel like i gave myself extra work. If there are any tips so i can be a ...
My apologies for a "repost", my original post was only partial and confusing. Here is a better snippet. This runs fairly slow cycling through 20 workbooks or so. Any suggestions for improvement would be appreciated; I have left out my dimming of variables at the beginning, as well as my error han...
I am writing a JavaScript calculator as a Freecodecamp frontend project. Here are mine .html and .js files. Your help or advices are welcome. Task objective: Build a CodePen.io app that is functionally similar to this.
Fulfill the below user stories. Use whichever libraries or APIs you need. Giv...
Could someone please check my query and the table structures and let me know if there is any way to improve it.
I would like some tips for my own personal development
Query in PHP:
// Load all records so can be displayed in list
function load_all($page = NULL, $chat_type = NULL){
if(!$pag...
I have been working on a Spring boot microservices application, and I want to get your reviews on both classes below.
Is there a shorter, more readable way to implement both of them?
Is there a more more efficient way to do it without ModelAndView?
Download the project
class ModelAndView
...
My current IRepository implemention uses a single db context. It's simple and yet effective and has worked great for the past year. Now new requirements have been introduced that require another dbcontext in addition to the primary dbcontext.
Here is how the Repo is implemented currently:
IRepo...
This is my first Haskell program, a command-line sdl-based(so, hopefully, cross-platform), parameter-less sound recorder. Tutorials, articles or chapters that concern mistakes in my code are just as welcome as concrete code corrections.
{-# OPTIONS_GHC -Wall #-}
-- Dependant on cabal packages:...
You are to ask the user to put in a hexadecimal number to be converted to binary
and then the program out put should give a simple run as
put in a number :
22A
The binary form is :
.......
"How do I implement X" questions are not a good fit for Stackoverflow. It's far too broad of a question for anyone to be able to give you a comprehensive answer. I suggest you have a go at writing something yourself. If it doesn't work, post it and we'll try to identify how to fix it. If it does work but isn't well-structured, post it on Code Review and they'll help you to refactor it. — Michael14 secs ago
Is there a way to improve the Javascript that I wrote in this code? I made a dropdown box that toggles between showing and hiding the textbox. I then realize that the Jquery/Javscript code I was writing began to repeat itself.
Just want to know if there is a way to simplify the Javascript/JQuery...
Urgh, I just spent a while typing up a review the diff comparison one and the user deleted it after getting downvotes
It wasn't even down-vote worthy which sucks, that's another user which won't benefit from code review now and will go back to writing poor (but not awful) code.
// I dedicate all this code, all my work, to my wife, Darlene, who will // have to support me and our three children and the dog once it gets // released into the public.
I'm writing some code which needs to be compatible accross a Cortex-M based embedded device and x86 / x86_64 based PCs. I needed a solution for sending binary data between the Cortex-M and the computers. Formerly I was using GCC-specific packed structs for this, but then I realized that it's not ...
Your RAII wrappers are not designed very well. If the code basically works now, I suggest taking it over to codereview.stackexchange.com to get better advise. For instance, always initialize the handle members to zero. Also, if you have RAII wrappers, it cries for error handling via exceptions instead of "C-style" error return values. — zett4233 secs ago
You are given two arrays A and B containing elements each. Choose a pair of elements (x,y) such that:
x belongs to array A .
y belongs to array B.
gcd(x,y) is the maximum of all pairs (x,y) .
if there is more than one such pair (x,y) having maximum gcd, then choose the one with maximum sum...
I've lately been asked in a job interview to program a solution for the well known anagrams problem: given two strings s1 and s2, decide if they are anagrams or not.
Additionally the characters should be one of [a-zA-Z] and case-insensitive, so AbA and Baa should be valid anagrams.
As a side-...
I have been working on a simple game in c++. the game consists of a die and several player it can be 1,2,3 or 4 players and each of them can has 4 bolts(pegs).
I have been working on a simple game in c++. the game consists of a die and several player it can be 1,2,3 or 4 players and each of them...
Concerning your problem: Read the basic tutorials. This is standard stuff. If you get a direct answer in here, this means only that you will fail at the next task. Read the basic tutorials. That said, I'd recommend you to put your code on CodeReview. There are several issues. Variable names starting with capital letters, public members, parameters not being declared const, just to name a few. — Aziuth20 secs ago
Is it acceptable? Well that really depends on how you look at the issue.
First thing first: passwords are supposed to be secret. This means other people should not have access to your password, and should not be able to see it, blah blah blah. (This has been covered by the other answers for th...
@chux I was not aware of codereview.stackexchange . I might try there. Just to clarify I am not looking for just an working solution or ready-to-compile code. Any suggestions or hints on how to handle the operations more efficiently but maintaining the readability will be of much help. Thank you. — avikpram39 secs ago
I am very new to python and I am just learning things from tutorials online and code snippets.
My code is below, it works in that it scrapes the data I want but I think I could make the code much more efficient.
Code:
import requests
import time
import csv
import sys
from bs4 import Beautifu...
Problem :
A zero-indexed array A consisting of N different integers is given.
The array contains all integers in the range [0..N−1]. Sets S[K] for 0
≤ K < N are defined as follows:
S[K] = { A[K], A[A[K]], A[A[A[K]]], ... }.
Sets S[K] are finite for each K.
Write a function ...
I have a large array (around 1 MB) of type unsigned char (i.e. uint8_t). I know that the bytes in it can have only one of 5 values (i.e. 0, 1, 2, 3, 4). Moreover we do not need to preserve '3's from the input, they can be safely lost when we encode/decode.
So I guessed bit packing would be the s...
@TonyTannous As is, the post does not meet codereview's standards, yet only needs some additional wrapping code and a few other things to meet that sites standard's - accessible here — chux50 secs ago
I am new to android developmend and this is my first app. So I tried to modify HomeStartFragment.java file and added some new ad networks following their documentation. However, I'm getting lots of errors in Android studio. The majority of errors are the same: error: illegal start of expression,...
This answer would be much better if there were some kind of explanation of what's going on. I can't help thinking it's far more complicated than it needs to be; and I have serious doubts about whether it covers all the cases that it needs to. If code like this were submitted to me for code review, I would reject it immediately. — Dawood ibn Kareem45 secs ago
No. "It works" isn't good enough for professional software development. Code needs to be testable, readable and maintainable. Otherwise, we wouldn't bother with code review - we'd just do system testing. — Dawood ibn Kareem36 secs ago
@skypjack, actually we do have code review stack :) — CroCo41 secs ago
This is used to round to any desired quarter, half etc.
Is there any improvements that can be made for performance, unforeseen roundoff issues etc...?
//Equals 1.0
var test = RoundNearest(1.0000002, .5);
//Equals 1.5
var test2 = RoundNearest(1.3, .5);
//Equals 1.0
var te...
Just for fun, I tested your code. It allows a whole lot of characters other than Arabic ones. For example, with the input "مرحبا كيفك i'm fine and you كله تمام . كم عمرك . I like Ćevapčići" it gives the output "مرحبا كيفك كله تمام كم عمرك Ćčć". I don't think that's what OP wanted. It's cases like this that testing doesn't always uncover, which is why code review is so important. — Dawood ibn Kareem37 secs ago