instruction
stringlengths
71
71.9k
I made a LinkChecker program which checks URLs from a text file and outputs status into another file like this: http://valid-url.com;OK http://invalid-url.com;The remote server returned an error: (404) Not Found. I have about 1400 URLs in the input file and it takes about 12 minutes to run. I made it work. In what ...
I have a comboBox and a TextBox in the View and when the view is loaded, the ComboBox should be populated. After that when a user selects particular item from the ComboBox, its related ValueMember should be displayed in the TextBox. The View doesn't know about DAL or Presenter and, it only has properties and events. ...
I have a method that transforms any input uint into a [min,max] set. I am looking for improvements on the function, specifically to get rid of the input == uint.MaxValue case. public static uint NumberInRange(uint input, uint min, uint max) { decimal divider = uint.MaxValue / (decimal)max; if (input == uint.Max...
Please take a look at this class and point out its flaws. I am developing a simple Finite Element Method analysis with PHP. What this class basically does: Given an input set (coordinates, properties, plane type), calculate an output/analysis set (area, matrix, etc.). Possible hints on flaws: This is a full static cl...
I was trying to implement a foldTree function to generate a balanced binary tree from a list of values using foldr (Question 2 here), but the resulting solution is not really written in a proper manner: data Tree a = Leaf | Node Int (Tree a) a (Tree a) deriving (Show,Eq) foldTree::[a]-> Tree a...
In this problem you are given input of phone numbers and you are supposed to determine whether any number is the prefix of another. I have an addchild method that returns true or false if a given string can be inserted and is not a prefix of another string. How could I improve the efficiency of my code so that I could ...
Could you please tell me if there is better way of performing division without +, * or /? I've tested this code for different values of a and b. Could you please tell me if there is a cleaner solution? private static int divide(int a , int b){ if(a<b) return a; boolean isNeg=false,sign=true,bothNeg...
Detect if tree is complete binary tree. This question is improvement over previously asked here. Looking for code-review, optimizations and best practices. Verifying both space and time complexity to be O(n), where n is number of nodes. public final class CompleteBinaryTreeDetection<T> { private TreeNode<T> root; ...
We have machine hostname as - dbx111.dc1.host.com dbx112.dc2.host.com dcx113.dc3.host.com dcx115.dev.host.com Here dc1, dc2, dc3 and dev are our datacenter and we will be having only four datacenter as of now. And also it might be possible that machine hostname can have more dots in between separated by another domai...
Curious to know how I can improve it, especially the pattern matching part seems a bit repetitive at the moment (lots of case x if ds(x)) def binarySearch(ds: Array[Double], key: Double): Int = { @annotation.tailrec def go(low: Int, mid: Int, high: Int): Int = { mid match { case x if ds(x) == ke...
I've created a utility program for combining multiple .vec files into one. The program's main application is in training haar cascade classifiers in openCV (details). This is my first open source contribution that other people may find useful and I would like to improve it if possible. I'm mainly interested in feedback...
K and R Exercise 5-10 Write the program expr, which evaluates a reverse Polish expression from the command line, where each operator or operand is a separate argument. For example, expr 2 3 4 + * evaluates 2 * (3+4) #include <stdio.h> #include "expression_parser.h" int parse_polish(int size, char *expression[...
The model takes a long time to run. I have tried to vectorise it as far as I can, but it's still taking about a day to compute. I'm wondering if it's possible to speed it up. Maybe the problem isn't even with the code, but with the model being improper/bad priors/...? Or maybe the data set is simply very large and supp...
This is a follow-up to this question: Division without using addition, multiplication or division Could you please tell me if there is better way of performing division without +,-, * or /? I've tested this code for different values of a and b. I've also tested working for: divide(8,3) divide(5,10) divide(9,6) divide...
Tear it apart. I'm mostly concerned around the appropriate use of ConfigureAwait(false), and possible poor handling and duplication of the HttpClient in Invest and Get<T>. Additionally, I'd also like thoughts on the fact that for usage of these methods, one must call .Result to get the actual results. Is this standard ...
I would like to use this in a program to save users' names even after they relaunch the script. I was just wondering if there were some ways I could clean up this code. Note: this currently was made to not support name changing, but could possibly be implemented in the future. if os.path.isfile('names.json'): # if ther...
I find that this function is one of the biggest causes of slow program execution. I can write a square root version with BigInteger only, but with the cube root, the algorithm sometimes gets caught in an endless loop unless I also use BigDecimal, because the values of r and s never reach equilibrium. I've already used ...
I'm new to ReactJs and trying to figure out the preferred style. I also have tried it enough to realize that I'm not a fan of jsx and prefer how React looks when written in coffeescript. This is a very simple control (eventually will be a series of controls). It contains a select element and a button. When a selection ...
I've started learning C++ and I wanted to ask you to take a look at my linked list implementation and give comments what's wrong with. It compiles and runs fine, but I am curious about const correctness, proper use of pointers/references, etc., so feel free to go super tough on me! I've read about these concepts online...
There's a part in my page where you can add, edit or delete school details, and it wasn't supposed to save entries to the database until the user hits Enter, so I save all data in an object first. My object looks like this: schooldetails : { "1": { "school_ctr":"schoolctr_1", "school":"Fiat Lux Academe", ...
Some context I've been tasked with supplying an escaping function to arbitrary CSS values that are entered through a form. The goals and caveats are: I know it's bad practice to let users input CSS. Deal with it. Data will be injected either to a style attribute, or to an external stylesheet. This is run on PHP 5.1 (A...
I would like to add some capabilities to the server. Firstly, it should accept and handle connections with multiple clients, so that there are no mixups between clients. Secondly, there should be some very basic JDBC connectivity: serialize a result set as a List, and then, as requested pop from the list and send tha...
I building a very simple price tracker web app. I am using MongoDB with pymongo. The user will enter the URL of the product he wishes to track and the desired amount, when the price goes below this amount, he should get an alert. It doesn't matter how many products he is tracking, I will send the alert when price chang...
Aim: To Assess if one, or more, examples of a value exists in a Database in the quickest time as I only needs a True/False result. The variable is Alphanumeric. Question: Is this the quickest and best way to do this? Public Function PrcCheckIfValueExists(vVariable As String) As String 'Here we check if the Valu...
I use a thread to read from a UDP socket. Afterwards the string gets parsed. In another thread I send to every connected client via this socket. I would like to keep latency and resources for running the script as low as possible. It would be nice to add a time-out. Every attempt to read should be cancelled if longer...
I have the following function that checks if a number is prime: def is_prime(n): """ Is n prime? """ if n < 2: return False if n in (2, 3): return True if n % 2 == 0 or n % 3 == 0: return False limit = int(math.sqrt(n)) divisor = 5 while divisor <= limit: ...
I've recently started writing a tic-tac-toe game (following the Odin project) and am trying to write a class to hold the board game. What I'm not sure about, is that the board class holds all the data related to the board in a variable called @board. Now after thinking about it I decided that the Board class shouldn't ...
I want to resize an image with good quality, and the most important thing is having less weight for an image so that webpages will load it faster. I am using the below method for this. Please check it out, if it is proper or let me know if it needs any modifications. If there is a better method than this, then also ple...
My code takes 143.023 seconds for extracting nodes from a road network of city like Göteborg in Sweden. Please check it out if I can optimize it. # -*- coding: utf-8 -*- import arcpy from Class import loading_layer import time def node_extraction(network_input): time_start=time.time() nodes_list = [] lis...
I have three models which look like this: class Post < ActiveRecord::Base belongs_to :user, :counter_cache => :count_post has_many :likes end class User < ActiveRecord::Base has_many :posts has_many :likes end class Like < ActiveRecord::Base belongs_to :user belongs_to :post, :counter_cache => :count_like...
As part of an assignment for my intro Java class (please bear with my beginner skill set), I'm working on a program for which a Die object class is used to play a Yahtzee game. An overview of the directions are as follows: The program should give an introduction of what it is going to do, ask the user how many dice ...
I want to calculate the nearest cosine neighbors of a vector using the rows of a matrix, and have been testing the performance of a few Python functions for doing this. def cos_loop_spatial(matrix, vector): """ Calculating pairwise cosine distance using a common for loop with the numpy cosine function. """...
Reverse a doubly linkedlist. Looking for code review, optimizations and best practices. public class ReverseDoublyLinkedList<T> implements Iterable<T> { private Node<T> first; private Node<T> last; private int size; public ReverseDoublyLinkedList() { }; public ReverseDoublyLinkedList(List<T> c) {...
Like everyone, I use ListViews in a lot of apps. And I pretty much always end up making a custom Adapter. Yet 90% of my custom adapters end up doing the same thing (mapping directly from an ArrayList or array) with getView() overridden to update the views. I hate rewriting this part of the code. I also hate that th...
I recently started using the Builder pattern in one of my projects. Below is my builder class - public final class DataKey { private final long userId; private final String uuid; private final String deviceId; private final int clientId; private final long timeout; private final FlowEnum flow; ...
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 ...
I extended NumberPicker with several methods needed in my application. When I came to defining a OnValueChangeListener this is how I did it: import android.widget.NumberPicker; interface ValueChangeCallback { public void execute(RemListView list, int oldVal, int newVal); } public class RemListView extends NumberP...
I've posted a revised version of this here. I posted about this basic problem a while ago, and I got the recommendation to move the code for managing the Jobs of my game to another class. I have been working on it for a little while now, and I have code that I believe is ready for review. The result is three classes,...
I was reading Joshua Blochs "Effective Java 2nd edition" item 29, which describes how to create Heterogeneous containers, in the end of chapter he wrote: A Class object used in this fashion is called a type token. You can also use a custom key type. For example, you could have a DatabaseRow type representing a dat...
I have written this code for an Edx course called CS50x (a beginner course). This problem set required me to write a program which: loaded a dictionary into some sort of data structure (I choose to implement a trie) and which could take an input text and search for misspellings uses a file with an already implemented ...
This is my first solo Objective-C program... it does the complicated task of displaying a button and counting how many times it's been pressed. It retains that count (along with the last time it was pressed) between uses of the app. I have a few specific questions, but eagerly await any and all feedback. Is the try/...
Working through Learn You a Haskell, I made a Reverse Polish Notation calculator. Please critique it. -- LYAH uses `(Num a) => String -> a` as the signature solveRPN :: String -> Double solveRPN xs = head $ foldl (\acc x -> foldingFunction acc x) [] $ words xs foldingFunction :: [Double] -> String -> [Double] foldingF...
I recently started using Builder pattern in one of my projects and I am trying to add some sort of validations on my Builder class. I have already asked a question, got some feedback and incorporated it into my code. Below is my builder class - public final class DataKey { private final long userId; private fi...
So, another challenge from my professor. I've finished it, but wanted to get some feedback, and see how other people might work this problem. Assume you have a string, such as "Hello 34215 World 5620 From 384 Bloomington" Use list comprehension to separate the words from the numbers, and the numbers from the words. Th...
I have a spreadsheet, called "To Do", with set of percentages in column E and importance levels in column A: On another spreadsheet, I'm entering a formula to calculate the average of these percentages, but only those between certain importance levels: See it on googledocs This is the formula in question, indented f...
Here is the link to the problem Peragrams. Peragrams: If a word is an anagram of at least one palindrome, we call it a Peragram. Problem: Given a string, find the minimum number of letters you have to remove from it, so that the string becomes a Peragram. Input #1: abc Output #1: 2 Input #2: abb Output #2: 0 My P...
This is for Project Euler #30: Surprisingly there are only three numbers that can be written as the sum of fourth powers of their digits: \$1634 = 1^4 + 6^4 + 3^4 + 4^4\$ \$8208 = 8^4 + 2^4 + 0^4 + 8^4\$ \$9474 = 9^4 + 4^4 + 7^4 + 4^4\$ As \$1 = 1^4\$ is not a sum it is not included. The sum of these numb...
I need to find all paths from a given graph. I can do that for now, however my recursive code is not efficient and my graphs are very complicated, hence I need a better algorithm. def findLeaves(gdict): # takes graph and find its leaf nodes leaves = [] for endNode in gdict.iterkeys(): if not gdict[e...
I have the following two queries: res=session.query(t_marketing_mailing_stats_tbl).filter( t_marketing_mailing_stats_tbl.c.mailing_id==mid) res_t=session.query(t_marketing_time_stat_tbl).filter( t_marketing_time_stat_tbl.c.mailing_id==mid) try: return res.one() + res_t.one() except NoResultFound as e: ...
Is there any way to optimize this stored procedure? Maybe something instead of so many joins? It takes some time to execute. Maybe there are other options that I could look into? SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO ALTER PROCEDURE [stimulator].[GetLastMessages2] @serviceId bigi...
I am trying to grasp the concept of delegates and protocols in Swift. So I have implemented my own PlayableMedia protocol with two concrete classes BlueRayMedia and DVDMedia like so: protocol PlayableMedia { func play() func stop() } class BlueRayMedia:PlayableMedia { func play() { println("BlueRa...
I'm iterating through two lists to find matching objects. The objects have two string properties, Id1 and Id2 below. If Id1 is not null, empty or whitespace, I want to use it to find a matching object in the other list. Otherwise I want to make use of Id2. If both Id1 and Id2 are set to null by the extension method on ...
Some time ago, this question was posed, asking for help in optimizing a Sudoku solver implemented in C++. I decided to reimplement the code using C++11, but without guessing. That is, this Sudoku solver does not make guesses or backtracks, but instead only solves based on valid logical inference. With that in mind,...
I'm using Google Guava 17.0 library. I have a class named AroundBust containing only two properties id of type Integer and size of type BigDecimal. This class is instantiated based on the data stored in an XML file. A java.util.List is populated by a list of objects of this class. This list is displayed in a PrimeFace...
To review my use of multiprocessing, I don't think it is at all necessary to understand the algorithm, but it's the scrypt key-derivation function. This uses hashlib.pbkdf2_hmac which was added in Python 3.4. To run it using earlier versions, you can paste in pbkdf2_hmac from here. I've split the below to multiple code...
This program is to return a number one at a time from a given input list of numbers, with a frequency proportional to probability/fraction associated with each number. I know it could be made a generator function. But if I have to do it inside a class, can you please suggest improvements to this code, particularly with...
I have implemented a producer consumer problem, following the resources below: Oracle doc CSEE I have used mutex_t and sem_t. The reason for using mutex_t instead of binary semaphore because of my understanding- mentioned here. And hence I have avoided using sem_t as binary. Also the Oracle doc link I have provided ...
Follow-up posted here: Refactor this method to a cleaner state (continued) I am refactoring a legacy application. I DO NOT have the ability to change the Permissions, CustomerReport or the ListItems classes. They are in external dlls that are given to me. I realize that the ref usage is dumb and it makes NO SENSE. I am...
This is continued from here: Refactor a legacy application to a less-unwieldy state I am refactoring a legacy application. I DO NOT have the ability to change the Permissions, CustomerReport or the ListItems classes. They are in external dlls that are given to me. I realize that the ref usage is dumb and it makes NO SE...
I'm writing an utility audio plugin that specializes in "fullscreen" (the window is freely resizable) visualization of audio, like spectrograms, oscilloscopes and in this instance, a vectorscope. For those who doesn't know, a vectorscope is a coordinate system where each sample in an audiostream maps the coordinates (l...
I have written a small container class which groups a 3D position, a normal vector and a texture coordinate into one object. It uses the glm library for the actual data types (vec2 and vec3). This class is named Vertex. Here is the source: Vertex.h #ifndef CPP3D_VERTEX_H #define CPP3D_VERTEX_H #include <iostream> #inc...
I have put together a naive implementation of a VB6/VBA parser, and I'd like to see if the CR community sees the same things as I see can be improved with this code, before I start refactoring. I've never written a parser, so this naive implementation is naive in all senses: I wanted to push it as far as I could possib...
I wanted to make a dynamic select statement from this year to 10 years. This gets the job done, but I feel like it's a little much. form_dropdown('year', array_combine(range(date('Y'), date('Y')+10), range(date('Y'), date('Y')+10)), set_value('year')); Specifically, is there a better way to create this array, other t...
I have a form that allows the user to select a server. This will execute the exact same query just on a different server. private void QueryButton_Click(object sender, EventArgs e) { switch (this.FindByComboBox.SelectedIndex) { case 0: ByTargetVDN(); break; // ... } ...
I am using this script to get the admin pages via this query string ?page= once the admin is logged in. Just needing a review, opinions Function: // GET PAGE FROM QUERY STRING public function page_select($page) { $ext = '.php'; $file = 'pages/'.$page.$ext; if(file_exists($file)) { return $file; ...
I was searching for a pseudo-random number generator for C# and stumbled upon Tales from the CryptoRandom by Stephen Toub and Shawn Farkas, so I tried to implement a variation of their code. The main difference with their implementation is mine returns inclusive ranges (e.g [0,1] and [min,max] instead of [0,1) and [min...
This is my second linked list implementation for review. I rewritten pretty much all of this and have added iterators, sentinels and The Rule of Five. Please let me know what's wrong with it; I am still not confident in many areas. #include <stdlib.h> #include <memory> #pragma once template <typename T> class Linked...
I wrote this little JavaScript function that starts with the number 1 and continually either adds 5 or multiplies by 3. This function tries to find a sequence of additions and multiplications that find that number. Keep in mind, this function does not necessarily find the shortest sequence of operations. I am looking ...
I'm attempting this code challenge. Here's my code modified to handle one simple example test case: string = "bcdefghij" l = string.size result = [] permutations = string.split('').permutation.to_a l.times do permutations.each {|p| result << p.sort.join} permutations.map! {|p| p[1..-1]} end puts result.uniq.sor...
I have created this regular expression to validate usernames which I need in my projects: ^(?=.{3,32}$)(?!.*[._-]{2})(?!.*[0-9]{5,})[a-z](?:[\w]*|[a-z\d\.]*|[a-z\d-]*)[a-z0-9]$ It works just fine. But I'm wondering if there is any improvement and optimization for it, since I'm not exactly a regex-guy. The regex and te...
Given a Perfect Binary Tree, reverse the alternate level nodes of the binary tree. Given tree: a / \ b c / \ / \ d e f g / \ / \ / \ / \ h i j k l m n o Modified tree: a / \ c b / \ / \ d e f...
I have some code that reads an email from a text file, parses the text, removes some lines (the 'cc' and 'to' lines) and then finds the line numbers of various phrases (e.g. "Regards", "Thanks") and then removes all the text for the lines after the first phrase found. It works fine, but is not generic enough as I will ...
I am wondering what the best way to update multiple records with Entity Framework is. This is how I normally do it, and it does work: private static void SetNcprpCodesAsComplete(string[] ncprpCodes) { using (var ent = new Data.Entities()) { var query = from ba in ent.BuildingAssessme...
I'm fine with any sort of answer that helps better my code -- I'm not necessarily looking for a full refactor. I have a script that converts input (IPv4 address, submask, cidr, etc.) into usable information to subnet networks. If you need any more info here's the GH repo. It's only 350 lines with comments. (PS: I use ...
I'm developing a Windows Service that receives data from somewhere and saves it to DB one time per 5 minutes. The Service is multithreaded and I actually got problems when several threads saved data at same minute (no thread sync was implemented). Now I've implemented it and am looking for code-review and optimizations...
I have to store various HTML named character references for the following purposes: Escaping special characters myStringBuilder.Replace("À", WebHelper.Agrave) Insert spaces in legacy reports ReportButtons.Controls.Add(New LiteralControl(WebHelper.Space)) This is the way I used to store until now: public static class ...
I am trying to solve this problem Chef Ceil has some matchsticks in his kitchen. Detail of matchsticks: There are N matchsticks in total. They are numbered from to 0 to N-1 inclusive. All matchsticks have same length. But they may have different rates of burning. For ith matchstick, we denote bi as the time req...
This is just a little hobby project I've been working on. I've been using it to learn/improve my knowledge of C++. The program generate Norwegian personal-numbers (11 digits) for males born a given year. It works just fine, but I'd like some input on how to improve the code. For now I have a basic class structure. No...
Coming from a Java background, this is my first JavaScript-only game. I'm looking for some advice on what to improve. Also, I'm having trouble when it comes to program design. Sometimes I don't know if I should write class-like code or just plain functions. How does one go about deciding on this? Code of the snake: ...
I want to build the markup below by iterating on an array of objects. The structure of the object is also listed below. I need some tips on how to make it clean. Markup I want to build: <!--the markup I want to build--> <div class="pull-left col-xs-4"> <div class="thumbnail"> <div class="caption"> ...
I would like to get some feedback from the community regarding a plugin I recently moved from requiring jQuery to a stand alone JS implementation. It is meant to handle browser communication protocols such as XHR, XDR, WS & WSS without a lot of fuss. The project can also be found @ comm.js. /** * Description: Handles ...
I'm new to C++ (about 4 weeks with no prior programming experience in other languages) and am writing a program that's supposed to do the following: Define an array of 100 sequential numbers of type float. Define an array of 20 Fibonacci numbers of type int. Use an overloaded function to compute the mean of the array ...
The following code should solve these issues: Handle namespaces; Be a class factory from Pojos Be a object factory Create a class with inheritance capabilities from a POJO using john resig inheritance implementation; Handle singletons Here is an example of it's usage: var OliveOil=require('OliveOil')(); var handler=...
I have a server that cannot be connected to from the internet, but I need to get some info to it. I have another server that can, so I have a simple passthru script that I want to see if you all think is secure. Basically, you hit this and if it is in the white list, it returns everything, including keeping the proper ...
I'm trying to calculate what time a certain time in a time zone is today, so I can schedule something to happen at that time in that time zone. I've got a table with what I have termed the Nominal Time, which is stored as a datetimeoffset with an arbitrary date, as the only parts I care about is the time and the time ...
I am trying to generate a dataset from a query that has a where statement. If the user passes a value additional things need to be added to the where statement. Is this the best way to go about this? class TableAdapters { public class FindScriptByTargetVDN { public static DataSet Fill(SqlConnection conn...
I maintain a VBA process that prints a large number of PDFs. It was awful when I inherited it and I've been making improvements over time, but I'm a bit stuck on this one. There are at least 4 functions with this exact same code used to check to see if the program has been initialized properly. They could all be called...
During breaks, I find myself playing Emerald version a lot and was tired of having to use the school's slow wifi to access the internet. I wrote a scraper to obtain cheat codes and send them to my psp device. I couldn't come up with a better way of removing the extra whitespace. Any areas I could improve on? #!/bin/bas...
I'm a C++ programmer learning Java in preparation for an OOP class this fall. That being said, Java is fairly new to me so I'd love to hear feedback on how to improve this code. A few notes: Code works as expected and is ported from my C++ equivalent code I wrote some time ago. Not all operations that should be implem...
I have a Python script that creates a diff of two images using PIL. That part works fine. Now I need to find an efficient way to count all the non-black pixels (which represent parts of the two images that are different). The diff image is in RGB mode. My initial cut was something like this: return sum(x != (0, 0, 0) f...
My first ASP.NET MVC 6 / jQuery web site - the site header has a "Change Language" selector (named LanguagePicker) - this is actually placed in a _Layout view, a container shared by all views. When users change the language, I need to save that in the db, and reload current page, with language changed. I have this on ...
I'm building an in house query tool. The main form has a drop down which allows the user to select how they want to find scripts, and a drop down for what server they want to run the query on. There is also a text box to allow the user to populate a specific value which can be left blank. I think I did pretty well he...
I have these two methods which are generating two different xml files whose header section is same and detail section varies. The root node is different for both xml files. Here I have two methods written, one for each. I want to optimize the code by avoiding the duplication of code in these two methods. Can you please...
After reading the same question on SO about how to bold a word in a label for the nth time today, I decided to write a formatted Label. At first I toyed with the idea of writing a MarkDown clone (again), but I really wanted a rather lightweight Label. So I came up wih another easy to use markup. The original answer wa...
I have a code similar to this: public class PlayerRound { private final List<Strip> playerStrips = new ArrayList<>(); public boolean addStrip(final Strip aStrip) { // ... if (playerStrips.contains(aStrip)) { playerStrips.set(playerStrips.indexOf(aStrip), aStrip); // DOES THIS LINE C...
I posted my first attempt at this here. It's an app that generates both a preview of an interactive eBay listing, as well as the raw code which the user can copy and paste into their listing. I received some friendly suggestions about separating all the HTML/CSS/JS markup which needs to be included in the preview and ...
I'm solving the coin change problem having target of n and upper bound as n. Also the maximum number of coins is 10. For example. if the target is 11. then the possible outcomes are - 11 10,1 9,2 9,1,1 .... .... .... 2,1,1,1,1,1,1,1,1,1 So the last iteration having eleven 1's are not allowed as the max coins is 10. ...
As a sample of dialects and teaching myself parse with block! values, I wrote the following dice dialect with the following grammar: [ word! | integer! word! ] Where the word!s are defined as integers (d10: 10) so an expression of this dialect would look like: dice: [d2 20 d100 d10 5 d6] This would sum the...
I am writing a copy paste detector using esprima.js and Hmm. This particular function checks a number of sequences and reduces them. Due to the parsing I might have 2 sequences with the same piece of text, if so I need to merge the 2 sequences and add the start/ends ( both are source token indexes ) and occurrences ( c...
Given a linked list of 0s, 1s and 2s, sort it. Looking for code review, optimizations and best practices public final class SortZeroesOnesTwos { private Node first; private Node last; private int size; public SortZeroesOnesTwos(List<Integer> items) { for (Integer item : items) { ad...