instruction_seed
stringlengths
71
95.1k
_source
stringclasses
1 value
Given such a structure the output should be 10->5->12->7->11->4->20->13->17->6->2->16->9->8->3->19->15. Given a linked list where in addition to the next pointer, each node has a child pointer, which may or may not point to a separate list. These child lists may have one or more children of their own, and so ...
stackexchange/codereview
I had to write some code that receives a number 'x' and an alternately sorted array (an array with all even indexes sorted upwards and all odd indexes sorted downwards) and checks if 'x' exists in the array. If it exists, the method will return the index, if not, the method will return -1. If there is more than one 'x...
stackexchange/codereview
Factorio is a game about building factories and about automation. Items can be crafted (just like Minecraft) yourself, or crafted automatically by assembling machines. To help me expand my factories I created a little script in Python 3 that shows me what other items that I can produce once I create factory of an item....
stackexchange/codereview
I've been playing around with 8051 assembly lately and thought I would make a little project of implementing RC4, since it is pretty interesting and the algorithm doesn't seem too hard. Plus, taking mod 256 is REALLY easy when you're only working with single bytes. Below I've included my (hopefully well-commented) code...
stackexchange/codereview
I have a function that looks like this: def getMaxUserLevelByUserId(userId: Muid)( implicit connection: Connection): Option[OrganizationMembership.Level.Value] = { val organizationMemberships = getAllByUserId(userId) if (organizationMemberships.exists(_.level == OrganizationMembership.Level.Admin)) { ...
stackexchange/codereview
I want my application to support multiple UI-languages (aka i18n). To do so, I have built the static class below, to automatically translate the form and all its contents to the desired language. It looks into a resource file for the user's Culture, and replaces the .Text properties of the controls with the strings it ...
stackexchange/codereview
Here's a program I wrote to convert numbers into English words using Haskell. import Data.Char import Data.List type WordNum = String ones :: (Integral a, Show a) => a -> WordNum ones 1 = "one" ones 2 = "two" ones 3 = "three" ones 4 = "four" ones 5 = "five" ones 6 = "six" ones 7 = "seven" ones 8 = "eight" ones 9 = "n...
stackexchange/codereview
As I'm working with a proprietary programming language in my daily job, my java skills unfortunately missed out. In order to change this I am currently working on a minesweeper clone. So far, I have finished the basic implementation (business logic and command line view). The next step will be a graphical user interfac...
stackexchange/codereview
I am given a task to create a function that prints a random anagram of a given string: def anagram(value): '''Prints random anagram of given value''' import random newWord = '' for i in range(len(value)): pos = random.randint(0, len(value)-1) newWord += value[pos] value = value[:...
stackexchange/codereview
I have multiple models which all have the same functions in my framework. I decided to create one "parent" model and all of my other models would extend and inherit its functions like this. My other models would be like this: class Games_model extends MY_Model { protected $table = 'games'; protected $_default_...
stackexchange/codereview
Please take a look at this class and point out its flaws. I am developing a simple Finite Element Method analysis with PHP. What this class basically does: Given an input set (coordinates, properties, plane type), calculate an output/analysis set (area, matrix, etc.). Possible hints on flaws: This is a full static cl...
stackexchange/codereview
I am new to C++, learning from the book primer C++ The exercise: Write a program to read strings from standard input looking for duplicated words. The program should find places in the input where one word is followed immediately by itself. Keep track of the largest number of times a single repetition occurs and whi...
stackexchange/codereview
This is the third iteration of my reCAPTCHA validator. Iteration II can be found at: Google reCAPTCHA Validator: Iteration II It does almost everything required to do reCAPTCHA validation on anything .NET. I removed all the XML docs to shorten it up a bit. GitHub commit of the version in this thread (with all the docs ...
stackexchange/codereview
I have a simple form validation script. Could you tell me how I can improve this script (mainly regarding security)? HTML page <form name="input_form" action="process_form.php" method="post"> <p> <label for="name">Name</label> <input type="text" name="name" id="name" maxlength="25" /> </p> <p> ...
stackexchange/codereview
I'm making a robot with Raspberry. My goal is: Code a server on Rasbperry using Python that captures the image from camera and sends data via socket Code a client on PC using Java that reads data from socket and show it in a JavaSwing window So I can see in real time what the Raspberry Camera see. I tried this code f...
stackexchange/codereview
I've ported some standard library facilities like vector, algorithm, etc. to my kernel so I can code in C++ instead of C. This is one of them. I'm looking for concerns regarding: Performance Safety Friendly interface Perhaps there are more idiomatic ways to accomplish what I'm going for? #ifndef _LIBCPP_STRING_H_ #de...
stackexchange/codereview
Here is my problem: Return the number of times that the string code appears anywhere in the given string, except we'll accept any letter for the d, so cope and cooe count. I solved it by creating a list with all 26 possible co_e combinations and then used two for loops to iterate through the list and search for match...
stackexchange/codereview
While trying to understand monad transformers in Haskell I came up with a sudoku solver based on a combination of the ST and Reader monad. I am positively surprised with the performance, however solving particularly difficult sudokus still takes about 3 - 4 seconds on my computer while using the same strategy in Java t...
stackexchange/codereview
I have a number of enumerables, and I want to randomly pick one value from one of the enumerables so that each value has a certain weight in the randomisation process. This is simplification of my current code: private enum ActionPlan //Just an example, there can be many different enums { DoNothing, Eat, St...
stackexchange/codereview
For some reason or another, I want to have available unsigned integers of sizes other than 1, 2, 4 and 8 (e.g. an unsigned integer with 3 bytes). For most platforms, compilers don't make those available; so - I rolled my own. Other than asking for a general review, I will also pose a few specific questions / requests f...
stackexchange/codereview
I had a lot of fun writing these. I haven't seen a version minimizing turns, so that was a neat challenge. Any suggestions are very welcome. Is there anything to gain by making more method variables like those in the search() method; visited or open_pos into instance variables? I would like to have something returned ...
stackexchange/codereview
I often receive Excel worksheets (with empty rows) which I have to process as a pivot table. Because pivot tables don't allow empty rows, I've made this script. Any feedback is welcomed. ' Removes empty rows from an sheet. Public Sub RemoveEmptyLines() Dim lastRow As Long Dim currentRow As Long Dim emptyLine As ...
stackexchange/codereview
I have created a named function with signature PadInternal(base, width, paddingStr) where: base is a string you want to add padding to width is the length of the individual chunks paddingStr is the string to pad with called from a cell like: PadInternal("Hello", 1, " ") = "H e l l o" PadInternal("World", 3, "**") = ...
stackexchange/codereview
Parallism is achieved by using a simple call to tbb::parallel_invoke(). However I can't break a speedup factor of x2 (after ~3-4 parallel HW threads), although 8 parallel HW threads are used. Advice on this is highly appreciated. template<class In> void insertion_sort(In b, In e) { // pretty standard insertion sort for...
stackexchange/codereview
Rate my code and tell its quality like how well its formatted and all. I want to see how well its written. I have recently started learning Java. so some suggestions will also be appreciated. package e.banksolutions; import java.util.Scanner; import java.util.Random; import java.util.Date; public class EBankSolution...
stackexchange/codereview
Discussion I just started learning about Merkle Trees and wanted to get some practice by attempting to implement a very simple Merkle Tree. The constructor for the tree takes some type of hash function, and an array of byte[] values that represent the "leaf" node values. I construct a tree by first hashing the leaf nod...
stackexchange/codereview
One of my first projects. I present to you - Android Flashlight app! public class MainActivity extends AppCompatActivity { Camera cam = null; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } ...
stackexchange/codereview
This is a snippet of code written in Python 3.9 to implement the concept of "enum unions": an enum made up of several sub-enums whose set of members is the union of the sub-enums' members. This aims to be fully compatible with the standard library enum. Up-to-date code with some documentation can be found here. Usage a...
stackexchange/codereview
Trying out gRPC for the first time in a few years and looking for some feedback on the simplest of the APIs, since no one is currently using it extensively at my company and will end up pioneering its use. The API is for managing groups, i.e. you have users with UIDs and groups with GIDs. A user can belong to any numbe...
stackexchange/codereview
This is my second attempt to solve this problem, my first attempt is here: UVA 100: "The 3n + 1 problem" This time I tried to take lessons from the failures and mistakes You pointed out in my first attempt. I resigned from packing multiple statements in one line. (This resulted in the code length balooning, though :( ...
stackexchange/codereview
I just wanted to get some criticism on my programming to make me better. I made a game in Unity, just a simple question and answer game. Demo using UnityEngine; using UnityEngine.UI; using System.Collections.Generic; using System.Collections; using System.Linq; using UnityEditor.VersionControl; using System.Threading; ...
stackexchange/codereview
The following code takes a string and converts it to it's number equivalent. A=1 ... Z=26, while keeping all other characters intact. It formats the string using two delimiters. One for between characters and one for between words. I want to optimize it, and have fixed a lot of redundancy, and slow parts. However, I ca...
stackexchange/codereview
I find myself frequently converting between formats, so I have come up with the following conversion framework. The converter interface surfaces a method to convert from a source type to a target type. public interface IConverter<in TSource, out TTarget> { TTarget Convert(TSource source); } The factory is for prod...
stackexchange/codereview
I am trying to use Two Step View pattern in WPF. The problem is about keeping things in sync – I need a way to data-bind models to view models. Are there any good existing solutions? My approach is to introduce Property<T> to be used this way: public abstract class TextField : ObservableObject { public Property<boo...
stackexchange/codereview
I am trying to solve running median problem in hackerrank https://www.hackerrank.com/challenges/ctci-find-the-running-median and below is my code public class Solution { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); MinHeap minHeap = new ...
stackexchange/codereview
This is a school assignment, it's the longest program I've wrote this far, and I feel it's a bit messy and all over the place. I will try to translate the assignment to the best I can: We have a binary file for cars, each car struct contains (Car ID, manufacturing year, colour, an array with the IDs of this car's owne...
stackexchange/codereview
I have this piece of code placed in ESI class. There is switch statement nested in a try-catch block and it feels simply wrong for me (I have a suspicion that I'm close to exception driven development). I'm looking forward to read your suggestions on how could I potentially improve this code. @PostConstruct public void...
stackexchange/codereview
I have a longer Macro has sub functions opening many different Workbooks, takes the data, and pastes into a Destination Workbook through arrays and .value. There are also a few functions to bring over title and data value information. However, the macro seems to get stuck for a few seconds every time a source Workbook...
stackexchange/codereview
I tried so many things to do this task. I have no idea why doesn't it work. Please help! '''Create a function in Python that accepts two parameters. The first will be a list of numbers. The second parameter will be a string that can be one of the following values: asc, desc, and none. If the second parameter is "asc,"...
stackexchange/codereview
Question Input number of test cases. Input each test case and output its next palindrome number. Link: https://www.spoj.com/problems/PALIN/ Language Used: C++14 (gcc 6.3) My code #include<iostream> using namespace std; int main() { long long int t,rev=0,x,no,f=0; cin>>t; while(t>0) { cin>>no;...
stackexchange/codereview
This is a simple program to convert a number, from 0 up to 99999999, to English words. Example: If the input is: 1234 The output would be: one thousand two hundred thirty four I would like to get feedback regarding this small program. #include <iostream> #include <vector> #include <string> const std::vector<std::s...
stackexchange/codereview
I want to get text1 and text2 by splitting time format Text1 10:24:02 Text2 Of the two working regexes below, which is faster? Regex 1 String regex1= "([0-9]{2}):([0-9]{2}):([0-9]{2})"; Regex 2 String regex2= "[0-9][0-9]:[0-9][0-9]:[0-9][0-9]"; This is the code I've used: String s="Text1 10:24:02 Text2"; String[] ...
stackexchange/codereview
How can I simplify this in Delphi? Procedure colori1 Begin if Temperatura<=15 then begin Form1.Label1.Font.Color:=clBlue; Form1.Label2.Font.Color:=clBlue; Form1.Label3.Font.Color:=clBlue; Form1.Label4.Font.Color:=clBlue; Form1.Label5.Font.Color:=clBlue; end; if (Temperatura>=16) and (Temperatura<=18) th...
stackexchange/codereview
This is a thread I started from here. I organized my code to make it more organized. Everything works well, but I have not made all the changes from the last link (namely namespace since I am exactly sure why or what to do). Overall I just wanted to show my generic single linked list I made and see if there are any er...
stackexchange/codereview
Here is the Egg Holder function for \$m\$ dimensions: $$\displaystyle f(x)=\sum_{i=1}^{m-1}\left[-(x_{i+1}+47)\sin\sqrt{|x_{i+1}+x_i /2 + 47|} -x_i \sin\sqrt{|x_i - (x_{i+1}+47)|}\right]$$ I am trying to find the global minimum of this function using hill climbing. Here's how the algorithm works: initialize best fitnes...
stackexchange/codereview
I need to create a sparse Markov chain. It is supposed to receive text, so the number of rows or columns can easily go up to 20000. Besides, if I want to consider higher orders of the Markov chain (creating pairs of consecutive words) the dimension can become much bigger. Hence the need to have something sparse. I adde...
stackexchange/codereview
I have a command called sprinkle. I'm not going to explain anything about it, because I want whoever that reviews the code to also tell me how much of the command documentation they understood. Here is what I need help with: Is the documentation good enough? Is it too verbose? Does the constant domainName help you und...
stackexchange/codereview
I got tired of running the same command in multiple directories, so I thought "there has to be a way to make this easier". The commands I was running was mostly git status, git stash list, hg summary, mvn clean test, and so on and so on... So what I did was to create a bash script that you can pass a parameter to. It w...
stackexchange/codereview
I created some classes for easier management of RabbitMQ and to practice OOP in Python. I would care about a few issues and any code advice would be appreciated :) is it a good practice to use the isinstance function in the constructor? does using the context manager in these cases close the channel? It seems to me th...
stackexchange/codereview
I have a code for a short Python 2 Pig Latin translator. Is it a good code, or should it be revised? pyg = 'ay' original = raw_input('Enter a word:') # allows user input ^ if len(original) > 0 and original.isalpha(): word = original.lower() first = word[0] new_word = word + first + pyg new_word = new_word[1:len(new_wo...
stackexchange/codereview
Since reading Robert Martin's book "Clean Code" I have been inspired to revisit and refactor some of my code to break it down into succinct methods and small specialised classes. Given the need to retrieve the NameAttribute off the Name2 property of the TestObject class below... public class TestObject { ...
stackexchange/codereview
I wanted to open Database (Mongo) connection only once when I start application and share the same connection across the application. What am doing as part of app.js is Creating connection var dbConnection = mongoose.createConnection(config.database.address, config.database.dbName, config.database.port); passing dbCo...
stackexchange/codereview
I am developing an application that has different configurable versions - "a1" and "a2". The version name is initially being set from the database as "a1" in the $rootScope. I reference the version name in every templateProvider in UI-Router, which ends up being over 30 times: .state('app.auto.public.inventory.list', {...
stackexchange/codereview
Is there an algorithmically better way of doing this? import numpy as np l=np.random.permutation(10) p=list(range(10)) print(l,p) i=0 k=0 prod=1 z=0 def gcd(a, b): while b: a, b = b, a % b return a def lcm(a, b): return a * b // gcd(a, b) while z<10: """count how many times we have cros...
stackexchange/codereview
I recently struggled with implementing AI in Tic Tac Toe game. For better understanding of minimax algorithm I've decided to separate AI's logic. When I finished I thought that some may find it useful, so I packed AI in easy-to-use API and described its usage in README file on GitHub. I am wondering if my code uses an...
stackexchange/codereview
I'm new to C++ and I decided to experiment with the language, by writing a mathematical expression evaluator, using the Shunting-Yard algorithm. A design choice that may stand out as weird is the fact that the parser creates an abstract syntax tree rather than just converting it to Reverse Polish Notation. The reason f...
stackexchange/codereview
I am a beginner in Django and would like some advice regarding best practices. I have the following model: class Company(models.Model): name = models.CharField(max_length=200) class Interview(models.Model): company = models.ForeignKey(Company, on_delete=models.CASCADE) position = models.CharField(max_lengt...
stackexchange/codereview
So I'm almost 100% certain I've done something wrong simply due to the inefficiency of what I've written, I'm entirely a novice to coding and am working on an assignment for my introductory programming course. The only way I could think to display the input from 4 check boxes was to go down 16 different branches to cov...
stackexchange/codereview
I am just into redux. I am developing a dashboard using ReactJS redux and material-ui for components. It's a large app as my dashboard contains various features like add/edit/delete device, add/edit/delete tab, create card etc etc. It's growing very large and I am just into redux, so I am not sure how I can refactor my...
stackexchange/codereview
I want to calculate the intersection of two squares where the coordinates of the input square are given by the bottom left corner and the top right corner. The other square is 6 units wide and has a variable positive integer height h (to make the task simpler). For that I defined some functions: The first one is to ma...
stackexchange/codereview
I created a key in Windows registry to have an option on every folder which allows me to simply right click, choose the right option and have a PDF made, either from JPGS, or PNGs, or TIFs. My registry key is as follows: '"C:\strawberry\perl\bin\perl.exe" "C:\Users\michal\Documents\createpdf\790024.pl" "%1"'. The cod...
stackexchange/codereview
The graphic guy wants to display dates like 16. February 17. - 24. February, or 25. February - 02. March. Here is my solution: $d1 = new \DateTime('2015-02-06'); $d2 = new \DateTime('2015-03-02'); $dateDiff = $d1->diff($d2); if (intval($dateDiff->d) != 0) { $d = $d1->format('d.') . ' ' . ($d1->format('m') != $d2...
stackexchange/codereview
I think the following is good but wondering if it can be simplified or improved. My condition for code execution is the following: It is a Monday AND It is not the Monday following the last Saturday in the month. This is the current sql: DECLARE @now DATETIME = DATEADD(dd,DATEDIFF(dd,'19000101',SYSDATETIME()),'19000101...
stackexchange/codereview
What would make it better? This is my first Python project. Do help in making it better, for me to learn something new. secret="12345" guess="" count=0 limit=3 limited=False while guess!=secret and not(limited): if count<limit: guess=input("Enter guess: ") count +=1 else: limit=True...
stackexchange/codereview
I am beginner in EmberJS. I have made todomvc for ember v2 for learning Ember. My implementation works without controller. I use components instead controllers. In the documentation I see: Controllers are very much like components, so much so that in future versions of Ember, controllers will be replaced entirely wit...
stackexchange/codereview
I did the following Excercise: simulate single inheritance in C. Let each "base class" contain a pointer to an array of pointers to functions (to simulate virtual functions as freestanding functions taking a pointer to a "base class" object as their first argument). Implement "derivation" by making...
stackexchange/codereview
Here is my code which is going to through multiple for loops to get the matching product attribute. I have single product with attributes trying to find out the matching product with same attribute value from a list of Product. I am having a multiple for loop. Can anyone suggest a way to optimize this solution? // This...
stackexchange/codereview
I was reading some programming brain teasers and saw a T9 translator teaser on Crazy for Code and wanted to go about implementing it in node.js. Print all possible words from phone number digits. This question is asked by companies like microsoft, google, facebook, Amazon. Lets see example input/output to understand...
stackexchange/codereview
I am working with System.Array and I am trying to convert System.Array objects to array of specific type (such as int[]) in C#. A series of array downcasting methods is designed as follows. The experimental implementation The experimental implementation of array downcasters are as below. class ArrayDowncasters { pu...
stackexchange/codereview
I know this implementation is very bare-bones, but are there any improvements I can make to it? (E.g. more pythonic, style, speed, comments). I was considering using @property decorators a bit more, but I thought that was overkill for this example. class Node: def __init__(self, value=None, next=None): self...
stackexchange/codereview
This Python script does following activities: clone repo, as provided from the list creating a new branch "jenkinsMigrate" rename Jenkinsfile to Jenkinsfile.migrate push code to GitHub in a new branch. NOTE: credentials were configured already. import git import os import subprocess gitUrl = "https://*****" cwd = "...
stackexchange/codereview
I am currently learning how to create nodejs express rest api using async making it fully scaleable and secure. My goal is to ensure maximum functionality and speed, currently I am using MVC structure with route, controller, service and model. Database is mysql and using mysql2 pool. I am looking to know if the example...
stackexchange/codereview
I'm trying to solve Project Euler problem #3, which asks: The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor of the number 600851475143 ? Can you please review the code and suggests improvements? namespace FullPractice { public class PrimeFactorFinder { private readonly HashSet...
stackexchange/codereview
This is a follow-up question for Two dimensional gaussian image generator in C, Two dimensional bicubic interpolation implementation in C and A SubPlane Method for Generic Two Dimensional Data Plane in C#. Besides gaussian image generating and bicubic interpolation, I am attempting to make a C version subimage function...
stackexchange/codereview
I am working on the subject of the French championship 2019, composed of 20 teams, and each team plays 38 times, if team A plays with team B, whatever the result, each team plays another time with another team determined by the draw. If team A plays with team B, that means there are three possibilities 1/3 team A wins....
stackexchange/codereview
I wrote a Hangman text-based game in Java that needs to include the features that I included in the comments of my code. In short, the game will ask the user to type a word that they (or a 2nd person) will then guess. The word will be censored by the program. The program will tell the user if their guessed letter is in...
stackexchange/codereview
Around June of last year, I made my very first GUI 'app.' Wish I knew of this amazing site then, I thought for posterity's sake it would be great to get it reviewed. It's a simple I/O window just to keep track of the quantity of X exercise that was done, and if I used these two other workout apps. I'd like to evaluate:...
stackexchange/codereview
I have function that I need to run on window load as well as window resize and I was wondering how can I make my code more efficient. Here is my current code: jQuery(window).resize(homeSliderAdjust); var windowWidth = jQuery(window).width(); if (windowWidth < 750) { var hmLeft = jQuery('.page-home #slides .lef...
stackexchange/codereview
I have implemented a solution to Project Euler problem #60. In summary, the problem asks to find the smallest sum of a set of five prime numbers such that the decimal strings of any two numbers in the set concatenated together form the decimal string of a prime. I'd like some comments on the structure and style of my p...
stackexchange/codereview
I want to get familiar with PyTorch and decided to implement a simple neural network that is essentially a logistic regression classifier to solve the Dogs vs. Cats problem. I move 5000 random examples out of the 25000 in total to the test set, so the train/test split is 80/20. I was able to achieve the accuracy of 59 ...
stackexchange/codereview
I'm currently converting a CSS 960 fluid grid to SASS. How can I improve my current implementation? My column classes .two.columns are getting a bit unruly. Is there a better way to write them? // Variables $width: 960px; .container { position: relative; width: $width; margin: 0 auto; padding: 0; ...
stackexchange/codereview
I'm a novice at C++ in comparison with other languages, so as an exercise I wrote a square Matrix class that doesn't use STL. #ifndef MATRIX_H #define MATRIX_H #include <initializer_list> #include <algorithm> class Matrix { public: Matrix(std::size_t sz) : elements{new int[sz * sz]}, size{sz} {} Matrix(std::size_...
stackexchange/codereview
This code is part of my Google Summer of Code project. It will be used in a file manager to provide file management in a root-owned directory. As the title suggests this will be used to share file descriptor using unix local domain socket. There are two classes: FdReceiver and FdSender. FdReceiver acts as the server a...
stackexchange/codereview
I have a scenario where my BaseRepository gets a lot of commands in a short time period. At other moments, this doesn't happen. What I want to achieve is to throttle these commands. I.e., when a command must be executed, wait for a short period (0.2s) for any other calls. If none are made, execute the command (go to th...
stackexchange/codereview
I am an elm beginner and I want to provide an elm practical course to my coworkers. I will do a short presentation of elm, then we will move to practical lessons. The first lesson is to read together the following file to discover elm basis and syntax: Basis.elm {- Here we will discover some elm basis and syntax. You ...
stackexchange/codereview
I would like to compress a Magento HTML page using some regex, and this is what I have written: function html_compress($string){ global $idarray; $idarray=array(); //Replace PRE and TEXTAREA tags $search=array( '@(<)\s*?(pre\b[^>]*?)(>)([\s\S]*?)(<)\s*(/\s*?pre\s*?)(>)@', //Find ...
stackexchange/codereview
One of the features that is missing from C++11 are lockless queues. Therefore I have decided to write one myself. A few remarks: I know the code isn't technically lockless. However the lock is only used for a blocking call and can be omitted. I have tested the code and it seems to work. However I found I had some trou...
stackexchange/codereview
By "Pseudo-Enum" classes I mean cases where someone's used a class with public static properties to emulate enum behaviour; e.g. as described here. Per the example below, this is useful for classes such as [System.Management.Automation.VerbsCommon], where there is a list of values we're interested in, but no "Get All V...
stackexchange/codereview
I recently started C# and I've got the feedback that I still repeat too much. How can I make it less repetitive? namespace ExtraOefLabo { /// <summary> /// Interaction logic for MainWindow.xaml /// </summary> public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); } ...
stackexchange/codereview
I am processing around 3 billion records using this piece of code. It's pretty slow; it would be really helpful if you could suggest better ways to do this. ''' Created on 27-Mar-2015 @author: siddarth ''' import rake import multiprocessing as mp import time import os import csv filename = 'Large_Input_File.csv' out...
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
We were discussing Standard Deviations in chat, so I decided to write a standard deviation calculator: static double PopulationStandardDeviation(List<double> numberSet) { double mean = numberSet.Average(); return Math.Sqrt(numberSet.Sum(x => Math.Pow(x - mean, 2)) / numberSet.Count); } static double SampleSta...
stackexchange/codereview
I have recently implemented my SQLite helper class that supports SQLite in a memory class to be opened to not to be lost. Please review it and tell me if there is a coding problem and tell me what to do to prevent\fix it. using System; using System.Collections.Generic; using System.Data; using System.Data.SQLite; using...
stackexchange/codereview
I've been working on some kind of mapper that would allow me to map between types. My objectives: it should allow mapping between two enums it should allow mapping enum to string_view it should allow reverse mapping using a single configuration (enum1 <-> enum2, enum <-> string_view) the fewer resources it uses the be...
stackexchange/codereview
I want to test a number of different functions I have written to solve the Fizzbuzz challenge and would like to know what is the best way to check the result? Each function returns a list of the answers and I want to check the list is correct. One of the functions is shown below def fizz_buzz_using_boolean(): f...
stackexchange/codereview
ReSharper has a very handy feature that's particularly useful when coding against abstractions. Since coding against abstractions is something that can also be done in VBA, the next release of rubberduck is going to include that functionality as well: The click handler for the code pane context menu simply calls the ...
stackexchange/codereview
I am trying to solve ProjectEuler.net problem #50, Consecutive Prime Sum. Here is the problem: The prime 41, can be written as the sum of six consecutive primes: 41 = 2 + 3 + 5 + 7 + 11 + 13 This is the longest sum of consecutive primes that adds to a prime below one-hundred. The longest sum of consecutive primes bel...
stackexchange/codereview
I wrote a simple Python IBAN validator, which I'd like some reviews on. INTRO Quoting from wikipedia, we know that: The International Bank Account Number (IBAN) is an internationally agreed system of identifying bank accounts across national borders to facilitate the communication and processing of cross border ...
stackexchange/codereview
Since I am new to Java, I wanted to see if there were better ways of answering the same question. Are parts of my code redundant or maybe there's an easier way to get the same result? Problem J4: Big Bang Secrets The encoding algorithm is a Caesar cipher with a shift (\$S\$) that depends on a parameter (\$K\$) and its ...
stackexchange/codereview
When onSaveInstanceState() is customized it should always call the same method on the super instance first. I usually write: @Override public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); saveState(outState); } private void saveState(Bundle outState) { outState.putParcela...
stackexchange/codereview