instruction
stringlengths
71
39k
I'm just going through some array exercises in PHP on w3resource. I have just completed: Sample array : $Color = array('A' => 'Blue', 'B' => 'Green', 'c' => 'Red'); Expected Output : Values are in lower case: Array ( [A] => blue [B] => green [c] => red ) Values are in upper case: Array ( [A] => BLUE [B] => GREEN [c] =...
I need to produce a list objCollector with some results: objCollector = [] allRows.each () -> obj = source: self.source url: '' host: '' currentTag = $(this) links = currentTag.find('a') getTextFromSpan = currentTag.find('span.lnk').text() ex...
I'm writing to some serial comm port with specific bytes set into buffer. My protocol for write buffer is written below. Platform is Windows and IDE is Visual C++. Byte 0 will have message type indicator (Byte) Byte 1-4 will have message number (Uint32) Byte 5-8 will have unix epoch time (Uint32) Byte 13-14 will have...
Today I made a clumsy update without WHERE. Yeah, I know. I have backups but I found a way to fix it without loosing anything. It implies a SELECT and a loop of 50.000 updates, not a fan of this approach. Maybe I can merge the SELECT and the UPDATE so it's only a big query, witch in my head seems like a better approach...
I present my solution for Project Euler problem 23 written in Python (2.7). The problem statement is: A perfect number is a number for which the sum of its proper divisors is exactly equal to the number. For example, the sum of the proper divisors of 28 would be 1 + 2 + 4 + 7 + 14 = 28, which means that 28 is a ...
I have a form with 11 inputs that relate to each column on a table, which is displayed above. Each input has an id that matches the a class in the table based on the column name. I want all the inputs to be droppable, the logic for all of them is identical to below. $(function() { $( "#dest_city" ).droppable({ dr...
Is there any way to improve the performance of local report or even an alternative if not? I have been looking for a solution for quite some time but the general consensus seems to be that it's just slow. public byte[] genReportBytes(int id, string fromm,string too,string filetype) { reportDetails repD = new report...
I am creating unit tests but the class uses objects that have long JSON. What can I do to improve the readability of this? In tests, only insert those JSON really needed for the test. The class I tested is responsible in turn that JSON in a modified spreadsheet (xlsx) and it seems difficult to maintain the code. @Test ...
I'm working on a client proxy for my WebAPI. I've looked at WebApiProxy but I feel DTOs are unnecessary in my scenario. I made an ApiProxyBase class that supports basic Get, Post, Put and Delete functionality using generics. Using this base class I've setup an implementation as follows: public sealed class MyProxy : Ap...
I am writing a (multi) filter that is created when the user enters in the data through wordpress. There can be anywhere between 2 - 10 filters so I need this to be as dynamic as possible. My first approach was to write out a boolean for each possible filter being created and check if it is there or not. Inside the bool...
I got tired of following Android-SQLite's transaction idiom, briefly documented here. It requires too much boilerplate code, IMHO, especially when you add the obligatory null checks. So I came up with this pattern, inspired by the Objective-C library FMDB: // Inside the class that manages the database interface Transa...
I've created a PHP script which take an array of filenames as a comma-separated parameter and concatenates them, serving them as one, single JavaScript file. I've also built a caching mechanism into it - each time, it checks if any of the individual JS files have been updated and, if one or more of them has, it updates...
I'm working on a singleton object to manage size changes in the viewport, I wanted it to be a singleton because there may be different unrelated objects that need to be notified when a change in viewport dimensions has occurred. So I came up with this solution based on the singleton design pattern found in here. var C...
I have recently been working on my first game with an isometric perspective. For those who don't know, an isometric perspective is a pseudo 3D view created from 2D tiles. I am working off of this tutorial about isometric graphics. I believe my approach is fairly clean and efficient. I have tried to do things in an ob...
I'm working on a tile-based game, and am looking to improve the efficiency of my code to slightly improve framerate. I call this method on every tile, every frame, so it is very performance critical. What optimizations can be made? public bool OnScreen(Vector2 point) { Rectangle rect = this.Rectangle; return (...
My code is designed to simply trigger alarms; it is not supposed to be used by anyone but me. import subprocess,time,threading, winsound, sys, basepipe commands = '' def alarm_checker(alarms): """This will be the main threaded process, and will be the meat of the program.""" global commands hours = [int(a.s...
This uses the Stack Exchange API to quickly batch replace tags in questions. I still need to fully comment and make the Wiki, but are there any glaring mistakes in it? I have tried to use try: except: wherever I can to prevent any errors, and have attempted to make it compatible for Python 2 and Python 3. # -*- coding:...
The point of this is to concatenate a vector of std::strings into one string starting at an index of the vector. std::string vectorSubstr(std::vector<std::string> vec, int startPos, char seperator) { std::stringstream ss; for (int i = startPos; i < vec.size(); i++) { if (i == startPos) { ...
I'm doing some exercises from another good website aimed at a similar problem - exercism.io, and my 1st C++ problem was to pass a certain test suite. Here is the README for relevant information: Bob is a lackadaisical teenager. In conversation, his responses are very limited. Bob answers 'Sure.' if you ask him a quest...
Here is the code that I wrote to give me sum of prime numbers between n and m: class TestClass { final static int MAX=1000000; final static boolean[] isPrime=isPrime(); public static void main(String args[] ) throws Exception { BufferedReader keyboard= new BufferedReader(new InputStreamReader(System...
I have finished a really short and small import / export script using Python 2.7, and now I would like to structure it using classes and methods where possible. Could anybody give me some advice on what would be the best approach for this? I haven't used any OOP because I would also like somebody to give me some best p...
I recently put in a submission for a small coding challenge using Angular. The challenge was to get a token and array of values using a GET request then make another GET request passing the token and sum of values within the url. I'm still getting to grips with promises and want to know if the flow in the service and c...
To append data I am using parent() method five times in the code and I think it seems like an ugly way to do this. $("div.commentItem a.showReplies").on("click", function(){ var jqData = "i am so eE"; $(this).parent().parent().parent().parent().parent().find('div.commentItem span.repliesholder').append(jqData);...
I was assigned a task to fix the SQL injection flaw reported by a code analysis tool. I am not the original author of the code. I am fairly knowledgeable with SQL. public int ExecuteNonQuery(string query, SqlParameter[] parameters) { using (SqlCommand command = CreateCommand(query, parameters)) { i...
function RequestValidation() { $(".RequestTrigger").on("click", function () { var selectedButton = $(this); var arr = []; if ($(this).data('multiple') == true) { var ids = $('input:checkbox:checked.check-box').map(function () { var value = $(this).data('entityid...
I have written a small function to generate an array of page numbers for displaying a pagination. The inputs to the function is an active page number p, and the max page number. The function will return an array of 5 possible page numbers available near the active page. Example input, output: pages(1,10): [1,2,3,4,5] ...
I'm working through the Assembler assignment in the Nand2Tetris course (chapter 6). The suggested implementation contains 4 modules: Main, Parser, Code, SyntaxTree. Today I wanted to get some feedback on my implementation of the Code module. The book specifies a general API in order to allow students to use whichever ...
I wrote this code in Java using the Jaunt library. The program scrapes all words from Wiktionary from category "English_uncountable_nouns". And after save each world to text file. I am not sure that exceptions are handled in best way, so I'm looking for tips on how to make this code easier to understand and more stable...
I am using Scroll Magic for the first time and I am in general very new to JavaScript/jQuery. I got it to work but it is very messy and repetitive code. Here is the fiddle. This is the messy code (I just gave this as an example, in my project there is about 50 scenes after each other in this manner!): var controller = ...
I have the following controller: angular.module("UserRoles") .controller("UserRolesController", function($http, $scope){ $scope.usersearch = ""; $scope.users = []; $scope.roles = { } $scope.getusers = function(){ $http.get("/api/finduser/"+$scope.usersearch) .success(function(d...
I’ve written a small utility tool capable of backing up a directory, restoring a backed up directory, syncing two directories (copying missing or changed files from src to dst). I’d love your feedback - any code smells, improvements, potential bugs, non-idiomatic approaches, etc., please let me know. Here's how I ba...
I recently created a custom static class in C# to encode, hopefully, any object it is given (or collection of objects), because I was, at the time, unaware of a native C# library that did the same thing. I am using Generics instead of System.Object because I am aware of the overhead that comes with boxing/unboxing. Af...
I am currently using the following glsl code to retrieve separate textures from a tile atlas: #version 330 core in vec2 TexCoord; out vec4 color; uniform sampler2D image; void main() { //width and height in tiles of atlas int width = 8; int height = 8; //x and y position of a tile in the atlas int...
I've created two classes that contain only sudoku logic. One class Sudoku generates sudoku grid and returns SudokuGrid object with has specific number of values in it(removing values from filled grid). Second class SudokuGrid contains all logic that player needs, checking whether any rules are broken. In my opinion Sud...
In our automated test framework, written in Java 8, there are different entities representing test data, having different states and transitions between them. To model this behavior, I started to implement a simple finite state machine (or at least what I understand as a FSM). The idea to use it would be like this: pub...
You are first confronted by three links. Each link triggers divs to slide out. The divs slide out and up to appear as if unfolding. The slide back in reverse when any other link on the page is clicked. The code works exactly how we want it to. However, the code is very long and needs re-developing into a neater script....
I have just finished the sololearn C++ course and wanted to create a basic login program in the vein of a basic operating system. #include "ubuntu_login" #include <iostream> #include <string> using namespace std; Ubuntu_Login::Ubuntu_Login() { cout << "\t Welcome to Ubuntu!\n" << endl; } void Ubuntu_Login::usr_lo...
def triangularNumber(n): if(n == 1): return 1 else: return triangularNumbers(n-1)+n works great to find the nth triangular number up to 996... I get some error in the recursion after 996. But can tell what it is because it just keeps running through the loop. Anyone see the error?
I took all your suggestions to heart and I think it improved the code a lot. The Map got it's own typedef: IntStrDict. It's a perfectly applicable name, but I can't help but feel it's not according to best practices. The code now accepts arguments. If no arguments are given, the code fails. If one or more argument is g...
I made a MS Word style ribbon header, but it all seems very hacky, and I'm not really sure how to simplify it to something more reasonable. Rolling over one of the navigation icons changes the related z-index to positive revealing it. Then, on hover it changes its own z-index to remain positive keeping it up even when ...
These classes are to count keys in a text file. The file has key, value pair like these examples: John, 12 Sara, 2 Adam, 19 John, 1 Adam, 3 and the main class FileKeyCounter prints output as: The total for John is 13. The total for Sara 2. The total for Adam is 22. It consists of 3 classes: FileKeyCounter: This...
I've just made a github repository for a simple packet scout in C#. It is my first time using C# (other than Neoaxis 3D engine logic) since I am more familiar with C#. Below is the main bulk of the code that I'd like to improve. You can see all of the code here. If you have any suggestions please share them. using Syst...
I'm using the Observer design pattern in order to manage events in the game I'm currently developing. I based myself on the implementation demonstrated here but improved it in order to ease its use. class Observer { public: virtual ~Observer() {} virtual void onNotify(Subject * entity, Event event) = 0; priva...
I am currently self-studying Java using the resources available on the internet (Stanford's cs106a introduction to programming lecture). I am still a beginner, and I hope that I can improve my coding skill after receiving some feedback here. This is a program that plays 2-player Tic Tac Toe (I might add an AI feature i...
I would appreciate any feedback you could offer. I'm self-learning, so I don't really know a "standard" that my code should be up to. I'm also not sure how to get rid of that bit of logic at the bottom, or if it's acceptable. class Board attr_reader :board, :place def initialize @board = [1, 2, 3, 4, ...
I recently discovered the file_get_contents function and wanted to put it to some use, alongside preg_match_all, off the information in this Stack Overflow thread. <?php //use a site with lots of email address on. $string = file_get_contents("https://stackoverflow.com/questions/3901070/in-php-how-do-i-extract-m...
I'm trying to create a class that's able to 'crawl' through a generic 2D matrix. Crawling through a Bitmap (which can be viewed as a 2D Matrix of Colors) should yield the same result of a flood fill. So the first thing I did was create a IMatrix (previous name was I2DMatrix. I renamed it since i don't intend to code a ...
I had this code repeated in many Actions: public ActionResult History(int? patientId) { if (patientId == null) { return new HttpStatusCodeResult(HttpStatusCode.BadRequest); } var patient = patientService.GetPatient(patientId.Value); if (patient == null) ...
This code parses mail server log files and outputs statistics into an external file. Is there a way to make it more pythonic? Is it a good idea to use regex anywhere? Which libraries can reduce the length of code? import sys deferred_as_error = '--deferred-as-error' in sys.argv # {session id: email} logged_in = dict...
I am combining two lists of separate objects into a single combined list. The below code works perfectly but it is not the most elegant or efficient solution. Is there a better solution? var articles = context.Articles.Where(a => a.Author.ID == authorID).ToList(); var reviews = context.Reviews.Where(a => a.Author.ID ==...
To learn Haskell, I've been going at this challenge, which is to check a list of phone numbers to ensure that no number is a prefix of another. However, my code is way too slow. I am really new to Haskell so I don't know what to look for in performance optimization. I have generated a sample input which takes 5s (uncom...
I want to find the intersection of two lists of dicts. Note that equality—i.e.: what is to appear in the intersection—is given by which keys they must have equal. See the obj_equal_on function. def obj_equal_on(obj0, obj1, keys): for key in keys: if obj0.get(key, False) != obj1.get(key, None): r...
I have written this helper function. I want to know if there is an even better approach, considering that I do not want to add a dependency to any additional module. def _isobjectInList(lst, name, criteria='startswith'): """ Find item in the list starting or ending with name passed. :param lst: list of it...
The purpose of this code is to get data from the database and output it into a multidimensional array in JSON for my web app. But my gut instinct is telling me this code is way too messy and just generally badly written. // Structure of user_medication http://i.imgur.com/gTrZm7B.png public function getUserMedication($...
I wrote a simple little script, designed to load some log file. Clearing lines and loading updates is done by double clicking on the log line to clear. <html lang="en"> <head> <meta charset="utf-8"> <title></title> <style> pre { margin: 0; } </style> <script> var chunks = []; v...
This program reads a filename from standard input and then prints its content. Please review: #include <unistd.h> #include <fcntl.h> #include <stdio.h> #include <errno.h> int main() { char fileName[20]; // Get the filename from the user: int fileNameLength = read(0,fileName,19); // We need to get rid...
I was needing to provide the hex-dump of a code, but I needed to create my own. And, for fun, I decided to do it. function hex_dump( $value ) { $start_time = microtime(true); switch( gettype( $value ) ) { case 'string': $lines = array_map( function( $line ){ ...
I'm trying to solve a challenge where you need to calculate the median every time you add a number. say you have a list of numbers: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 When you scan in the first number (1), you calculate the median of that. When you scan in the second number (2), you calculate the median of 1 and 2, and so...
I have implemented a couple of functions in python as part of an online course. Although the functions seem to work fine I feel that the code is inefficient with a lot of nested loops. Are there any improvements I can make? I am new to the language so any advice is welcome. Here is the code and some simple tests: def m...
This is a followup of this question. @Corbin made a very interesting review, and I re-wrote most of the code. function hex_dump( $value ) { $to_hex = function( $number ){ $hex = strtoupper( dechex( $number ) ); //if we don't check if the number is 0, it won't fill the whole space return ( $...
I'm building a website where all data interactions are done over ajax other than the initial page load. Now I discovered the need for CSRF tokens. I elected to deliver the token in a meta tag like so: <meta name="csrf" content="JI8qMif9gHuD06m/HByCzg==" /> The function that generates the token is as so: public functio...
I recently wrote a program involving a MySQL database using C#. The program is simple: it allows users to enter numbers and ensures that no same number is entered twice. Now I know that it is not efficient and I need help in order to improve the code. using System; using System.Collections.Generic; using System.Com...
I am going to send a C++ array to a Python function as NumPy array and get back another NumPy array. After consulting with NumPy documentation and some other threads and tweaking the code, the code is finally working but I would like to know if this code is written optimally considering the: Unnecessary copying of the...
Suppose in a School, you can only study, teach, or walk; in a Mall, you can only purchase, walk, or sell; Outdoor, you can only study or walk. These actions are all functions that can be called, but we only want to make the appropriate functions callable in the different location types. Here's my way of implementing...
I know it is a simple game, but what I am doing here is practice what I took in an AI course. I'm also playing a little with the canvas and trying to improve the readability of my code and using JavaScript as an object oriented language. I divided my code into 3 main classes (objects). Board class which represents th...
I have a list of items, and a list of actions that extract data from those items. I iterate over the list of items and create a Dictionary for each item that has the data extracted from the item. I have written a foreach based version to get the data, it works well but is a bit long. I could see that there is a shorter...
The program below was made for a game named CheckIO, and it works. I'm just wondering if there is any way to make the code more readable. edit: hi luke15g def checkio(maze_map): #the walls of the maze are already surrounded by 1's start_x,start_y=1,1 stop_x,stop_y=10,10 class Point: directions={...
I have the following problem statement: Modify a given list such that one specific element is "weaved" into that list. Examples if the element is 'module': [] remains [] ['a'] remains ['a'] ['a', 'b'] becomes ['a', 'module', 'b'] ['a', 'b', 'c'] becomes ['a', 'module', 'b', 'module', 'c'] I solved it using the foll...
I've been working on my new lighting system, at the moment it works really good but it has some bugs and color blending doesn't work as I want. Do you know some tricks to improve my code? the drawing system is based on pixel. this.draw = function(data, w, h) { var r = Math.floor(this.radius), ra = r * r...
The following program generates the S3 URL and response (status code?) for the key, provided the bucket name and if the S3 URL is a mess (wrong url), then it generates empty string as URL and error as the response. The code works fine, but the way it handles the messy S3 url seems buggy to me. Please provide some insig...
I have 1 client and 1 server. Client passes Java objects (throughput 10000/sec). I am using Netty. I am short on CPU and this code consumes a lot. I have to make Server1 (Netty Client) talk to Server2 (Netty Server). I do not expect any response from Netty Server (Any optimization on this point? e.g closing some events...
For a plugin I'm writing in jQuery, I have two optional parameters. For each parameter I do a check for its value. However, I'm curious if I can't write it shorter. jsFiddleiddle (function ($) { $.rgbGenerator = function (color, options) { var args = $.extend({ returnAsObj: false, ad...
How can I combine multiple DNS lookups without nesting a whole bunch of if else statements? How would this impact performance? I would ultimately like the function to lookup all DNS addresses simultaneously. function checkInternet(isConnected) { require('dns').lookup('a.root-servers.net', function (err) { i...
This program accepts either a 27 digit binary bar code of type string, or a 5 digit integer zip code of type int. The program can return a binary bar code of type string from a 5 digit zip code of type int or vise versa. I would like to know if this is a good implementation of a class. What would you suggest? I am also...
I'm writing a prototype for an application that uses MailKit and imap to connect to gmail. It's the first time I've used MailKit and I'm a bit stumped around the best way to do this. Essentially, I want to write an async method hosted in a class library that downloads emails based on a simple header text search and inv...
I'm a beginner to Java and OOP, and I would really like to learn how to better organize my code! Over the course of a month or two, I made a calculator program with little functions I thought of here and there with a few small jokes built into it. After looking at it a second time, I realized that it is extremely poorl...
I've just encountered this question and am trying to solve it using Java. Here is my solution to it, which may not be optimized or might not be right way to do it. Someone please review whether it is correct or there is some good way to do it. For focusing on logic, I have hard coded List creation and code repetition i...
After my Dialogue parser has parsed a dialogue, it needs to be validated. To that end, I have several checker classes that go through the lines of the Dialogue. These checker classes get huge as I add more and more features to them. Eventually they get intertwined with checks that they're not really meant to be doing, ...
@Annonomus Penguin, @QPaysTaxes, and I are building an engine for easy creation of text-based adventure games, like Zork. The engine is still in its early stages of development, and the following code is my prototype. Here's the library code. cactus.py class MapPosition(object): """ Describes data about a posi...
After figuring out DXGI, I wrote a class that combines the act of creating a window and its associated swap chain (as well as an OOP approach to messages). The class supports different window modes that are useful for games and editors, and handles XInput behind the scenes, combining gamepad, mouse, and keyboard contr...
I was reading a Java book and I came up with this kind of problem and I tried to solve it: Problem: Write an application that inputs one number consisting of five digits from the user, separates the number into its individual digits and prints the digits separated from one another by three spaces each. For example...
I've created a chessboard model in JavaScript that will eventually iterate through some moves of a championship game. I've created a board object and a piece constructor. I've also created all the pieces with their correct position on a typical chessboard by rank and file. I don't think I've created my move method corr...
The following code is used to access a shield which converts settings written over I2C to Servo output. I make use of the MRAA library since that's the default supported by my hardware. To prevent my I2C commands from being written all at the same time, I use setTimeout to wait a given amount of time before executing t...
This is a follow on question from one I asked a few days ago here: Single process blocking queue Using the comments I determined that there probably isn't a pre-built solution for this and so I have had a go at writing my own implementation using a PriorityBlockingQueue. In order to avoid propagation of poor code, bef...
This challenge is from Talent Buddy: Tweets per second Japan Castle in the Sky airing broke a Twitter record on August 3, 2013. At one point during the classic anime movie showing, people submitted 143,199 tweets per second. This particular spike was about 25 times greater than Twitter’s steady state. Given an ...
I'm using SQL Server 2014 with Visual Studio 2013. When I add a new record, identity column (seed 1, increment 1) "ID" increases by 1, and record added to the database. My table consist of two rows: ID, set identity, seed=1, increment=1 Column1, int Column2, nvarchar(10), Primary Key ID Column1 Date 1. 1 300...
Challenge description is here need to find the first non repeated character from the string: Write a program which finds the first non-repeated character in a string. Input sample: The first argument is a path to a file. The file contains strings. For example: yellow tooth Output sample: Print to stdout the first non...
Answering this SO question recently, I've developed the following code (based on a well-known Active Code recipe, as discussed here): wheel = [2,4,2,4,6,2,6,4,2,4,6,6,2,6,4,2,6,4,6,8,4,2,4,2, 4,8,6,4,6,2,4,6,2,6,6,4,2,4,6,2,6,4,2,4,2,10,2,10] wsize = 48 def primes(): yield from (2, 3, 5, 7) yield fro...
This very fast, simple sieve quickly finds 31 bit primes. It uses a memory efficient BitArray for odd numbers. How a 32 bit int is a 31 bit prime Since a prime number must be > 1, the sign bit has no bearing, leaving 31 bits to store the positive numbers. This differs from uint which truly would be 32 bit primes. See...
All that the program does is query a database that I have setup, when the user selects the returned fields, which are populated based on the selection of the field above it. The application is basically 3 classes: DbConnect: Generates queries that are sent to the database Nested - QueryFields: Contains all user-sel...
I decided that since I was learning AngularJS and Bootstrap, I'd be remiss not to post a FizzBuzz, but FizzBuzz bores me, so I've extended it. My version of FizzBuzz is configurable, and allows you to create an infinite number of different "Fizz", "Buzz" etc elements with whatever names you like. function element(nam...
I just wrote this C++ code in Visual Studio. The code is working fine but I wanted to ask whether my code is written in a safe way or not. #include "stdafx.h" #include <iostream> int input() { int x; std::cin >> x; return x % 2; } int main() { using namespace std; cout << "...
Basically, I have three sheets in my workbook where only the second and third worksheets are being used. I want to copy columns from the second sheet to the third sheet only if the column headings match. For example, the code will check the first row of sheet2 to check if it matches any of strings in an array and if it...
This is a script that creates a base dataframe from a sqlite database, adds data to it (also from SQLite), cleanse it and formats it all to an Excel file. I feel like it is incredibly verbose and my code could be simplified quite a bit. One thing I definitely want to do is eliminate the direct references to the db, /...
I am trying to create a script that shows my login modal on page load. I have a button that opens the register modal and closes the login modal if clicked. Here is the script I am using: $(document).ready(function(){ $('#loginmodal').modal('show') }); $(".hidelogopenreg").click( function() { $(...
I'm trying to solve exercises where I am required to use recursion. I wrote this: static String reverse(String word){ if(word.length()<2){ return word; } else{ int index = word.length() - 1; return word.charAt(index) + reverse(word.substring(0, index)); } } But the answer for th...
There was a task on Stack Overflow which quite obviously was too broad (it didn't have a solution provided or anything!) which was the following: Give an object oriented design for a game that has the following requirements: It is a game of cards. Cards can have four symbols - Hearts, Diamonds, Clubs, Leaves Cards...
Note that this problem is equivalent to finding the longest line segment defined by any two points in a collection of 3D coordinates, which may be an easier way to visualize the problem, and is almost certainly a version that has received more research. Essentially, given a List<Color> and this method... public static ...
I made a bigint class that can add unsigned unlimited precision integers by splitting number into chunks less than 9999, and if a part is bigger than 9999 I take mod 10000 and carry 1 to the next part. The adding function looks a bit messy as I had to make adjustments for the algorithm if rhs has more/less digits than...
This is my implementation for Sieve of Eratosthenes in Java.Please let me know how can I further improve my code: public static void main(String[] args) { ArrayList<Integer> numbers = new ArrayList<Integer>(); for (int i = 2; i <= 120; i++) { numbers.add(i); } int digit = 2; while (digit ...