instruction_seed stringlengths 71 95.1k | _source stringclasses 1
value |
|---|---|
A hashmap is a data structure that implements an associative array abstract data type using keys and values and has a hash function to compute an index into an array, from which the desired value can be set and get [reference].
Based on some tutorial, I wrote this hashmap class:
class HashMap():
def __init__(self)... | stackexchange/codereview |
I've implemented a Huffman tree for one of my academic coursework. For each of the nodes in the tree, there will be a left child, right child, and a parent. For each Node class, to add the children, I have the functions, addLeftChild() and addRightChild(). All is good.
However, I am a bit divided for the function that ... | stackexchange/codereview |
(using GNU sed)
I want to grab some output from xrandr and leave out everything but the resolution and offset.
Input:
eDP1 connected 1366x768+0+0 (normal left inverted right x axis y axis) 290mm x 160mm
1366x768 60.02*+
1280x720 59.74
...
640x360 59.84 59.32 60.00
HDMI1 connected p... | stackexchange/codereview |
The Stocks Problem: Given an array of n integers representing the
price of a stock over the course of n days, determine the maximum
profit you can make if you can buy and sell exactly 1 stock over these
n days.
My solution is using the same approach as the merge sort algorithm. It is implemented using Java. I a... | stackexchange/codereview |
I just wanted to get an opinion on my dynamic-programming Haskell implementation of the solution to Project Euler problem 18.
The Problem:
By starting at the top of the triangle below and moving to adjacent
numbers on the row below, the maximum total from top to bottom is 23.
$$\begin{array}{ccc}
& & & \color{... | stackexchange/codereview |
I created this shared pointer mainly to use it as RAII for handles that have to be shared between classes or threads.
For pointers:
It supports raw pointers and pointer to classes and arrays and also support classes inheriting from ref_base to save an allocation for the reference counter.
For non-pointers:
They must be... | stackexchange/codereview |
This is working code for input KML files into leaflet map
// Load kml file
fetch('lotA.kml')
.then( res => res.text() )
.then( kmltext => {
// Create new kml overlay
parser = new DOMParser();
kml = parser.parseFromString(kmltext,"text/xml");
console.log(kml)... | stackexchange/codereview |
I am making a Sudoku game and I have managed to add random numbers, add numbers, and to checklines (if there is 2 numbers on the same line). I am trying to check the 3x3 boxes if the number is twice or more in the same box. I have managed to do it one way, but is this the easiest way? In that case I need to do this 81 ... | stackexchange/codereview |
I rewrote a ActionResult method that will output list of users depending if it is a SuperAdmin, OrganisationAdmin or GroupAdmin. I know there is a lot of things in the codes I still can improve so I would ask the community here the things I should learn and keep in mind when writing codes.
You might ask why I have para... | stackexchange/codereview |
The object is to be able to pass some dates (start date, holiday) and the number of days you want to skip. We only want to skip working days, not weekends and holidays.
Just let me know what you'd do different than what I have. The code works, but I was told there are issues with it, but not told what issues they are.... | stackexchange/codereview |
I have a predicate builder that initially evaluates to false. Because of this, the very next expression should be a logical Or. But if I need a logical And I need to keep track of a boolean value. And this boolean value hasPassedFirstCheck is the thing I want to get rid of.
var cars = PredicateBuilder.False<Cars>();
va... | stackexchange/codereview |
I am working on an MVC solution. My DAL layer I could solve with Repository classes, everything is working great.
But in my BLL layer I have repetitive code:
My CRUD is the same, my fields and consructor are different.
I can also have some extra methods.
Is there a way to solve this properly?
Class 1
public class JobT... | stackexchange/codereview |
On a Manhattan grid, find the intersection of two paths closest to the origin. input_3.txt can be found here and the prompts can be found in the original problem statement.
import re
with open("input_3.txt", "r") as f:
coordinates = [wire.split(",") for wire in f.read().splitlines()]
class Point:
def __init_... | stackexchange/codereview |
This is my most recent login system I have been developing. It is working with Sessions. I want to know if I am doing well, if my code contains any serious exploits, and if my logic is correct.
This is the login class, handling everything related to users:
/**
* UserHandler.class
*
* Handling login/logout and others
*
... | stackexchange/codereview |
I'm working on a "framework" for Telegram bots and right now everything "just works". I'm now in the process of rethinking about what I wrote and one of the things I dislike a lot is how I implemented the API client.
Right now I have an interface (TelegramBotApi) which maps every API endpoint to a method. This interfac... | stackexchange/codereview |
I am trying to solve this InterviewBit question
https://www.interviewbit.com/problems/search-for-a-range/.
My code for this seems to be working properly and it does give me the correct answers on my IDE and on all the sample test cases online but it gives me a TLE on the online judge. It runs in O(log n) time, just a v... | stackexchange/codereview |
I am a high-school freshman who is kinda new to Ruby, and I am doing a small project on Ruby. One of the big things that I want to get out of this project is how to follow the "Ruby standards" that programmers should follow. Being as new as I am, I have no clue what I should/shouldn't do with this program. Can anybo... | stackexchange/codereview |
I have code which returns whether or not a sliding tile puzzle state is solvable.
I was wondering whether there is any way I could either make the code a bit more readable or increase the performance in any way.
public boolean isSolvable(int[] puzzle) {
int parity = 0;
int gridWidth = (int) Math.sqrt(... | 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 |
Now I have this fluent API for creating random integer arrays. I can say that I want an array of particular length, having a particular minimum/maximum values and using a particular (or default) java.util.Random. See what I have:
FluentArrays.java:
package net.coderodde.util;
import java.util.Arrays;
import java.util... | stackexchange/codereview |
Problem
In this HackerRank problem we are asked to rotate the elements of a matrix in the following way:
Example Input and Output
First and second entry specify the size of the matrix and third entry how many times it has to be rotated. As an example, the following input:
4 4 2
1 2 3 4
5 6 7 8
9 10 11 12
13 14 15 16
... | stackexchange/codereview |
I am building a Python client for an alert process engine. The users can use this client to publish and clear the alerts.
The client exposes two methods publish and clear to the users. These methods accept some parameters which would define the alerts from the users and enriches them with a few more fields and valida... | stackexchange/codereview |
In your opinion, do I need to do all these validations? I thought to do well and stay safe but it seriously raises the question if it isn't slower.
jQuery
$(document).ready(function () {
// jQuery validate plugin
$('#login > form').validate({
rules: {
username: { required: ... | stackexchange/codereview |
So this is my code and I would like to add subtraction, multiplication and division. If you have any suggestions on algorithms to use I would be very happy to see it. I do not wish to copy the code, I just want an outline of how to simply, and efficiently create a calculator. I want to make a calculator for KIDS with a... | stackexchange/codereview |
Having a text file './inputs/dist.txt' as:
1 1 2.92
1 2 70.75
1 3 60.90
2 1 71.34
2 2 5.23
2 3 38.56
3 1 61.24
3 2 38.68
3 3 4.49
I'm reading the text file to stor... | stackexchange/codereview |
I have written a program to optimize a point cloud in dependency of their distances to each other. The code works very well for smaller number of points. For 1700 points it takes ca. 6 minutes. But I have 300000 points in the point cloud. The code is still running after almost 30 hours.
I am sure there is a pythonic w... | stackexchange/codereview |
I'm writing a markup for:
And I've split it for these sections:
<header>
<div id="logo"></div>
<nav id="mainNav"></nav>
</header>
<div id="banner"></div>
<div id="content">
<section id="advantages">
<section class="advantage"></section>
<section class="advantage"></section>
<se... | stackexchange/codereview |
I have a main form for adding and deleting records and a button that opens a child form that displays records from an access database. Child form will have buttons for moving though the rows like first, last, next, previous and search. When user selects a record the child form will close and the selected record will ... | stackexchange/codereview |
I have an application in which I have multiple slow running prerequisite methods I need to call in order to have the data I need to continue.
To try to speed this up I am doing this:
Dictionary<string, string> processOptions = null;
Dictionary<string, string> businessAreas = null;
Dictionary<string, string> requirement... | stackexchange/codereview |
I have a method(C#) which takes an XmlNodeList and a String and saves the xml data into a database. That code isn't the problem (at least for the moment), but because I have multiple XmlNodeLists, each needing a different String (the heading), I end up with code like
saveToDB(students, "Students");
saveToDB(teachers, "... | stackexchange/codereview |
I have created a program to find prime numbers up to the 32nd power of 2. It uses the sieve of Eratosthenes. I would appreciate it if you could let me know any bugs or improvements I can make.
/*
* prime32.c
*/
#include <stdio.h>
char isprime1[0x10000];
char isprime2[0x10000];
typedef unsigned int UINT;
void solv... | stackexchange/codereview |
Suppose, I have a data access layer class, where I want to specify database connection parameters. Usually, I do it as static variables and initialize it right after definition, e.g. see DB_NAME variable case.
Performing code review, I paid attention that sometimes such logic is implemented with a static block, e.g. se... | stackexchange/codereview |
If one enters, say, "2, j" then it prints:
j
jj
If there is no second it should be *, so if it's just 2, it's * **.
#include <iostream>
#include <string>
#include <vector>
using std::string; using std::cin; using std::cout; using std::endl; using std::ostream; using std::vector;
class tree {
public:
friend ostre... | stackexchange/codereview |
I needed to make a multi-page form, with slides, but without using too much js code like slick.js or the likes. So I tried to figure out how to make it really simple, but still cross-browser and responsive. I ended up with a small test using transform transitions. My question is: do you maybe see any relevant drawbacks... | stackexchange/codereview |
The function below is part of a trading system. Its purpose is to assign a volume (order size) to a bid (buy) quote and and ask (sell) quote, depending on the value of the position_size argument.
This trading system strictly cannot exceed a position limit of 100 in either direction, so our order volumes need to never ... | stackexchange/codereview |
This is part of my chat client's code. It works fine but it looks messy. Any ideas?
//IP Validation
private void textBox3_Leave(object sender, EventArgs e)
{
IPAddress ip;
bool ValidateIP = IPAddress.TryParse(textBox3.Text, out ip);
if (ValidateIP)
{
button2.Enabled = true;
button3.Ena... | stackexchange/codereview |
This method finds the maximum in a binary tree. I have used generics to make this code more usable. However, I am not sure if I have written efficient and good Java code.
This is a method inside a class using generics and implementing Comparable interface for the generic parameter E.
private E maximumElement(TreeNode<E... | stackexchange/codereview |
I am about to post a question to Stack Overflow about how to do a better job adding a number to the list inside the User class. But I feel if I refactored this I might solve my problem with coupling my data like this. So I am open to suggestions.
Ideone
public static void addOrUpdate(Dictionary<int, User> dic, int key,... | stackexchange/codereview |
In my application, I need to allow the user to store variables. Variables can only be of specific types, but I effectively handle all variables the same way no matter the type. I would also like to avoid any casting. Therefore, I have several HashMaps for each variable type, which is causing lots of duplicated code.... | stackexchange/codereview |
I am trying to recreate a neat effect that I saw posted on Stack Overflow as a GIF .
I am trying to recreate this with CSS and JavaScript and I have created a similar effect with a button press.
I know there is a better way to position the divs since I am working with 3d moving and rotating. I need to have a formula th... | stackexchange/codereview |
I coded a simulator of the Game Of Life by Conway. I made using Kivy, so that it has a graphical interface.
Any suggestion on how to improve its pythonism or performance would be highly appreciated.
This it my .kv file:
<MenuGrid>:
id: actions
cols: 1
rows: 1
BoxLayout:
size_hint_y: None
... | stackexchange/codereview |
Note, I discovered a bug after I posted this. The current implementation drops any fields that have an associative value, which is not the intended behavior.
I'm writing a Tamagotchi clone, and need to be able to save the game's state to the disk. I want to save the entire state since it contains data other than the ... | stackexchange/codereview |
I got tired of the boilerplate and tedium restoring formatting context, so I made an RAII stasher that relies on the destroy-at-end-of-full-statement temporary semantics. With C++17 I can get it down to a single type, no helpers:
#include <iostream>
template< template<typename, class> class streamtmp, typename charT, c... | stackexchange/codereview |
This code add functionality to a GUI designed using PyQt. It cannot run alone, but I can provide the code. I am not asking for someone to provide criticism for every single function written here, but one or two tips would make me a happy camper. I would like to know if there is something I am making more complicated th... | stackexchange/codereview |
I originally had the following code:
type Suit = | Spades
| Clubs
| Diamonds
| Hearts
type Face = | Two | Three | Four | Five
| Six | Seven | Eight | Nine | Ten
| Jack | Queen | King | Ace
type Card = { Face:Face; Suit:Suit }
let suits = [Spades; Clubs;... | stackexchange/codereview |
I am Displaying mask images & allowing user to upload the custome image inside mask image, now i want to give an option for user to Edit & Delete the Uploaded image....
Video link : https://drive.google.com/file/d/158RCO_NaXUg9KWOKSX6_SQ5r0CYF40oK/view
For that I need to create Pop up box once user click on Edit butto... | stackexchange/codereview |
I was able to make an implementation to detect the OS.
I'm not sure if it works the way it should, so I asked this question
TargetOS.hpp
#ifndef TARGET_OS_HPP
#define TARGET_OS_HPP
#if defined(__unix__) \
|| defined(linux) \
|| defined(__unix) \
|| defined(__linux__) \
|| defined(__APPLE__) \
|| def... | stackexchange/codereview |
After failing to answer an interview question, I went back home and coded the answer for my own improvement.
The questions was: Given two arrays containing a number, but with each element of the array containing a digit of that number, calculate the sum and give it in the same format.There must be no leading zeros in ... | stackexchange/codereview |
I am learning tree on Leetcode. Need to prepare the testing data.
It is easy to convert the array to an organized node, where its elements are integers.
such as [3, 9, 20, 15, 7]
Here is my code:
extension Array where Element == Int{
func arrayToTree() -> TreeNode{
var nodes = [TreeNode]()
for num in 0..<self.... | stackexchange/codereview |
I have three primary tables:
Customer
Product
Order
Relations:
Many to many between product and order.
CREATE TABLE Customer (
CustomerId int NOT NULL AUTO_INCREMENT,
CustomerName varchar(50) NOT NULL,
CustomerMail varchar(50) NOT NULL,
CONSTRAINT Customer_pk PRIMARY KEY (CustomerId)
);
-- Table `... | stackexchange/codereview |
I am trying to write an REST API using php from scratch which I am gonna use to play with Angular.js. It is working fine now and I need your opinions on the things I have done in this code to improve myself.
NOTE: I am not going to use the below code in production and I am not recommending anyone. I am just trying to l... | stackexchange/codereview |
I'm learning Python & practising from this site and here is the particular problem at hand:
Return the "centered" average of an array of ints, which we'll say is the mean average of the values, except ignoring the largest and smallest values in the array. If there are multiple copies of the smallest value, ignore jus... | stackexchange/codereview |
I've been playing around with porting a simple strategy game over to Javascript, the idea being to run it in a browser for testing. I've done some simple Javascript code in the past, but this is my first model/view setup. I'd love to get feedback on following Javascript best practices and avoiding pitfalls. I know t... | stackexchange/codereview |
This is a personal project of mine. I am currently in the research phase of developing my own bootloader that will be used to load a single task operating system. I am far away from the final goal, but have been trying to document my process as a reference. The content of my code documentation and code can be found at... | stackexchange/codereview |
The Context
My daily workflow largely consists of producing, styling, and circulating plots from a dataset to my advisor and collaborators. We use the C++ framework ROOT to generate and store histograms and I am writing my code in Python to take advantage of its Python bindings (PyROOT).
Since a ROOT file is the funda... | stackexchange/codereview |
I just wanted to post my code to request for any improvement. Originally, I did NOT come up with this code, but rather I 'improved' it visually (i.e. not performance). This code originally had several if statements that I wanted to improvise with a dictionary.
In summary, this will generate a canvas named "c" that will... | stackexchange/codereview |
I want to force my compiler (C++ or perhaps CUDA) to unroll certain loops that it would rather not unroll. So, I've written the following:
template <size_t N> struct unroller {
template <typename ForwardIterator, typename Function>
static void unroll(const Function& f, ForwardIterator& it) {
unroll<N/2,... | stackexchange/codereview |
For the purposes of this code review, I will use the standard library, but pretend that <cstddef> is <stddef.h>, that I didn't use std::cout, that new and delete[] are overloaded and call custom malloc functions, etc. So this is -std=c++11 -ffreestanding.
Here are my questions:
Currently my tohex function returns a bu... | stackexchange/codereview |
I'm trying to optimize some VBA that I put together. I know that using Select a lot slows down performance quite a bit so I've been trying to cut that out where I can. Is there anything else in my code that I can change or do differently to improve performance? Thank you in advance!
Sub PP_Formatting_Saving()
Applica... | stackexchange/codereview |
I have written this code Floyd Cycle finding algorithm. The methods I have used are createLoop() , doesLoopExist(), lengthOfLoop() and insert().
I want to optimise this code and improve using advanced C++.
#include <iostream>
template <class T>
class LinkedList
{
struct Node
{
T data;
Node * next;
Node... | stackexchange/codereview |
I'm learning python and i'm trying to practice what I learned recently.
I wanted to make a quiz game using pandas.
What do you guys think? Is there anything I could do better?
import random
import pandas as pd
pd.options.mode.chained_assignment = None # default='warn'
"""We need one excel file(kerdesek.xlsx), then we... | stackexchange/codereview |
I am currently coding a PHP script that connects to a database and inserts a phone number and IP address if either item is not present in the table. I believe I have completed it and it is working but I want to make sure that I have used best practices in regards to security. I have read here about how to connect to My... | stackexchange/codereview |
For the sake of learning JavaScript better and getting used to the Google Chrome Extension API, I'm currently writing a little Chrome extension.
To keep things simple and being able to make use of prototypal inheritance, I decided to write a little instantiation/inheritance helper before I get started.
But as I am stil... | stackexchange/codereview |
I have written an n-body simulator, implementing the Barnes-Hut algorithm. Please comment on anything you can see wrong with this.
Wikipedia Barnes-Hut page
This is a screen shot of the simulation 20 hours in. All the particles spawn in a uniform disk, given an initial velocity in order to "orbit" the "Galactic center... | stackexchange/codereview |
I've been doing a lot of programs for classes that require a prompt from the program. I thought it would be much faster for me to rapidly test inputs if I didn't have to execute the program and then type the input once inside the program (as opposed to just hitting ↑ and adjusting the input that way).
My concern is thi... | stackexchange/codereview |
Can anyone help improve the performance of my query? When I run it, it locks the database for 5 to 10 minutes.
SELECT
u.username,
u.email,
u.created_at,
p.firstname,
p.lastname,
p.address,
p.address_2,
p.city,
p.country,
p.state,
p.zip,
p.phone,
p.phone_... | stackexchange/codereview |
Description
This is a utility algorithm that selects a number of elements from a source list without repeating elements.
Background
My use case is creating a random path for a NPC that has to investigate a zone (polygon) containing predetermined interest points. Different effects are triggered upon reaching a point: ac... | stackexchange/codereview |
This is a header file for my bezier curve utility and several of BezierCurve2D's methods return newly created arrays of Point2D objects.
Should I create (using new) and delete objects in the same scopes? Should I have these methods receive a pre-allocated space of Point2Ds?
#ifndef BEZIER_UTILITY_H
#define BEZIER_UTILI... | stackexchange/codereview |
Please ignore row "B. and C." as it works in the environment where it was implemented and is missing the JavaScript reference. The rows highlighted in light blue are the issue. I injected row "A." to calculate (addition) the input of the rows above it. I am appealing to experts who know how to better recognize loops... | stackexchange/codereview |
I don't really have any specific questions for this thread. I have been working on an independent project recently and have been learning everything from the web. Just yesterday I became aware of templating and the idea of separating business and presentational logic.
I would be very thankful for any comments regarding... | stackexchange/codereview |
Is there any reason NOT to wrap a long query over multiple line via new lines vs using concatenation?
For example, consider this:
$this->query("SELECT u.*, COALESCE(c2.name,u.state) AS real_state, c.name AS real_country, bc.alpha3 AS country_iso, bs.code AS state_iso
FROM " . MAIN_DB . ".users AS u
... | stackexchange/codereview |
I am developing code for a problem posted on StackOverflow.
I have written my solution in Java but it is taking too much time to execute for numbers such as 21432154197846387216432. How could I improve the performance of the following code?
import java.util.Scanner;
public class Main {
// private static final d... | stackexchange/codereview |
This is my first calculator in Java. I just started learning a week ago so any feedback (positive and negative) is welcome. Tell me what's good and what I can improve on.
import java.util.Scanner;
public class Calculator {
public static void main(String[] args) {
// Creates scanner object
Scanner... | stackexchange/codereview |
I have tried to achieve the following task using Factory Pattern with PHP version 7.0.
Define the classes and their methods (including parameters and return types) for a system that consist of a bookshelf,
books, magazines, and notebooks. The bookshelf should allow store and retrieval of the items as well as reporting... | stackexchange/codereview |
I recently started work on my own Async file input "library" in C++. I got it done today and I decided to put it on Code Review to see how well I actually did, and where I can still improve the code.
The log++ #include is just some logging header I created for writing colored output to the console.
EDIT: Since the time... | stackexchange/codereview |
Right now i have a WPF application supposed to display some media into a WPF Window, from actions in another WPF Window ( for example : you write text in a textbox, you click on a button, and the text is displayed in a textblock in the second Window ).
It's working even tho it is completely not optimized, and i would l... | stackexchange/codereview |
In my application I have an accounts model:
class Account < ActiveRecord::Base
belongs_to :user
has_many :invoices
end
The Account model belongs to the User model. After the user is created, some default accounts must be created:
class User < ActiveRecord::Base
has_many :accounts
after_create do
Account.c... | stackexchange/codereview |
The F# web-development framework Giraffe supports a functional style of Dependency Injection using a form of the Reader monad, as explained in this GitBook. I would like to use this pattern more generally, moving away from a service-locator pattern I use today in which my injection sites are coupled to the specific se... | stackexchange/codereview |
Now FizzBuzz itself isn't a big challenge but I agree that it can be a good tool to see if someone can code or not. I wanted to practice my LINQ a little bit so here's my single line FizzBuzz solution.
Enumerable.Range(1,100).Select(
n =>
(n % 15 == 0) ? "FizzBuzz" :
... | stackexchange/codereview |
This is a chat using Node.js, socket.io and MongoDB for storage.
I'd appreciate any feedback on what can be improved. I understand that this allows for non-unique usernames to be used, and it's currently a JavaScript prompt, however this is simply a demonstration for entering a username to test the functionality.
index... | stackexchange/codereview |
I built an easy inheritance implementation for JavScript that works similar to other OO languages and wanted some feedback on it. This works perfectly how I'd like it to, but I've read a lot of varying opinions about using __proto__ and was wondering if there's a better way to do this.
jsFiddle
/**
*
* Extensible Pro... | stackexchange/codereview |
I recently overhauled my solution to Project Euler Problem 23 (which asks for the sum of all positive integers which cannot be written as the sum of two abundant numbers) to move it from an imperative style to a functional style and tried to increase its speed. However, the performance is still slow. I have clocked thi... | stackexchange/codereview |
I wanted to practice functional programming (fp) without using any library but using vanilla JS only. So I took a problem from Project Euler:
The sum of the squares of the first ten natural numbers is,
12 + 22 + ... + 102 = 385
The square of the sum of the first ten natural numbers is,
(1 + 2 + ... + 10)2 = 552 = 3025... | stackexchange/codereview |
Sometimes I have the date as part of the file name. And then when Emacs autocompletes the file name, it puts the part of the date. In these situations I have to write the rest of the date manually. Here is a solution, so that I can press Super+d and the suffix of today's date is written in the buffer. For example, ... | stackexchange/codereview |
We are given a string which is compressed and we have to decompress it.
(a(bc2)d2)$
"$" indicates end of string.
(abcbcd2)$
abcbcdabcbcd (This is the final uncompressed string.)
My code:
import java.util.*;
class decompress
{
public static void main(String[] ar)
{
int end = 0, st = 0;
Scan... | stackexchange/codereview |
I've done a bit of modifications and finally got it working, and did a lot of reading about @ vs @@ vs just declaring and I came up with.
It goes to Steam's API to return information (JSON Format) based on the endpoint. A list of games they own, a list of games they recently played, profile information, etc.
class Stea... | stackexchange/codereview |
I am in the process of writing a Cloud application (mostly hobby, learning) that required a very quick cache, queue, and messaging system. I have looked at a few different options from Microsoft (hosting is on Azure) and all seem to be slow (for my relative needs). Then I hit Redis, and the speed was right where I need... | stackexchange/codereview |
The following code interweaves two linked lists together in three flavors: iterative, recursive top-down, and recursive bottom-up. My iterative solution feels like it can be optimized better and my bottom up recursive design skills are not necessarily the best (although this solution is a much smaller task than most re... | stackexchange/codereview |
I'm fairly new to Angular 2 and I started off with creating a clock for my app. I tried to stick to the official documentation tutorial.
Folder structure:
The CSS file is still empty and the HTML is not very spectacular:
<p>{{time | date:'HH:mm' }}</p>
The clock component itself looks like this:
import {Component} fr... | stackexchange/codereview |
I have written this PrimeFactorize utility method in C# (using LINQPad) which works fine, but feels like it is a bit slow, I was wondering what might be improved. Also looking for any criticism not related to efficiency to make the code better.
// Generate prime factors for a number, e.g., input 12 returns 2 2 3
public... | stackexchange/codereview |
I am solving problem GRAVITY on SPOJ. Each test case is a rectangular ASCII grid of dimensions m × n, and you have to determine whether it is possible to find a path from the 'S' square to the 'T' square, moving using the space squares and avoiding '#' obstacles, in at most O steps (diagonal steps allowed).
I am using ... | stackexchange/codereview |
What follows is an evaluator for a toy expression language. The language includes functions of a single variable (with lexical binding), along with numbers and a way to apply functions to expressions. For the sake of simplicity, bound variables are represented using De Bruijn indices.
The main questions I have are:
I ... | stackexchange/codereview |
Disclaimer
I've created this post not only for the code review, but rather because I think it would be helpful for the users of the CAEN V2718 module.
Problem description
I have a VME board (V2718) which may be used as a square form generator. To set the frequency and duty cycle user must specify three parameters :
Th... | stackexchange/codereview |
This is fairly simple, so I'm just looking for ideas on anything that can be cleaned up, places it can be extended, and suggestions regarding style/naming (I'm terrible at naming).
It allows you to write something like:
object TimerTest extends App {
import Timers._
val time: Long = TimeBlock { timer =... | stackexchange/codereview |
I have an array for an English sentence (enSentence) and for a German sentence (deSentence). Each value represents one word. I want to print every possible phrase pair (enPhrase and dePhrase), where no phrase contains more than maxhPhraseLength words. A phrase can consist of a single word, all words of the sentence, an... | stackexchange/codereview |
I wanted to make a feature rich string in C++. Similar to one in python.
I am using C++14.
I have not added much yet, I just want to get my code reviewed to ensure I am going the right way.
Features:
Negative indexing.(.at(-i)) (Slices coming soon)
Mutable string, no fixed length.
Can delete according to index.(.pop(i... | stackexchange/codereview |
I wrote this class today, but I am trying to figure out how to make it more accurate. I pass in seconds and multiply by 1000 to make it milliseconds, and the time does not line up. I need the ability to have multiple timers, so using timer_gettime(), which limits one clock per process, is not an option. Also note I bor... | stackexchange/codereview |
This code shows a table's records via JavaScript using a JsGrid file and can edit or delete by AJAX.
This is my topic How can I load rows in JsGrid table that got from php file?,
The problem I am not sure the data is secure during inserting and loading or not?
Is it really secure?
The names of PHP files are: newsConf, ... | stackexchange/codereview |
I am not really having any problems with this. I'm just wondering if anybody has any ideas for a path for me to look down for bettering this little FF turn-based style of game in my free time.
I know somebody is going to complain about my global variables and the fact that I am not using object-oriented programming, b... | stackexchange/codereview |
I am using an array_count_values function since I have translated the code from php to javascript and javascript does not have this function, but not sure on the performance of it. I'm sure it can be faster. It currently takes 50ms for 32000 iterations each time it is called.
I have one that returns a simple array:
fun... | stackexchange/codereview |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.