instruction
stringlengths
71
71.9k
(See the next iteration.) I have this Python (3.4) script for demonstrating the performance of the BFS algorithm, both traditional and bidirectional: #! /usr/bin/env python3.4 import time import random from collections import deque __author__ = 'Rodion "rodde" Efremov' class DirectedGraphNode: def __init__(self...
The following code fetches a set of company IDs from a database if there are any events associated with a company that has a missing property. Because the set of company IDs is embedded into the SQL query using parameters, and the number of parameters may exceed the maximum for the RDBMS / database driver, the set is p...
I have such objects that I need to merge: defaultConditions = where: enabled: true acc_id: ne: null conditions = where: id: 2 acc_id: ne: 5 This helper recipe, which replaces where from defaultConditions with where from conditions, is not quite right for this purpose. So I wrote...
Is this good OOP style? Do I need to split this class into two classes? If so, how do I do this? What methods should I need to add to the interfaces? public sealed class DeferredResultCollection<TResult> : IEnumerable<TResult>, IDisposable { private readonly IAsyncCursor<TResult> _asyncCursor; private readonly ...
I set out to make a simple dynamic resize method for images. Obviously, it's better to serve images that are pre-sized to avoid unnecessary server loads. But it was fun to make for a novice/beginner jQuery project and not really meant for a production project. For many of you, I'm sure it'll be rudimentary at best, but...
I have designed a Backspace button (part of a keyboard which I am designing) in windows forms and it works perfect with no errors (the code works very good). This button deletes what is inside the textbox. I just want to see other people's views and what they think about my code, so because I am new to c# I think there...
Pardon if this is silly, but I'm pretty new to coding. I have this code, that works, but I feel like it could be tighter than this, I just can't seem to get it to work any other way. The idea is to read a .txt file find incoming e-mail strings and organize the data by frequency of hour sent. Here is an example line tha...
I had an interview and was asked a problem. I provided a solution and wanted to make sure if this is correct. There is a Tile class. It has a boolean variable isGoldenTile which is false for all but true for one tile. There is a List<Tile> neighbors. These are list of its immediate neighbors which are tiles. There is a...
I am creating a blog using React, MongoDB, Express and Node. I have three components: App, List, and Item. The item is a blog post; the list is a list of the blog posts, and the app includes a place to enter text and submit it. I will eventually add more functionality, but I want to determine if I am adhering to best p...
I am implementing a SQL-like datbase system in python, and so I needed to implement a value changing function, but what I ended up with seems very convoluted. Here is code relevant to the value changing: def _get_primary_rowval(self): idx = 0 for n in self.def_column: if n.is_primary: return...
At the moment I have a Reminder Date. In the UI I have two fields to create the reminder date. The first field is an int and the second field is a combo box. public int Frequency {get; set;} public ReminderComboItems item {get; set;} public enum ReminderComboItems { Minutes, Hours, Days, Weeks, Months, Years } p...
I thought of writing a utility class where I can implement patterns that are useful for day-to-day parsing of strings, without having to to import java.util.regex everywhere. So I wrote this simple class as a model. This was inspired by a (now deleted) Stack Overflow question: For ex: String str="asd14sd67fgh007"; I ...
I think I solved the following problem. However, I was wondering if there was a faster or more efficient way to solve this. I believe the the runtime is O(n) and space is O(1) (O(256) assuming ASCII) # Longest substring with at most 2 distinct characters # # Given a string S, find the length of the longest substring T...
wRecently needed to swap keys with a colleague on the other side of the country. This script encrypts a file using the other persons public key that is stored on github. It outputs a script that will re-generate the original message (if you have the private key). #!/bin/bash # # Usage: # ./crypt <GitHub User> <File T...
I wanted to take on the challenge of the classic Robot Path's problem but solve it using Pascal's triangle. The approach was generate pascal's triangle, then grab the middle element from the row. I saw the following pattern: //where combos are on pascal's triangle: // 1x1 grid on the 1st line ===> 1 // 2x2 grid on 3rd...
I've written this Wack-a-mole like game on my iPad in the app Pythonista. Keeping that in mind, it uses a different graphic interface from the one I have usually seen used, Tkinter. I'm a beginner and this is my first major project, so any tips on how to code more efficiently and improve this program would be greatly a...
This is my simple jQuery form validation/submit logic and it is working perfectly fine. But still I am posting this to see if someone check the logic and suggest me if there is any other simple way to get the same results. In my form I put all input boxes and select into .valid1 class, all checkbox and radio buttons to...
I have a situation in which I need to get the closest road to a DbGeography point. This takes 5 - 8 seconds to run in some cases. I have a Spatial_Index on the column and I re-organised it, so it is not fragmented. This query is quite heavy, sometimes the CPU usage raises to 100% because of this. This is what the tab...
This (working) code is supposed to return a new array that consists of elements of both arrays that were not marked as duplicates (find duplicates in both arrays, remove such elements from both arrays and create an array from the leftovers, if any) Is there a way to simplify this function? function diff(arr1, arr2) { ...
I think this code has far to many if else clauses and not enough abstraction via functions. I would like to break the code down into a series of small functions, or methods if i decide to go OOP, but I'm not sure of the best way to do so. If you brilliant Pythonista's could guide me in the write direction I would appre...
This function sorts an array and returns the unique items. I'm trying to get it down to a readable 5 lines of code. So far I've renamed the variable cursor variable and inlined the assignments. I'll appreciate fresh eyes. Before function uniques(array) { var result = [], val, ridx; outer: for (var i = 0, le...
I am having a simple foreach where I add objects to a list: List<SoonestDrawDateModel> soonestDrawDateModel = new List<SoonestDrawDateModel>(); foreach (var item in drawDates) { SoonestDrawDateModel sdModel = new SoonestDrawDateModel(); sdModel.DrawDay = item; sdModel.DrawDayId = it...
My task was to write a server class, which uses select(), for a student projet. It was working, but i'm now willing to improve it a lot, and be able to use it in other personnal projects, so any critique and improvement idea is welcomed ! Here is the main.cpp : // example packet typedef struct packet { char ...
I am looking for the way to speed up my script. The final output is as required, but it's clunky and really slow. I know it's slow because of the double for..in.. loops. So, how could I make it a bit smoother? My script updates existing feature classes. I have two folders where all up-to-date shapefiles (shp) are store...
I made my own version of merge sort: (defn rsort[a] (cond (<= (count a) 1) a :else (let [half (/ (count a) 2) [lh rh] (split-at half a)] (loop [res () slh (rsort lh) srh (rsort rh)] (cond (empty? slh) (into srh res) ...
Problem (Tape Equilibrium): A non-empty zero-indexed array A consisting of N integers is given. Array A represents numbers on a tape. Any integer P, such that 0 < P < N, splits this tape into two non−empty parts: A[0], A[1], ..., A[P − 1] and A[P], A[P + 1], ..., A[N − 1]. The difference between the two parts ...
gotoxy() allows you to place the blinking text wherever you want. I wasn't able to get it to behave the way I wanted, so you will notice I had to insert a bunch of spaces in the cout portion of the blink function. Obviously this could be refined. blink() I put a "/r" to set the cursor back to the beginning of the line,...
I have made a simple Tic Tac Toe game but I think I have not followed a few conventions. I hope if you could help me improve it by suggesting some fixes. package practice; import javax.swing.*; import java.awt.*; import java.awt.event.*; public class TicTacToe extends JFrame implements ActionListener{ /** *...
A short time ago, I discovered the LinuxFromScratch project. After getting a system up and working (after much struggling), I realized that if I wanted to continue using LFS, some sort of package management would be quite nice. Of course I could have installed Pacman, apt-get, rpm, etc. like any sane person, perhaps. I...
In this question related to rolling multiple dices, the OP pretty prints for a single case where number of dices is less than or equal to 6. This led to me finding this code golf on "Draw dice result in ASCII", but still only 6 sides. I wanted to extend this to at least 20 sides, and possibly some day any number of sid...
(See the next iteration.) The following snippet is a brute-force algorithm for computing a graph radius in time \$\Theta(V^2 + VE)\$ and space \$\Theta(V)\$ simply by doing \$|V|\$ breadth-first searches over each node in the graph. The graph radius is a minimum graph eccentricity of any node of the graph, where eccent...
I'm building cross-platform application (every mobile/desktop OS + web in ASP.NET). I'm using Xamarin, so I can do everything in C#. But before I start working on UIs, I want to build soild, flexible Core/Domain project that will be shared in all Client apps. I read a lot about DI and IoC containers, I know a lot of t...
I have this task to find the longest identical phrase which appears in 2 given files. With small files (~500KB each) it works just fine, ~10 secs to finish. But with larger files (~5MB each) it took ~43 mins to complete. The text in larger files are just copied and pasted over and over again. And I want to improve that...
Arguments: The directory in which you would like to change file extensions Old file extension And what the new extension should be Example: $ touch /tmp/spam.eggs $ python change-ext.py /tmp .eggs .spam $ ls /tmp $ spam.spam My Concerns. Is the code easy to read and comprehend? Is the code Pythonic? Does the code h...
I created this class for a project when I wanted to have List<T> properties on a class and also listen for items being added and removed. I looked at using BindingList<T> or ObservableCollection<T> but I felt that their collection changed events are too complicated. I simply wanted to know when items are added and rem...
I created an evolutionary algorithm that optimises the range of a "glider"...ignore the accuracy of the physics behind the problem! Any comments on how to improve the algorithm/my coding style would be greatly appreciated. If it helps, here is the link to the github repository. from __future__ import division import r...
Let's consider following function that return some risk levels enum type: func calculateRiskLevel()-> ResultFirstLevels { let result = self.result if result < 1 { return .Level1 } else if result >= 1 && result < 5 { return .Level2 } else if result ...
I have some code that does what I want - it just doesn't feel correct for being done in JavaScript. What it does is take data that is like this: var data = [['Marker', 'sampleName1', 'sampleName2'], ['CCR4', 71.6, 83.4], ['CD27', 42.3, 76.2]]; And create a list of objects that looks like this (to use the ...
I have a simple custom attribute MessageDeliveryAttribute that has one string filed. Also I have several classes that mark with this attribute like: [MessageDeliveryAttribute("MessegaToDb")] In the app.config are settings like: <appSettings> <add key="MessageToConsole" value="true"/> <add key="MessageToDb" v...
I made a game in python which plays a bit like old terminal based RPGs, though a lot more basic. I had originally intended to implement a weapons and armour system and thus remnants of this can still be seen in the latest version of the code. Please review this, from the documentation to the actual code. from random im...
I made a simple tic-tac-toe AI app, where the AI, who is always O, wins or ties. I just wanted some input on it, and wanted to know if there was any ways to improve it (not the functionality of it, but how efficient it is, cleaner ways to write stuff, better naming, etc.). I also don't know if I'm supposed to go throug...
I've been practicing my algorithms using The Algorithm Design Manual. I've decided to implement the breadth first search section (5.7) using javascript. I also have a findShortestPath and a connectedComponents function that utilize my BFS. My BFS function accepts an adjacency list. /* A Queue object for queue-like func...
You may want to take a look at Rounds 1, 2, and 3, though that isn't necessary for understanding what's below. The major change since Round 3 is that my code is much cleaner and I'm including profiling information here. Here's my script: #include "hansel.h" #include <deque> int main() { // Parameters. const doub...
This is a basic Tic-Tac-Toe game with a minimal interface. The only concessions to ease of use are input validation (7 lines) and 1-indexed rows and columns (a few bytes). I've been trying to tighten it up while still maintaining readability and PEP-8 style. I'm pretty happy with most of it, except for printing the boa...
The fn odd_ones(x: u32) -> bool function should return true when x contains a odd number of 1s. Assumption: x is 32 bit unsigned. Restriction: The code should contain a total of at most 12 arithmetic, bitwise and logical operations. Forbidden: Conditionals, loops, function calls and macros. Division, modulus a...
I have written a simple pager in C. It works fine for most things, but I'd like to know how it can be improved. Specific things I'm looking for are if there are size and/or speed improvements to be made, as I have noticed that it sometimes performs slowly (but that might be my slow computer ;-), and usability. This obv...
I was looking for a way to better define email recipients along the lines of the To/CC/BCC convention. Although SYSTEM/STANDARD/EMAIL contains CC and BCC fields, they are not currently functional, see: "How to Add Addresses to the BCC Field Using Rebol's Send Function" Therefore in this solution, I've reorganised the S...
See the previous and initial iteration. Terminology Given an undirected graph \$G = (V, E)\$, the eccentricity of a node \$u \in V\$, \$e(u)\$, is the maximum length (number of edges) of a shortest path from \$u\$ to the furthermost node from \$u\$. The graph radius is the smallest eccentricity over all its nodes, or n...
I wrote a program that finds out if matrix has 2 oblique lines that each oblique line has the same value. The lines does not have to be the same value. for example: for this example, output is false (there is only 1 oblique of 1,1,1) for this example, output is true (there is 2 oblique: 3,3,3 and 2,2,2) This is my co...
I have created this fake API just because I want to learn how to use JWT. It is a simple unsigned token exchange with two methods call: login and adminPassword. I've used https://github.com/lcobucci/jwt as a JWT implementation. This is the server code (index.php): <?php // https://github.com/lcobucci/jwt require_once '...
I'm developing an iOS application where data is fetched from a third-party REST API. Each request must contain an authorization token. In order to implement this, I've written a fetchToken withCompletionBlock:(void (^)(ASToken*) token,NSError * error) method in AppDelegate: -(void) fetchTokenWithCompletionBlock:(void (...
Implementation of a hash function in java, haven't got round to dealing with collisions yet. I tried to use good code, refactored, descriptive variable names, nice syntax. My code must be efficient and extensible. Would be interested to know how you guys would improve. Three classes: TestHash - main method is here, ha...
So I needed a a star rating feature to appear in my app - it doesn't need to be interactive. I have my app connected to a database I've set up in Parse, and I've made a column for OurRatingof type Number, and I just set a number between 0.5 and 5. In my custom cell, I have 5 images which will display my star images. Th...
dataListOne and dataListTwo will be full of BO objects (around 4000 - 5000). Lets say dataListOne comes with objects with business keys: "one,two,three,one" and dataListTwo has: "three,four,five". At the end I must have: insertList: "one,two" updateList: "three" deactivateList: "four,five" There may be 2 BO's with sa...
I've been practicing my algorithms using The Algorithm Design Manual. I've decided to implement the depth first search section (5.8) using javascript. Note you can execute the code here if you don't have node.js. var doDFS = function(graph, source, directed, processVertexEarly, processVertexLate, processEdge, logOff) {...
Given a typelist, return a typelist of all the permutations of it. For example: using Types = typelist<char, int, double>; using Permutations = typelist< typelist<char, int, double>, typelist<char, double, int>, typelist<int, char, double>, typelist<int, double, char>, typelist<double, char, int>, ...
I am building a database for a hypothetical university. This is my SQL definition, with generated data added for my future use, such as demonstrating queries: Create Table Semesters ( Semester varchar(6) Primary Key Not Null, ); Insert Into UniversityDatabase.dbo.Semesters Values ('Spring'), ('Summer'), ...
I have written this piece of code that implements the double factorial in Python both iteratively and recursively; the code works without problems, but I'm interested in improving my overall programming style. Here's the code: def semif_r(n): #recursive implementation if n == 0 or n == 1: z ...
I'm learning how to write tests in Angular (these are my first tests in general). There are a lot of tutorials out there but each one of them has a different approach. I'm a bit confused if I'm doing things the right way. I made a simple directive for testing purposes and I've called it tooltip (though its not really a...
I have a list of lists of 4 integers, each representing the length of one side of a tetragon in clockwise order (so each number is the length of the side of the right-hand-adjacent-side of the previous one). Integers can be negative or positive or 0. My idea is that if any of the sides are less than or equal to 0 then...
After seeing Pretty print dice faces from multiple rolls of multi-sided dices, I decided to make an infinite ASCII dice generator. There was one requirement, it to follow a normal dice face. And so I decided on making two classes, the Dice and Rings. Dice outputs the ASCII dice, holds the rings, and tells the rings how...
I've attempted a functional solution to Conway's Game of Life in Python. The example code allows you to see the next generation of the universe by calling the step() function, passing the current generation of the universe. The universe is represented as a set of live cells. Live cells are represented as a tuple of x, ...
I'm somewhat new to writing real-world projects in C, so I'm not familiar with best practices and standards. I'm writing code dealing with EGL and OpenGL, and some setup calls might fail for reasons outside my control. I want to write an initialization function that performs all necessary setup for my application, but ...
I have the following code to solve dinning philosophers problem using Go channels and am looking for review comments: package main import ( "fmt" "time" "sync" "os" "bufio" ) type diner struct { thinkTime time.Duration eatTime time.Duration free []chan bool done []chan bool n ...
I've written a JavaScript dictionary sorting algorithm, which takes a .txt file (the dictionary), and loads it via node's file system. The purpose of this algorithm is to sort every word into its corresponding array based on its letter pattern. For example, the word little would have the letter pattern of ABCCDE, and h...
I started learning the Java language about 10 days ago, reading Introduction to Programming Using Java by David J. Eck. I've made it halfway through chapter six in about 9 days. I realized I was going way too fast to learn efficiently, and so I'm going back to reread the focal points of the chapters and finish the exe...
In a recent interview I have been asked to write a program to generate the following output: * * * * * * * * * * * * * * * * * * * * * * * * * * * * * I had written the following code in java public class Triangle { public static void main( String[] args ) { show( 5 ); ...
There is data stored in JSON file with the following structure: goods_data = {"year" : {"month" : {"day" : {"01" : {"name" : "some item", "price" : "10.01", "category" : "root | first | sub first | twice sub first", "02" : {"name" : "another item", "price" : "10.99", "category" : "root | first | sub first"} }}}}} Th...
The IRubberduckParser interface has seen breaking changes, and now looks like this: public interface IRubberduckParser { RubberduckParserState State { get; } Task ParseAsync(VBComponent component, CancellationToken token); void Resolve(CancellationToken token); } This new interface does more than breaking ...
This form will store research article information in a database. It would be nice to somehow add buttons to add additional author and university fields or also multiple universities for 1 author. Do you see any glaring issues with my code? <!DOCTYPE html> <html lang="en"> <head> <title>Input Form - Research Ranke...
When my go-to Japanese transcription site went down for a while, I decided to write my own. My application converts between Romaji, Hiragana and Katakana — however, unlike any other converter I've seen, this one does a three-way conversion: there are three text boxes, and typing in one will update the content of the ot...
I have written my very first Haskell module and I feel that the code can be improved based on the simplicity of the problem I am solving. Do you have any suggestions? Problem statement: You are given a String code containing a message composed entirely of decimal digits ('0'-'9'). Each digit consists of some number of...
I have made a class what uploads an image to imgur (a service with an API where you can upload images). And then I read the response of the API what contains the URL and the HTTP status code (200 if succeeded). And I'd like some feedback, since the runtime is pretty long for a 50kb image. The current runtime is around...
I made the following code. Since it is a Batch, any kind of problems can appear. Please review it and point any problems when copying files into Dropbox! Its intent is that you will copy a file into an Dropbox folder. Its syntax is dropbox <files-to-dropbox> <dropbox-folder-to-copy-to>. @echo off set dropbox=%userprofi...
I was reading about making fake 3D effects or so-called "mode 7" on 2D contexts. I have made a small program to demonstrate the fake 3D effect by using SFML. How can I improve it? #include <SFML/Graphics.hpp> #include <array> #include <cmath> struct P { struct Screen { float x, y, w, scale; }screen...
I have solved the Problem 25 of the Euler Project: The Fibonacci sequence is defined by the recurrence relation: \$\qquad F_n = F_{n−1} + F_{n−2}\$, where \$F_1 = 1\$ and \$F_2 = 1\$. Hence the first 12 terms will be: \$\qquad F_1 = 1\$ \$\qquad F_2 = 1\$ \$\qquad F_3 = 2\$ \$\qquad F_4 = 3\$ \$\qquad F_5 = 5\$ \$\qqu...
The following is my tree coloring realisation attempted to get a feel of Elixir (simple, but slow coloring algorithm from Principles of Distributed Computing). Coloring runs from the root, using alternative colors 0 and 1. defmodule Graph do def add_v g, v, label do :digraph.add_vertex(g, v, label) g end ...
Because it is a lot of code, I don't want to ask for details what is wrong, but want to ask about review what can be changed in approach to this. This is controller that make query: It grabs data within time range Does aggregation so I get sum of some fields Because there are some fields from different collections i....
I am working on a simple console chat in Python. I started from this Winforms application, removed all the forms (so that the chat could run on Windows and Linux) and did some refactoring (the "click events" did not exist any more, it needed a workaround). The new client code: import thread from MinimalNetworkTools imp...
Task: I have two dimensional array of chars filled with random values [a-z] and need to find if the word ala appears vertically, horizontally or diagonally in it. In my program, I go through all characters and try to find word in all dimensions. I feel there is more intelligent way to do this task which will: Work wit...
I'm reading the book Head First Java and got an assignment to re-create the 99 Bottles of Beer song according to those lyrics found in the URL. I've had to do this with a Java while loop. class SecondBeerSong { public static void main(String[] args) { int beerBottles = 99; String word; whil...
I wrote this bit of C that prints a half-pyramid, * ** *** **** Here's the main body: #include <stdio.h> #define SIZE 4 void printrow(int threshold); int main() { int i, threshold; for (i = 0; i < SIZE; i++) { // threshold slides to the left with each iteration: // ===| // ==|=...
I am trying to learn how to build a very basic MVC structure before jumping on rails and other frameworks. I am working from a .txt file, and I organized a project into four parts: a model, a view, a controller, and a runner. .txt file pattern: line1 -> "question" line2 -> "answer" line3 -> "" #blank line line4 -> "qu...
I am not quite sure how to attach my data, but it is 5737 observations of 3 variables. Variables V and P are strictly < 0, and variable R is -2 < R < 2. The last function, correcttot, will help me find the optimal constants, or ranges of constants, for this function. However, the function that it runs over, percentcorr...
I programmed in C# and I used the Qt framework. Both of them have their own signal slot mechanism which are really powerful. I looked at several implementations in C++ and based on what I learnt from those sources, I started to implement my own version to better understand how these could work under the hood. My implem...
I have written a simple flashcard program that runs in the terminal: It loads the cards from an ordinary .txt file. It provides a way to add flashcard from within the program to avoid that beginners editing the plain-text mess the formatting up. It asks questions one after the other, because it maximizes learning (no ...
Inspired by this post, I decided to try to implement my own Conway's Game of Life. I started with a non-warping board: /** * Represents a single generation of a Conway's Game of Life. * */ public class Generation { protected static final int[][] SURROUNDING_CELL_POSITIONS = { { -1, -1 }, { 0, -1 },...
I wanted to write a function that when invoked, will scroll the page downwards in a smooth fashion. Comments and criticism welcome. I don't like, for example that determining whether it is done is not based on the scroll position. const EASING = BezierEasing(0, .1, .1, 1); // Example values. const DURATION = 1000; //...
I've written a singly linked list in C++. Would appreciate reviews on code efficiency and best practices. #ifndef SLIST_HPP #define SLIST_HPP #include <stdexcept> #include <iostream> template <typename T> struct node{ node(T data):data(data),next(nullptr){} T data; node<T> * next; }; template< typename ...
I wrote some code in Python, to benchmark mathematical operations. It does not do anything in particular besides just calculating a lot of floating point numbers. To clarify: I need 128-bits precision floating point numbers. from __future__ import division from numpy import arctan, sin, absolute, log10 from mpmath im...
I wrote basic Python code for the summation of n primes. It works but I wanted to find out how I could improve it and what shortcuts I missed. """ So this program is designed to add up the first 'b' primes ==> Prime number is defined as a number only divisible by itself or 1""" def is_prime(a): """ This f...
I have just started implementing Binary Search tree on my own without using any tutorials online. Please have a look and suggest how can I make code less cluttered and more faster. Right now I am using lots of if-else conditions and want to remove them as much as I can. boolean deleteNode(int data, TreeNode node ) { ...
Here is my working code for a min-heap sort using an Array-List. I would like any input as to areas that need additional refining and any areas that are against proper formatting/usage. Although not defined, I was attempting to use an array implementation instead of the Array-List collection as the class has been creat...
I am a PyGame newbie and am learning as I go. I would like to become familiar with normal PyGame conventions. I would like you PyGame experts go over my code and let me know if there are any places I should modify my code to follow best practice. The point of the game is to collect as many pills as possible. Yellows ar...
I've decided to revisit a chunk of code I wrote a while back, and see what I could do to make some changes. As a result, I know have slow, but working piece of code which is able to simulate gravitational attractions between \$n\$ amount of bodies. Like usual, I'm using the formula described in Newton's Law of Gravitat...
I am trying to solve apparatus problem, paraphrased below. There is an apparatus with n on/off switches with a one-to-one correspondence to n lights (but with an unknown permutation). We have several different photographs of the apparatus showing different configurations of the switches and lights. Are these photos ...
A while back I made a custom String struct (see github repo) because of the difficulties in dealing with Mongolian Unicode rendering when using Swift String or NSString (see this question and the accepted answer for more details). The struct is an array of UInt32 so that it represents a string of Unicode scalar values....
Time complexity is supposed to be \$O(n \cdot \log(n))\$ and space complexity is supposed to be \$O(1)\$. Neither the elements of the container nor the container should be modified. // Copyright [2015] <none> #include <cstdlib> #include <cstddef> #include <cassert> #include <iostream> #include <vector> #include <iterat...
I've written a function which, given a number string, returns the next largest palindrome in string form. For example, if the input string is "4738", the output should be "4774". The original problem description is found here. The function seems to be working for all the tests I have thrown at it so far, but the probl...
This seems to work, but for some reason I'm not entirely sure about it. Can anyone point out any issues with this simple pub/sub library? Thank you! (function (undefined) { window.mylib = $.extend(window.mylib, (function () { var subscriptionsBag = function() { var self = this; se...