All Questions
0
votes
0answers
2 views
TLE in APS - Amazing Prime Sequence in Python at Spoj
This series is similar to Fibonacci Series defined as : a[0] = a[1] = 0 and For n > 1, a[n] = a[n - 1] + f(n), where f(n) is ...
0
votes
1answer
8 views
Should I Check for null color?
I have the next piece of code which changes the colors of some buttons.
...
0
votes
0answers
8 views
Small haskell text-processing script
I'm a bioinformatician and mainly use python, but I'm trying to learn Haskell. So far I like this language because it's beautiful and fun, but my Haskell scripts usually end up being much slower than ...
-2
votes
1answer
34 views
Decorator pattern using Java 8 [on hold]
Wikipedia has an example of a decorator pattern here:
https://en.wikipedia.org/wiki/Decorator_pattern#Second_example_.28coffee_making_scenario.29
I was trying to solve this using functional style ...
1
vote
0answers
22 views
jQuery needs Optimization - Each Loops vs For Loops
TLDR: Rendering is too slow when having lots of custom fields and rules. So I need help to improve this javascript code.
#9606: Trac ticket about issue
I have a trac 1.0.8 installed on a ubuntu ...
1
vote
2answers
18 views
Optimizing Java SHA-512 String-to-Hash Generator
In an attempt to learn Java and SHA-2 I created a very simple String-to-SHA512 generator. Here is the code:
...
2
votes
0answers
25 views
Implement 3 stacks using a single array in C++
One of the questions that is presented in Chapter 3 for Cracking the Coding Interview is this:
Describe how you could use a single array to implement 3 stacks
I'...
-1
votes
0answers
13 views
Doctrine - is it bad to have flush() instantly after persist in repository create/add function?
I showed my code to people who have experience with doctrine and symfony and they said that it is bad that I call flush() instantly after persist() because maybe client class who uses this class might ...
1
vote
1answer
11 views
Dynamic Official Receipt increment algorithm
I made a function that would automatically generate official receipt for POS. it is able to accept format such as xxx, xxx-xxx, xx-xx.
But my code is really messy and horrible and it needs review. I ...
-1
votes
1answer
24 views
Controller method to modify Active Directory, other systems, and send notification with error handling
I have to handle an Action (Modify) about my web application.
The app working with SMTP Email, ActiveDirectory, External System (...
0
votes
1answer
9 views
Power flow analysis using the PSS/E simulation tool
The intro is a bit long, but I think it's necessary. I'm very interested in any improvements, but you can assume that all calls starting with psspy. are correct and ...
2
votes
1answer
26 views
Total number of stops for an elevator to serve certain people
I have seen this question asked around a bit, such as this Code Review question in Java:
Write an optimal program that would determine the total number of stops
a elevator has taken to serve X ...
-4
votes
1answer
19 views
1
vote
0answers
17 views
Permutation index Python
Here is my Python code for finding the permutation index of a given digits and a target number. And by permutation index I mean, for example, given digits ...
1
vote
3answers
27 views
Acronym Generation
Problem
Implement a relatively naive acronym generation. I was trying to implement a solution without using regex.
Portable Network Graphics => ...
0
votes
0answers
26 views
Drawing app with JS / canvas
Created this drawing app with JS / canvas. JSHint is throwing errors but the app works just fine. Need help with code clean up / refactoring as I'm fairly new to JavaScript.
JSHint in Atom is fine ...
1
vote
0answers
14 views
Angular 1.x Data Connector Service
I've been writing in Angular 1.x for about a year now but I always wonder about my structure and performance as I'm self taught and in a very small team with limited time for code reviews.
This ...
-1
votes
0answers
12 views
0
votes
1answer
25 views
Generating random numbers and decks of cards
So I have some code here:
First a simple random # generator and a array-choosing function:
...
0
votes
0answers
19 views
Converting a Website Into a Single Page App [on hold]
I want to convert my website into a single page app. This function does the trick:
...
3
votes
0answers
13 views
“Log in”, extract number from a map, increment it, and log out
Basically, you just run main and it allows the client to "log in", and extract their number from a map, increment their own number, and log out.
It all compiles ...
4
votes
2answers
40 views
Rainfall challenge: how big are the basins?
August 2016 challenge
The Rainfall Challenge
Problem description is copied verbatim from the linked Code Review
question:
Problem Statement
A group of farmers has some ...
0
votes
0answers
13 views
Why does my script throw an error when I send successive requests in a short time? [on hold]
My code work as well and all fine.
I have a question and answer like stackoverflow. Following codes are for marking an answer as accepted one part. As I said it works perfectly, but sometimes it ...
1
vote
0answers
14 views
Extracting site visit information from a REST API call, including addresses from a MySQL database
I'm building a web app that pulls data from a ticketing system via REST API. I'm currently able to pull all of the data I need just fine but the loading process is really slow. I'd love any feedback ...
3
votes
1answer
37 views
javascript - create an object containing objects based on JSON data
Based on JSON data I receive, I am trying to track a team's home and away games. The JSON data is stored in $scope.gameSchedules and has "team1" for home games and "...
2
votes
0answers
12 views
Phishing Project - Refactored Controller Class
Following the last review, I felt that my project was starting to get too complex to continue moving forward as such. So I created a new project and migrated pieces of it over to streamline it's ...
4
votes
1answer
16 views
Testing file IO errors in python
Below is a simple class with two methods: the first calls open() to read in a file. The second calls the first method and does error handling.
There is also a ...
1
vote
0answers
11 views
Simple Node.js localization package
I wanted a simple localization module to manage multi-language strings in my new personal Node.js project. As I'm working on this project primarily to learn and play around and the packages I found ...
1
vote
2answers
53 views
Webdriver-based test that uses configuration parameters from a database
I am writing automated functional tests for my application. To interact with the application, I use the SQL database to retrieve data and validate data.
One of the challenges that I'm facing is that ...
-1
votes
0answers
37 views
3
votes
3answers
47 views
Time Limit Exceeded for ETF - Euler Totient Function at Spoj
In number theory, the totient φ of a positive integer n is defined to be the number of positive integers less than or equal to n that are coprime to n.
Given an integer n (1 ≤ n ≤ 106), compute the ...
4
votes
3answers
283 views
Button click handlers for a JavaScript text-based adventure game
I'm pretty new to JavaScript, and I'm trying to created a text-based game. I've written a few scenarios and based on the player's decision I have different scenarios written out. As of now I have the ...
4
votes
1answer
32 views
Determining whether a date is within a range
I am taking a user input which consists of a from date and a to date. Those dates are compared against 4 cells in a row - a post date, pause date, resume date, and a close date. My goal with this code ...
0
votes
0answers
16 views
Real Coded Genetic algorithm performance issue [on hold]
I am pretty new to genetic algorithms, and wrote a real valued genetic algorithm with an sbc function used for crossover. Currently I was trying to use the class below to train the weights for ...
4
votes
1answer
25 views
VBA Print Summary Pages - Excel - Runs Slow
Looking to speed up this code some if possible. There is a main page with this macro assigned to a button. Once the button is pressed it ask if you wish to continue and mentions it takes a while to ...
4
votes
1answer
33 views
Showing virus scan results from an API and a CSV file
I am utilizing an API module for interacting with virustotal.com in order to get AntiVirus results based of SHA256 hashes. The code I have is working but I feel like it can be improved greatly. I ...
3
votes
1answer
23 views
Yum Notification Script
This is a Bash script I wrote to email me when updates are available for my server. I'm new to bash programming, so I don't know if I've done this well.
...
2
votes
1answer
27 views
Validations in filter class
For my web application I have written AuthenticationFilter which validates each request to check against CSRF attacks, Browser Checks, Session Validity etc. Instead ...
3
votes
1answer
30 views
Merging hashes, summing values that have the same key
I'm trying to group by keys in an Array of Hashes in the following form and add their totals. Maybe with #map and #reduce/#inject. I know there is a more compact way to do this.
Given I have
...
1
vote
2answers
37 views
Function for getting strings consisting of random characters
I've made this function for to be used while testing.
...
4
votes
0answers
39 views
Simple matrix class C++14
I created a simple 4x4 matrix class (column-major). I would like it to be efficient and to use C++14's full capabilities. Can I improve it?
...
-1
votes
0answers
26 views
if else cascading replacement [on hold]
I am developing a simple java program which is run from command prompt using the JAR that I built. My program involves a lot of if conditions. My scenario is like, ...
7
votes
4answers
1k views
Regex to enforce password requirements
I'm trying to write regex to validate the password for the given rule.
Passwords must be at least 8 characters in length and contain at least 3 of the following 4 types of characters:
lower case ...
6
votes
1answer
28 views
Count how many times a value is referenced in a grid
I've got list of points: List<Point> seedPoints. Each Point contains x and ...
6
votes
1answer
59 views
My tetris implementation
I just wrote a tetris game and I'd like to humbly request for code review especially in terms of code transparency, code efficiency (whether something can be coded in faster way using less resources) ...
-3
votes
0answers
19 views
Can any one check my simulated annealing code c++? [on hold]
My code is for the AC system and I used SA algorithm but there is a run time error.
I couldn't find what is wrong with it.
-3
votes
0answers
15 views
Bind_param is not taking whitespaces [on hold]
While using bind_param in the below set of statments, the ? doesnt take account >of whitespaces. Example if $var contains "UFL", it'll work properly but if its >"university of florida", then it will ...
-2
votes
0answers
34 views
Pong game scoring system C# [on hold]
I am currently making a simple pong game in Unity2D, following this tutorial. I currently have a scene where there is a title, and a game board. I want to add a scoring system so that when each player ...
1
vote
2answers
30 views
Capturing the positions of “start” and “end” markers in a multi-line string
Is there any better (and shorter) way to get index of a regex match in Python?
...
1
vote
1answer
49 views
Implement a generic Priority Queue in C++
I wrote a Priority Queue that is stored using a doubly linked list. The queue can return the head and tail of the list, and contains a print function that is only used for testing purposes.
I'd like ...