instruction_seed stringlengths 71 95.1k | _source stringclasses 1
value |
|---|---|
I recently began learning C++ and would appreciate your review of this simple tic-tac-toe game I made. I know the "3-in-a-row algorithm" is inefficient, but in what other ways could I improve the code? Thanks for the help!
#include <iostream>
#include <cstdlib>
#include <time.h>
#include <string>
std::string endText;
... | stackexchange/codereview |
I have simple class that I want to ask if is there any possible to improve it? I mean, for me it looks poor. Is there any way to use here try-with-resources, stream or optional?
package bookstore.scraper;
import lombok.extern.slf4j.Slf4j;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import java.io.IOExcep... | stackexchange/codereview |
I have a method which checks if a control of an entity's attribute is 'multiControl' or not:
private boolean entityHasMultiControl(IEntityMetadata entityMetadata) {
for(IAttributeMetadata attr : entityMetadata.getAttributes()){
for(IControl control : attr.getAttributeType().getControls()){
if(c... | stackexchange/codereview |
I'm trying to build an email verification for user signup using CreateView. This view check whether the user is a new or already existing inactive user? and resend verification if the user is inactive.
Here's how I did it(email sending part),
views.py
class SignUpView(CreateView):
""" SignUp view """
form_cla... | stackexchange/codereview |
How could I possibly shorten / clean this up? I suppose mainly clean up the loop at the start asking whether they would like to scramble the code.
def userAnswer(letters):
print("Can you make a word from these letters? "+str(letters)+" :")
x = input("Would you like to scrample the letters? Enter 1 to scramble ... | stackexchange/codereview |
I wrote this script template at work to save typing repetitive commands and to improve my Bash-fu. I'd like to know of any moderate-to-severe quoting, robustness, security or usability issue. All code provided in answers should work in Bash 4.
.sedevrc:
#!/bin/bash
se_projects=()
se_cvs_dir="${USER}@172.0.0.1/export/h... | stackexchange/codereview |
I was in the mood for some data structures and I decided to code up an ordered map using AVL tree. I will post only map.h and map.c. The demonstration driver may be found here.
See what I have:
map.h:
#ifndef MAP_H
#define MAP_H
#include <stdlib.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef struct map_entry... | stackexchange/codereview |
I've been given a homework assignment to make a function to check whether 2 given arrays with the same given size have exactly the same set of elements.
My function seems to be working but I feel like I don't use the principles of recursion properly in my function.
I'm not allowed to use dictionary like data structures... | stackexchange/codereview |
I am solving interview questions from here.
Problem : Given an integer n, generate the nth count and say sequence.
The count-and-say sequence is the sequence of integers beginning as follows: 1, 11, 21, 1211, 111221, ...
1 is read off as one 1 or 11.
11 is read off as two 1s or 21.
21 is read off as one 2, then on... | stackexchange/codereview |
I'm hoping for some input on if my code is DRY or how I could have made it more efficient. I am pretty new in terms of jQ/JavaScript and this took me far longer than I care to admit. I will post the CodePen and also the entire JavaScript (Unsure which is better in terms of formatting.)
Forked CodePen so new changes won... | stackexchange/codereview |
I read time complexity of radix sort is O(wn) or O(n log n), if all n numbers are distinct. After implementation it look to me as if I have implemented radix sort which has time complexity of O(n ^2). Please take a look at my implementation and suggest, if there is some implementation problem or my observation about ti... | stackexchange/codereview |
We use a third party dll which has an object called CServer and was provided by one of our software vendors to act as an API between our applications and their applications.
CServer has the following method:
bool SynchroniseData() which can be called if we want to fetch data from server which is very important for our... | stackexchange/codereview |
I'm trying to avoid strings being passed around as a valid value. The ability to make a mistake is too high for my taste and the solution that I've come up with is to use an Enum. This provides the benefit of intellisense when trying to use the values. Similar to typing sheet1.Visible = which gives the valid options a... | stackexchange/codereview |
Problem
Suppose we abstract our file system by a string in the following
manners:
The string dir\n\tsubdir1\n\tsubdir2\n\t\tfile.ext represents:
dir
subdir1
subdir2
file.ext
a directory dir contains an empty sub-directories subdir1 and a sub-directory subdir2 containing a file file.ext.
The string
... | stackexchange/codereview |
I sometimes have to schedule some tasks and wanted to have my own reusable scheduler. Since I like the Rx, I build it on top of it.
Follow-up
There is a newer version of the Scheduler.
The Scheduler class is really simple. It's backed by a newer implementation of my old CronExpression.
There are currently only these ... | stackexchange/codereview |
For the company I work for we spec lengths of tube of varying lengths.
For a given project let's say there is a list like this
100', 115', 105', 205', 195', 240', 240', 130', 180', 140', 225', 85'
Edit 4: Entries in the list can not go over 285', and are always rounded to the nearest 5'.
The goal is to figure out how t... | stackexchange/codereview |
I'm very new to programming in C and I attempted to make a program that converts temperatures to and from Fahrenheit and Celsius. I have been running the program and I have realized that not all conversions are correct. For example, if I use the boiling point of water (100C or 212F), I get an incorrect answer. I though... | stackexchange/codereview |
The program is running fine but I was just wondering whether there was anything I could do to make it more user friendly or efficient.
from random import randint
import time
word = "a"
shield = 5
#The main function
def main():
#This will trigger the introduction
intro()
while True:
shield, word, fin... | stackexchange/codereview |
I was creating a Volunteer Signup Report report in Microsoft Excel yesterday for my job and I had a moment of inspiration. What if I turned it into a website and made it dynamic? The volunteers sign up, the data is logged in a MySQL database, and then the report is automatically updated for the managers to view.
Obviou... | stackexchange/codereview |
I'm trying to implement pbkdf2 in Python 2.7/3.4 without needing the pbkdf2 module. (I'm also trying to avoid using classes.)
Any insight would be appreciated:
from binascii import hexlify, unhexlify
import hmac, struct, hashlib, sys
is_python2 = True if sys.version_info.major == 2 else False
def pbkdf_two(passwd, sa... | stackexchange/codereview |
This is a code for an android thread. This is a tcp server and gets data from socket, maps it to an object and sends that object back to the main service. If there is anything I'm doing wrong or if something can be done better, I would really appreciate comments.
public class SocketManager extends Thread {
Handler... | stackexchange/codereview |
When generating a matrix barcode, it takes 1 minute per 10000 files .That's how to generating a matrix barcode for big quantities in less time.
Here is the library used to encoder data.
My code for button generating:
Class1 CLS = new Class1();
DataTable dt = CLS.ShowalldataSerial(textBox4.Text);
for (int i = 0; i <= C... | stackexchange/codereview |
I have this table (inradar_ad) with almost 300k entries. I want to know why my query takes 160 secs to run.
I tried limiting with LIMIT 10 to see if I get a speed boost, I but didn't. Does LIMIT speed anything up? I don't think so in this case, since it has to calculate everything and then limit it.
-- --------------... | stackexchange/codereview |
I made the UI for the hacking minigame from the Fallout series. Could I get some feedback on the main Game.js component? It's my first React app.
I'm especially curious as to whether my code is easily testable, and also if it has a lot of clarity, ie. if it's easy to understand. I am also curious of improvements that c... | stackexchange/codereview |
I made a simple comparison window in WPF that has two RichTextBoxes highlighting the differences (in red) of two StringCollections.
I knocked the code up in about 5 minutes and having gone back to look at it it appears pretty shoddy. I've included comments to show my intentions.
private static void DifferentiateText(R... | stackexchange/codereview |
I have the following bit of code in a service worker that checks to see it the url contains any of the values in an array and if so it breaks out of the function. As it is run for every asset on a webpage, it can be run a lot of times so I was wondering if it could be optimised in any way:
const urlsToIgnore = [
'... | stackexchange/codereview |
I'm currently working on a simple simulator in Unity3D that involves planets orbiting each other. I wrote the following C# script to do that. It uses the classic gravitational formula,
$$F=G\frac{m_1m_2}{r^2}$$
using UnityEngine;
/// <summary>
/// Class used for calculating
/// how an object orbits another
/// object... | stackexchange/codereview |
I am currently working on some fade out alert boxes where once the fa-close is clicked, it will then fade out and then slide the rest of the alerts/content upwards.
Here's what I've got:
$(document).ready(function() {
$(document).on('click', 'div.alert > i', function() {
var trg = $(this);
var parent = trg.... | stackexchange/codereview |
I have the following code, it takes a list of maps representing bands and transforms the band properties via the pipeline_each method.
As you can see in the code, I am dealing with a lot of Options being returned when I modify the band data in the map - I am using an immutable map object and therefore need to return a... | stackexchange/codereview |
Here's my first serious attempt at writing Go code. This program counts the number of days until a certain date and displays that in the system tray.
To do that, it first reads the target date from a file — containing, for example, Dec 25, 2016 — and counts the number of days inbetween, then writes that number to an ... | stackexchange/codereview |
Read the current inventory from a file. Either adjust inventory based on orders or generate a purchase of new inventory. When a product goes below a certain point, it will be asked to calculate it and then restock it to a target point. I am trying to make it more efficient, such as making it shorter.
check = 0
GTINC... | stackexchange/codereview |
I am working on my first HTML5/CSS web site and, like all of my first-time projects, they end up cumbersome, crude, and hard to work with when changes need to be made later in the life cycle. I am attaching some code with a small amount of HTML and CSS. I have read up on CSS and HTML and, after quite alot of effort, ha... | stackexchange/codereview |
This code finds the index in the string and removes the one which will make the string a palindrome. If the string is already a palindrome, it should return -1.
This code works correct, but I am looking for a better implementation of it. Here is the problem description.
def palindrome(string):
return string == stri... | stackexchange/codereview |
I am working through the UPenn CIS194 lectures and homework assignments in an effort to learn more about Haskell.
The first part of the first homework is focused on validating credit card numbers.
To validate each credit card number (passed in as an Integer), the Integer should be converted to a list of digits.
Beginni... | stackexchange/codereview |
I just implemented a version of A* search in JavaScript for educational purposes. I'd really love it if you could take a look and tell me how to improve my code.
The grid passed in is just a multidimensional array (2-D array) where each slot in the inner array is an object with property weight.
The point of this functi... | stackexchange/codereview |
I'm doing this HackerRank problem which basically boils down to what I've written in the title. We have to find out the distance between all the odd values in the array. I've written this code below which passes all the test cases but I think I can do better, namely, I don't have to make a separate array (oddindices) t... | stackexchange/codereview |
This is an interview question I saw online and thought to give it a try.
The question is about implementing a hash map with a setAll(V value) function. This function assignes a value to all the keys in the map at O(1).
Examples:
HashMapSetAll<Integer,String> map = new HashMapSetAll<Integer,String>();
map.put... | stackexchange/codereview |
I have completed an application which gathers specific records and marks them as Collected. As of now, the application runs perfectly and does exactly what I need it to, but the problem comes in when a large data set is reviewed. If I am pulling records for one day or even maybe a week, it runs at a decent pace, but on... | stackexchange/codereview |
This script allows you to practice your typing skills, as soon as you finish typing a new word appears for a non-stop typing experience. The code has in memory the top 100 words as per the Pareto Principle and Zipf's Law, of these, the top 10 are more common than the rest.
To start, type start.
Tested in Linux, Python ... | stackexchange/codereview |
I wrote my Split() extension, it's main goal is to save delimiters and add them to splitted strings.
For example:
I have a string "-1-2+3+4-5-6", and separators '+', '-'
and I want to have following: "","-1","-2","+3","+4","-5","-6" or "-","1-","2+","3+","4-","5-","6" depends on input separator option.
My extension met... | stackexchange/codereview |
I'm new at scripting, but I thought it would be handy to have a script that would change the extensions of selected files in Finder. I run this script from an automator service so that batch changing extensions in Finder is always just a right click away.
So far, it has worked as I expect, but since this is one of my ... | stackexchange/codereview |
I'm working on my pet project with MVC 5 and EF, and everytime I'm adding a parent with it children (I have the children ID's) I have to go to the database, because if I just create a new child with this ID it just inserts a child object. Is there anyway to avoid this?
This is part of my code:
My classes:
public clas... | stackexchange/codereview |
Program description
The goal of this program is to get a number, which is the number of lines of inputs (lets call that number N) that the program will receive. Then the following N lines will consist of two parts, first a char which is either 'T' or 'M'. The next part will be a string that is a little different for 'T... | stackexchange/codereview |
The usecase of my app I am trying to build is about Inventory Management System for a single company. I have
attached a layout depicting what table or model should look like. I have designed the model the following way
class Office(models.Model):
title = models.CharField(max_length=200, blank=True, null=True)
... | stackexchange/codereview |
I had to make a program to crawl through a bunch of PyPI packages and see how many of them implement custom compare operators (i.e. grep for def __le__ etc). After downloading an HTML file with links to all Python 3.4 packages on PyPI (i.e. the directory page), I wrote this simple crawler to go through all the links, d... | stackexchange/codereview |
This is my first attempt at creating an event system.
My plan is that upon publishing, the listener receives both a reference to the model and to the publisher. This allows the publisher class to have multiple owners, and provide a way for listeners to know exactly how they were called.
To do this I've made the base cl... | stackexchange/codereview |
Please see the code below:
public class Customer
{
public int _iD { get; set; }
public decimal _salary { get; set; }
public List<String>_assignedOffers { get; set; }
private AbstractValidator<Customer> _validator;
private IRulesOfferCalculator _rulesOfferCalculator;
public Customer(AbstractVal... | stackexchange/codereview |
This is a working Neighbours method. Is there any way to make this simpler and concise?
public int Neighbours(int xCoordinate, int yCoordinate)
{
xCoordinate = xCoordinate -1;
yCoordinate = yCoordinate -1;
int NeighbourCounter =0;
int incrementer = 0;
... | stackexchange/codereview |
I have recently started writing a userscript for Mozilla Firefox to tighten security and make it more private, but before I want to start publishing it, I would like to have some experts take a look at it to see if I made any mistakes, I am by no means a experienced coder, and this is my first little project. Things I ... | stackexchange/codereview |
The goal here is to pull all alerts from a single iterable:
obj = Alerts(db, args)
for alert in obj.alerts()
pass
Now, I need to add a few more sources and I'm not sure if this is a good approach to instantiate all classes in the AllAlerts constructor? I also don't like the fact that I'll have to add them to the s... | stackexchange/codereview |
I just learned Merge sort, and I really like this Merge sort implementation since it is very logical and very easy to follow. If I was asked in an interview to implement merge sort, will this implementation suffice?
I know creating those new arrays every time the mergeSort() method is called is bad practice. I fully un... | stackexchange/codereview |
Description:
The task involves processing a set of workflows, each comprising rules. These rules define conditions based on part ratings and dictate the destination workflow if the conditions are satisfied. The objective is to compute the total rating of the parts that are eventually accepted after traversing the workf... | stackexchange/codereview |
I have the following snippet of LESS code to generate CSS. I have some different classes which I apply to different elements, and on hover or focus they should change color.
.social-icons {
color:#bbbbbb;
// Material design palette, 500
.blue {
&:hover, &:focus {
color: #2196F3;
}
}
.red {
... | stackexchange/codereview |
A user wrote an issue asking if inside the bio (or any arbitrary tag), any tagged accounts can be automatically linked like on Github.
I gave them this function:
<script>
let bio = "The coolest company to work for is @github! There is also @aws and @microsoft.";
let linkedBio = "";
let found = false;
... | stackexchange/codereview |
The objective of this code is to contact a server with a reporting API and run the specified report from the user generated configuration file, once the report has been requested to server responds with a job id for the requested report.
The code takes the job id, sends another API call with the specified id to retriev... | stackexchange/codereview |
if (isset($_POST["save-options"])) {
foreach ($names_of_array as $type => $value) {
update_option('updated_img', $_POST['show_img_url']);
if (isset($_POST["post0"])) {
update_option($names_of_array[0], true);
} else {
update_option($names_of_array[0], false);
... | stackexchange/codereview |
(See the next iteration.)
I have this template function for computing standard deviation in one pass over the data. The underlying math is here.
coderodde_sd.h:
#ifndef CODERODDE_SD_H
#define CODERODDE_SD_H
#include <cmath>
#include <iterator>
#include <sstream>
#include <stdexcept>
namespace net {
namespace cod... | stackexchange/codereview |
I've created a simple Perlin noise generator in JavaScript and am trying to find ways to optimize it. It lives inside a webpage and generates an image using nothing more than random number generator and a lot of arrays and algebra.
The end result is kind of slow. Not unusable, but a lot slower than a Java applet woul... | stackexchange/codereview |
I'm picking up Go, and wrote this simple script to parse a two csv files (spending.csv and savings.csv) to plot savings rate graph.
I would like to hear some generic comments on code readability, libraries I missed out on using, and Go-ness of the code I wrote.
I also used global variable months which I am not very ha... | stackexchange/codereview |
Please provide constructive feedback so I can learn from my mistakes. Please tell me what I did right and where I came up with very good solution and where I should improve. Here is the code (Please pardon some indentation, formatting errors):
/*
Author: Filip Mirosław
Author's GitHub Account: https://github.com/Sproza... | stackexchange/codereview |
Racetrack:
The August community challenge is to implement a program that plays the Racetrack game. Each player starts with an integer position on a square grid. On each turn, the current player can accelerate by -1, 0, or 1 unit in each direction. The first player to reach the finish line wins.
This is a Java implement... | stackexchange/codereview |
I recently started learning C# and am taking the opportunity to try and accelerate my introduction by helping the RubberDuck team (Website and GitHub Repo). The full class code that I'm working on can be found here. Its purpose is to create a Module in VBA that will allow unit testing.
Since FakesFieldDeclarationForma... | stackexchange/codereview |
I have a Laravel project that has courses. I want to take the related courses from one.
Should I create the method in the model (the php class) or in the controller?
Currently I have this code in the model:
class Course extends Model {
public function relatedCourses() {
$all_courses = new Collection;
... | stackexchange/codereview |
void removeForbiddenChar(string* s)
{
string::iterator it;
for (it = s->begin() ; it < s->end() ; ++it){
switch(*it){
case '/':case '\\':case ':':case '?':case '"':case '<':case '>':case '|':
*it = ' ';
}
}
}
I used this function to remove a string that has any of the f... | stackexchange/codereview |
I am looking for ways to make this code more "pythonic" and any issues with my implementation. This was designed to solve Crytopal's Challenge 10. This challenge requires recreating the AES-CBC cipher using a library-provided AES-ECB function. PKCS7 padding is also used to align bytes to block boundaries.
from Cryptodo... | stackexchange/codereview |
I am refactoring this piece of code.
The main part I am fixing is:
for (i = j = 0, len = lines.length; j < len; i = ++j) {
line = lines[i];
lines[i] = maybeCode && (match = /^([ ]{4}|[ ]{0,3}\t)/.exec(line)) ? (isText = false, line.slice(match[0].length)) : (maybeCode = /^\s*$/.test(line)) ? isText ? lang.symbol : ... | stackexchange/codereview |
I decided to try my hand at a Hangman game to familiarize myself a bit with the language.
use std::io::{stdin, stdout, Write};
fn main() {
let stdin = stdin();
let mut stdout = stdout();
let to_guess = String::from("BENEDICT");
let mut letters: u128 = 0;
loop {
// Replace unguessed lette... | stackexchange/codereview |
I would like to simplify and optimize this function which finds me the neighbors of a cell thanks to cartesian coordinates of a cell Id
const getNeighborsCellId = cellId => {
const neighbors = []
const {x, y} = getCoordinatesFromCellId(cellId)
// LOL ->
const isStaggered = y % 2
if (isStaggered... | stackexchange/codereview |
I tried this program in both Orwell DevC++ and Visual Studio 2013 (program works correctly). My astonishment is the performance of the same program in both IDEs. While the former took only 395 milliseconds, the latter took a whooping 34984 milliseconds. What's wrong with VS2013? Is it due to the compiler it uses? Or is... | stackexchange/codereview |
How's the following function to update an immutable Map's values?
scala> def updateMap[A](map: Map[A, Set[A]], item: A, toAdd: A) = {
map.map(x => if(x._1 == item) (x._1, (x._2 + toAdd)) else (x._1, x._2))
}
scala> val map = Map(1 -> Set(2), 3 -> Set(4))
scala> updateMap(map, 1, 5)
res1 ...= Map(1 -> Set(2, 5)... | stackexchange/codereview |
I have ported from Fortran to Python an algorithm that calculates the numerical derivative along the x direction (longitudinal) of a scalar function s on a rectilinear grid that has equal grid spacing in the x and y direction (2.5 degrees x 2.5 degrees). The input data s is oriented south to north for the latitude and ... | stackexchange/codereview |
I am using mod and my code works. I am wondering if there is a more efficient way to write a method that returns the total number of divisors for an integer.
function getDivisorsCnt(n){
var divisors = 0;
mod = n;
while (mod > 0){
if(n % mod === 0){
divisors++;
}
mod--;
}
r... | stackexchange/codereview |
I am working on a component for a navigation bar. This navigation bar currently has two variations: a "back" version, and a "close" version.
I have come up with three different implementations but I am uncertain of which one is the best. Currently, I am leaning towards this implementation as it reads the best in my opi... | stackexchange/codereview |
First line will contain two integers N and M separated by a single space. Then the next M lines will contain three integers a, b and k separated by a single space. N is the length of the sequence. M is the number of operations performed on that sequence. a is the starting index from a sequence and b is ending index fro... | stackexchange/codereview |
I decided to make a simple RPG game to practice JavaScript. I don't know a lot about JS best practices or things like that, so I rather have my code criticized now than build more code on top of bad habits. I'd be greatful for any advice.
document.addEventListener("DOMContentLoaded", function(){
showStats();
});
l... | stackexchange/codereview |
I have a custom AuthenticationProvider for getting authentication via LDAP and authorization via JDBC. It's running but I think it's not the best way.
My custom AuthenticationProvider:
public class ADAuthenticationJDBCAuthorizationProvider implements AuthenticationProvider {
private final ActiveDirectoryLdapAuthen... | stackexchange/codereview |
I'm busy rewriting some from my spaghetti code into OOP classes. I'm still learning OOP and very new to the concept. From help from this answer from @EliasVanOotegemto on a previous question I've asked I have written the following class which sets up conditionals according to 4 values passed to it by a user and checkin... | stackexchange/codereview |
I created a function that takes a dictionary as parameter. This dictionary is expected to have lists as value pair. (i.e. {1: [1, 2, 3], 'a': [4, 'b', 5, 'c']} )
This function has to return the key associated to the biggest list in the dictionary, or None if the dictionary is empty. (considering the above example, it w... | stackexchange/codereview |
I'm trying to unit test how my class responds to a NEST 1.7 IElasticClient's return values, using NUnit 2.6.4 and Moq 4.2. I feel mocking the Get function requires very "heavy" It.IsAny calls, and am mainly looking for feedback on how to mock IElasticClient in a way that my tests remain readable.
My code is mostly 100%... | stackexchange/codereview |
I'm developing a mobile app with Cordova, jQuery and jQuery mobile. To synchronise the data saved on a device I make AJAX calls to a server (I'm sending and requesting data). The data is saved in a database on the device with this SQLite plugin for cordova. The server-side connection is handled by a php file.
Everytime... | stackexchange/codereview |
I am writting a program to remove the duplicate values from an array, is any way to optimize code by removing one loop?
var arr=[10,20,30,20,40,10],
newarr=[];
var foo=function(ele, index, array){
match=array[index];
for(var m in newarr){
if(newarr[m]==match)
return true;
}
newarr.push(match);
};
arr... | stackexchange/codereview |
I have a requirement to check all records in a table which is big (Around 1.5-2 million records). What I am doing is very simple, just get all the records and loop through one by one, and do things. I have a quartz job which will run every 2 minutes to check things.
ApplicationDetailCheckingJob.java
public class Applic... | stackexchange/codereview |
Functions and features: paste/type search keywords to go straight to google.com search results pages - explicitly google.com NO google.TLD
chrome.webRequest.onBeforeRequest.addListener(
function (details) {
var requestURL = details.url;
var re = new RegExp('^(http(?:s)?):\/\/www\.google\.(?:(?!com\/)[a-z]+\.?[a-
z]+)... | stackexchange/codereview |
I have a parent view which has a dblclick event handler bound to it. I also have a view which is a descendant of the parent. This child view has a click event handler bound to it.
Currently, my code works as intended, but looks like this:
var ParentView = Backbone.Marionette.ItemView.extend({
events: {
'dbl... | stackexchange/codereview |
This is a practice for operator overloading, I am well aware that some of these don't make sense. I am seeking review only on the code/practices, not the purpose.
/* (C) 2017 ZACH HILMAN
* PROPRIETARY/CONFIDENTIAL. ALL RIGHTS RESERVED
*
*
*
*
*
*/
#ifndef COMPUTERSCIENCE_ENHANCED_STRING_H
#define COMPUTERSCIENCE... | stackexchange/codereview |
I'm working on a nice approximation for the Bilateral Filter.
I have a working code which runs pretty fast yet still I think much can be improved.
The code (C Code, compiles with C99) is given by (See code on Compiler Explorer):
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#includ... | stackexchange/codereview |
I used the following Stack Overflow questions as references for writing this code:
Select columns from result set of stored procedure
What is the equivalent of String.Join on TSQL?
The idea behind my stored procedure is to give an explanation of why a particular worker is unsuitable to care for a particular patient u... | stackexchange/codereview |
Question:
Given an integer array nums, return all the triplets [nums[i], nums[j], nums[k]] such that i != j, i != k, and j != k, and nums[i] + nums[j] + nums[k] == 0.
Notice that the solution set must not contain duplicate triplets.
Here's my pythonic approach to leetcode 3Sum, it passes and actually beats 93% in tim... | stackexchange/codereview |
As part of a larger project, I've written the following code for interacting with git-annex's addurl command in batch mode. addurl takes a series of URLs and output filepaths on stdin, and it outputs a one-line JSON object for each file when that file finishes downloading. git-annex performs the downloads asynchronou... | stackexchange/codereview |
Quick disclaimer. I've programmed Java for years but this is the first Objective C I've ever written.
I've written some code which almost unfortunately works but frankly hurts my eyes with the number of lines of code and quality. Basically looking for the right way to convert the original string:
<TUHandle 0x280479f50 ... | stackexchange/codereview |
Exercise 1: skips :: [a] -> [[a]]
The nth list in the output should contain every nth element from the
input list. For example, skips "hello!" == ["hello!", "el!", "l!",
"l", "o", "!"].
The question UPenn Homework 3: skips function and it's associated answers inspired me to write a solution in Javascript. I used ... | stackexchange/codereview |
I have full working code, but when I run it, it shows these warnings:
given is experimental at grocery.pl line 38.
when is experimental at grocery.pl line 40.
when is experimental at grocery.pl line 62.
when is experimental at grocery.pl line 89.
when is experimental at grocery.pl line 100.
How can I fix these?
use st... | stackexchange/codereview |
I'm using C#, .NET Core and the entity framework and am currently working on optimizing various functions for better performance.
One of the main functions is getting a calculation based on two indexes; a product and machine. The records in this database table is currently at 500 rows but can go upwards to 10.000.
My c... | stackexchange/codereview |
I am studying algorithms and I did this "Union Find Like" algorithm.
I have one array of objects with a reference and I make the union pointing to the same reference instead of have two int[] with numbers and weights.
Its not necessary to initialize the array.
You will have a maximum of N/2 extra objects ( if you do a... | stackexchange/codereview |
Consider the following code:
#include <iostream>
#include <vector>
using namespace std;
struct test {
int j;
test& operator>>(int & i) { i = ++j%26; return *this; }
operator bool() { return j%26; }
};
int main () {
test t;
int i;
while (t >> i) {
cout << i << endl;
}
}
I have impl... | stackexchange/codereview |
This is supposed to encode and decode small strings of text. Unfortunately, even on a really good laptop, it performs slowly. This might have to do with my looping, or just the sheer computation.
It takes a string, uses simple RSA, subtracts by random #, converts both to fixed binary, then compresses using base 80 "eve... | stackexchange/codereview |
Today I had an interview where I was asked to solve "Given an binary tree, convert it to binary search tree in minimum time, space complexity".
I wrote this code, but got the feedback that complexity could be improved without using sort and without using external storage.
How to do it?
##code goes below##:
class Node:... | stackexchange/codereview |
The following code implements a simple interface to operate on mutable* Strings in C. It is composed of two files: one for the structure definition and the available operations, and the other with the actual implementation.
*This can be inexact, as only adding characters to the end is implemented.
Any comments on codin... | stackexchange/codereview |
I'm trying to figure out what the best way to do this is.
I have a part on my website where people can search for a particular card based on multiple different factors. Like the name of the card, color, cost, etc. When the user types in the criteria, I send the information via ajax GET. So the url looks something like ... | stackexchange/codereview |
Below is the code for a compiler I created for a language called Jack. This compiler is one of the projects for the book "The Elements of Computing Systems" (http://www1.idc.ac.il/tecs/plan.html) where you build an entire computing system from the ground up. Anyway, what this compiler does is translate code from a high... | stackexchange/codereview |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.