instruction
stringlengths
71
71.9k
I'm new to akka and would like to get some feedback on my first attempt. The code takes text from stdin and finds the top 10 most frequently occurring words. Specifically, I would like to know Is passing the wordFrequencyAccumulator to the tokenizer a reasonable thing to do? Are there better alternatives? Is the use...
I have a server side operation which takes a percentage value from 0 - 100. The user controls this percentage using a SeekBar on the android client. Time-wise the operation is expensive, so I don't want to send commands faster than the server can update. To limit the amount of actions sent, I have limited the client it...
I'm learning command design pattern right, so I decided to make this project. Basically it's a remote controller and it issues commands to VCR. I've seen different implementations of this pattern so I'm not really sure if I got it right. So the key points are: Is the implementation correct? If not, what's the problem?...
I wrote this up out of necessity, then realized that I actually needed to write it in PHP. Just so I didn't waste the last hour, I'd like a review of it. My concerns: This is my first time using the module pattern. Am I implementing it correctly? To restrict the creation of Either objects, I'm using Success and Failur...
I'm working on a game using the now abandoned Famo.us Javascript framework. I have the game in a running prototype and I'm building with Cordova and running it on an iPhone 6 using PhoneGap. There seems to be some performance issues with it and I can't help but notice that a bit of lag happens right as a new enemy is ...
Recently, I redesigned the Rubberduck settings pane. Here is the unit test settings view, which is posted in this question: The part we are referring to is the section in the right pane. The rest of the window is part of a parent control that will be posted in its own question later. This is the XAML for this window...
I am writing a function gives all possible ways of merging two ordered lists such that in the merged list, the elements are still ordered according to the elements in their respective starting list. For example, merging (a b) with (1 2) would result in: ((a b 1 2) (a 1 b 2)(a 1 2 b) (1 a b 2) (1 a 2 b) (1 2 a b)) My i...
Here is the code I wrote to calculate the minimum of a complex function. The code uses the incremental steepest descent algorithm which uses gradients to find the line of steepest descent and uses a heuristic formula to find the minimum along that line. The algorithm should zig zag down a function and find a local mini...
The following code reads from Microsoft EntityFramework 6.0 domain model and returns the single view_patient object. The view_patient object is defined in the backend database and uploaded to the .edmx model of EF. I am new to EF, but it seems there should be a better way--(better means less typing)-- of going from mod...
Trying to print the closest sibling in a BST. How can I improve on this algorithm in terms of space/time efficiency? Please point out any potential bugs too! I'd appreciate that. import java.util.ArrayList; import java.util.List; public class ClosestSibling { public static void printClosestSibling(Nod...
I am writing a storage for articles and I have decided to use GridFS from MongoDB. I have found and tested some code, but I am not sure that it is a best one. Could you advice me how to make it better? private GridFS gridFs; public String getPostContent(String name) { GridFSDBFile file = gridFs.findOne(name + ".ht...
My code below find the duplicates based on 2 criteria: The first criteria is the Name in Column A The second criteria is the Country in Column D Sheet("RawData") : Sheets("Conso") after the macro: What I am looking is to increase the speed of this code, because I am working with more than 150K rows and it takes hou...
We've had a situation whereby we have to cater for certain exceptions and retry a particular method whenever these exceptions occur. This is required in various parts of the system. In addition, we (might) want to invoke a 'callback' upon the need to retry. I'll show you the code, then give you an example of useage: ...
I am writing an R package. The package consists of a main function and lots of auxiliary functions that perform different calculations. The main function The idea behind the package is to make the user use only the main function and through it select which auxiliary function to use. This would imply that only the main ...
Is there any way I can make this function more inline? def nDimensionalArray(n, s): x = 0 for i in range(n): x = [x for j in range(s[i])] return x
I want to add red borders to required fields, if the fields are empty. The ShowSelection() function is run when the interface is loaded, and everytime the interface is refreshed. I have the following form fields: First Name, Last Name, Birth Date, Email, Cell Phone, Address, Post Num, Post City, and Consent Checkbox. ...
Here is my code for a sprinting game in Python. You have to tap the 'a' and 'd' keys as fast as you can to run 100 meters. Any improvements? import msvcrt import time high_score = 50 name = "no-one" while True: distance = int(0) print("\n--------------------------------------------------------------") print...
At work we have a need to know what printers are getting dangerously low on their toner, and paper consumption, etc.. So I've created a program that pulls the printer information off the websites the printers are located at and outputs the information. This program has the option to use two separate flags -e for every ...
Using various answers from Stack Overflow and Ask Ubuntu, I've hacked together this simple C program that wipes terminal history. It works but I'm relatively new to C so I'm not sure if everything is correct. #include <stdio.h> int main(void) { // check if the program is being executed in a terminal if (isatty(0)...
I wrote a package a few years ago to make my interactions with the Stack Exchange API more straightforward. I've maintained it over the years and used it in several scripts I've written that interact with Stack Exchange. Now my goal is to release it to PyPI. Before I do so though, I'd like to ensure it's a clean, well ...
I have a dedicated stylesheet <style id="dynamicStyles"></style> for my page's dynamic styles. They are controlled by this JavaScript: function style(className, sty) { var sheet = document.getElementById('dynamicStyles').sheet; sheet.insertRule('.' + className + ' {' + sty + '}'); } // No validation, do not pa...
This is my second Ruby coding attempt. Also - this is my first OOP usage in Ruby. I'm using if __FILE__ == $0 form here - same as it is in Python because it's really comfortably as for me. Is there is any objections/restrictions for such usage? Any other tips/links about this code appreciated as well. Script intended ...
Here is a serializer. My concern is to make the convert_to_internal function more pythonic, efficient and ideally more functional. Maybe I could also get rid of three nested loops. class TimeSerializer(serializers.Field): DAYS = { 0: 'monday', 1: 'tuesday', 2: 'wednesday', 3: 'thursd...
Here are the app.js, users.js and user.js routes of a node application I am building. As you can see I am connecting to the SQL DB in each route, and this is not ideal. I have tried passing the connection to different routes at least 3 different ways based on examples online. I have failed multiple times. Please advise...
In PHP how can I follow the DRY (don't repeat yourself) principle in this piece of code? The 2 classes in question share an awful lot of code. <?php interface iSelect { public static function display(); } class CountrySelect implements iSelect { static $template = 'select_template.php'; public static f...
I have a list of Comment objects comments. Each Comment has several properties, one of which is the date the comment was posted. I've sorted this list by date and there is at least 1 comment per date in a range. I would like to loop over comments and for every date, create a new list of comments just for that day. Howe...
I just wanted to implement the enum singleton in java. Here is my implementation where I have tried to create a singleton DataSource instance: public enum EasySingleton { INSTANCE; private DataSource dataSource; private EasySingleton() { this.dataSource = MYDB.getDataSource(); } public D...
Summary: How can I best write tests that override socket-based communication for a library, capturing what is sent over the socket, and simulating responses based on what is sent? Details I'm adding a new feature to ruby-mpd, and it's extensive enough that I'd like to add tests covering many scenarios. The library comm...
I am working on a script for an automated workflow. It expects a CSV and a disk image to be present in the directory that is supplied as args.input. I want to check for and handle every possible scenario: no CSV, no disk image, too many CSVs, too many disk images, and any possible combination thereto. I've written the ...
For this project, I'm using the non-Boost version of the ASIO library. The basic idea is that it is a relatively simple stand-alone class capable of functioning either as a server or client depending on its needs. It performs all networking in an asynchronous paradigm, and as best as I'm able to determine, it can handl...
I wrote this function to convert an array of bytes to a C/C++ string representation using hexadecimal escape codes (\xhh). Any suggestions are welcome: std::string toEscapedHexaString(const std::uint8_t * data, const int dataSizeBytes, const int maxCols = 80, const int padding = 0) { ...
I want to see if I used the Observer pattern correctly. Right now I'm using a VolumeManager.cs that implements ISubject and a MusicVolume.cs that implements IObserver. I'm doing this to make it easy for me to change volume along a lot of different sounds and musics. My VolumeManager.cs is set the execute first in th...
I have used PHPmailer to send email to users upon registering to the site. Now, everything works as should, however, I find myself doing painstaking work adding the HTML elements in. Here's an example piece of HTML code: <p>This is a paragraph</p> <span>Now this is important!</span> <h4>Uh Oh!</h5> Now in the PHP cla...
After writing this answer, I was inspired to try to design a more elegant solution to the problem of printing binary trees. And what better tool with which to seek elegance than Clojure? Overall design The solution I ended up with involved creating, merging, and printing what I'm going to call sparse strings. A sparse ...
I am fairly new to Python but I have been improving, and I wanted to try writing a simple program that simulates locker with multiple chambers (4) for storing "objects". I recently used lockers at a theme park with a similar functionality. A chamber can be reserved by simply typing a unique PIN. In the real world, the ...
My code will check if the variable myString has 20 running numbers. I'm new to JavaScript and I'm wondering if there is a simpler way to do this. How can I shorten my code and possibly make it more efficient? var myString = "tuxwuhkocx14789470019215498263ljmgwsxvne"; var runningNumbers = 0; for (i = 0; i < myString.le...
I'm learning F#, and have challenged myself to write a good functional implementation of FizzBuzzWoof. (The difference from "standard" FizzBuzz is that any number that either is divisible by or contains the appropriate number must be replaced by the appropriate string of text: 3 = Fizz, 5 = Buzz, 7 = Woof. Also, the st...
There are two methods I am using here for merging day, month and year. First one $scope.firstOption = moment(new Date($scope.register.db.day + ' ' + $scope.register.db.month + ' ' + $scope.register.db.year)); Second One $scope.secondOption = moment($scope.register.db.day + $scope.register.db.month + $scope.register....
I am a bit worried about this small PHP base as it has been running a bit slow. Can anyone notice anything majorly wrong with it? root/Index.php: define('START', microtime(true)); define('RAM', memory_get_usage(true)); define('ROOT', dirname(__FILE__) . '/'); define("SECURE", true); ini_set('date.timezone', 'Europe/Lo...
I'm working with Apache POI framework. This code go through sheets, row and get value of cells. I will try to get value from directly indicated column. I need this because I want convert only some information from xls to csv. FileOutputStream fos = new FileOutputStream(outputFile); Workbook workbook = null; for (File ...
I was doing a programming question in C++ at HackerRank. Given a set of up to 500 bitstrings, each up to 500 bits long, the task is to find the pair a and b such that the bitwise OR contains the most 1s. I solved the question with Time Complexity of O(n3). I can't figure out how i can solve the question with a better ...
I am trying to create a class that parses a JSON and selects all labels, or just a particular label that you prefer to later do a calculation with the value pair extracted off that label. This is working well for .all() This is the first function, wich selects ALL available labels. But then I want to make it flexible a...
This is not very memory-efficient. Can you please suggest a better way or improvement? public class Test{ public static void main(String[] args) { System.out.println(replaceSpace("All men must die")); } public static String replaceSpace(String s) { String[] stringArray = s.split(" "); ...
We are new into hibernate, in our project for saving an entry the below given code is used, please have a look. public void save(Object obj) { Session session = null; Transaction transaction = null; try { session = sessionFactory.getCurrentSession(); transaction = session.beginTransaction();...
I'm having trouble with a current algorithm I'm writing that takes a corpa, a list of characters in sets (1 one or larger) with a frequency number attached to it. Against another list of character sets that need to be created using the most frequent occurrences of the combined sets... if that makes sense. I'll explain ...
I don't know if this method uses a lot of time to process, or if it is bad but I wanted to know if there is any better way of actually doing this? I have a few class files that I want to stop users viewing through the browser, and only allowing them to view it if actually load it from the index.php So I have this nice ...
I am making an ArrayList, keeping note of all the indices where zero has occurred. Later on, I am taking out the indices from ArrayList and making the corresponding row and column to zero. Please suggest improvement and the better ways to do it in place. public void setZeroes(int[][] matrix) { if(matrix.le...
In my Symfony (v2.7.9) project I have a set of entities which share some view functionality i.e being displayed in a table with some of their values as columns. Following the separation of concerns principle, I've made a ListTable class which handles getting the table headers, rows and column values and I'm extending t...
Please suggest improvements and a possible better way of doing it in place. public static void main(String[] args) { int[][] mat = { { 1, 2 }, { 3, 4 } }; rotate(mat); } public static void rotate(int[][] matrix) { if (matrix == null) { return; } int n = matrix.length - 1; int temp = 0; ...
Want to create time series for the nuclear power plant performance using the equation for Time to fail and time to repair for 8736 hours in the year so that I have the time series in hours when the generator is operating in when is not. The starting condition is that the generator is operating on the first hour. For s...
This essentially performs the same function as exact-integer-sqrt in math.numeric-tower. (defn isqrt "Returns the greatest integer less than or equal to the principal square root of n." [n] {:pre [(not (neg? n))]} (let [n (bigint n)] (if (zero? n) n (loop [x (.shiftLeft BigInteger/ONE (quot (...
In my spare time I'm working at a perl library, which is the lightweight implementation of a package I did some time ago. In the previous iteration I used Moose as object-oriented framework, as suggested by many people on the Internet. Later in time I realized how Moose was a total overkill for my use case (I'm not a b...
Could you please tell me what you liked or may have disliked about this code? What can be made better? #!/usr/bin/python3 def change_char_at(ch, s, indx): """ Strings in Python are immutable objects. So, it is not possible to change a certain character in a string in place. For example, an attempt to run t...
I developed a Chinese Poker game for better understanding classes in Python. It is not finished yet, but the main part is. The game mechanics: There is 1 board for each player. Each board have 3 rows. The first row can receive up to 3 cards, and the other 2, 5 cards each. A total of 13 cards in each board First, each ...
I made an ASP.NET MVC application using Entity Framework for code-first migrations to the SQL Server database. I also use Unity (DI/IoC) for managing the services and repositories. I made an overview page but I'll limit the items on that page to 10, 50 or 100 (variable named pagecount) items as selected by the user. Th...
I was reading a typical interview question found here. Given an amount and a list of denominations, count the number of possible ways to break the amount into different combinations of coins. For example, if amount = 4 and denominations=[1, 2, 3], there are 4 possibilities. Here's my Python solution. def _get_num_of_c...
I recently built a Docker image for Composer. I'd love to get a review of the image, the Bash based wrapper script, its recommended use, and the repository structure. Here's the Dockerfile for the latest tag: FROM alpine:edge MAINTAINER Samuel Parkinson <sam@graze.com> RUN echo "http://dl-4.alpinelinux.org/alpine/edg...
I currently have two projects. One called Models, a second called TaskEntityModels, a model first Entity Framework 6 project. Here is an example of a class in my models project: public class ImportRequest { private readonly TaskEntities _taskEntities; public ImportRequest(TaskEntities taskEntities) { ...
I have an Active Record update with the following data model: TvMenuProfile has one rich_text_special Bar has zero to many tv_menu_profiles Special has one bar_id and one description I want to copy all of the Special.description columns to each TvMenuProfile. The link between the two is tv_menu_profile.bar.specials.f...
I have a REST WS in Java using Jersey that connects to a database. I don't know what should be the ideal time for execution but I feel the time it takes is too much. The actual call to DB completes in range of 0-3 milliseconds but the overall time to complete the REST request takes >9 milliseconds. Here is one of the m...
I wrote a function template to compute the GCD of two integers. This function checks that its arguments are an integral type. I also wrote a function template which accepts a pair of iterators in order to compute the GCD of two or more integers. It calls the first function to compute the GCD of pairs of integers. Here ...
Is there some way to speed this up, since it keeps timing out while running? The spreadsheet is shared with a Google Group with editing permissions. I've loaded what I can into memory but each .addEditor and .removeEditor takes up to 3 seconds each x 100s of cells. I have the sheet deleting the first row in the spreads...
I created a highly effective Reverse Polish Notation calculator using Java 8, but am uncertain if there are any better ways to handle the problem. Feedback on any evident taboos and bugs is greatly appreciated! public final class RPN { /** * Removes all characters that are not operators, whitespace, or digits...
When I'm writing Python, I wanna be able to pull up an interpreter quickly, and import what I need easily. Previously, this involved: bash4.3 $ python3 >>> import os, sys, readline, lxml I was irked by the amount of typing in that, so I wrote a couple of tiny bash functions that live in my .bashrc, so I can just do (f...
In an answer to this question I mentioned best effort. Here I try to explain what I meant. Please keep in mind that the implementation is intentionally incomplete (missing features such as NAN are trivial to add) and focuses specifically on the numerical stability. It was surprisingly hard to get it right, but it paid ...
This looks quite verbose to me, using the command substitution and echo: # Source file source=$( [[ ! -z "$1" ]] && echo "/home/$1" || echo '/root' ) source="$source"/.bash_history [[ ! -f "$source" ]] && echo "History file '$source' not found." 1>&2 && exit 1; # Am I dealing with root isRoot=$([[ "$source" =~ ^/root ...
I am a newbie and I am using basic HTML to render and check. No JSON at the moment. With that said, I’m having a hard time conceptualizing organization of a group of matching series (e.g. a series that falls under a given number, say 1) into a single link that expands into the subseries (say, 1a, 1b, 1c...) for a detai...
I'm trying to respect the Ruby principle of keeping my code dry; however, in my conditional, I have different constants set to different days. But that's the only thing different. They're pretty much the same code minus the evaluation of days from_now. if term_type == TERM_MONTH subscription.suspended_at && subscript...
I would really appreciate a general review of my Tic Tac Toe game in Python as I have spent a lot of time on it. Any improvements or suggestions? def print_board(board): print "The board look like this: \n" for i in range(3): print " ", for j in range(3): if board[i*3+j] == 1: ...
I wrote a short script in Python 3 that connects to the Stack Exchange API, gets all questions on Programming Puzzles & Code Golf over the past two weeks, and determines the average number of questions per day as well as the average number of answers per question. The number of questions per day is intended to match th...
First, the context: I'm working with a student to build a web frontend for a star cluster simulation package called starlab. Typical starlab usage involves chaining sequences of commands together with Unix pipes. We want to store both the output and the set of commands (and arguments) used to generate the output in a d...
I'm working on a project where I have to prompt a user a enter several dates. This is the code I came up with for prompting the user for the day, month, and year. Console.WriteLine("Day: "); var dateDay = Console.ReadLine(); var dateDayInt = Convert.ToInt32(dateDay); Console.WriteLine("Month: "); var dateMonth = Conso...
I've solved the Google Jam store credit problem. but there's some inefficiencies that I want to get rid of them to improve the algorithm and reduce the multiple iteration. What are other better ways to do so? Problem: You receive a credit C at a local store and would like to buy two items. You first walk through the s...
I made this resource queue in Love2D. function GameState:queue(file, arg) self.res.loaded = self.res.loaded + 1; self.res.queue[self.res.loaded] = {f = file, t = game.getResourceType(file), id = self.res.loaded, s = arg}; game.log("Resource Queued: "..file); return {f = self.res.loaded, t = game.getReso...
I need to analyze shell-sort. Currently I am working with it having an increment of N/2. I will then go on to try more efficient increments. However, my count for comparisons/exchanges seems too low for an array of 2000 elements. I've tried changing it around some but still everything seems too low. Could someone look ...
This question is an extension of this one, which is my implementation of a coordinate system using the Java learning software Karel J. Robot. With the below code, I created a way to automatically make the robot place beepers on spots on the coordinate plane to imitate drawing letters. Here is the code that is the basis...
I'm a bit new to Python and sort of learning on my own. I wrote a small function to help me find the latest file in a directory. Taking a step back, it reads a bit janky and I was curious what steps or what resources I could look into to help me make this more friendly. Should I be returning False? Or 0? Inside my exam...
I'm trying to create a graph representation in Adj Matrix in Python. I'm not sure if this is the best pythonic way. class Graph(object): def __init__(self, edge_list): self.edge_list = edge_list def add_edge(self, edge_list): self.edge_list.append(edge_list) def adj_mtx(self): v =...
How do you handle AggregateException? It is really useful in many TPL or business scenarios, but handling is a real pain. I defined the following three extensions to help myself a little bit. They can be used this way: try { throw new AggregateException( new ArgumentException(), new DivideByZeroException()...
In mobile phones technologies, a SectorId is a 128-bit value broadcast by a 1xEV-DO BTS system. That is a 16 bytes data. I made a structure to store them: using System; using System.Globalization; using System.Linq; using System.Text; public struct SectorId { readonly byte[] id; SectorId(byte[] id) { ...
I use 2 methods in order to parse those 2 lines: flux=rp_evtmedprev_out partitions=a054010a,a054020a,a054030a,a034040a,a054050a,a054060a,a054070a,a054080a,a054090a This is the call: BufferedReader reader = new BufferedReader(new InputStreamReader( httpConn.getInputStream())); StringBuilder buf = new StringBuil...
After learning the basics (isolated state, communication and computation) of the the Actor-Model, I wrote my own implementation and I'm ready for a thorough code review. You will be able to see that in the test code I've created 2 tasks which are simultaneously sends multiple messages to an instance of the Actor class....
Below is the code to a Message Service. Does anyone have any ideas on how to improve the methods. It doesn't feel clean to me. public enum MessagesType { Standard, LocationTargeted, Scheduled, Expired } public class MessageService : GenericService<PushMessage> { public MessageService(IGenericReposi...
I have written a small Hello World application that uses Python's C-API. The C library requires some functions to be called for global library (de-)initialization and the objects created by the library eventually need to be released by passing the pointer to a specific function. I think this is a fairly common pattern ...
I'm trying to implement a memory scanner in python. The problem is, it's too slow. What it does it gets a number from the command line and compares it to every address, then writes it to an output file. How can I improve my algorithm? import ctypes as c from ctypes import wintypes as w from struct import * from time im...
This is a Python program that requires the user to type the colour of the text and not the name of the colour. They have a set time limit and a scoring system. If you have any improvements or suggestions I would greatly appreciate them. #import the modules we need, for creating a GUI... import tkinter #...and for creat...
I want to remove/add classes when the user is at different distances from the top by using jQuery. I have successfully done it, and it works fine, but I think I'm doing it wrong, and I would like your help to optimize the code. The html is simple, basically the sections(including the header), have 100% width. and diffe...
Today I'll demonstrate a simple function that searches for a item in all sublists of a list. For this it uses iteration, and keep in mind that it can be slow because of this. How can I improve it? Linked lists? I doubt __contain__ can do the same. def ListContainWSublist(searchfor, *args): Result = False for ...
In an exam question I need to output some numbers self.random_nums with a certain probability self.probabilities: I have written the following program that successfully returns the correct answer and also a test at the bottom which confirms that everything is working well. Here my questions: Are there any better ways ...
I've tried my best (I'm new to JS) to write a script that make an image fit to its parent div with respect of the ratio and overflowing when needed. For example, if the height of the image is smaller than the window's height, I set the height equal to the window's height and the width overflow the window's width. I the...
I've tried to roll out my own HyperScript implementation. I would be interested in any suggestions to improve it or point me to any other better implementation which is still maintained. I checked the HyperScript project, but it doesn't seem to have any recent updates, so I tried this: var DOM = { h: function(tagNa...
I've made a working version of Connect Four in Python. I'm pretty new to Python so it's decently primitive. Please take a look and let me know what you think! import random board = [["." for x in range(7)] for x in range(6)] symbol = "" winCondition = "" fullCols = [] def boardLogic(pick, user): if user == "user"...
I've made a nice little Python program using the requests module using the Trade.tf Developer API and the Steam WebAPI allowing the user to look up the price of Team Fortress 2 items through Trade.tf's spreadsheet. For those of you that may not know, Team Fortress 2 is a free-to-play team-based shooter game which also ...
I've spent the last few evenings learning PHP, CSS and HTML through Codecademy and now on Team Treehouse. My goal is to progress with PHP over the next year or two and perhaps obtain Zend cert. Anyway, I've worked on a simple calculator to test what I've learned. I'd like to see, (given the same 'functionality')what mo...
#pragma comment(lib, "sfml-network.lib") #include <iostream> #include <SFML/Network.hpp> const unsigned short PORT = 5000; const std::string IPADDRESS("192.168.0.100");//change to suit your needs std::string msgSend; sf::TcpSocket socket; sf::Mutex globalMutex; bool quit = false; void DoStuff(void) { static st...
I have the following program running. It has so far been taking several days straight and has yet to finish. So, I'm just wondering if there is any way it can be optimized or better structured to reduce how long it takes to run (yes, I realize there's a lot of calculations). struct NumberSets { std::vector<double> ...
Business rules: This application is for internal employees to request supplies. All requests must be approved my the persons manager. In the database, a manager is an employee, with a self referencing key joining an employees managerid to the managers employeeid. The database does not pull employee records from anywh...
A working label expression for ArcGIS 10.3. I was using dictionary key:values but sometimes the keys would have the same value so my items were 'disappearing' out of the dictionary. Now I use this simple counter to group my values from a list (0,1) (2,3) (4,5). I think the if functions might be able to be combined, as ...
SPOJ problem #0074 DIVSUM - Divisor Summation requires computing the sums of proper divisors in bulk (200000 test cases, time limit 3 seconds): Given a natural number n (1 <= n <= 500000), please output the summation of all its proper divisors. Definition: A proper divisor of a natural number is the divisor that is st...
I have written a function that builds an array of paging options for rendering on the view. I have modelled it after DataTables for jQuery, a live example with lots of data is available here: http://www.companieshousedata.co.uk/a/490 Is there a better way to write this? The function also returns ellipsis (as strings) ...