instruction_seed
stringlengths
71
95.1k
_source
stringclasses
1 value
I'm posting my code for a LeetCode problem. If you'd like to review, please do so. Thank you for your time! Problem Given a 2D board and a list of words from the dictionary, find all words in the board. Each word must be constructed from letters of sequentially adjacent cell, where "adjacent" cells are those horizonta...
stackexchange/codereview
This is my first program ever made in C. Before that I programmed just a little bit in C++ (didn't touch OOP so I did only structural programming). This is my second "project" ever made, the first "project" was even bigger joke. I am new to programming. The project is nowhere near to be finished. However, it somehow wo...
stackexchange/codereview
This project is the natural extension to my attempt to make a templatedgenerator coroutine. This time, I tried what I called a "task" (may be not the real term for this) : it generates a value or not, and is recursively awaitable. It can call other coroutines which each pause will also pause the main coroutine. It was ...
stackexchange/codereview
This is a continued discussion from here, and I use new a approach (bounding box/or envelop algorithm) to improve the algorithm efficiency. Any code bugs, algorithm time complexity improvement or general code advice is highly appreciated. Major structure of my code: assign_box is used to build the bounding box or enve...
stackexchange/codereview
I've been fiddling with Unity, trying to make nice walking/running animations. So, i found the Stealth tutorial and I used pretty much the same animator as the AI, only I only use Speed and AngularSpeed and, of course, added a control script. The controls work as intended but the whole script is laggy. I know, my Updat...
stackexchange/codereview
I use the following code to filter data from SQL and it works fine. However, below code is vulnerable to SQL injection, but all the $post values are checkbox value (it's not user input). So can I use below code? Or do I need to use "prepared statement" as per this answer? I can only send number in array. Conn.php ...
stackexchange/codereview
I am trying to solve the below problem from an online coding site: Fredo is pretty good at dealing large numbers. So, once his friend Zeus gave him an array of N numbers, followed by Q queries which he has to answer. In each query, he defines the type of the query and the number f for which Fredo has to answer. ...
stackexchange/codereview
I made an algorithm in C# that solves any system of linear equations using the Gaussian elimination. There are 2 text boxes in the program for input and output. Input is in the format of the coefficients of the variables separated by spaces and lines. I want to know if this code can be cut shorter or optimized somehow....
stackexchange/codereview
I wrote a script that places documents to the folders they should be (based on my preferences of course). It even creates the folder if it doesn't exists. Here's how it works: You run de script by clicking on it. (idk if I should let this run in the background constantly, I don't use it that much) Checks the selected ...
stackexchange/codereview
Is there a way I could somehow have all this classes condensed into one, while keeping the code as clean as possible? They are all doing essentially the same thing, just for the different number type. I don't know how to "generalize" TryParse() without using switch or if tree which doesn't seem very clean to me. Base c...
stackexchange/codereview
In A Tour of Go, you are given the following problem: In this exercise you'll use Go's concurrency features to parallelize a web crawler. Modify the Crawl function to fetch URLs in parallel without fetching the same URL twice. This is the code you're given package main import ( "fmt" ) type Fetcher interfa...
stackexchange/codereview
I'm not so good with recursion, so I've decided to tackle an exercise consisting of drawing this pattern using characters: * *** ***** ******* ********* *********** ************* *********** ********* ******* ***** *** * Here is my code so far. What could be improved? Furtherm...
stackexchange/codereview
Following This post : https://stackoverflow.com/questions/630803/associating-enums-with-strings-in-c-sharp/56482413?noredirect=1#comment107635743_56482413 I wanted to go further as it didn't quite fully met my needs for a Enum like Class that would act as string I ended-up with a solution that allows me to do the foll...
stackexchange/codereview
I am making a GUI application for a class. I have made the form layout (make_form()) using both Frame and grid, but I am not exactly sure that one should be mixing those two together. What is the best way to make a layout, using grid to incorporate not just the labels and Entry fields, but also the buttons? import tkin...
stackexchange/codereview
In our application we have complex objects with many nesting levels, each with various properties that are important to the business. We currently serialize and persist these objects along with their corresponding workflows (Windows Workflow 4.5), but, due to issues with updating active workflows (WF4.5 Dynamic Update...
stackexchange/codereview
I have a struct which nests other structs like following: #[derive(Debug)] pub struct Rankings { conferences: Vec<Conference>, } #[derive(Debug)] pub struct Conference { divisions: Vec<Division>, } #[derive(Debug)] pub struct Division { teams: Vec<Team>, } #[derive(Debug, Clone)] pub struct Team { na...
stackexchange/codereview
I am currently applying to many Software Engineer positions, and have been asked to complete several coding challenges. The most recent was an equation evaluator, written in C++, that was supposed to evaluate equations. The criteria given were as follows: Each equation is specified on a separate line LHS is the left h...
stackexchange/codereview
I'm creating a Banking system program using Python, and the requirements of this program are very basic: Register and maintain Customer Details Update Account balance through Deposits and Withdrawals I've managed to program the basic functionality, and now I'm in need of any feedback on how to improve my code, in ord...
stackexchange/codereview
I am searching for a more efficient way to calculate the so called vec-trick used in Tensor algebra, see Wikipedia. Introduction: Suppose you have a matrix vector multiplication, where a matrix C with size (np x mq) is constructed by a Kronecker product of matrices A with size (n x m) and B with size (p x q). The vect...
stackexchange/codereview
The method have paramete account object contains ranges list, on other side i call services received list of users each user contains list of ranges . this method should compare ranges received from user with ranges account if match add this user to ranges account. private void fillUsersAccount(Account account,String c...
stackexchange/codereview
I have the following function which works properly and returns all of the rows from a specific table, then loops through each row to add data related to it as a subarray. public function fetch_products() { $return = $this->db->all("SELECT * FROM consumables_products"); foreach($return as &$r) { $r[...
stackexchange/codereview
Take this: has_competitors:function(){ var c = false; _.each(this.competitors, function(obj, index){ // lodash here if(obj.name && obj.name.trim() !== ''){ c = true; return false; // to break the loop } }); return c; } I don't like the form of this, but till now I didn't find a more concise...
stackexchange/codereview
I am trying to solve the common "print a character after every item in a list, except the last one" problem. I do not want to use list indexes. There are a couple of simple ways to do this in Python, but I am not sure how to apply them to my code. Is there a more readable/couple liner way to do this? def echo(*args): ...
stackexchange/codereview
Background I have a simple logic where i get total_kits. I usually make some function call to get the value for this variable. Then if total_kits is less than some MIN_KITS_THRESHOLD then i want to print some message and do nothing. If is_delivery_created_earlier_today() function returns true i also want to print some ...
stackexchange/codereview
This is a short program meant to give me an Erlang hook into the ImageMagick FFI for performance reasons. All comments welcome, but specifically my C experience is minimal, bordering on nonexistent, so I would particularly appreciate hints in that area. the setup here is one of a long-running process that will be a...
stackexchange/codereview
Secondary Review Changes: I recently requested a review: Script to convert Shift + Spacebar into four spaces on SE. After accepting suggestions and improvements by David Harkness, I heavily updated my code to include his suggestions, improvements, and other revisions. The code is now very different from the originally ...
stackexchange/codereview
I have picture in certain cells. When I run following code (With Intersect Method) in smaller number of selected cells, it runs correctly but when the number of selected cells increase - say above 1000, then code slows down a bit (Intersect Method). Can it be optimized? Code without intersect method runs Ok.Can interse...
stackexchange/codereview
I've made my first turn-based game in PyQt5. I suppose that its idea can also be used by other novice GUI programmers. There is a 5 by 5 squared unpainted field and 4 players. Each player starts at corner square and has his own colour. Player can move to adjacent square and fill it with his colour if it isn’t occupied ...
stackexchange/codereview
I have a dictionary which I use to lookup my binary and ASCII values (from A - P). It works, but my ascii2bin function just doesn't really feel right (and beautiful). Is there is a better way to write it? The ascii2bin function splits a 2-letter string (i.e. 'LA') and looks up the keys in the dictionary. Then concaten...
stackexchange/codereview
I'm trying to find my bug or any potential bottleneck that cause my program to be really slow. The script is to get all the followers and friends and save that in MongoDB. import pymongo import tweepy consumer_key = '' consumer_secret = '' access_token = '' access_token_secret = '' from pymongo import MongoClient cli...
stackexchange/codereview
I have a TCP Listener with NetworkStream that reads 530 bytes from the Client once a second. Within the TCP Listener BackgroundWorker, I write those bytes into a MemoryStream, and invoke a method that breaks down the MemoryStream into smaller arrays. Then, I have another BackgroundWorker that constantly compares those ...
stackexchange/codereview
This provides text file conversion capabilities like the common Unix utilities "ux2dos" and "dos2ux". I needed the capability to perform Unix text file conversions, round trip, within a VB.NET project without being dependant upon external binaries. I couldn't find anything like that on NuGet so I wrote my own. I'm fair...
stackexchange/codereview
My problem is this: Given two strings, append them together and return the result. However, if the strings are different lengths, omit chars from the longer String so it is the same length as the shorter String. So "Hello" and "Hi" yield "loHi". The strings may be any length. Is there a way to do it without using of S...
stackexchange/codereview
I have this stored Procedure that is passed in the data below that will building the SQL select that will get EXEC. The data that can be passed in can me null so I have three IF ISNULL checking and then adding to the @SqlWhereCommand object. Any help would be great. parameter @StartDate AS DATE = NULL, @EndDate AS DAT...
stackexchange/codereview
I have been trying to get as close to SRP in my code as possible. I have a situation where I need to log leads when interactions happen for a contact. A lead may be created or updated. There are three different states that I would like to set leads to. Active - new interested interactions causes active lead to be crea...
stackexchange/codereview
All I am trying to achieve is better use of built-in ES functions. var arr = [0, 1, 2, 3, -1, -2, -3]; function countPositiv(p, c, i, a) { if(c > 0){ return p+1; } else { return p; } } var positiv = arr.reduce(countPositiv, 0); console.log(positiv);
stackexchange/codereview
I am reading hadoop source code , Here I have a doubt "org.apache.hadoop.util.StringUtils" they reassigned a list which is already intiailized. public static Collection<String> getStringCollection(String str){ List<String> values = new ArrayList<String>(); if (str == null) return values; StringToken...
stackexchange/codereview
Request to review my code please and see if I am following the best practices. This is sending a POST operation via a Python script using the requests library to a networking cloud orchestration endpoint import requests import sys requests.packages.urllib3.disable_warnings() token = input("Please enter your token: ")...
stackexchange/codereview
I've completed the small challenge in the eloquent JS book to create a chess board pattern: Write a program that creates a string that represents an 8×8 grid, using newline characters to separate lines. At each position of the grid there is either a space or a “#” character. The characters should form a chess bo...
stackexchange/codereview
I've done tutorials as well as searches. I need assistance in simplifying this code. Please don't do it for me- instead inform me of what, where and why you are trying to simplify or write less code. I'm already working on an if loop to exit on enter. This is just version 3 for me. ## Program gets the date, Employee ID...
stackexchange/codereview
class Connection { private string param1; private string param2; private static readonly ConcurrentDictionary<Tuple<string, string>, Connection> connections = new ConcurrentDictionary<Tuple<string, string>, Connection>(); private Connection() { //Prevent instantiation } privat...
stackexchange/codereview
I have modularized my code and currently my "main" function is movieSalesReport(). I am coming from Python where you can have the functions return multiple values. In C++ it is not so simple and I learned through this question that I had to use something called referencing in C++ in order to mimic returning multiple va...
stackexchange/codereview
I have the following code which iterates on an Integer[] and makes sure that the the values in the array are in ascending order and that there are no neighbouring duplicates: Integer previous = null; for (Integer tb : trancheBoundaries) { if (previous == tb) { throw new IllegalThresholdConfigurationExceptio...
stackexchange/codereview
I'm using the asset BestHTTP in unity and I'm downloading a few image from amazonaws to use as texture. It used to be one image, but now I have a few. I was not able to shorten it. When I'm trying to do it in a foreach loop loop it is misbehaving. Could someone help me to optimize this working code? for (int i = 0; i...
stackexchange/codereview
I have mongoose model: var mongoose = require('mongoose'), Schema = mongoose.Schema, Imager = require('imager'), env = process.env.NODE_ENV || 'development', config = require('../../config/config')[env], imagerConfig = require(config.root + '/config/imager.js'); var LinkSchema = new Schema({ ti...
stackexchange/codereview
I use Ubuntu (Trusty and Xenial) and usually put my computer in sleep mode rather than power it down. A common problem is that upon wake the network is down so one has to restart the network-manager service. E.g. sudo service network-manager restart I am tired of doing this so I have hacked the following together: #...
stackexchange/codereview
I have a small function that when passed a str that names a file that contains a program; it returns a 2-tuple with the number of the non-empty lines in that program, and the sum of the lengths of all those lines. Here is my current functioning code: def code_metric(file_name): line_count = char_count = 0 with ...
stackexchange/codereview
Hello I don't have any specific problem but I'm just interested how someone who is experienced in JavaScript would write this small toy program. it's a simple Todo List app, there are many approaches to writing something like this but I'm not sure if the way I wrote it is the most optimal. I want to see how others woul...
stackexchange/codereview
I'm trying to do this: Getting user's ID based on his email name. Using that user_id to check all his emails that have been sent for him so far. // db connection here $sth = $dbh_conn ->prepare("SELECT id FROM users WHERE email = ?") ->execute(array($email)); $num_rows = $sth->fetch(PDO::FETCH_ASSOC); if($num_rows)...
stackexchange/codereview
I created a little singleton-like class that gets deleted when there is no reference to it anymore (so its lifetime shall be somewhat predictable). I aimed to make it thread-safe. #include <memory> #include <mutex> template< typename t_type > struct shared_instance { static std::shared_ptr< t_type > get_shared_ins...
stackexchange/codereview
I have a long list of data pulled in from a csv file that has comments / descriptions scattered throughout the document. I'd like to collapse the descriptions into the last element of each row of data, and my current solution seems slow and overly complex. Rows with data have values in the first index and description r...
stackexchange/codereview
I have a function in a project that I feel could be written better. The purpose of the function is to return the direction of an arrow based on two parameters. positiveDirection: The direction for a positive result. The values could be increasing or decreasing. changeType: Whether the result was positive, negative or ...
stackexchange/codereview
I have following Java code, which is to print PDF, but in a busy location this code is taking about 20 to 30 second delay before submitting to the hardware. get the PDF file via the network download and save locally then submit local file, to the print job to printer printer hardware warm up printer hardware prints ...
stackexchange/codereview
You have to write a C++ program that reads in the employee hierarchy of a company and computes a statistic called 'salary budget' for all employees. For this problem, the 'salary budget' of any employee is defined as follows: For employees who are not managers, the salary budget is same as their salary For man...
stackexchange/codereview
I am using Digital Persona 4500 Fingerprint Scanner for my project. I used U.are.U SDK 2.3 for Windows as the SDK and I am able to insert the serialized fingerprint minutiae data to database using this code: void reader_On_Captured(CaptureResult capResult) { try { if (!_sender.CheckCaptu...
stackexchange/codereview
I have written a Python 2.5.4 function which accepts as input a list of numbers alongwith the desired number of classes and yields a frequency distribution (i.e. a histogram) of the same data. While setting class boundaries, I've attempted to increase the accuracy (i.e. number of digits after the decimal point). Here...
stackexchange/codereview
While reviewing a C question I started writing my own implementation and in no time I had a completely refactored completely different implementation. As the asker is learning I did not want to post it, instead I ask you for further review and possibilities of improvement. #include <stdio.h> #include <stdbool.h> int g...
stackexchange/codereview
I have already made a function of multiplication of long numbers, addition of long numbers, subtraction of long numbers and division of long numbers. But division takes a very long time, how it could be improved? Here is my code: /// removes unnecessary zeros vector<int> zero(vector<int> a) { ...
stackexchange/codereview
I made a scraper for Steam that get different info about a Steam game, such as the price, the specs and the supported platforms. The reason I made this was because I have a super slow laptop, so looking at many games would take a long time :) Some things I would like to improve is have better error handling, as the web...
stackexchange/codereview
Every day I get 5 to 30 Appointment emails with almost the same content from which I need to create the Tasks in Atlassian Jira. I wrote a macro to automate this process. I've never written anything in VBA before and would be grateful for correcting my code. This macro works. There is a function Base64Encode that I cop...
stackexchange/codereview
I know, this sounds really difficult, but it is really easy. I needed to convert a single Portuguese word in the plural into singular. I know there's a right name for that, but it is escaping me. The rules are simple, and will compile them from http://www.easyportuguese.com/portuguese-lessons/plural/ (but applying in r...
stackexchange/codereview
I was fed up with the default alarm clock when doing laundry. The washing machine is in the basement and takes different time depending on the choosen program. The stopwatch has to be configured for every use and can run only one instance (we also have a tumble dryer). The alarm itself is only for fixed times, not for ...
stackexchange/codereview
If I want to make a binary tree from an array in the following order: Example: for the following array: { -1, 17, -1, 3, -1, -1, -1, 55, -1, 4, -1, 15, 11, 2, 3 } the following tree is created: 55 15 3 2 4 * 17 3 11 * * * * The function is recursive and returns a Tree...
stackexchange/codereview
I wrote a small script to get the probability of a given text to be spam. I downloaded some ham (good content) and spam (bad content) text from the internet. The spam corpus is a 1.8 MB txt file, and the ham corpus a 3.6 MB txt file. My method is pretty naive: I count how many times each word appears in the ham and spa...
stackexchange/codereview
I'm a newbie in servlet API. I have a test task to create a very simple web app with one home page and an authorization form. The requirement is to use filter somewhere in my app. Given that it's a super simple app, I implemented basic login and registration functions right in my filter (it was a much simpler way for m...
stackexchange/codereview
I'm about to post quite a bit of code. Hopefully, someone is willing to put some time into reviewing it all. I know linked lists have been done a lot on here, but I wanted to improve the basic C++ skills I learned in college by learning more about templates, inheritance, move semantics, smart pointers, SFINAE, etc. My ...
stackexchange/codereview
For readability sake, is it better to use optionals or write my code in an iterative manner? Here's a route I'm working on, does this look readable do you? @PostMapping("/verify-email") public ResponseEntity<String> verifyAccount(@RequestBody String email) { Optional<AppUser> optionalUser = appUserService.findByEma...
stackexchange/codereview
I have been researching and experimenting with HTML5 and CSS3. I was aiming to create a very simple but efficient tiled gallery / grids. So some sort of grid system that I can layout anything inside. Below is what I have created, what are your opinions? I also have a question, why the distributing of the images change ...
stackexchange/codereview
I incorporated the substantial changes suggested in my previous question that involved building a web-scraper for gathering tennis data. The improved code is shown below: Scraper class: package scraper; import org.jsoup.Jsoup; import org.jsoup.nodes.Document; import org.jsoup.nodes.Element; import org.jsoup.select.Ele...
stackexchange/codereview
I am writing an application that shows a news feed, much like Instagram. For this, I have a function in the model to select the feeds as shown in the code. For some reason, this runs quite slow and I am sure my code is the issue. Is there something I could do to optimise this. public static function getPublicFeed($user...
stackexchange/codereview
I've been working on a way to optimize pixel computation in OpenGL with C. If this information helps, my current environtment = Linux (terminal) + GPU (Nvidia 1080Ti). I'm working with old OpenGL (with GLUT) and not Modern OpenGL. Here's what I'm doing, this function will take image input, this is how I call the image ...
stackexchange/codereview
Introduction I have this semi-dynamic range minimum query (RMQ) tree in Java. It is called semi-dynamic due to the fact that it cannot be modified after it is constructed. However, the values associated with the keys may be updated. An RMQ tree maintains a set of (distinct) keys and associates a value with each key. Th...
stackexchange/codereview
A while ago I asked for a code review of my automatically keyed map and I have recently had the time to get around to writing some unit tests for it using JUnit4. The test ensures that all of the "primary" functionality works, i.e. the things that could actually go wrong. The reason I don't test every method is that ha...
stackexchange/codereview
I have a class that I am using to generate 10 character alphanumeric 'tokens' (Strings) and writing them to a txt file. I would like to be able to generate as many as possible as quickly as possible without producing any duplicates. This is what I have so far: import java.io.BufferedWriter; import java.io.File; import...
stackexchange/codereview
I recently learned how generators can be infinite in Python. For example, the infinite sequence can be the triangular numbers: $$1, 3, 6, 10,...$$ def triangle_stream(): """ Infinite stream of triangle numbers. """ x = step = 1 yield x while True: step += 1 x += step yield x I ...
stackexchange/codereview
I wrote a simple Pomodoro Timer in Python 3: from datetime import datetime, timedelta from gi import require_version require_version('Notify', '0.7') from gi.repository import Notify import sys class State: #length: the length of the state in minutes def __init__(self, length): if not length == None: ...
stackexchange/codereview
Two Sum Problem: Given an array of integers, return indices of the two numbers such that they add up to a specific target. You may assume that each input would have exactly one solution, and you may not use the same element twice. Example: Given nums = [2, 7, 11, 15], target = 9, Because nums[0] + nums[1] = 2 + 7 = 9,...
stackexchange/codereview
Preliminaries I have CAEN Digitizer N6720A and use WaveDump software for the data acquisition and recording. As a result of data recording this software produces a binary file in which the sequence of events is present. Each event has the following structure: Header of an event Event's data points So the entire binar...
stackexchange/codereview
I'm working on getting myself comfortable with C after only working in high level languages for the past 10 years. I've done rust as well and really like the concept of notating immutability in functions. That being said I'm confused on if I should use const wherever the compiler lets me, or just use it where it seman...
stackexchange/codereview
I'm building an application that's going to create different autocomplete suggestions of data that sits in Kafka using Kafka Streams application. Data is read from a relational database and looks as follows: +--------------------------------------+--------------+--------------+-----------+---------------------------+--...
stackexchange/codereview
I am working on creating a scheduler which will connect to cassandra database and extract data from few tables and store it in few variables. Then from my main thread I will be using those variables by calling getters on them from CassUtil class. Basically, I will cache the result in memory and then from a single backg...
stackexchange/codereview
I'd found myself getting back into programming, and had recalled a fascinating little 'game' many might know of. I'm a very inexperienced programmer, and I know this is sloppy, but I'd wanted to make something that had a sort of pseudo-cellular life kind of behavior. There's no real pattern to their movement, but it do...
stackexchange/codereview
Is this the best way to implement a genetic algorithm framework? I'm just a student and wanted to know if I can improve the code that I have done. Some of the code I copied from the framework documentation: namespace xx.xx.xx { class Program { static GrafoDistrito grafo; static int total; ...
stackexchange/codereview
What I'm wanting to do is create a String readFile(Path filePath, Charset encoding) method, that returns the entire contents of a given file. I'm wanting the equivalent of Guava's Files.toString(file, encoding), but without calling the Path.getFile() method (as this method only works with the default filesystem provide...
stackexchange/codereview
Related to, but not exactly a follow up of this question. After fixing some issues discovered in the last review, I added a little more functionality to the Enumerable class. The problem is, I've never sorted before. I tried (and failed)to implement a few of the standard algorithms before coming up with this. It's not ...
stackexchange/codereview
I'm just starting to understand the Python syntax and I created a module that does what I wanted, but really slow. Here are the stats of cProfile, top 10 ordered by internal time: ncalls tottime percall cumtime percall filename:lineno(function) 1291716 45.576 0.000 171.672 0.000 geometry.py:10(barycen...
stackexchange/codereview
I have written my first Python script that will go into live use at my workplace. I am relatively new to Python and I think this script is pretty good but I would like your input. It runs very fast, as far as I can tell (~0.01seconds). It is also my first time writing a script that takes arguments from the way it is c...
stackexchange/codereview
I've created a simplified prototype solution as a sort of proof of concept before starting a larger program. Here is the test data used to build the objects: create table blah.dbo.tb_sandpitCreateMultipleLinkedObjects ( CustomerName varchar(50), ItemCode varchar(50) ); insert into blah.dbo.tb_sandpitCreateMult...
stackexchange/codereview
The idea of the algorithm is to decrease a number from a word. Is there a better way to write this algorithm? limitiation: it is important to decrease with a limit, if BB is the word we decrease from, after decreasing by 1 the result will be BA, but after decreasing by 2, we expect logically for the result to be AZ,...
stackexchange/codereview
I'm learning promises and now I'm trying to figure out if something in this code can be improved. This code is expected 3 urls and then async parallel calls should be done. When all requests are finished thet just show each request's data. const hyperquest = require('hyperquest'); const BufferList = require('bl'); cons...
stackexchange/codereview
I haven't programmed in a while and need to improve my code in any way possible: efficiency, readability, etc. This program is for getting integer coefficients of any polynomial and factoring: ex. $$ 2x^2+8x^1+8 \longrightarrow 2(x+2)(x+2) $$ What advice can you offer to help me out? factor.py (Main file) #!/usr/local/...
stackexchange/codereview
I need to iterate through a couple million essays that are about 500 words long and for every essay & I have to return the character is repeated the most. I have the following code but to iterate through 1 million essay (I have the same essay hard coded). It takes almost three minutes before it has a collection of all ...
stackexchange/codereview
I'm writing a function that returns all (nested) sequences reversed: (defn my-reverse-v1 [input] (let [head (first input) tail (rest input)] (if head (conj (my-reverse-v1 (vec tail)) (if (sequential? head) (my-reverse-v1 (vec head)) head)) []))) (defn m...
stackexchange/codereview
I just deep dived to Python and I came with this Hackerrank problem: Create two class, Person with firstName, lastName, idNumber as its attributes with method printPerson() simply print last name and first name and id, and the derived class Student. The Student class has additional attributes, its score and an array wi...
stackexchange/codereview
I'm using Bootstrap 3 to build a tab-panel component, based on information coming from the end-user. I don't like how there's a second foreach loop, but I don't know how else to print the HTML correctly. Given an array structured like this: [ { "title": "Title 1", "content": "Lorem Ipsum" }, ...
stackexchange/codereview
I have a JSF project composed by some Maven Modules. I have one module that needs to read and write some files on server. To do this I need to know the "real" full path of the application/server. The way it is coded, only the View layer can access this information by this method: public final static String getRealPath(...
stackexchange/codereview
I wrote a package manager in clojure that does 5 things: depend a b //creates a and b (if they don't exist) and adds dependency on a install a //installs a and its dependencies list //prints out the install packages sys //prints out all packages remove or uninstall packages and dependencies that are no longer needed....
stackexchange/codereview
I decided to try and learn Julia for doing scientific computing, and I decided to tackle the problem of finding $$ \int_{D_{\frac{1}{4}}} x^4 + y^2 dA $$ where \$ D_{\frac{1}{4}} \$ is the part of the unit circle in the first cuadrant. My code in Julia is the following: using Distributions e = 10.0^(-3); p = 0.85; var...
stackexchange/codereview
What this function does it's to return an array of remaining dates that are e.g. Mondays. Is this really the best way to do that? function range(start, count) { return Array.apply(0, Array(count)) .map(function (element, index) { return index + start; ...
stackexchange/codereview
Challenge Determine the largest contiguous sum of integers in a list. Specifications The first argument is a path to a file. The file contains multiple lines. Each line is a test case represented by a comma separated list of integers. For each test case, find and print the largest contiguous sub-array sum. Sample Inp...
stackexchange/codereview