instruction_seed stringlengths 71 95.1k | _source stringclasses 1
value |
|---|---|
I created an Excel AddIn that has a function called SLOOKUP which can replace INDEX MATCH combinations in an easy and smart way. For more info please visit my blog post. I would like you to optimize this further if possible.
Function SLOOKUP(database As Range, lookupCol As Range)
' Description: Excel UDF that implemen... | stackexchange/codereview |
This is a Sudoku solver program which uses backtracking. It is a problem from Online Judge and I made it work after some struggle, but it needs to be faster as I'm getting a Time Limit Exceeded message.
The input format:
.46...9..
.3.1.....
.2..6..85
...87....
6...3...4
....14...
79..5..3.
.....2.4.
..2...61.
And then... | stackexchange/codereview |
Code dump:
function factor(n) {
function count(a) {
if (a.length == 0) {
return [];
} else {
var x = a.pop();
var l = count(a);
if (l[x] == undefined) {
l[x] = 0;
}
l[x]++;
return l;
}
}
... | stackexchange/codereview |
I have to extract all elements of array with the given list of coordinates and insert into 2*298808 as position given in while loop
How can I compress the code even more?
def arr_func(arr,selected_pixels_list):
rows = 2
m = 0
n = 0
i =0
#Calculate the number of pixels selec... | stackexchange/codereview |
My job required me to learn jQuery the last couple of weeks, but it's a mess and I do not know how to structure my code in an acceptable manner. I come from a Java and PHP background and have never touched JavaScript before.
I've searched the web for some guidelines, but I could not find anything of real value.
functio... | stackexchange/codereview |
I am new to ASP.NET (C#) and MVC 5. I'm really enjoying it so far, but want to take a step back and make sure that I'm following best practices here. My controller seems like it may be getting too fat, but perhaps that's just part of it?
This is the Index action for the TicketsController in a support ticket application... | stackexchange/codereview |
I wanted to use an async-cache to store URLs of images that I have to display in a list. The image URL is fetched (REST call) using a unique UUID associated with each item of the list. I store this URL locally and then use it to show images in the future.
I came up with the following async-cache to make my life easier.... | stackexchange/codereview |
Given a balanced parentheses string s, return the score of the string.
The score of a balanced parentheses string is based on the following rule:
- "()" has score 1.
- AB has score A + B, where A and B are balanced parentheses strings.
- (A) has score 2 * A, where A is a balanced parentheses string.
Based on the Pyth... | stackexchange/codereview |
I am having a game with a lot of GameBodyObjects and some of them are moving, some of them are not. When I calculate A* for the moving objects it gets really slow when all the objects are present. If there is just a Player then the A* is fast.
Here is my Game update loop:
public Game update(float dt) {
if(isStarte... | stackexchange/codereview |
I am trying to concatenate the echo statements but I am failing. Also any other tips are appreciated in your review.
<?php
// load all 'category' terms for the post
$terms = get_the_terms($post->ID, 'category');
// we will use the first term to load ACF data from
if( !empty($terms) )
{
$term = array_pop($terms);
... | stackexchange/codereview |
I'm actually spending time on it, unlike the first time and going through, understanding and implementing the several suggestions I've landed on two different approaches.
Approach 1: Employing Java 8 Lambdas and stream functions made to be the equivalent of David Zheng's answer in Python.
import java.util.ArrayList;
p... | stackexchange/codereview |
I have been playing around with OpenGL and created a fairly basic 2D animation was just hoping someone could take a look and give me some pointers.
Main.cpp:
#include "glut.h"
#include <math.h>
#include <stdio.h>
int bc = 0.4; //building color
int frame=0;
class points{
public:
float x, y;
};
points startLine[2... | stackexchange/codereview |
I am a moderately new Scala developer working mostly by myself, so I don't have anyone to tell me what I'm doing wrong (except that the system mostly does work, so it can't be too awful). I would appreciate some feedback on how to make better use of Scala as well as any comments about obvious performance issues.
The cl... | stackexchange/codereview |
I am writing library code to help other developers send messages to a pub-sub event broker.
In many cases, the message source will not be "stream-like". Specifically, most messages are coming from SQL Server change data capture, and are therefore much more efficiently read in sets (batches).
Additionally, in most cases... | stackexchange/codereview |
I am creating a GUI program using Tkinter wherein I utilise the Feedparser module.
My code executes in the following way:
Get the stock ticker to insert into the URL from the user.
Parse the URL and append key data to a text file.
Read the file and output it to a message box.
At the moment, the order that the items are... | stackexchange/codereview |
I want to create a network in which the links are formed based on a similarity metric defined as the Euclidean distance between the nodes. The distance is calculated using socio-demographic features of customers such as gender and age. The problem is the code takes 200 seconds to just create the network and as I am tun... | stackexchange/codereview |
I have slightly refactored the Delayed, concurrent event stack in Java. Now it looks like this:
DelayedEventStack.java
package com.github.coderodde.cconcurrent.eventstack;
import java.util.Deque;
import java.util.Objects;
import java.util.concurrent.ConcurrentLinkedDeque;
/**
* This class implements an delayed event... | stackexchange/codereview |
I have a function to handle image uploads. Originally, it contained a goto:
restartA:
$name = $this->random_name() . $ext;
if(file_exists($this->img_path . $name)){
unset($name);
goto restartA;
}
It seems pretty clear to me what the code does, and I think anyone who reads it would immediately understand what... | stackexchange/codereview |
I want to solve for n in the expression (binomial coefficient):
\$y=\frac{n^2+n}2\$
let y = (Math.pow(n, 2) + n) / 2;
I know the \$y\$ value, but I want to compute \$n\$.
Here is what I have so far, but I would want to know if there was a way to compute the value rather than look it up. In this example, I have to loo... | stackexchange/codereview |
We have a Spring Boot parser application, that supports a bunch of formats.
We need to divide this Parser application into several types. Each such type is simply defined by the set of formats supported.
A Provider sends a Message in its own format, which is described in an XML Schema.
Example:
Schema:
<Message forma... | stackexchange/codereview |
I have a small Python application that needs to load a few different files (templates and config files). It should look in a number of destinations, in the following order, and load the file from the first destination that contains such a file.
current working directory
$MYAPP_PATH (may contain several paths,separated... | stackexchange/codereview |
I have a hierarchy of of groups, and I want to get a collection of all the lowest level groups (or leaves if we'll look at this as a tree).
I wrote the following code. Is it inefficient?
public static class FeatureWeightGroupExtensions
{
public static IEnumerable<IFeatureWeightGroup> GetLeafGroups(this IFeatureWeig... | stackexchange/codereview |
I'm attempting to scrape data.cdc.gov for their COVID-19 information on cases and deaths.
The problem that I'm having is that the code seems to be very inefficient. It takes an extremely long time for the code to work. For some reason the CDC's XML file doesn't work at all, and the API is incomplete. I need all of the ... | stackexchange/codereview |
I am still in the process of learning modern C++, and decided to write this dummy program for actually benchmarking copy semantics vs. move semantics:
#include <chrono>
#include <iostream>
#include <cstdint>
using std::cout;
using std::endl;
class List {
public:
void push_back();
List() : sz{0}, head{nullptr}... | stackexchange/codereview |
Common Lisp does not have a generic copy function for reasons outlined in Kent Pitman's article The Best of Intentions. However, it may still be convenient for rapid prototyping purposes to provide such a function that would recursively copy any given lisp object down to its immutable core objects. In the initial stage... | stackexchange/codereview |
I'm currently working in a Windows.Forms project where its very common that I need to show a responsive feedback form while a task runs. These tasks take typically around 5 to 10 seconds to complete and the user can't do anything else until the task has successfully finished or failed.
To keep the UI responsive I've co... | stackexchange/codereview |
I would like to use the following routine in my submission script for GAMESS calculations. I am not entirely sure if this is the optimum way to go.
This function would need one of the messaging routines, message, to function properly, but I decided to put echo in front of it, since this is basically what it does any wa... | stackexchange/codereview |
I've written a variety of libraries that query and work with data from APIs. While the classes and objects being passed around vary from project to project, I'm generating GET requests in the same manner in each project.
I have a basic method to generate a GET request:
private string GenerateWebRequest(string conn)
{
... | stackexchange/codereview |
What i have so far is a nice and rapid algorithm for finding the pixel dominant from bmp image.
I am not sure how to make it to work.. i though it works, but the program freezes.
RGB
bitfox_get_primecolor_direct
(char *FILE_NAME)
{
RGB primecolor;
BYTE rgb[3];
dword *counts = calloc(pow(256, 3), sizeof(*co... | stackexchange/codereview |
I just submitted this code to solve the "When to take medicine" challenge on CodeChef:
#include <iostream>
#include <string>
#include <sstream>
int countDays(int dd, int subtract)
{
return ((subtract - dd) / 2) + 1;
}
int main()
{
int t {0};
std::cin >> t;
std::cin.ignore();
while (t--)
{
... | stackexchange/codereview |
I need to clean up and simplify this code (I am a beginner in Python):
print ("Type in four inputs.")
word_first = raw_input("What is your first input? ")
word_second = raw_input("What is your second input? ")
word_third = raw_input("What is your third input? ")
word_fourth = raw_input("What is your fourth input? "... | stackexchange/codereview |
The original question where the general concept of this implementation was discussed: Using ID's with a "scope" -like hierarchy
I have designed a resource manager as part of a game programming project that I have been working on as a hobby. Implementing as much functionality as possible in the least amount of time and ... | stackexchange/codereview |
See the next iteration.
I designed and implemented this adaptive heap sort in Java. It works as follows:
Copy the range to be sorted into auxiliary array \$A\$
Create an empty run heap \$H\$
Scan \$A\$ from beginning to the end and whenever we have counted a longest possible run (a run is a longest ascending or descen... | stackexchange/codereview |
I'm trying to study network diffusion. I took the code form this. However, I would like to see if there's any potential to optimize the code to be faster and clearer. This is what I'm trying to do.
In a node, get all the successors and loop through to get the property in an edge to see if the probability is more than ... | stackexchange/codereview |
For my application, I was using array_diff_assoc, when I noticed it was returning the wrong value. I was using multidimensional arrays, therefore I needed a array_diff_assoc_recursive method.
I Googled around and found a few, but they all only took 2 parameters. The official array_diff_assoc can take an infinite numb... | stackexchange/codereview |
What I want is to extract min/max range of salary from a text which contains either hourly or annual salary.
import re
# either of the following inputs should work
input1 = "$80,000 - $90,000 per annum"
input2 = "$20 - $24.99 per hour"
salary_text = re.findall("[\$0-9,\. ]*-[\$0-9,\. ]*", input1)
if salary_text and ... | stackexchange/codereview |
I am designing an in-depth poker game. I am first focusing on recognizing the strength of a hand given the set of cards.
Is the following algorithm suitable for the stated purpose?
Am I using correct OOP design principles and implementation in my code?
Algorithm:
Go from a top down approach checking for the following... | stackexchange/codereview |
This code below is for one of my scripts that I am trying to automate. I am dealing with the rows and all the data that is in those rows. What I am trying to do is make this look neater and maybe adding some different variables to make it look decent.
Foreach ($row in $csv) {
If ($row.Type0 -eq 'Domain') {
$row."Uni... | stackexchange/codereview |
This is my first shot at implementing a fully static version of the Observer pattern in C++11. It is static in that all notifications are dispatched via CRTP, and therefore there is no virtual overhead. It also has the benefit of catching unimplemented notifications at compile time, by checking available overloads ba... | stackexchange/codereview |
I've been working on this elevator program for quite some time now and finally finished it and made it work and I'm pretty proud of myself, but I'd like to see ways how to optimize my code so I can learn for the future. By optimizing, I mean making the code look better, maybe by using fewer lines of code.
import java.a... | stackexchange/codereview |
I've two working ways to do so, but which one should I use?
Common part: var textarea = document.getElementById("textarea");
First way:
function updateStatusBar() {
var text = textarea.value;
statusBar.value = "Words: " + (text ? text.match(/\b\S+\b/g).length : "0") +
" Characters: " + text.replace(/\s/g... | stackexchange/codereview |
I got this HW question from my freshman year at college - "Create a python function to check whether a string containing only lowercase letters has any repetition in it".
So, I did it a few ways:
Brute forced it by checking if a character in the string was present in the substring to the right of it using a nested for... | stackexchange/codereview |
A rags-to-riches of A method to capitalize the first letter of all words in a String.
To recap the requirements:
Please implement this method to capitalize all first letters of the words in the given String. All other symbols shall remain intact. If a word starts not with a letter, it shall remain intact too. Assume t... | stackexchange/codereview |
I wrote a Pomodoro timer daemon for BSD systems in C (may work on Linux with -lbsd).
The server uses poll(2) and sockets to communicate with the client and to implement the timer.
The client starts or stops the timer and gets information about it.
For example, in a terminal run $ pomod (the server).
In another, run $ p... | stackexchange/codereview |
I wrote the code and would like to change it to more readable and elegant:
@Repository
public class ProductRepositoryImpl implements ProductCustomRepository {
private static final int MORE_THEN_RESULT = 1;
@PersistenceContext
private EntityManager em;
public List<Product> findByFilter(Filter filter) {
final Crit... | stackexchange/codereview |
I have this code block, where I search for the value of Ordnungsbegriff. I have to search through a tree of my CurrentDocument.
How can I rewrite it to be more dynamic? I don't know at which level I will find my value.
string xy = "";
try
{
if (string.IsNullOrEmpty(CurrentDocument.Ordnungsbegriff))
{
... | stackexchange/codereview |
In a former question on SO I described a problem with a construct called 'EnumBase'.
As I sad there, I am not involved when basic implementation happened. So I'm not sure why the thinks are a they are. I only know that the code was written in times of .Net 2 and 3.5. The derived classes are useed as DataSources in ASP.... | stackexchange/codereview |
I have this function that gets an item passed from another function, together with the subtotal and the fee of the item. The function has to act as fast as possible, as other people also want the item. However, the function seems to take a very long time, and almost never ends up buying the actual item because it was t... | stackexchange/codereview |
I have written this code for checking whether all leaves are in the same level or not, in a binary tree. Any suggestion or improvement is appreciated.
import java.util.LinkedList;
import java.util.Queue;
public class Methods {
//* ---- Method for check whether all leaves are in the same level or not --- * ... | stackexchange/codereview |
Project Euler Problem 23
A perfect number is a number for which the sum of its proper divisors is exactly equal to the number. For example, the sum of the proper divisors of \$28\$ would be \$1 + 2 + 4 + 7 + 14 = 28\$, which means that \$28\$ is a perfect number.
A number \$n\$ is called deficient if the sum of its pr... | stackexchange/codereview |
The code follows the requested format of the output exactly for my assignment. But, for my own personal reference, is there a better way that I could have done anything? Are there any additional tips? Maybe some simple ways that I could gold plate against exceptions or errors? I know how try, catch and throw exceptions... | stackexchange/codereview |
This is a HackerEarth Challenge Problem.
Question:
Puchi hates to carry luggage, but unfortunately he got a job to carry
the luggage of his N friends in office. Each day, one of his N
friends, gives him the luggage of a particular weight to carry. You
will be given the weight of luggage of each friend in the a... | stackexchange/codereview |
The following code fetches a set of company IDs from a database if there are any events associated with a company that has a missing property. Because the set of company IDs is embedded into the SQL query using parameters, and the number of parameters may exceed the maximum for the RDBMS / database driver, the set is p... | stackexchange/codereview |
This code reaches time limit on 1 test case, solving this challenge. The approach that I'm using is from the book Algorithms Functional Programming Approach, which is a backtracking depth searching method. How do I improve speed of this code? Or is there better way to do it?
searchDfs :: (Eq node) =>
(node... | stackexchange/codereview |
extern crate serde;
use serde::{Deserialize, Serialize};
use serde_json::json;
use std::error::Error;
use std::fs::File;
use std::io::prelude::*;
use std::io::{BufReader};
use std::time::Duration;
const NER_SERVER: &'static str = "http://127.0.0.1:5000/parse";
#[derive(Serialize, Deserialize)]
struct Article {
... | stackexchange/codereview |
As part of an job interview process, I was tasked to write a solver for a simplified Tetris game using JavaScript. The game board size is 4x4 and there are 4 different pieces given in a .txt file. It is not allowed to rotate the pieces, so they should be placed exactly as they are specified in the file. Following norma... | stackexchange/codereview |
Here I am parsing a JSON array and inserting it into a MySQL database. The JSON Array comes from my android code.
This is how my JSON array looks like:
["{custInfo=Ujwal 9975022560, rate=24000, weight=21.00000, desc=GENTS ANGTHI 22k NO STONE, makingAmt=200, vat=RS.3064.38, itemTotal=51073, sum_total=RS.156283.38, barc... | stackexchange/codereview |
Wondering if I can get a review of the following script.
I used to be a Python dev back when 2.7 was the norm and haven't really touched Python3, so interested to see where some new features might tidy things up. And obviously any improvements / direction on general style.
The script consumes an API that provides data ... | stackexchange/codereview |
This will compile, but I'm thinking that this implementation of read/write is very hard coded and would not be easily adapted to larger situations where large XML documents are being processed or if they are in a different format structure.
using System;
using System.Collections.Generic;
using System.Linq;
using Syste... | stackexchange/codereview |
I recently posted my old .NET MSSQL Wrapper to be code reviewed: .NET MSSQL Wrapper
I had some good feedback and based on that, I was able to re-factor it quite a bit and ended up with the following version: http://pastebin.com/Yhd6RTeS
The above wrapper library is used like this:
Program.cs test console app
using Syst... | stackexchange/codereview |
Yesterday I wrote a serialization/deserialization for my B-Tree library.
Since the code for whole tree is too large to upload here, I'll upload only serialization/deserialization and node class definition/tree class member variable parts here.
I think my code is not broken, but I want to know how to do error checks bet... | stackexchange/codereview |
I am interested in hearing your opinion on the approach I have taken to have inherited classes initialize their base class.
Here's a Machines collection class from that maintains a list of Machine objects. Each Machine needs to be able to inform its parent, using a delegate, of something they do but they do not have a ... | stackexchange/codereview |
I have a PHP function which sets/unsets something (category and tags) in the cookie and then makes a dynamic query based on it:
public function tagged(){
$this->specific_tag = true;
function unset_cookie($cookie_name) {
setcookie($cookie_name, "", time() - 3600, '/');
unset($_COOKIE[$cookie_... | stackexchange/codereview |
I have a considerably large directive which is doing many things: First it renders a Google Map, then it adds a listener to check when the bounds of the map change, then it renders points on the map based where the bounds currently are, and finally it has a menu of options which allow the user to turn on and off variou... | stackexchange/codereview |
Challenge
Conceal a binary code within a word.
Specifications
The first argument is a path to a file.
The file contains multiple lines.
Each line is a test case represented by a space separated word and a binary code.
For each test case, print the binary masked word.
The mask alters the word according to the following... | stackexchange/codereview |
I have attempted to implement a "fast Pimpl" idiom based on the talk slides and further sources, which is essentially an aligned storage of some size that can be used as a drop-in replacement for std::unique_ptr when implementing the Pimpl idiom:
// ...
private:
// std::unique_ptr<Impl> pimpl_; // allocation and poin... | stackexchange/codereview |
I have the following type of many functions so many if condtions are there is there is any way to reduce no. of lines.
enter: function(request, callback, callback1){
request.on={};
if(callback==undefined && NodeClientUI.initdata.join!=undefined){
callback=NodeClientUI.initdata.join;
request.on.join=... | stackexchange/codereview |
I have made some simple functions to find the first SO chat message. How can I improve my code?
Even if there is a stackoverflow link that will get the job done (I'd be glad to know), I'd like to improve upon my already written code.
import Network.HTTP
import Text.Regex.Posix
type UserID = String
type MessageLi... | stackexchange/codereview |
I have list of tuples like so:
lst = [(106, 210, 108, 134, 134),
(106, 210, 108, 134, 210),
(106, 210, 108, 168, 268),
(106, 210, 108, 168, 671),
...]
I need to only keep the tuples that contain:
keep = (106, 210, 108, 168)
Which I am currently doing using this statement:
kept = [item for ... | stackexchange/codereview |
I'm working on this code for exam in an MIT Python course. It's working but I'm trying to improve it. What could I do, and what should I avoid?
aDict = { 0: 1,
1: 2,
2: 2,
4: 2,
5: 2,
6: 3,
7: 2}
values=list(aDict.values())
keys=list(aDict.keys())
value_copy=values[:]
uniqe=... | stackexchange/codereview |
The following is a small snippet from a pretty large program written to analyze raw data and find specific trade structures. I am new to VBA and this is my first large scale program I have written in the language.
I definitely did things unconventionally and I wanted to ask for some review and pointers how to improve m... | stackexchange/codereview |
This is my game manager script and is there anyway i can improve this code.
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine.SceneManagement;
public class GameManager : Singleton<GameManager>
{
public Game game=new Game();
public PendingGam... | stackexchange/codereview |
I have the following code:
for j in range(rows):
for i in range(cols):
k = j * rows + i
k1 = k + 1 if i < cols - 1 else k - 1
k2 = k - 1 if i > 0 else k + 1
k3 = k + cols if j < rows - 1 else k - cols
k4 = k - cols if j > 0 else k + cols
w1 = U[k]
w2 = U[k-... | stackexchange/codereview |
I am working on an arbitrary math lib. Below is a class I use to handle the binary mathematics needed for the library.
The class is quite simple. All it does is wrap around a vector of any unsigned integral type designated. Which in turn support binary operations on individual bits, or whole register words. Basic b... | stackexchange/codereview |
I have solved Leetcode climbing-stairs problem which is stated as:
There are n stairs, a person standing at the bottom wants to reach the
top. The person can climb either 1 stair or 2 stairs at a time. Count
the number of ways, the person can reach the top.
I used dynamic programming to solve this like below:
cla... | stackexchange/codereview |
I've been playing around with functional programming for a while now and just started learning Clojure. So the problem I'm trying to solve is the following:
I have a tree-like hashmap of tasks where each task can include a number of tasks and each of those can include other tasks. The toy one I'm using for starters loo... | stackexchange/codereview |
A little bit of background; I'm a high school student in my junior year and I attended a tech competition last year when I enrolled in my high school's CS I course. Below is what I submitted to the competition and even though I won in my category, I remember the judges telling me that I could do better by implementing ... | stackexchange/codereview |
I have a problem set which requires me to print all the multiples of a number in given range in reverse order.
So far I have tried this but not sure it is optimized or not!
#import <objc/objc.h>
#import <objc/Object.h>
@implementation TestObj
int main()
{
int limit = 0;
int divisor = 5;
printf("enter a nu... | stackexchange/codereview |
The output result is perfect to what I wanted, but takes a tad bit too long to pull data then render into a graph. Is there a better way to rewrite this code to speed up the process?
CASE "TestGrid":
$SnapArrayResult = array();
$PlayArrayResult = array('A','B','C','D');
echo "<table id='tb' style='width:20... | stackexchange/codereview |
I'm trying to implement a Timer that schedule an async action with the following requirements:
thread safe
only one action should be running at any given time (period countdown should start when the previous action has been terminated)
the action should be cancellable
Here's the code, can you please review it and po... | stackexchange/codereview |
I'm trying to write a program that will check if a window is opened or not, during a given time. I was able to do that, but now I'm trying to make my code look cleaner. I don't like how I implement the way I handle all possible error cases. Here is my current code:
int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
_I... | stackexchange/codereview |
I have a method that finds 3 numbers in an array that add up to a desired number.
public static void threeSum(int[] arr, int sum) {
quicksort(arr, 0, arr.length - 1);
for (int i = 0; i < arr.length - 2; i++) {
for (int j = 1; j < arr.length - 1; j++) {
for (int k = arr.length - 1; k > j; k--... | stackexchange/codereview |
I have created one generic Page class for store paging information with its data.
The class look like:
public class Page<T>
where T : new()
{
private List<T> _list = new List<T>();
[JsonProperty(PropertyName = "total_count")]
public long TotalCount { get; set; }
[JsonProperty(PropertyName = "pag... | stackexchange/codereview |
I've created the following SEDE query which calculates the reputation averages of users on a particular site. It also optionally excludes "new" users (users with rep of 1 or 101 so note 100% accurate).
DECLARE @exclude_new_users INT
SET @exclude_new_users = ##ExcludeNewUsers:int?0##
DECLARE @excluded_rep_table TABLE (... | stackexchange/codereview |
Just looking for opinions on which is the best way to use exceptions?
Should the exception handling go inside the function or should it go outside the function when you actually call the function. For example, we could have the following function:
def divideMe(a,b):
return a/b
This function is risky because ther... | stackexchange/codereview |
I have been trying to write a sample code block to read file contents into a buffer.
I am assuming that:
Code must be platform independent
Should work in all cases(or report proper error)
It should be readable and maintainable
It shouldn't be over-complex and shouldn't have errors
Do you think the return of fseek sho... | stackexchange/codereview |
Given an array, return True if the array contains consecutive values:
has22([1, 2, 2]) - True
has22([1, 2, 1, 2]) -False
has22([2, 1, 2]) - False
I do aware of a quick solution by iterating the list in a for loop and comparing current and next items for equality until it reaches the end, also using modules like ... | stackexchange/codereview |
I am attempting to implement a GetNeighborhood function in order to get a specific region from inputCells by sizeInput and centralLocation parameters in 3D cells structure.
The experimental implementation
The experimental implementation of GetNeighborhood function is as below.
function [output] = GetNeighborhood(inputC... | stackexchange/codereview |
There is a need to authorize the Users based on their Roles, particularly a set of roles that should allow all GET operations and a second set that should allow all POST operations.
Eg:
All Get methods should be accessible to the reader
Post method access is granted to contributors
I don't want to mark the individual... | stackexchange/codereview |
The idea is exploratory data analysis, the output rendered as a histogram to get an idea of relative frequency of records:
The example data set looks like this:
{"blockNumber":"1941895","blockHash":"0x53464299a83cecc3e4d930b617c9518b8f74139265423d8110a919f5180bec79","hash":"0x0abe75e40a954d4d355e25e4498f3580e7d02976... | stackexchange/codereview |
here I am taking 3 inputs. 1st input will take test cases and the other two input will take starting and ending range. the program is running fine as expected but the limit of this question for compilation is 1 sec, and my code is taking 5.01 sec.
How can I make it more efficient so that I can submit the code?
The cha... | stackexchange/codereview |
I am using a std::priority_queue to implement Dijkstra's algorithm:
while(!Q.empty())
{
u = Q.top().first;
Q.pop();
int size=G[u].size();
for(int i=0; i<size; i++)//tle
{
v = G[u][i].first;
w = G[u][i].second;
//cout<<u<<" "<<v<<" "<<w<<endl;
if(d[v] > d[u] + w)
... | stackexchange/codereview |
I decided to write a small script to make writing HTML interactive stories less tedious:
import doctest
import re
import sys
import tkinter
import tkinter.filedialog
HTML_START = """<!DOCTYPE html>
<html lang="en">
<div align="center">
<head>
<title>{}</title>
<h1>{}</h1>
</head>
<body>
"""
HTML... | stackexchange/codereview |
I have a class in C# that uses a Random object to get a list of numbers randomized from an array of 1-25. Now what I need is improve this method to use RNGCryptoServiceProvider because it is not random enough for the application.
I know that RNGCryptoServiceProvider is slower than Random, but I need to change it and I ... | stackexchange/codereview |
The Game
Go or weiqi is an amazingly simple yet complex board game. This game is typically played on a 19x19 grid, and pieces are played on the intersections of lines. Pieces are removed when they are surrounded by opposing stones on all orthogonally adjacent points, in which case the stone or group is captured and rem... | stackexchange/codereview |
I have just finished coding this class that will load all columns in a MySQL database in to a cached Dictionary<string, string> which will only be modified on class construction when its populated with the correct data.
I wanted to ask the codereview community their opinions on it, if its a good idea, what are the down... | stackexchange/codereview |
I am fully aware that Qt is quite good with handling ownership in its object trees. The usual pattern seems to be to use a raw new, assigning the result to a raw pointer and then giving up the ownership with some widget->add(...) call.
This does not seem C++11/C++14, or modern, or RAII-style to me -- especially not in... | stackexchange/codereview |
I am a beginner in FPGAs, and I am studying Verilog HDL. Could you please check the quality of my code (a shift register)? Any comments are welcome.
The shift register serializes parallel from wr_data_i data to serial_data_o and has two variations of first serialized bit. It may be most significant bit or least signifi... | stackexchange/codereview |
I wrote a function, which takes a list of Integers, and then makes a balanced binary tree.
Please critique it. I'd like to know know how to make it more concise and idiomatic.
-- Note that the Integer represents the height of the Tree
data Tree a = Leaf
| Node Integer (Tree a) a (Tree a)
de... | stackexchange/codereview |
Below is my code for the problem:
ItoR = {
1: 'I',
4: 'IV',
5: 'V',
9: 'IX',
10: 'X',
40: 'XL',
50: 'L',
90: 'XC',
100: 'C',
400: 'CD',
500: 'D',
900: 'CM',
1000: 'M'
}
def convertItoR(number):
number_str = str(number)
number_len = len(number_str)
rom_str = ''
for i in range(number_len):
# Ex... | stackexchange/codereview |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.