instruction
stringlengths
71
71.9k
Apart from general JavaScript knowledge, this snippets requires someone who knows how to properly use Google Analytics API. To log errors on my site, I use this code: try { window.addEventListener("error", function(e) { var file = e.filename.substr(e.filename.lastIndexOf("/")+1); // for some reason, filename ...
I try to use complex numbers in a lua program. I need to parse a table of complex numbers printing side by side the name of the complex number and its value. Can't get through it : I don't ask how the library works. require "complex" a = complex.new (0,1) b = complex.new (7,1) c = complex.new (1,6.4) t = {a="a", ...
Can you review my F# code and point out some insights about it? What I want to know, in order of relevance: Avoid so much common code between DFA and NFA. I want to make something more generic, there is much code in common there. Make it more F# idiomatic Performance is not a concern. Readability is. module DFA = ...
I've been building an IDE using C# and only the console. To get keyboard input in real time (as opposed to a read–eval–print loop,) I have the following method to get keyboard input: public static ConsoleKeyInfo[] GetInput() { // A list of characters List<ConsoleKeyInfo> input = new List<ConsoleKeyInfo>(); ...
Please provide constructive criticism for this TinyMCE plugin which allows the user to save the content, or cancel and go back to the original. JS Bin <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Testing</title> <link href="//aj...
The purpose of the code is to store arbitrary number of types. The type can be extracted from it using Extract template, which uses template recursion to get the needed type. There will be compilation error if user will try to get out of bounds. I think it supports both fully defined types and only declared types. In ...
This basically creates a namespace for Storage among other things. I'm looking for feedback on the structure of the code. /******************************************************************************************************************(120) ** Storage ** - Dependencies - None ** - Basically creates a namespace for S...
I'm doing a college assignment with jQuery Mobile and JSON. Best practice with jQuery mobile is my main concern. My html starts off with a main 'page' (data-role="page") inside a div with id="all-pages". I use jQuery's .getJSON method to connect to a local JSON file called profiles.json. profiles.json contains an arra...
I'm working on a Wall-runner reaction based game. Whilst I know my way around a lot of the features Unity provides, I'm still in the beginner phase when it comes to working with several classes and functions simultaneously. I have currently got the two following classes that work together: Obstacle class public class O...
I have a regular expression that match the string that contains the word "duration", followed by a < or > operator and then a number. Here is the expression: duration\s*(<|>)\s*([0-9]+) Is there any way I can make this expression better?
I'm trying to re-implement the C stdlib function qsort using a median of 3 quicksort. void qsort(void *base, size_t nitems, size_t size, int (*compar)(const void *, const void*)) This is my first major project in C, and I'd like to know how my style looks and what techniques I might be missing out on. Thanks for the h...
I have made a simple tic tac toe game and need help tweaking it to fit the bill of object oriented design. Any suggestions most welcome. I basically want it safer, and more "best practice-like" It is a game consisting of four classes, and I'm pretty happy with it as I am new to programming, but maybe it is worthless se...
The app: Creates CountDownTimers and displays them in a simple layout. The user can choose how long the timer should be through SharedPreferences and a settings activity. Each timer has a preparation period before it actually starts. The problem: I'm not sure how, but I feel like the code is messy and needs to be clean...
I am currently implementing the Ace-editor embeddable code editor. In to my application. I use a div with a certain class(example: editor_js) to render the editor the div also gets a data attribute (data-key) corresponding with the name (example: Site[tagmanager]) of a textarea. The session from the div get stored in ...
I would like to ask more experienced developers to review my code, it's my first app, self-made, I know there is a lot to improve, it would be great if you could just point the main errors. I'm aware that my implementation is not universal, but I couldnt get past it. My edit option with usage of DTO seems shi*y to me,...
Given a string, S, of length N that is indexed from 0 to N−1, I want to print its even-indexed and odd-indexed characters as 2 space-separated strings on a single line: Hacker -> Hce akr My code works, but I feel it could have been done more elegantly and maybe in a single stream instead of in two... Any ideas how to...
All I have built an MVC WinForms application where Views are blind and deaf of their controllers. To facilitate this I have used Ninject as my Dependency Injection (DI) Inversion of Control (IoC) container. I have a question regarding my design/architecture of the way I handle showing dialogs (remembering I want full t...
I have the following VBA code, which works perfectly well to calculate "q" However, the code is very slow and that is due to the large number of q's being calculated (roughly 7.2m q's are being calculated). So I thought the best way to proceed is to try store the calculated q values in an array and then dump them into ...
I'm creating an application to get data cross domain all the line of code seem work as well but I'm not much understand about performance with my code process with the real server and real action because sometime there are a lot of case will happen when I fetch those data so I want to make a method to get those errors ...
I have a simple query using query builder of VS2012 C# which updates the database in my winforms application. The database has 216 entries so far and it's taking a lifetime to update the database. How to reduce the time? Should I make more queries for each column or is there something else? UPDATE StudentInfo SET ...
I'm a complete beginner to Python, and wanted to get some feedback on my first app. I tried to make a clone of the 'evolution of text' app found on the Using Python website. Enter some text, and watch the program 'evolve' the answer. The program just prints a load of random text, but keeps the correct bits each time. ...
I have a Pi with a camera module that I control with Python. I created a web server with web.py that allows me to make HTTP requests to the PI to retrieve an image. There are two optional parameters to specify the width and height of the image. The code looks like this (imports omitted): urls = ( '/capture', 'Captu...
I am developing a plugin for a GIS (Geographic Information Systems) software which uses Python. I have been using Python for over a year (on-off) and have the following code which works. It basically reads the names of files loaded into the GIS software to compose a QGIS expression for every group of files. Finally it ...
This code get a list<dynamic> from a repository class using Dapper. I need to bind this list to a ComboBox. The only way I can get this to work is by using a simple class (ComboBoxItem in my case) and than use that to do the binding. UI.cs var mRep= new MaterialRepository(); comboBox1.Items.Clear(); foreach (var item ...
On Sheet 1 is a legend that contains unique values in Column A every ten rows. To the right of each value in the next five columns over are a series of color filled cells that extend down ten rows to the start of the next unique value. The color fill of each 5x10 area is what I want transferred to the dataset sheet. Th...
Here, i build one form validation script in php using understanding SOLID concept. My question is the way i coded my code is true way for OO concept ? Use of abstract class and the extend it, is that true way ? can i strongly use interface for this functionality ? i use namespace but i can't include using use keyword ...
I am working with a TreeView (default control from .Net Framework) that displays hierachical data. Data are bound to the view using MVVM pattern with the HierarchicalDataTemplate. <HierarchicalDataTemplate DataType="{x:Type models:TreeItemViewModel}" ItemsSource="{Binding Children, Mode=OneWay}"> <TextBlock Text="{...
I've done a lot of reworking to this main file recently, in regards to using a new speech recognition engine and integrating the last reviews suggestions. My question before is going to be phrased very similarly to how it was previously. How Khronos Works The process starts by recording a .wav file with LibSndFile an...
This algorithm sorts a list of Individuals, each with two fitness values, into what's called non-dominated fronts. A non-dominated front is a set of individuals where none of the individuals dominate each other. An individual is said to dominate another if is equal or lower (<=) for all fitness values and lower (<) in ...
I am trying to solve an SPOJ problem: print all prime numbers in a given range (as large as \$10^9\$). I have used the Sieve of Eratosthenes algorithm. But it is still slow when input is in range of \$10^4\$. import math no_of_cases = int(input()) for i in range(no_of_cases): x = input().split(" ") a = int(x[0...
This describes type util::any<std::size_t size, std::size_t align> - an implementation of std::any with a static size/no dynamic allocation. It closely follows the standard's specification for std::any. A discriminated type that can contain values of different types but does not attempt conversion between them, i.e....
How can I make this little program work a little faster? The task is to calculate the max difference between any 2 numbers from an array of numbers. Target time is 1 sec, now it works in 1.1 sec. I've tried BufferedReader, PrintWriter and nested loops (instead of Arrays.sort). import java.util.Arrays; import java.util....
Anyone have any tips on how to divide my code up into classes? This seems to work from me but would prefer to have it divided up into one or two separate classes if possible. static Scanner sc = new Scanner(System.in); public static void main(String[] args) { System.out.println(); System.out.println(); String prompt ...
When users log in to our website, we store some information in a session to retrieve it across the site. We created a few wrappers to help with data retrieval/storage to lessen duplication of code. I'm trying to redesign it as I don't like how the UserModel is written. I believe it's dangerous with the static propertie...
I am having a Python list of lists, that I get as an output of python-igraph (membership to clusters). The integers represent an association of a vertex to a certain cluster at a certain subgraph. I would like to organise this list in a way that the biggest cluster in the whole (unconnected) graph is getting the lowest...
I have written Python code which works absolutely fine but I am looking for other ways to do this: import itertools def permutation(word): for i in range(len(word)+1): perms=list(itertools.permutations(word)) for i in perms: j=(''.join(i)) j=j.casefold() k=reversed(j) ...
This function serves me as a testing-utility to check if the result is really numeric and sometimes as input-validation if there are a lot of operations before I would find out (with an Exception) if it's not-numerical. But I feel like the .dtype.kind in ... is too complex. I've written this function a while back and ...
I'd like to restrict user input in a form to a decimal with max two numbers before and 4 after decimal point. Valid values would be: 50 0.1 1.23 4.5678 12.943 I'm currently doing the following: $(function() { $('input').on('input', function() { this.value = this.value .replace(/[^\d.]/g, '') ...
I've recently created my own 2-player chess game, no AI... at least for now. I do plan to do that in the future, so one of my concerns is if the code is flexible enough to just use the same classes in all the different modes so I can avoid rewriting the same code over and over again. I've tried to explain most of the l...
(Part 1 here) I've recently created my own 2-player chess game, no AI... at least for now. I do plan to do that in the future, so one of my concerns is if the code is flexible enough to just use the same classes in all the different modes so I can avoid rewriting the same code over and over again. Resuming with the o...
I've been trying to learn Python and I've managed to muddle through enough to put together a simple Hangman game (albeit with a few bugs and game features missing!). However, I feel like I haven't done a very good job as I seem to have repeated a lot of code. Does anyone have any simple tips for how I could improve the...
I'm trying to implement a search bar in which the user sends a search term and the search bar displays the results. I have a naive solution which separates the original list into three sublists: a list with all the exact matches, a list with all the phrases containing the search term and a list with all the phrases tha...
I have been told for my code below i need to "Improve and optimise the codebase of the application to reflect modern and best coding practices". Can anyone help me in doing this? As I know the service worker code can't be optimised so I am not sure what other code I can change/improve for best coding practices. The HTM...
I'm trying to recreate strstr in c, my code works but I think it is too long, and it needs some improvement. #include <stdlib.h> static int find_str_indx(char *str, int index, char *str_to_find) { int i; int temp; int found_index; while (str[index] != '\0') { if (str[index] == *str_to...
This program reads all files in a folder and subfolders line by line, converts them in a supported character set, replaces all unsupported characters and inserts them in a SQL database. My idea was to insert all CSV files. It works fine indeed but it takes a long time to insert all the data, especially for files that a...
I've built a Search Engine class for a website that permits to search companies in base of their locations and their categories (companies pay a plan to be found in the places that they will). In the constructor you can pass an index array cointaining the parameters or you can set them later with setters. All parameter...
I am aware this problem has been asked before but in java e.g Printing longest sequence of zeroes. This is a similar problem but in C#. A brief explanation of the problem is to find the longest sequence of zeroes in a binary representation of an Integer. For instance, the Integer 529 in binary gives 1000010001 and th...
I wrote this script to automatically install the relevant version of MacPorts. It's supposed to be used in a fashion similar to the official installer for HomeBrew. FYI: The real reason that I decided to write this script is; I'm not all that confident in every aspect of my bash scripting abilities and I needed a proj...
I've created following code which works just fine: GraphBar1.GetComponent<RectTransform> ().sizeDelta = new Vector2 (50, oScript.reactionTimeArray [0] * 1000); GraphBar2.GetComponent<RectTransform> ().sizeDelta = new Vector2 (50, oScript.reactionTimeArray [1] * 1000); GraphBar3.GetComponent<RectTransform> ().sizeDelta ...
I have a user-editable dictionary of content used to fill in a string.Template and I wanted to allow the user to fill the same template with several values at once. Using only values, itertools.product would be enough for my needs but I needed dictionaries to fill in a template. I also wanted users to be able to enter ...
I wrote a method which sorts an array of hashes by given hash keys. The method should put nil values at the end. def sort(records, *attrs) records.sort do |a,b| result = 0 attrs.each do |attr| unless a[attr] == b[attr] result = if a[attr].nil? 1 elsif b[attr]....
I’m pretty new to programming and python in particular. This is a simple ICMP/TCP scanner that dumps output to a terminal and/or csv file. My goal was to make a daemon that could do simple scanning without requiring any special imports. It is my first attempt at writing something that would be useful and that I might e...
I am doing a college project and I would like to write my jQuery code following best practices. The project involves using the jQuery .getJSON method to retrieve information from a json file. I have left out parts of the code so that it is more readable (however this is indicated in the comments). The code shows two ap...
Problem: Write a program that, given an age in seconds, calculates how old someone is in terms of a given planet's solar years. Earth: orbital period 365.25 Earth days, or 31557600 seconds Mercury: orbital period 0.2408467 Earth years Venus: orbital period 0.61519726 Earth years Mars: orbital period 1.8808158 Earth...
I've been working on an iOS IOT client app which uses MQTT. After some reading I decided to go with CocoaMQTT. I have only been programming in swift/iOS for about 2 weeks now, so I thought I should have my base code reviewed here before continuing any further. The idea is to have most of the MQTT connection handling ...
Inspired by this question and therefore this one I decided that clearly the best most readable way to solve this is with Regular Expressions. A binary gap within a positive integer N is any maximal sequence of consecutive zeros that is surrounded by ones at both ends in the binary representation of N. For example, num...
I'm working on building understanding of data structures in general, and specifically linked lists in this example. I'm also trying to increase my ability with templates. In cross-referencing dozens of examples, I've blended what I've seen into the following node template "Node.h" file: /* 11 May 2015 VS 2015 Communit...
There are a number of topics pertaining to entity change tracking. All the ones I've seen involve either 1) notifying when a property has changed or 2) merely determining whether or not an entity is dirty. My goal is quite different. I wrote a mini-repository framework that generates SQL for inserts, selects, updates...
I have categories and subcategories in my view. The code looks like this <ul> <% Category.roots.each do |category| %> <li class="col-md-2"> <a href="#"><%= category.name %></a> <% if !category.children.empty? %> <ul> <%= category.decorate.draw_tree %> </ul> <% end %> </li> <% end %> </...
For Khronos, I've had to develop these utility functions to help me deal with storing the .wav files. However, they could also be used in a variety of applications. A description of what the three functions do are given in the header documentation comments. util.h: #ifndef UTIL_H #define UTIL_H /** * @return the te...
So I needed to write a function that takes a string and returns a javascript object with vowels and consonants properties that maps to the number of vowels and consonants in the string function getCount(words) { let answer = {vowels: 0, consonants: 0}; if( typeof words !== 'string') { return answer } let vowel ...
Unfortunately due to my job I will have to leave out some of the information that is created by this generator, however I will be replacing it with another string of information. I have created an email generator for work, that will user a template and add the information provided into the email, I would like some crit...
I wrote this in order to solve the fractional knapsack problem. Any feedback is appreciated. def get_optimal_value(capacity, weights, values): value = 0. if sum(weights) <= capacity: return sum(values) if len(weights) == 1: value = values[0]/float(weights[0])*capacity densities = [(v/flo...
This code works, but I want to refine it: # ======================= # Dir Walk # # This will recursively walk a directory # ======================== function dirwalk(path::AbstractString, fn::Function) content = readdir(path) for c in content p = joinpath(path, c) if isdir(p) dirwalk(p, fn) elsei...
I recently implemented Linked List on my own. I did not use generics as I am still learning. How can I improve it: package datastructures; class LinkedList { Node head = null; Node tail = null; int size = 0; public void add(int data) { Node n = new Node(); n.setElement(data); ...
I can feel that something is wrong with my code. Here's an excerpt where I think the code smell is... internal Hazen(IRawDataReceiver rawDataReceiver) : base(rawDataReceiver) { SerialPortConnection = rawDataReceiver as SerialPortConnection; } private SerialPortConnection _serialPortConnection; ...
Assume that you have the ready sorted array Is it a good solution? Plunker OR: <script> var score = [10, 20, 20, 20, 40, 50, 60, 60, 60, 60, 70, 80, 80, 90] var j = 0; var k = 0; for( i in score ){ var grade = ''; if( i== 0 || score[i] > score[i - 1] ){ grade = j = j+1+k; ...
I have the following "upsert" trigger in SQL Server 2005, which is handling a large data import from a SSIS package. It is taking a very long time to complete - I suspect due to the concatenation and CASTing of keys. Is there a better, faster way of doing this? CREATE TRIGGER [dbo].[MP_VOD_UPSERT] ON [dbo].[vwMP_VOD...
I'm writing a shell in C for Linux and BSD. My code was unreadable before but I did a rewrite and now it is much more readable. The purpose of the code is to create a command pipeline and execute it. int run_cmd(const char *cmd) { struct str_list *chunks = list_split(cmd, '|'); struct pipeline *pipe = malloc(c...
I am trying to figure out a good way to store and load a password in the application configuration of my C# application. To achieve this I use the BouncyCastle library and the DPAPI from Windows. To protect the password from getting decrypted by other applications just using DPAPI under the same account it got encrypt...
I have the following snippet of code which gets a load of time intervals (every hour, every 2 hours etc), then groups the results for each of the intervals (e.g, the max value for each hour). This data needs to go into an array (which will be sent to a Chart). The user can select if they wish to group my Min, Max or A...
At my new job, with new young developers, we are seriously discussing improving code structure and performance. (They keep more than 80 lines of code in a method). However I've read more tutorials, and based on my experience, I think I should use some method to wrap that code by its conditional and call it back but tho...
I have a code that fetches rates from a website called X-Rates, and outputs to excel the monthly averages of a chosen country. The code runs quite fast, but I still think I could improve the code a little bit, but just don't know what to look for. I've done the obvious things like, making the option explicit and disab...
I was lucky enough to stumble into this task during a job interview. I was gently guided to use string reversals and a few other things to speed up my process. I kept thinking that I wouldn't have done it the way I was coached. It bothered me enough that I went home and coded up my version. How could I improve this...
The purpose of the class is to set permissions for a user. These include delete, download, upload, view, etc. These properties often depend on other properties, and setting them has side effects. For example, if I set CanUpload=false, then I need to also set CanManagePermissions=false since you cannot be an admin witho...
So I have implemented Single link list using java.Please advice if this is OK or can be made better. public class SingleLinkedList<Generic> { private Generic data; private SingleLinkedList<Generic> next; public SingleLinkedList() { super(); } public SingleLinkedList(Generic data, SingleLinkedList<Generic> next) ...
I wrote this header for generic use of a queue. The one thing I'm wondering is if I understood the usage of void*. I hope that if somebody teach me some conventions when coding in C. /* * array-based queue implementation by using void* * written by kidkkr * May 6 '16 */ #ifndef QUEUE_H #define QUEUE_H #define QU...
I need a custom exception for network errors that holds a related exception and more than one URL (the first one as the used service has its URL but it indirectly calls other URLs), so I wrote this: class ExtendedNetworkError(Exception): def __init__(self, reason, *args, **kwargs): kwargs_copy = dict(kwarg...
I need to find 2 different string and compare their hash value. Both string must contain "abc". I looking for the first eight character that are the same and stop. I have been running for more than 24 hours and still not found. My code has no problem running but i am wondering is there any more effective ways to find t...
I've made a small thread pool that i'll be using to communicate with a Redis server: #include "redox.hpp" redox::Redox rdx; void my_cool_function() { // do stuff with rdx } int main() { rdx.connect("localhost"); int max_threads = std::thread::hardware_concurrency(); std::vector<std::thread> pool; ...
This question is part of a series solving the Rosalind challenges. For the previous question in this series, see Wascally wabbits. The repository with all my up-to-date solutions so far can be found here. Problem: PROT The 20 commonly occurring amino acids are abbreviated by using 20 letters from the English alphabet...
The following method is part of a class that imports zip archives, and part of that class's job is to verify that a given zip archive contains "complete filesets". A "complete fileset" is one such that, for a given file name prefix, there exists a file in the zip archive with that prefix and each suffix. There are alwa...
I've been coding a helper container template to contain tiles in 2D games. What I figured out I would like when writing code for my games is forgetting all resize stuff, allowing negative indexes (for proceduraly generated worlds, that I hope to achieve in the future) and returning a default value (and not some error) ...
I have written a solution in Clojure for the following question: When starting from the number 1 and adding three numbers on each row a 3x3 matrix is formed as follows: 1 2 3 4 5 6 7 8 9 Starting from the upper left and spiraling inwards in a clockwise direction the following series is obtained: 1 2 3 6 9 8 7 4 5...
I've found a few places where control updates take longer than the redraw cycle. I started off surrounding them with Suspend and ResumeLayout: container.SuspendLayout(); updateControls(); container.ResumeLayout(true); After doing that a few times, I realized it could be refactored into a context: /// <summary> /// ...
I'm writing a program that has to check which are the two largest three digit numbers that are missing from a text file. I'm writing this in C++ and I'm trying to solve the mystery in a while loop. How can I "move" the search back to the beggining of the text file? More explicit: if the checking is now around the middl...
I am working on refactoring this method on the API. It's very slow, and can take the browser 12+ seconds to receive the result from the API. Can someone give me something to get me started or point me in the right direction? public List<LicenseProduct> GetProducts(int licenseId) { var totalpercentage = 0....
I am creating a sort of Sales Report for an Invoicing System. I have an extremely complex MySQL Query that takes a very long time to execute (usually about 10 - 15 seconds). It involves multiple tables (containing hundreds or even thousands of rows) in a database that an even more complex system is built upon. At this ...
I've got a simple Excel Data Manipulation Script to match one of my daily tasks, written in python 3. Intro Let's assume that I have 3 excel files: main.xlsx, 1.xlsx and 2.xlsx. In all of them I have a column named serial numbers. I have to: lookup for all serial numbers in 1.xlsx and 2.xlsx and verify if they are in ...
I seriously didn't know how to write this in Google, there must be an answer lying around. Here it goes: I'm using Ninject (IoC) and ASP.NET MVC 5. I have a business layer with a couple of classes. Is it ok if I have one class that holds all these classes? Like this: public class BusinessLayer : IBusinessLayer { ...
I am making a Connect Four type of game in Java. I want to make sure that all the code seems nice before I decide to add more. This is what the applet game looks like: Player input: Victory screen: I have three classes: Make4: import java.util.Arrays; import java.awt.*; import java.applet.Applet; import javax.swin...
I had a problem in my system where the class that sends messages to other systems sometimes gets flooded and so I needed to add rate limiting. I threw together something that would work, but I would really like to see what I can do to improve and/or clean it up. This class does not do the actual rate limiting, it only ...
I'm working on creating a user registration script in PHP. I have two tables that need to be inserted into. One that stores some general user information, and another that stores their login credentials. My issue is that my code to perform these insert is a mess of if/else blocks and I'm trying to figure out a good ...
I will be given the following input: const input = [ { value: "a1", colspan: 1, rowspan: 1 }, { value: "a2", colspan: 1, rowspan: 1 }, { value: "a3", colspan: 1, rowspan: 3 }, { value: "b1", colspan: 1, rowspan: 1 }, { value: "b2", colspan: 1, rowspan: 1 }, { value: "c1", colspan: 1, rowspan: 1 }, ...
During an interview I was asked to consider the following: You are trying to find an instance of an error code within a number of log files within a directory. The goal is to count the number of times that the error code appears within the specified files. For the written function, it was to be passed the following a...
I created a simple command line calculator, and then after some reading I made a few tweaks and then remade it with a friends idea to make it more simpler. I'm wondering if this can be more optimized or if any part of the code can be done "better"? I recently started learning Java and wanted for this first project of m...
I'm writing a finite state machine based on a transition table in C++ 14. My code so far looks like: #include <array> #include <functional> template < typename _State, typename _Event > class FSM { static constexpr size_t state_count = static_cast<size_t>(_Event::_); static constexpr size_t event_count = static_ca...
So for example, getTimes("12:00", "15:30"); should return: ["12:00", "12:30", "13:00", "13:30", "14:00", "14:30", "15:00", "15:30"] The input parameters are always in :30 or :00 intervals(so 06:00, 06:30, 07:00, ...). getTimes("06:00", "17:00"); -> should work getTimes("06:30", "17:00"); -> should work getTimes("06:25"...
In a project for fun/practice, I made a few builder classes that all started to feel the same, so I decided to generalize them by creating a factory that would automatically assign the similarities that they all shared. Each of my builders had a private variable, data, which would eventually become the built class. Ea...
The following code calculates the biggest number of consecutive ones in a binary representation of a number. For example 6 -> 2 (110), 5 -> 1 (101): String numberAsBinaryString = Integer.toBinaryString(number); List<String> listOfConsecutiveOneStrings = Arrays.asList(numberAsBinaryString.split("0")); System.out.printl...