instruction_seed stringlengths 71 95.1k | _source stringclasses 1
value |
|---|---|
Just thought I'd share this and see what kind of improvements could be made that I'm not aware of and taking advantage of.
The situation is this: I have a list of items on a page that have a button that opens a menu. I need a click away event as well as close others when a new menu is opened. Also some of the menu acti... | stackexchange/codereview |
I'm a beginner in programming overall, started about a month ago and so I'm still trying to fully grasph the concept of OOP, for instance. Here I used a class for the encryption and decryption processes, but everything else is in functions in the main part of the program (getting the cipher key, user message etc). What... | stackexchange/codereview |
I'm trying to make a sprite cache for SFML sprites. The basic idea I got was to use a map of an enum and a sprite pointer. Then when I would ask for a certain sprite I'd have a manager that would check if the pointer for that sprite is null. If it is, then it would create a new sprite object and clip it to fit what it'... | stackexchange/codereview |
I have done this quiz project and I have tried as hard as I could when I was writing to make it user friendly to read. Could you help me on improving and making it more user friendly please.
import random
import operator
import csv
OPERATIONS = [
(operator.add, "+"),
(operator.mul, "*"),
(operator.sub, "-")
]
NB_QUES... | stackexchange/codereview |
I am relatively new to LINQ queries as I normally just use plain SQL to get my data back but i am changing for the good - Anyway obviously with SQL you pass in parameters so you do not get any SQL injections etc. Now the LINQ query I have written I think is safe but I am thinking it may be able to done a little easier ... | stackexchange/codereview |
I've been using my Dynamic Exception with C# for quite some time already and it saved me a lot of time. This means, I don't have to create a new exception class for each and every case. I wanted to have the same functionality on Android and in kotlin/java so I can do this:
fun main() {
throw dynamicException("My", ... | stackexchange/codereview |
This is related to DataDictionary Application - Model
I haven't done much on the controllers yet, as it's the first time I've written Controller-type classes and wanted some quick feedback on really simple stuff, so these presently just contain various Get methods. If this is ok for a start, I'll begin adding in all th... | stackexchange/codereview |
I'm doing practice interview questions from here. Here is the one I am currently on - if you are given a very large sorted int array, then check of there exists a pair.
public static int sumOfTwoExists(int[] largeArray, int a, int b) {
A: for(int count = 0; count < largeArray.length; count ++) {
for(int cou... | stackexchange/codereview |
I wrote a "gradebook" program. This takes in grades for various assignments. The assignments types are weighted differently and final grade is computed at the end. The code works but I can't help but think I am being ham handed in my approach. Should I be using a dictionary instead of storing things like hw_final, la... | stackexchange/codereview |
Implement a method to perform basic string compression using the counts of
repeated characters. For example, the string aabcccccaaa would become
a2blc5a3. If the "compressed" string would not become smaller than the original string, your method should return the original string.
Can this be implemented in a bette... | stackexchange/codereview |
I am working on yet another toy project that I named SGL (for "Standard Generic Library" since it mimics some features of C++'s STL as well as a few more utilities from the C++ standard library). Since the library is not meant to be used in real code, I decided that I would have fun and tried to implement a setjmp/long... | stackexchange/codereview |
I am practicing interview questions and have written the following
code for the given task.
Task : Given a non-negative number represented as an array of digits, add 1 to the number (increment the number represented by the digits). The digits are stored such that the most significant digit is at the head.
Code:
class ... | stackexchange/codereview |
Basically I want to create a concurrent LinkedHashSet which returns proper size too.
I am mainly concerned about adding and removing iterations. Suggestions relating to implementation of set modification during iteration are also welcomed.
import java.util.Collection;
import java.util.LinkedHashSet;
//TODO still not ... | stackexchange/codereview |
This is a follow-up of my thread in Class SettingView sending messages to a console in C#.
Here is the whole project on GitHub.
The starting point
After attending online courses covering configuration and dependency injection this is my attempt to transfer the knowledge in something I have designed. One of the goals is... | stackexchange/codereview |
I've been trying to learn Python for a bit now. I've taken a few courses, but I've found that I've been going about them wrong and had allowed them to "hold my hand" too much. I'm trying to build projects on my own and thought I would start off small. My third or so project was this Pig Latin translator and I wanted to... | stackexchange/codereview |
I have a need to store data retrieved my ASP.NET Web Api to stop making redundant API calls for the same data when I navigate through my Angular page. On my API I have a database which stores a list of printers known to the PC and stores some basic information about them. Here is the model:
export class Printer
{
... | stackexchange/codereview |
I was unable to find how to get current URL so here's what I've made. Brief tests didn't reveal anything bad. Your thoughts, educated opinions, suggestions, and comment on potential bugs or improvements is highly appreciated!
Especially take a look at $_SERVER['HTTPS'] marked with // ???. I have found many different ... | stackexchange/codereview |
I have been following the advice to make tiny methods that does just one thing and does it well. I also have been keen on reducing or eliminating duplication as much as possible.
But when a very experienced developer friend reviewed my code, he mentioned I was taking it too far. And, in short, my code was unreadable as... | stackexchange/codereview |
I have just finished up making an object Depth Management system that I will be using for drawing and explicitly drawing. Because we all know that the order in which things are drawn heavily effects the way the game will look.
My system has a very simple and easy to follow code, and the only problems I have found are t... | stackexchange/codereview |
I am using the following function to make a specific filter passing the $scope.searchParams in this way:
<tbody ng-repeat="user in users | customFilter:searchParams "> ...
$scope.updateSearch = function() {
var searchParams = {},
loginArr = [],
nameArr = [],
statusArr = [],
accountsArr = [... | stackexchange/codereview |
Im finally done with my project and im going through my code and optimising it and trying to cut down on the chunky lines of code, how would i optimize this, it a series of if statments that matches text and adds value to a corresponding text box
private void btnfinalize_Click(object sender, EventArgs e)
{
... | stackexchange/codereview |
Thanks to Rotem and his help with this issue, I can offer an implementation that allows to use cvtColor to convert an AVFrame YUV420P into a BGR cv::Mat. The key is to create a temporary intermediate cv::Mat where all the AVFrame data is copied in the way cvtColor expects it.
#include <cstdint>
#include <vector>
#inclu... | stackexchange/codereview |
I'm trying to wrap my head around OOP, and am fairly new to PHP in general, so please forgive me if the following makes you cringe.
I've decided to try and create a basic database wrapper using PDO. Here's what I've done so far.
class DB {
protected $db_user = 'root';
protected $db_pass = '';
protected $db_... | stackexchange/codereview |
I've developed a crud "helper" of sorts. Fields/columns are derived from the database and contain everything from the name of the field to the type and size of the field. Part of the system integrates CodeIgniter's form validation library. In the particular function in question, a field object is passed to the function... | stackexchange/codereview |
Is there a better way to write this in vs2010 C#?
public bool IsAccept()
{
//check the status is accept
if (Status == null)
return false;
return Status.ToLower() == "accept";
}
public bool IsRefer()
{
//check the status is refer
if (Status == null)
return false;
return Status.To... | stackexchange/codereview |
Authorization Requests spec defines new authorization_details parameter. The authorization server have to somehow compare this parameter to decide whether client wants less, more or the same access.
My way to achieve this is to except two JSON arrays, but I feel my algorithm is not clear and not efficient.
My code look... | stackexchange/codereview |
Introduction and context
I am working on a small application which involves sorting 20GB files as one of the operations. This is being done, due to memory constraints, by breaking them into ~1GB chunks, sorting in memory and then writing back to disk. Then, as stage 2, reading the head of each file and picking the smal... | stackexchange/codereview |
Well, recently I'm working on a program which is able to sync files between different folders.
However, as a fresh man, the algorithm I worte seems feasible, but looks really disgusting, and inefficient as well (bruh~)
The following lines are the related things I wrote,
I really hope there would be experts who can help... | stackexchange/codereview |
I wrote an ugly mess of a JavaScript function that pops up a dialog box based on validation data, when a checkbox is clicked. I am wondering if it can be refactored somehow.
varButtons contains code for which buttons are used as a parameter to BootstrapDialog function.
//checkbox validation
var varButtons = [];
if (is... | stackexchange/codereview |
I was trying to get my computer information and I came up with this code. It is working but I need opinions on how I am doing it. It is my first time to using std::string to return strings. Is it good or is there another way around?
struct USER
{
std::string ID;
std::string Username;
std::string PCName;
... | stackexchange/codereview |
I wanted to implement Dijkstra's Algorithm in an Excel VBA Add-In and built it to be used as follows:
Define a list of paths with distances between points. This list needs to contain 3 headings that are used as flags to pick up where the list is. The 3 headings are !dijk:dat:from, !dijk:dat:to and !dijk:dat:dist
Speci... | stackexchange/codereview |
I recently started work on a game project, and decided to use GLFW for windowing / OpenGL context handling. GLFW doesn't have support for creating message boxes / dialogs, and I was unable to find anything simple online to do the job, so I decided to take a shot at creating a library to do so.
I've completed a first it... | stackexchange/codereview |
This is a huge project that I have worked on for the past few months, it contains 16 scripts, one of the scripts is used to analyze the other scripts. There are 111004 characters in all the script files, this exceeds the character limit of 65536 characters for a single post, and this figure doesn't include all the js... | stackexchange/codereview |
I have this piece of code:
final ResultDO response = transformJsonToResponseDO(rawDataResponse, ResultDO.class);
return Optional.ofNullable(response)
.map(results -> createPOIs(Collections.singletonList(response), providerResponse))
.orElse(Collections.emptyList());
The important part is that:... | stackexchange/codereview |
What is the most efficient and productive way to cut each N symbol from a string?
For instance,
n = 5;
str = '1234A1234B1234C';
result: "123412341234"
This is my approach:
def delete_each_n(str, n)
i = n
str.length/n.times do
str.slice!(i-1)
i += (n - 1)
end
str
end
| stackexchange/codereview |
I am a beginner in coding, writing my first bigger C++ project (aircraft initial sizing program). This code should be able to analyze the design in a probabilistic manner by using Monte Carlo Simulation. Hence, I have to generate random values for several independent random variables.
As I want to learn, how to program... | stackexchange/codereview |
here is my first virsion question: Is it good practice to have all my back end in one single file with all functions being static?
import java.sql.Statement;
import java.sql.Timestamp;
import java.sql.PreparedStatement;
import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.sec... | stackexchange/codereview |
Take the below code that I recently wrote:
.navbar-inverse .emphasis-text, .navbar-inverse:hover .emphasis-text, .emphasis-text {
color: #1caa98; /* Teal */
}
While this may be a dryer way of placing teal on all these link items, would you consider this readable? It seems to me like there is a lot to read, and it'... | stackexchange/codereview |
In terms of performance, what is the best way to bind mouseover/mouseout event on dynamically created elements?
This is what I have but I'm not sure it is ok for performance:
document.addEventListener('mouseover', (e) => {
if (e.target.getAttribute('data-tooltip')) {
// Show
}
});
document.addEventListe... | stackexchange/codereview |
This is pretty much an OOP version of this question, with the improvements:
import copy
import shelve
class GameOfLife(object):
def __init__(self, board, generations = 10):
self.__board = board
for i in range(generations):
print(self)
self.__nextGeneration()
def __s... | stackexchange/codereview |
The following app basically sums up the costs for an evening and calculates the costs per person. The user can input the description of the costs [String] (for example, round one = Spare Ribs Place, round two = Beer Place, etc.), the costs of the round [Double] (for example, 50$, 10.15$, etc.) and the amount of people ... | stackexchange/codereview |
I've been using this class for so long, I never thought about how terribly big and how bad it looks. Looking back on it, this class looks so out-of-date, and nothing explains itself; I want to get it looking much better, not with all the extra junk that it doesn't need.
Here's the class:
import java.awt.Canvas;
import ... | stackexchange/codereview |
I've been studying C# for about 6 months and am trying to make a simple example for an n-tier application. I want to learn to do things in the most proper and professional way. This example uses a table in the database called "Settings" where various application settings can be persisted to the database. I figure once ... | stackexchange/codereview |
I've written a small npm module. It is my first module. I'm asking you to review several things:
The code. I am rather starter, so any wise critic will be super.
Any suggestions or ideas on the library.
About module
Module is made to provide more comfort in using websockets via node.js, to help in organizing websocke... | stackexchange/codereview |
I'm trying to read a text file formatted as in this example:
5 3
3 1 5
6 6
6 1 3 2 5 4
Where the lines are coupled, with the line above always being of length equal to 2 and the line below having length equal to the the last digit in the line above.
(Unfortunately this is from an old note I took and I don't remember w... | stackexchange/codereview |
I have 2 methods that do almost the same things except a few lines of code. The sample is like below.
public void Method1()
{
DoX();
if (value)
{
var input = GetA();
DoA1();
DoA2(input);
}
DoY();
}
public void Method2()
{
DoX();
if (value)
{
var input ... | stackexchange/codereview |
Today was my first day working with JavaScript and I tried to implement some Linq-like (C#) functions as extension methods.
I'm pretty new to JavaScript and wanted to ask you for checking my functions and tell me, whether they're good and really usable in productive applications. Or maybe, what I could do better. I don... | stackexchange/codereview |
I wrote a simple 8-Puzzle and solver and am interested in seeing how it might be improved. Please let me know if any style or design changes might enhance the readability/performance of my code.
import random
import itertools
import collections
class Node:
"""
A class representing an Solver node
- 'puzzle'... | stackexchange/codereview |
I've written classes Store, Cart, User that manages methods that allow the user to add/remove products from a shopping cart, as well as being able to query different descriptions about the item (id, price, quantity). The User class hasn't fully been utilized yet. I'm wondering if there is any way to make this more comp... | stackexchange/codereview |
I'm new to Python, and just started to learn the principles of Object Oriented Programming, this does not judge strictly.
This code is fully working but confused some elements:
I don't understand what the __init__ method needs to return.
I don't like self. in get_parse that much.
Initially, I did it in order to be ab... | stackexchange/codereview |
Given a positive integer n, return the number of all possible attendance records with length n, which will be regarded as rewardable. The answer may be very large, return it after \$\mod 10^9 + 7\$.
A student attendance record is a string that only contains the following three characters:
'A' : Absent.
'L' : Late.
'P' ... | stackexchange/codereview |
I would like to use this feature
>>> def func():
>>> return 1, 2
>>> x, y = func()
But I have a formatting problem, because I want to assign values in the __init__() of a Class.
import csv
class Filewriter:
def __init__(self, jsonstring, filepath):
self.katAsk, self.katBid, self.promAsk, self.promBid,... | stackexchange/codereview |
I wrote a little bit of code in JavaScript that takes an array of objects and does some sorting, then outputs to an HTML page. I set a goal to do it without any frameworks, and in functional style on purpose to learn vanilla JS. It would be nice if someone could highlight any bad code or bad practice, and how I could i... | stackexchange/codereview |
I have been working on creating maintainable networking layer for our Asp.Net Core Web Api project. Right now I have created Generic methods for Get, Post, Put like this.
public class BaseClient
{
private HttpClient _client;
private ILogger<BaseClient> _logger;
private string AuthToken;
public BaseClie... | stackexchange/codereview |
A user can have many subscriptions, and a subscription belongs to one plan. The plans table tells us a subscription's cost. Is the query below the correct one for figuring out the number of subscriptions purchased by a user with an "ongoing" status and the total revenue brought in each day between Jan 1 and Mar 4, 2... | stackexchange/codereview |
I'm currently working on a PHP component: "Filesystem handler". I've run into a problem where I want to call one exact method in both dynamic and static ways.
I've ended up with this solution. Could you please give me a feedback ? I want to know, if there is a better or a simpler way to achieve the same result.
<?php
... | stackexchange/codereview |
I wrote this function to find the index of the first substring. I was wondering if you can help me find some flaws or possibly help increase performance?
Example:
str = "happy" substr = "app"
index = 1
My code:
public static int subStringIndex(String str, String substr) {
int substrlen = substr.length();
int ... | stackexchange/codereview |
I have implemented a simple do/while loop to handle a http request to a third-party. I don’t know when the data I receive will have elements in its array so I retry up to 10 times until the array given to me has data which then I stop and store the data in my database.
My question is in terms of performance is my API g... | stackexchange/codereview |
I've got some code that plots some displays from a weather URL and locations in a CSV file. I'd like to see if anyone can make the code more efficient, the code runs fine without any errors and I'm aware you won't be able to test it, but if anyone could take a look at making a class function or breaking up the function... | stackexchange/codereview |
In my last post, I wrote a long, non-general tail-merging† facility for insertion sort. I thought I should instead write a general-purpose tail-merging function, that works even when the two lists are of different lengths. So here it is (requires SRFI 1):
;;; Returns a list that has the same content as `lst`, sharing t... | stackexchange/codereview |
Which is more efficient? (Both memory usage and speed.)
arrayOfArrays.reduce((acc, innerArray) => {
acc.push(...innerArray);
return acc;
}, []);
Or
arrayOfArrays.reduce((acc, innerArray) => acc.concat(innerArray), []);
| stackexchange/codereview |
I'm using the following piece of JavaScript to emulate class extending. Is this a valid way to go or does it have some drawbacks which should definitely be fixed?
var Validator = function (inputId) {
"use strict";
var self = this;
self.inputId = inputId;
window.document.getElementById(inputId).onblur... | stackexchange/codereview |
I'm learning how to code in Java and I decided to re-write a program made in C++ into Java. All feedback is welcome.
Here is the original prompt:
This program generates a pseudo-random number between 1 and 100,
inclusive. The user will then be presented with opportunities to guess
that number. After each guess, th... | stackexchange/codereview |
After learning the concept of steganography, I've decided to code an application for it in PHP out of all languages, using the Least Significant Bit technique.
A pixel of a colored image generally has 3 channels, one for Red, one for Green and one for Blue. 8 bits are usually used to encode the value for each channel,... | stackexchange/codereview |
I was tasked at work to improve a system where through a web interface a client, which eventually became us, uploads a bunch of images with descriptions (latter coming from csv files), the images are then automatically resized yada yada for the site.
Nowt wrong with the latter, but the upload and image description dat... | stackexchange/codereview |
I'm looking for a way to do some route protection with react-router-4. Looking at an example in the documentation, they create a Component which is rendered like this:
<PrivateRoute path="/protected" component={Protected} />
and the privateRoute component:
const PrivateRoute = ({ component: Component, ...rest }) =>... | stackexchange/codereview |
My code works, but I need help on revising it to make it shorter and simple if possible on my main.cpp part ONLY. The other files is to make the program compile and work out if you want to see the output.
main.cpp:
#include <stdio.h>
#include "bintree.h"
#include <string.h>
#include <list>
#include <stack>
#include <st... | stackexchange/codereview |
I've been making this pet project of mine which is an implementation of a HashTable for a very specific purpose: storing huge amounts of objects in-memory (think Redis). I ended up with this implementation in C++ which is in my opinion a very basic and generic Java-inspired HashTable using buckets. I'd like to hear a... | stackexchange/codereview |
This is first time I code reviewing and would like feedback on coding in industry standards and optimum code.
This program adds number in array in two formats:
Adds adjacent numbers in a serial manner as proof for the actual sum to refer to the required output.
Adds the last and first variables in the array.
import ... | stackexchange/codereview |
As a self-taught student of Web-Development and Web Technologies, I created a simple sign in/out form in PHP, just for practice purposes and some fun!
I read the O'reilly's book about PHP and I found one sentence there (I really don't remember where it was though):
A novice web developer will program procedurally, but... | stackexchange/codereview |
As indicated in the title, this small project fetches content from the SEC's Edgar REST API. It was designed with the intention of automatically gathering/refreshing large datasets of public company financial data on a Linux server.
For some additional context, I am starting a pivot from a pure financial services role ... | stackexchange/codereview |
I know I never have to reinvent the wheel, but I did because I need speed performance. Also, I need these features:
introspection or metaprogramming
actuate like API backend
private variables interpolation
embedded Perl code inside template like text template
avoid in the minimal no core modules
work with eval in env... | stackexchange/codereview |
I'd like some feedback for the code I wrote. I haven't programmed in C++ for two years.
#include <string>
#pragma once
template <class T>
class StackLinkedList
{
public:
StackLinkedList() : m_List(nullptr), m_Size(0) {}
~StackLinkedList();
void push(const T& val);
void pop();
T& top();
const T&... | stackexchange/codereview |
I am currently in the process of creating a website which requires it to work with and without JavaScript enabled. All callbacks to the server with JavaScript enabled will be made through Ajax callbacks. In order to keep my code very DRY, I wanted to reduce the amount of views that was required to be created.
For that ... | stackexchange/codereview |
The standard library heapq in python doesn't support updating keys as a public method, which makes it hard to be used as a priority queue. Although the official documentation has suggested a workaround, it is somewhat convoluted. So I decided to implement my own priority queue as a min-heap.
Here is my code:
class Heap... | stackexchange/codereview |
Purpose: to make an adjacency PHP array with parent_id, name, level and root_id (the id of the root category) starting from a "flat" table-like structure.
This is the starting array where name1, name2 and name3 represents the category name and nesting level:
$categories = [
['id' => 1, 'name1' => 'A', 'name2' => 'B... | stackexchange/codereview |
Codewars Kata: Given integers a and b, count all primes p where a ≤ p < b and the digits of p are all prime. b may be as large as 107.
To start with, I hardcoded all valid 1903 primes in \$[1, 10^7]\$ that can be formed from digits \$\{2, 3, 5, 7\}\$ and stored it in a list. Then I use binary search to locate the index... | stackexchange/codereview |
I'm working on a simple waiter implementation, waiter - is a code that polls an external API until a desired response is received within a given period of time. I would like to keep it simple, but at the same time write it in the native Golang style. At the moment I come up with the following code (the actual API reque... | stackexchange/codereview |
The question is:
Write a program that prompts the user to input ten values between 80 and 85 and stores them in an array. Your program must be able to count the frequency of each value appears in the array.
Is there any more efficient ways to present the count for frequency number between 80 to 85? Below is the sampl... | stackexchange/codereview |
Probably the hardest part of learning lisp has been to think in the "lisp way" which is elegant and impressive, but not always easy. I know that recursion is used to solve a lot of problems, and I am working through a book that instead uses apply to solve a lot of problems, which I understand is not as lispy, and also ... | stackexchange/codereview |
I recently created this Income Tax calculator based off your filing status (Single, or Married Filing Jointly) and which tax bracket you fall into for the 2020 tax year, taking into account the Standard deduction. I know the code is a little robust, but the math checks out as compared to several other tax calculators. ... | stackexchange/codereview |
I am new to PHP development. So Kindly, review my code and guide me make it better/optimize. Currently, it works well with inputs that I have tried.
<?php
// Program to find the word in a sentence with maximum specific character count
// Example: "O Romeo, Romeo, wherefore art thou Romeo?”
// Solution: wherefore
// Ex... | stackexchange/codereview |
I am trying to implement an HashMap in C. I am trying to used a linked list style of interfacing to make adding and removing keys easy and efficient. Searching is not something I am considering at this point as it is early in progress. I am looking for any tweaks that could make this faster, more memory efficient, more... | stackexchange/codereview |
I am using Python 3.8 with ArcGIS Pro 2.5. This code creates a joined table where I match values for plant greenness in the current month with rainfall X number of months into the past. Each loop iterates through about 600 files (the number of files in ws1 and ws2). The code works perfectly but slowly, taking approxima... | stackexchange/codereview |
Made some adjustments to the previous code thanks to the helpful and thoughtful review by @G.Sliepen.
Problem statement: This program should ask for the total number of shops that will be visited. At each shop, ask for the number of ingredients that need to be purchases. For each ingredient... | stackexchange/codereview |
I solved the standard "write a method to determine if one string is a permutation of the other" question with the following code, using xor, map, and reduce:
from functools import reduce
from operator import xor
def checkPermutation(str1, str2):
return not bool(reduce(xor, map(ord, str1 + str2)))
The idea is that... | stackexchange/codereview |
Given a string print its words in decreasing order of frequency.
Example:
i/p - "aa bbb ccc aa ddd aa ccc"
o/p - aa,ccc,ddd,bbb
Scala:
import collection.mutable.PriorityQueue
import collection.mutable.HashMap
object FindWordFreq extends App {
case class wordFreq(w: String, c: Int) extends Ordered[wordFreq] {
... | stackexchange/codereview |
I just built an audio player in Angular 2 using a player component and a player service. It's all working fine, I just feel like there is a much better way to do this.
Should the audio object be in the service or the component? I'm skeptical because I'm using three different observables and I don't think that is the be... | stackexchange/codereview |
I am making a subclass of a well-established python class: pendulum.Period, which overrides both __new__ and __init__ (it does this because it is subclassing the python builtin class timedelta, which uses __new__).
In my case, I want my class to handle a wider range of arguments than the superclass. The only way I h... | stackexchange/codereview |
I have solved the following problem using dynamic programming: Little Deepu and his Girlfriend 1. To paraphrase,
We have two players Little Deepu and Kate and M items in the bag B,
also we have a game set S with N elements, each element of game set is
an integer. The game is played as follows, each player takes t... | stackexchange/codereview |
I have a Django form with a lot of fields, including some FileFields. I want to validate the form based on the contents of the files: they must be valid gdal datasets, and if both are present (one of them is optional) then the optional dataset's extent must entirely cover the required file's extent.
To do this, I have ... | stackexchange/codereview |
I have some code which uses nested foreach loops to take the results of a query and drill down into the data, reassigning into a main data array at each level of the foreach nesting. The problem is that required reference variables are passed into the loops deeper down the tree, making it difficult to refactor.
I'd lik... | stackexchange/codereview |
CodeEval's "Grid Walk" problem is as follows:
There is a monkey which can walk around on a planar grid. The monkey can move one space at a time left, right, up or down. That is, from (x, y) the monkey can go to (x+1, y), (x-1, y), (x, y+1), and (x, y-1). Points where the sum of the digits of the absolute value of the ... | stackexchange/codereview |
I'm reworking PyCXX (C++ wrapper for Python).
I'm currently examining the following macro code, and wondering whether there is a way to write it using templates rather than macros.
If so, the question becomes: what is the best way to write it? (I personally favour a concise macro solution over an awkward template solut... | stackexchange/codereview |
I was writing an application with a few Monads in a transformer stack. The top level application state resides in a TVar, and various components of the application operate on parts of it.
I wrote a helper function to extract those parts:
hoistStateWithLens :: S.MonadState outerState m =>
Simple L... | stackexchange/codereview |
I had asked a first question about this class a while ago and got a few answers here which made me rewrite it completely.
I removed all statics and globals, added my variables as arguments for the constructor, and pass them again as reference through my constructor (for creating a controller from within a controller).
... | stackexchange/codereview |
The following code does three things:
The filename is determined by the RawData class
The reader and writer send data through a processing pipeline
(Hopefully) makes changes and extensions easy
Regarding (2), the processing pipeline consists of "processors", that can process and deprocess data. For example, if you r... | stackexchange/codereview |
I have written this module that takes input of configuration of multiple lines with first item as available storage and remaining are the process at different rate using sys.stdin .
#! /usr/bin/python
""" this script calculates the time remaining for available storage to get filled up.
"""
import sys
def time_to_mel... | stackexchange/codereview |
I have this method which calculates the average, median and percentile information given a long array of numbers. Is there any better and efficient way to do the same?
public static double median(long[] numbers) {
Arrays.sort(numbers, 0, numbers.length);
int middle = numbers.length / 2;
if (numbers.length... | stackexchange/codereview |
This class returns a cached contact by ID. The two cached functions here are doing the same thing. The only difference being an early return statement or using else and having only one return statement. CacheHelper class is a static class that is a wrapper around .Net's MemoryCache class. It's a dll reference so I don'... | stackexchange/codereview |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.