instruction_seed
stringlengths
71
95.1k
_source
stringclasses
1 value
I have an asynchronous controller. It is supposed to make a couple async calls then return combined data from then as one DTO. [HttpGet("[action]/{name}")] public async Task<CombinedDTO> GetSummonerData(string name) { SummonerEndPoint endPoint = new SummonerEndPoint(); SummonerDTO summonerData= await endPoint...
stackexchange/codereview
Background This is for an API and I'd like to use this Upsert action to take data from a request and only update the requested fields. I.e. These are partial updates and I will not update every field from a model in every request. A previous version from examples I was working through took the incoming data and updated...
stackexchange/codereview
The easiest way to explain this problem is to show these two test cases: assert solution('ABC') == ['A', 'B', 'C', 'AB', 'AC', 'BC', 'ABC'] assert solution('ABCD') == ['A', 'B', 'C', 'D', 'AB', 'AC', 'AD', 'BC', 'BD', 'CD', 'ABC', 'ABD', 'ACD', 'BCD', 'ABCD'] my solution is below: def subsolution(lst, length): re...
stackexchange/codereview
ActiveWindow is like the main container and below the subviews. Router trigger activewindow.render(options) then the switch operates. Is it fine to do that Or how bad is it? define('activewindowView', [ 'backbone', 'text!views/activewindowView/activewindowTemplate.html', 'ghostviewHunter', 'menuView', ...
stackexchange/codereview
This Program is a simple phonebook, user is given 3 choice, add a number to the phone book, dial a number or exit the program. Are there Any Improvements that i can make, either efficient or cleaning the code or something useful i can add? import java.util.ArrayList; import java.util.Scanner; public class PhoneBookV2 ...
stackexchange/codereview
I have a common issue that I face in my applications (because I don't know any better) and I want to improve. This is my usual structure: Project.UI (MVC Project) Project.BLL (Class Lib) Project.DAL (Class Lib) LinksConfigurationController public class LinksConfigurationController : BaseController { public async ...
stackexchange/codereview
I have created a simple implementation of the bubble sort algorithm. I have tried to make it as efficient as possible by following pseudocode which I have provided below, making some slight modifications to suit my needs. The pseudocode: procedure bubbleSort( A : list of sortable items ) n = length(A) repeat ...
stackexchange/codereview
I have implemented a QuadTree of my own, and I'm afraid I didn't use yield properly when I query my tree, my fear is that I create O(HN) iterators. Could you direct me how to better improve the performance of the following code? QuadTree public IEnumerable<T> Query(string leafId, Circle shape) { // Gets the...
stackexchange/codereview
Problem : A zero-indexed array A consisting of N different integers is given. The array contains all integers in the range [0..N−1]. Sets S[K] for 0 ≤ K < N are defined as follows: S[K] = { A[K], A[A[K]], A[A[A[K]]], ... }. Sets S[K] are finite for each K. Write a function that, given an array A consisting of N in...
stackexchange/codereview
After thoroughly profiling my program, I have been able to pinpoint that it is being slowed down by the vectorizer. I am working on text data, and two lines of simple tfidf unigram vectorization is taking up 99.2% of the total time the code takes to execute. I am extending the default TfidfVectorizer to add a stemmer. ...
stackexchange/codereview
I made a simple BlackJack game and I want to make it as good as possible before I move on to creating a few other games in my "casino" - let me know how I can improve it I added a few things here and there if you are interested my GitHub for this project is linked: https://github.com/sharoika/CasinoGames main.cpp : // ...
stackexchange/codereview
Recently I am working on batch to make a very simple command line interface. The code looks like this: @echo off echo Simple command-line interface echo. :input.get set /p input="COMMAND\>" set input5=%input:~0,5% if "%input%"=="something" goto something if "%input5%"=="echo " goto echo :echo set content=%input:~5% ec...
stackexchange/codereview
Here is my code: defmodule LineScanner do @spec scan(String.t()) :: [Token.t()] def scan(line) when is_binary(line), do: scan_(line, {[], ""}) |> Enum.reverse() ### The function below needs some refactoring ###### @spec scan_(String.t(), {[Token.t()], binary()}) :: [Token.t()] def scan_(line, {acc, ...
stackexchange/codereview
I created some functionality for JavaScript datepicker. I'm trying to store a value in the datepicker with the selected month along with which half it is. To do this, I wrote if/else statements to account for every month. Among the rules I noted were: 28 days - February 30 days - April, June, September, November 31 da...
stackexchange/codereview
Oftentimes people will shorten System.out to just out and make an analog called in (e.g. Scanner in = new Scanner(System.in);). I've seen two methods of doing this Method 1: import static java.lang.System.out; Method 2: static final PrintStream out = System.out; Is there a coding convention or best practices for this? ...
stackexchange/codereview
I was just playing around with some code and had the idea about writing some kind of ostream manipulator to delay the output of characters in a typewriter like style. The focus was mostly on how to use it and was inspired by std::fixed or std::setprecision. Overall it works pretty well. I just want to make sure that I ...
stackexchange/codereview
I have 2 sheets setup: Exclusions and Issues Issues has a list of CASE ID's and Columns that list the "Issue" Exclusions will be populated with CASE ID's that are to be excluded (and removed) from the Issues sheet. My question is 2 fold: Is my current code handling this correctly? Are there any ways to improve this? I...
stackexchange/codereview
I have created like this validator for reactive form, all working but I think I used so many statements, can somebody help me to make proper validation Here is my validator export function validateIfOneIsRequired(): ValidatorFn { return function validateIfOneIsRequired(formGroup: FormGroup) { const startTime = fo...
stackexchange/codereview
I have this function that allows the user to supply a number and that many rows are appended to the existing table: $('#add-row').click(function() { if($('#insert-rows-amnt').val() < 1) { alert('Please enter number of rows to insert'); } else { for(i = 1; i <= $('#insert-rows-amnt').val(); i++) ...
stackexchange/codereview
I have a class which inserts a list of tweets to a database table and also inserts the tweet's key with the associated filter's key to a many-to-many table. I am testing the sole public method of this class: class TweetByFilterDatabaseRepository { private final DatabaseFacade database; private final Mapper<Tw...
stackexchange/codereview
I've been learning Processing for the last week or two, and I've made a couple of little 'desktop toy' type apps like this one that I'm quite pleased with. However, it just occurred to me today to look at the activity monitor while my app was running, and I was unpleasantly surprised – nobody wants a desktop toy that's...
stackexchange/codereview
I've the following code working on stackblitz editor as shown in this URL. Right now I have only 2 tabs. Let's say if in future I have 20 tabs, I don't want to have 20 different this.initGrid(); for each tabs.Is it possible to create a separate file for first tab(something like firsttab.tsx) , the functionality is defi...
stackexchange/codereview
I was bored the other day and wrote the following little script to attempt to find insecure passwords for WordPress blog owners so they could be notified of how easy it would be to crack their WP admin password. I am mainly a Perl/PHP developer, so I want to make sure any Python work I do sticks to being Pythonic and n...
stackexchange/codereview
The app is functioning but I am not sure if I have done it properly. The code is present in my GitHub repository. The demo can be viewed here. In this application a user can search for anything in a location of choice. I have used Foursquare (used for getting search results) and the Google Maps API (used for getting lo...
stackexchange/codereview
I wonder if I should divide this class into two, since it contains two "ifs" with different messages. Would breaking it down be in keeping with the "S" of SOLID? internal class ValidDateApuration : IBusineeOfValidation<DtoFormGnre> { public MessageValidation Validar(DtoFormGnre obj) { var paymentDate = ...
stackexchange/codereview
I seem to be in a love-hate relationship with C++. It can make some parts of your code elegant and easy to grasp, and some others become an inconceivable mess. And it's not the language itself causing the problem, but the allure of some language constructs which can lead to many headaches in the long run. I have a coll...
stackexchange/codereview
I've been working on a regex-based UK postcode validation and format correction tool - with the aim of creating a list of postcodes that can be readily geocoded. The variety of postcode formats is explained here. I have based my regex on a discussion here. My correction tool is designed to cope with a number of commonl...
stackexchange/codereview
I'm creating a trip calculator that has some basic arithmetic and I'm just not grasping how to handle calculations. I feel like I'm doing a bunch of stuff wrong here. What initial values should I have in state? Am I putting too much in state? Is state saving these as numbers or strings? I included some commented out co...
stackexchange/codereview
Goal In the vector x, I would like to insert the elements of the vector values at indices stored in vector positions. Note that the vector positions is not sorted. For example, from the following input std::vector<char> x = {'H','e','l','l','W','o','l','d'}; std::vector<char> values = {'r','o'}; std::vector<size_t> pos...
stackexchange/codereview
My experience in bash is... well, around the Bourne shell on AIX. I wrote a semi-complex script in Bash, and I feel that it could be improved in 100 different ways. The Github project is here: https://github.com/mercmobily/lapser Questions: Does anything stand out in terms of things done horribly wrong, in any way? In...
stackexchange/codereview
This is a question about best practices. I have a project I am building and I have the following base Exception class: Namespace Project; class Exception extends \Exception{ //=============== BASE EXCEPTIONS 0 - 1000 ===============// /** * placeholder for unknown exeptions - the default type * @var...
stackexchange/codereview
I created this observable storage thing in JavaScript (partly for fun, but also because it came in handy and got bigger without me noticing it). The repository can be found here. (function(window, undefined){ "use strict"; var eagle = window.eagle = (function() { var storage = { feathers :...
stackexchange/codereview
Given two numbers L and R, find the highest occurring digit in the prime numbers present between L and R (both inclusive). If multiple digits have the same highest frequency print the largest of them. If there are no prime no.s between L and R, print -1. How can I optimize this code further in terms of running ...
stackexchange/codereview
I am doing a project in plant pest detection using CNN. There are four classes each having about 1400 images. While training the model using Convolution Neural Network, there is a smooth curve for training while for validation there lots of ups and downs in high range. After that,I start using alexnet architecture of C...
stackexchange/codereview
Code is a countdown timer. Should I keep this update function separate as is or can I save 3 lines of code and embed this.setState({newDeadline: event.target.value}) directly in the callback function below? eg. onChange={event => this.setState({newDeadline: event.target.value}} import React, { Component } from 'react'...
stackexchange/codereview
I have a function to filter a 2-d array. It works. But I am not sure if the following mechanism is a sensible concept. The idea is: loop over the input array which is received as input_arr(y,x) store the values in temp_arr(x,y), since in order to resize the y-dimension it needs to be last dimension, so I have to tran...
stackexchange/codereview
I've written this class as an exercise for a synchronization construct to be used across multiple threads. The intent is to have worker threads Increment() it, do some work, then finally Decrement()it. Meanwhile, when a master thread decides to shut down the program, it signals the threads using a CancellationToken and...
stackexchange/codereview
Is it? And maybe theres a better way to do this? $allowed = array("name_desc", "name_asc", "level_desc", "level_asc", "vocation_desc", "vocation_asc"); $order = isset($_GET['order']) ? $_GET['order'] : "name"; $order = in_array($order, $allowed) ? str_replace("_", " ", $order) : "name"; $query = "SELECT * FROM player...
stackexchange/codereview
I have made this small quiz with 10 question and 40 JRadioButtons. One question and 4 JRadionButtons for each panel. So I had to create an array of JRadioButtons and JPanels, and for all I need to call setText. Can this project be done with only four JRadioButtons, so when someone clicks on next question, the radio but...
stackexchange/codereview
So I've implemented the suggestions in Original question And now my code looks like this: <?php require 'init.php'; $Email = $input['Email'] = trim(filter_input(INPUT_POST, 'Email')); $Password = filter_input(INPUT_POST, 'Password'); $result = $db->execute_query("SELECT 1 FROM Users WHERE Email = ? && Password = ?", [...
stackexchange/codereview
I'm learning F# and for an exercise, I took a roslyn analyzer in C# and ported it to F#. In the excerpt below the GetParameterInfo function: takes in ArgumentSyntax which describes an argument passed to a C# method at an invocation site. And finds the corresponding IParameterSymbol which describes the method's param...
stackexchange/codereview
I'm building a clone banking app at the moment, and one of the things I'm trying to do is add Split Transaction (which can then be shared with a set of friends paying a given amount each). Initially, the transaction is split equally amongst friends (unless it doesn't split equally, in which case the remainder gets adde...
stackexchange/codereview
I'm trying to calculate speed between consecutive timepoints given data that is in a '.csv' file with the following columns: "Time Elapsed", "x", and "y". The ultimate goal is to get the data into a format where I can plot "Time Elapsed" vs. "speed" I'm fairly sure that my implementation is doing what I want, but it's ...
stackexchange/codereview
I've a sample code to create a simple menubar here which works, but I'm not sure if that's the best way to code it. Can somebody please validate if there is a better way to do the same? In short I've create a sample page with a directive called <menu-bar> <menu-bar></menu-bar> The directive merely points to a templa...
stackexchange/codereview
I have implemented generic doubly-linked list class, which supports IEnumerable<T>,IEnumerator<T> interfaces. DoublyLinkedList<T> is fully compatible with standart BCL classes. Targets: class can be used as a standard replacement for Stack<T>, Queue<T> and List<T>. class itself is immutable, so you can-not change the ...
stackexchange/codereview
I have done the supermarket pricing kata in TDD style and I would appreciate it if someone could review it for me. Kata: "...checkout that calculates the total price of a number of items. In a normal supermarket, things are identified using Stock Keeping Units, or SKUs. In our store, we’ll use individual letters o...
stackexchange/codereview
I've written a simple JavaScript function to find numbers that contain both the attributes of a Triangle (\$ n(n+1)/2 = x \$) and a Square (\$ n^2 = x \$) number. The challenge was given in Matt Parker's Things to Make and Do in the Fourth Dimension. function main() { for (var i = 1; i < 1000000; i++) { var trian...
stackexchange/codereview
Here is a naive version of a singly linked list in Java. It implements only Collection and Iterable interfaces. Any comments and suggestions are welcome. SinglyLinkedList.java: package com.ciaoshen.thinkinjava.newchapter17; import java.util.*; public class SinglyLinkedList<E> implements Collection<E>, Iterable<E> { ...
stackexchange/codereview
The idea is that the TUI struct handles what gets printed to the terminal (I will make it pretty in the future, right now I'm just building its core functionalities) and for processing input. It's what interfaces with the TaskManager struct, which stores, adds, removes, and modifies tasks. Here are the Task and TaskMan...
stackexchange/codereview
I'd like to know if the following code is a good implementation of MergeSort? I tried some examples and the code was right, so I guess that the algorithm works correctly. public static int[] myMerge (int[] array, int[] array2){ int[] giveback = new int[array.length + array2.length]; int i = 0; int j = 0; ...
stackexchange/codereview
I'm a beginner. This is my implementation of binary search algorithm in Python. Please review my code and give your valuable inputs for further improvements on overall coding style, rare cases etc. def binary_search(arr,value): left = 0 right = len(arr) - 1 while(left <= right): mid = (left + right)...
stackexchange/codereview
Hello StackExchange community, I am curious if there is a better solution than mine for this exercise below: Enter a regex that matches all the items in the first column (positive examples) but none of those in the second (negative examples). Positive Examples: pit spot spate slap two respite Negative Examples: pt Pot...
stackexchange/codereview
I have a list of dictionary let's say : l=[{'a':1,'b':2},{'a':5,'b':6},{'a':3,'b':2}] and I want to have another list l2 and add 4 to the 'a' in the all dictionaries l2=[{'a':5,'b':2},{'a':9,'b':6},{'a':7,'b':2}] (the first list l shouldn't change) so I am doing it this way but i feel there is better, it is a bit hard ...
stackexchange/codereview
I'm currently writing a game and want to encode everything that happens (GameObject has moved, hp changed, was created/destroyed, got/lost a component, ...) in Events that look like this: class HpChangedEvent : IEvent { public int GameObjectId; public int NewHp; } I hope that will make it easier to network the...
stackexchange/codereview
In my .net core hosted service console application, I am reading a database table, retrieving some values, and based on a status, I am sending emails. It is working as it is expected, I wonder if there are any improvements to make it better. So I would be glad if you can share your comments. Thanks in advance. Program....
stackexchange/codereview
I sometimes find myself using multiple expressions checking on a single flag to control the state of some template, in this example, a Facebook log in button. On a second look, however, I noticed this pattern might bear a significant performance drawback for making Angular have to update the DOM in multiple places ever...
stackexchange/codereview
I am looking for a simpler implementation of the following question. Could it get better? I am expecting the new solution via DFS again. Thanks. OA: Given a 2d matrix with chars and a target string. Check if the matrix contains this target string by only going right or down each time from the beginning point. public cl...
stackexchange/codereview
I have written this script that downloads two tables from the db, preforms an intersection on them and adds 2 new columns to the resulting table, and uploads the resulting table to the db. It's a bit slow and I realize my code is messy (I'm new to Python and GIS). I suspect more steps can be done in parallel, for examp...
stackexchange/codereview
I'm designing a table cell based map design for a little game I'm building, and I was hoping I could get some cleanup pointers or design tips to "perfect" my engine's design. Basically, in the end result, you'll walk around the map one tile at a time. On any visible tile you can walk to it, but only the tile you're on ...
stackexchange/codereview
not too experienced with SQL, wondering if I can make this better... I am trying to check if a row exists and then add one to the frequency column if it does, if it does not exist it should return false... The table is indexed by the column in the first select statement I know about the risks of using formatting with p...
stackexchange/codereview
I'd like to practice oojs so I've written code: function Randoms(c, l, h) { var count = c, min = l, max = h, nums = Array(), self = this; //returns random number from given max and min var getRand = function () { return Math.floor(Math.random() * (max - min) + min); ...
stackexchange/codereview
I'm updating a solution that I wrote a while ago. I've got a WinForm that does Update/Insert/Delete on a particular database table. I've got all of the database access code in the form. Is this bad practise? On the one hand, I know you should separate presentation and data access. Also, it would make unit testing easie...
stackexchange/codereview
I'm looking to create a library that extends kotlinx.html and will include functions that have default css classes. The goal is to be able to use a function row{} instead of having to type div(classes = "row"){} each time. I would like to create these functions for a lot more commonly used Bootstrap classes. In my ex...
stackexchange/codereview
This is my version of a linked list in C. The function mergeSort requires a reference to the first and to the last nodes, as well as the indices of the first and the last node and a comparator. You need to compile this source code using C99 standard in order to get it working. #include <stdio.h> #include <stdlib.h> ty...
stackexchange/codereview
What my code do: Connecting to 30 DB (consistently) Copying DB file to temp.dat Reading temp.dat Writing read data to file So, it connects 30 times with different databases. This take 6-7 second (on a powerful notebook), but if I run this code on notebook / PC with low hardware specifications these take more than 20...
stackexchange/codereview
I posted some code as part of an answer to another question and I thought it would be a good idea to get that code reviewed also. Any comments are welcomed, but I am mostly annoyed by terminalNode. It is basically a slightly convenient factory method, but I think it should either be renamed to something more enlighten...
stackexchange/codereview
I have a grid and a class Vehicle, which will have starting point(X, Y on the grid) and direction(one of N,E,S,W) taken from user and there will be commands, L & R turns the vehicle 90 degrees around left and right respectively and M moves the vehicle one unit to faced direction. For instance, if the command is M and...
stackexchange/codereview
I have this Sundaram's sieve to generate prime numbers up to limit in Common Lisp. (defun sundaram-sieve (limit) (let ((numbers (range 3 (+ limit 1) 2)) (half (/ limit 2)) (start 4)) (dolist (step (range 3 (+ limit 1) 2)) (dolist (i (range start half step)) (setf (nth (- i 1) numbers...
stackexchange/codereview
Can someone review this code, just have look if it's logically correct or If you may point me to a more simple and minimalist program import java.util.ArrayList; import java.util.Arrays; import java.util.PriorityQueue; import java.util.Queue; /** * Created by aishwat on 17/8/16. */ public class PrimsMST { publ...
stackexchange/codereview
I am trying to grab the ffprobe values from the video file into a variable that I can compare against others or move the value into a database. The question I have; Is there a better way of doing it than below? I don't like the multiple if/elif/line.startswith statements and I am not sure of split is the best way of ge...
stackexchange/codereview
I have this sample data: let trips = [ { from: "DEN", to: "JFK" }, { from: "SEA", to: "DEN" }, { from: 'JFK', to: 'SEA' }, ]; and my origin is 'JFK', I want to sort the list by how I have traveled. So for instance, this should be the end result: let trips = [ { from: 'JFK', ...
stackexchange/codereview
This is an implementation to simulate the basic functionality of c++ shared_ptr. This doesn't provide features like custom deleter and make_shared(). I would really appreciate any feedback to improve the below code, any other api's that I should be providing etc. #ifndef SHARED_PTR_H_ #define SHARED_PTR_H_ #include <u...
stackexchange/codereview
There is a Unity EventManager class from Unity tutorial that allows events to be registered, unregistered and invoked. The bad side of that EventManager code is that it uses UnityEvent which is slow and it does not take parameter. I decided to rewrite it with Action from C# instead of Unity's UnityEvent and also added...
stackexchange/codereview
I have created a PHP to change the user's login password: <?php require_once('Connections/conexion.php'); ?> <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { if (PHP_VERSION < 6) { $theValue = get_magic_quotes_gp...
stackexchange/codereview
I have binary files containing sparse matrices. Their format is: number of rows int length of a row int column index int value float Reading each row with a single struct call instead of looping through each row with single struct calls gave me roughly a 2-fold speedup. I'm parsing 1 GB sized matri...
stackexchange/codereview
I'm working on a parser library for substituting strings in dictionaries, with things like globals etc. Wanting to get opinions on the direction I'm taking and where I can improve the script. This currently works class DictParser(object): def __init__(self, dictionary): self.working_dict = dictionary d...
stackexchange/codereview
I have a script that contains functions from login in to posting status to friend request send and receive. Pretty much a social network script. Anyways i think my security is not up to date so if anyone can check my code out or review it live on the web: iphone.hostei.com. email is demo@demo.com and password is demo12...
stackexchange/codereview
This is a follow on to a previous question: Part 3: User Scripts All the code I am submitting here is available in github The reason to write these tools is so I can prototype and quickly verify that I am doing things correctly before implementing them in C++. This is mainly necessary because the documentation these s...
stackexchange/codereview
I am asked to implement the following part of code into kernel code. Actually, I have tried but not sure about the std::array. This is the original code for the function. int KNN_classifier(array<array<int, 20>, 4344>& array_X_train, array<int, 4344>& array_Y_train, int k, array<int, 20>& data_point) { // Cal...
stackexchange/codereview
I wrote the following function to convert List[Int] => List[List[Int]]. Its intended purpose is to extract 1, followed by its non 1 followers, into a group. input: List(1,2,2,1,3,3) output: List( List(1,2,2), List(1,3,3) ) Function def leadingOnesGroup(xs: List[Int]): List[List[Int]] = xs match { ca...
stackexchange/codereview
I'm an EE student who's taken a a couple digital logic/design courses, but they were focused on schematic representation, so I'm teaching myself Verilog to implement what I've learned. For a basic Hello World project, I've implemented a basic 8-bit ALU with addition/subtraction with carry/borrow, NOT, AND, OR, XOR, and...
stackexchange/codereview
I have started learning Java recently and was looking into the challenges on sorting on Hackerrank.I solved the following problemHackerrank on Insertion Sort. The challenge was : In Insertion Sort Part 1, you sorted one element into an array. Using the same approach repeatedly, can you sort an entire unsorted array? G...
stackexchange/codereview
EDIT: The result looks like this: http://gomokuu.glitch.me/ This is my code for gomoku. I made it with JavaScript and HTML. I think the checkWinner function can be improved or made shorter. Also, should the functions be re-organized? Here is the code: Javascript: var turn = 0; var width = 15; var height = 15; var game...
stackexchange/codereview
This code extract data from generic mailbox mapped by MS Outlook I failed at recursive iteration in subfolders, so it stays as iterative one. Added ASCII encoding to deal with crazy national symbols in body/subjects. My main target is to ensure scalablity and prevent it being slow (iteration over 100 generic mailboxes)...
stackexchange/codereview
This is a follow up to this post I uploaded a few days back on my alternative account about a circular buffer in C. I'm confident that I fixed most of the warnings and even added an iterator. circularBuffer.h #ifndef CIRCULAR_BUFFER_H #define CIRCULAR_BUFFER_H #include <stddef.h> // max_align_t in source struct cir...
stackexchange/codereview
I have written the following utility, as my first non-tutorial program in Go. The purpose of the utility is to connect to a torque/force sensor (aka load-cell) via UDP; to send an initialization command; and to record the resulting stream of measurements. Since I am planning further functionality (setting duty cycle ...
stackexchange/codereview
This is Conway's Game of Life written in Python and using Tkinter for GUI. Problems are: The "Play" button works so slowly. I can see how the canvas is redrawing from top to bottom. But when I quickly click on the "step" button - I see that I want to get from "play" button: I don't see redrawing process. How can I mak...
stackexchange/codereview
Problem Statement Generate as many distinct primes P such that reverse (P) is also prime and is not equal to P. Output: Print per line one integer( ≤ 1015 ). Don't print more than 106 integers in all. Scoring: Let N = correct outputs. M= incorrect outputs. Your score will be max(0,N-M). Note: Only one of P a...
stackexchange/codereview
I tried to implement an immutable list. public class ImmutableList<T> : IEnumerable<T> { public T Head { get; set; } public ImmutableList<T> Tail { get; set; } protected ImmutableList() { } public static ImmutableList<T> WithItems(IEnumerable<T> items) { if (items.Count() == 1) ...
stackexchange/codereview
Problem Have the function ChessboardTraveling(str) read str which will be a string consisting of the location of a space on a standard 8x8 chessboard with no pieces on the board along with another space on the chessboard. The structure of str will be the following: \$(x,y)(a,b)\$ where \$(x, y)\$ represents the p...
stackexchange/codereview
I created a function to test whether a single word string can be a rearranged into a palindrome (doesn't have to be a real word). My logic was if the string has an even number of letters, then each letter must occur twice. If the string has an odd number of letters, each letter must occur twice except for one. functio...
stackexchange/codereview
I am making a website using just HTML and CSS for a classroom project (we are in the 2nd week of boot-camp.) I have my site made, and want to get others' opinion on the code. I am mostly looking to have the site scale properly on different browsers, but other input is appreciated as well. body { font-family: 'Ant...
stackexchange/codereview
Banknotes are given specifically 100, 50, 20, 10, 5, 2, 1. Required to check and find out: What is the maximum possibility to keep these individually into the given integer value. For example: input: 576 output: 576 5 nota(s) de R$ 100,00 1 nota(s) de R$ 50,00 1 nota(s) de R$ 20,00 0 not...
stackexchange/codereview
The task is writing a function, which checks if a string contains only unique characters. Means: is each character is included only one time. Here's the solution, I have developed: func areAllLettersUnique(_ str: String) -> Bool { let arr = str.split(separator: "") for (i, chr) in arr.enumerated() { if ...
stackexchange/codereview
The following makefile builds my classwork for my various college classes and builds pdfs to hold the notes I took during class. I would like feedback on my directory structure and any optimizations that can be thought of to help improve it. I've been using and updating it for the past 18 months. I know that I should p...
stackexchange/codereview
I recently decided to try my hand at this problem of calculating the number of days between two given dates including leap years in the calculation. I chose to do it in C++ as it is the language I feel most comfortable with and was wondering about the quality of my code. #include <iostream> #include <vector> #include <...
stackexchange/codereview
I'd love to get a review of my code, which I've already submitted as homework. I'd like some guidance as to how to write it more DRY-ly: I wrote the whole round, sqrt and exponentiation twice — how could I write it only once? Ideally I'd want to do it within the same function, it'd be a little ugly to write a function ...
stackexchange/codereview
This code is a proof-of-concept which I intend to convert into a static utility / helper class. I'm looking at this review from a structure or performance viewpoint. Small detail such as whether it prints or returns something, or whether the output is well-formatted, don't concern me too much. The purpose of this code ...
stackexchange/codereview
Ruby's Fixnum and Bignum can hold very large integers and automatically handle overflow. I decided to implement BitArray using an integer as storage. Please let me know what you think about code and functionality of a BitArray. class BitArray include Enumerable def initialize size @size = size @field = 2**...
stackexchange/codereview
I implemented the iterative randomized depth-first search, with my goal for it to be performant, and have code that made complete sense. It utilizes AtomicReference<T> inside of Cell to keep track of it's walls (as multiple cells can share walls). The randomization does not utilize Java 8 streams at all. AdjacentDirec...
stackexchange/codereview