instruction
stringlengths
71
95.1k
I am following CIS 194: Introduction to Haskell (Spring 2013) online to teach myself Haskell. Following is my response to third exercise of Homework 3, namely Histogram. In which ways I could improve this, without getting too much into advanced topics of Haskell? {- For this task, write a function histogram :: [Integer...
As you know there is an algorithm in C++ standard library called std::merge, that merges two sorted ranges into another range. I try to write another merge (called multi_merge) that gets multiple sorted ranges (one or more), and merged them in one. The code is as follows: #include <utility> #include <vector> #include <...
I want to write an algorithm to count how many islands are in a given matrix. Consider for example: A = [ [1, 2, 1, 3], [2, 2, 3, 2], [3, 3, 2, 3] ] Directly adjacent (north, south, east, west, but not diagonally) numbers constitute an island, in this example matrix we have 9. I've written...
I have a nested set of for loops which achieves the desired outcome, but I don't know if it is the most efficient / pythonic way of populating this list. I would like all combinations of the one object functions, combined with 0 to n combinations of the two object function. Here, I have abstracted parts of the code awa...
I implemented a general function for a depth-first-search (DFS) using JavaScript with default arguments and functions that need to be provided in order for it to work. This function is using async & await, but both can be removed to make it synchronous. Is the naming sensible? Are there missing pieces that would be us...
I needed a Minecraft-like stone texture, instead of creating it using image editing software I decided to generate one using R. The idea is to create some noise and stretch it horizontally so the texture tends to have some horizontal lines. Example output (this example is upscaled, the original file is 32x32 pixels): ...
I'm trying out .net core with mvc in a personal project, the latest functionality I've added was a project catalog, primarily ajax based, it's displaying a list of projects fetched from the database using web api in a catalogish order and interface. Web API Starting with the infrastructure layer, I decided to have 2 c...
I'm studying with book "Introduction to Algorithms" and implemented PriorityQueue without existed Class. I made a MaxHeap class with Array and made a PriorityQueue with my Heap class. Actually code is working and refactored code I did my best, but I'm beginner so I need feedback for anybody. would you give me a opinion...
I'm new to VBA programming so the following code may look terrible which is why I want ways to understand how to better optimize it and other future codes. Sub Sequence() Application.ScreenUpdating = False Application.Calculation = xlCalculationManual Application.DisplayAlerts = False Dim unique_string1, unique_string2...
In my program, I have special id numbers. They have a fixed length of 10 characters and may only contain digits and lowercase letter. I created my own data type for this. I want to be able to assign string values to it (with the implicit operator). When I do so, there should be automatically a verification if all condi...
The challenge is to iterate over the vector only once and return the value within the range of the zero. However, if there are no matches or more than 1 match, deliver an error. The vector is unsorted and has no guarantee on it's size or the range of data. More technically, the number of data accesses into the vector c...
The code below is written as part of a parser, which files would be also added here: XMLParser, parser, Name, GenericElement, attrib It reads an XML files from a folder, turn them into a dataframe using pandas and then parse it into a CSV file. from generic_parser import XMLParser import pandas as pd import os opdatas...
Context: This script reads in a fasta file, counts the number '-' characters, alphabetic characters and total characters for each sequence (sequence descriptions are on lines marked with '>'), and then prints out a processed file with columns where 90% (or more) of '-' characters are removed. I've tested it with small...
I want to remake and sort an array. Is it possible to use "reduce" instead of "forEach" or "map"? return beeProps.valueInfos.reduce (reduce()) would be great. Anything else looks like it could be improved? const makeTableArrayMap = (beeProps: beeOfProps) => { const rowMap: Map<number, beeOfValue[]> = new Map(); ...
I am just starting to code by myself in Flutter. I've built this so far and here is the image. Can you show me what would be better or cleaner code? I used Row widget for it, but I guess I should maybe go with the Stack. Because now I want to add a text field box in the middle of the app bar that overflows in the down ...
I would like to do a refactoring of web API implemented in .NET Core. The Goal is to simplify Get method and to implement this to be more according to REST philosophy. I would appreciate any advice. As you can see the logic has many invalid combinations and too much code in one method. namespace Api.Treatments.V2 ...
I want to check that a some type has some methods: using Arg_t2 = int; using Arg_t3 = int; template<class T> struct ValidType{ using Ret_t1 = T; using Arg_t1 = int; // ... Ret_t1 method1(Arg_t1,Arg_t2,Arg_t3); //... }; Therefor I wrote a type-trait: #include <type_traits> template<class T,class _ = vo...
I'm not sure if Code Review is the proper SE site. If not, please point me in the right direction. Let's assume we have a simple function, where you can pass an array and it will do some work on it. For simplicity sake, let's just assume you pass an array of integers to the function and it doubles them I was wondering ...
I've just started the cryptopals-challenge, and now wanted to show my solution to the first challenge here: public class Challenge1_1 { public static void main(String[] args) { String hex = "49276d206b696c6c696e6720796f757220627261696e206c696b65206120706f69736f6e6f7573206d757368726f6f6d"; String ba...
I am writing a domino draw game in C# and would like to know if there is a simpler/better way to know the player that has been dealt the highest double bone (where x equals y) and what bone it is: public class Player { public string Name { get; set; } public List<Bone> Bones; public Player(string name) ...
I would like to record client information when they go into a location on the web site so I created this ProcessRequest class that will collect data and insert it into the database. This will collect HttpContext and send that data to a Store Procedure that will then insert into a database table. namespace DataCollectio...
In my project I used this code to create a GUI using JavaFX. The aim was to have a screen with 7 buttons on it. Next, depending on which button is pressed another set of buttons will appear on the screen. The user then chooses one of these which then sets an integer variable subchapter to a value and calls the next met...
I've now used the tips, you can find here and there, to improve my code: import javax.swing.JOptionPane; import javax.swing.JScrollPane; import javax.swing.JTextArea; import java.awt.Dimension; public class CaesarCipher { enum WhatToDo {ENCRYPT, DECRYPT}; public static void main(String[] args) { Str...
I'm required to calculate the average value of all nodes in a BST using a Visitor, I'm not sure if I did this correctly or if i could just calculate the average with inOrder() and therefore I'm not really utilizing the visitor. import java.util.*; public class Node{ int val; Node left; Node right; pri...
Supports backspacing, but not wrapped backspacing. %macro newline 0.nolist mov ax, 0E0Dh int 10h mov al, 0Ah int 10h %endmacro %macro getc 0.nolist %%get: mov ah, 11h int 16h ; get keystroke status jnz %%pressed hlt jmp %%get %%pressed: mo...
My best languages are Python and Rust, but I want to improve my C++ skills, so I decided to try my hand at Advent of Code 2019 in C++. So far I have not encountered any major issues, but I want to know what I am doing that is subtly (or not so subtly) wrong. The following program is my solution to the Day 9 problem. It...
I have been trying to come up a generic C linked list to store data as it comes and later sort them to use it for various purpose. Please have a look at the code below an provide me your review comments. This code compiles and runs in Windows and Linux. Naming Design Quality Usability you may run the main.c for exa...
I'm trying to implement some logic functions essential to control a small power system consisting of 2 Transformers labeled T1 and T2, 2 Generators (G1 and G2) and a bus tie (BT). I'm not going to overwhelm you with the unnecessary details. I need help figure out why my Arduino circuit doesn't work as expected even th...
I made this program to understand inheritance better. Now that I'm at this basic level it's not really a problem but I can see this coming in the future and so I'm asking what's the best method to ask the user to insert the width and height of a rectangle (in this case). The code I'm providing includes the simple way, ...
I've become a bit rusty in Java. This is an attempt at brushing up my skills. Bubble sort, sometimes referred to as sinking sort, is a simple sorting algorithm that repeatedly steps through the list, compares adjacent elements and swaps them if they are in the wrong order. The pass through the list is repeated until t...
A collegue and me implemented a simulator the iterated prisoner dilemma from game theory in haskell. We would appreciate any feedback on the quality of the code, how things could be worked out more efficiantly or elegantly. The code file together with a tex file (along with the compiled PDF) in literate haskell style t...
I'm trying to realize simple testing application. And I ran into a problem. I have two arrays. The first is an array with the initial questions, the second array is the answers of users. And now I need to count the number of correct answers. I wrote the following code. I wonder: how optimal is it and, if it's bad, how ...
I have 3 radio buttons all grouped inside a group box in a WinForms project. Currently, I am checking which button is checked and assigning values using the following if/else statement, similar to the below example if (rb1.Checked) { selectedButton = 1; selectedButtonText = rb1.T...
Below is my code for the “Minimum Window Substring” LeetCode problem in Swift: Given a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity O(n). Example: Input: S = "ADOBECODEBANC", T = "ABC" Output: "BANC My solution fails on a very long string, but passes ...
This little program was written for an assignment in a data structures and algorithms class. I'll just note the basic requirements: Given an inputted string along with mode (0=spell check, 1=AddToDictionary). If the mode is 0 the program should check to see if it exists in a dictionary of correctly spelled words. If no...
I would like to know if there are any things I could improve with the following code regarding writing it in a FP style: server.js: const express = require('express'); const app = express(); const person = require('./person'); app.get('/create-person/:name', (req, res) => { person.addPerson(req.params.name); r...
I am a beginner in Java. I have created this small project in Java with the inheritance concept. Here the Human will fill, pour and drink water. There are three classes: Glass, Jug and Human. Let me know how you think it is! Glass class: public class Glass { private float capacity = (float)0.5; private float q...
I have the following files: STUDENT_D19001.T103412_HU.txt STUDENT_D19001.T103412_KU.txt STUDENT_D19002.T113030_HU.txt STUDENT_D19002.T115055_KU.txt STUDENT_D19003.T115055_KU.txt STUDENT_D19004.T135040_HU.txt I want to process the common/pair files separately in this order (HU1 and then KU1; HU2 and then KU2) and the ...
I had another question for my Perl class assignment. Related question: Frequency analysis for simultaneous dice rolls use warnings; use diagnostics; use GD::Graph::hbars; use List::Util qw(max); my $number_of_dice=0; my $number_of_rolls=0; my @total_sum_of_eyes; my %count; my $counter=0; print "\n Plea...
I'm new to F# and functional programming in general (coming from an object oriented background). I just wanted to get some criticism on an algorithm for assigning jobs to crew members. I want to be as functional as possible and avoid loops and mutable state. Here is what I've come up with. let rec AssignJobs crewMember...
I created my first commit for ASF Maven today. In the PR I was asked two things. By the way: "understand" doesn't mean I speak another language. It is more about his and my opinions and arguments. Else-If instead of guard statements / early return So, there is no documentation and no check style rule that says this, bu...
I have a pandas data frame and I want to calculate some features based on some short_window, long_window and bins values. More specifically, for each different row, I want to calculate some features. In order to do so, I move one row forward the df_long = df.loc[row:long_window+row] such as in the first iteration the p...
I've created a simple JS 'To Do List' application. I'm very new to JS and this is the first JS project I have done. I would greatly appreciate any feedback on how to make the code more efficient, neater and better adhere to best practices. The 'To Do List' uses local storage to persist data, and does simple checks such...
I'm writing a helper script that I wish to be able to share with my co-workers. We all work using macOS Mojave, but all have their own shell configurations. For example, I actually use ZSH and bash 5.0. There are often times where I am working with data that is output from our nightly testing that runs on a remote clu...
Usually it is a good style in Java to create a named constant for a string (and other) hardcoded values. Using the example below I want to know how pedantic I should be in it. I use a Java class as a wrapper of XML settings. Each function is suppose to return a value from a related XML file. I defined a lot of constant...
My Objective is to create a fixed column array object of size 4 columns so that I can form a 2d array in the following format which I can use to print to a pdf later. The solution is working fine. But need help in figuring out if there is a better way to implement this. let input = [{ id:123, quantity: 4, value: ...
Is there a simpler way to write this ugly if/else statement? It's simply appending a query string to a url depending on whether the variables exist. if (start) { url += `?start=${start}`; if (end) { url += `&end=${end}`; } } else if (end) { url += `?end=${end}`; }
The desired behavior would be: [TestMethod] public void Compare_Value_Identity() { var source = new[] { 1, 2 }; var modified = new[] { 2, 3 }; var (inserted, deleted) = source.Compare(modified); CollectionAssert.AreEqual(new[] { 3 }, inserted.ToArray()); CollectionA...
I'm playing with ktor right now. If I understand this correctly, code in ktor's handlers need to be as asynchronous as possible. So I was trying to figure out how do you write synchronous (potentially expensive) code in a Kotlin coroutine. Here's what I've written: install(DefaultHeaders) install(CallLogging) {...
After a few trials I've written this code where the border of a link expands: a { position: relative; text-decoration: none; margin:0; } a::after{ content: ""; position: absolute; //relative to a bottom:0; left:0; width:0%; transition: 0.3s width ease-out; } a:hover::after { width:100%; border:...
The idea is to have a data structure that holds any number of objects of any type. Objects can be retrieved, or removed permanently, at random. Also, it can be cleared (or emptied). This class just provides the ability to select a random object from a collection, with the option of removing it. public class Sack { ...
I want to allow the user to enter a number of race results (A minimum of 2 participants and a maximum of 7) I feel that I could use a much shorter code, (I am a beginner of Java only 2 months so any recommendation would be highly useful! thank you Code below: int entrants = 0; String[][] runners = new String[2][2]; boo...
I want to create thumbnails from PDF files – specifically, a thumbnail of the first page. Currently I use pdftocairo on the command line: $ pdftocairo myfile.pdf -png -singlefile -scale-to-x 400 -scale-to-y -1 but I wanted to see if I could implement this without shelling out to an external tool. I've written a functi...
I am trying to solve this question. The essence of the problem is this: Given a list of school classes with start and end times, find the total number of non-overlapping subsets. I've written up a DP solution that I think is optimal in terms of time complexity - \$n * \log(n)\$. ''' https://www.spoj.com/problems/ACTI...
I wrote a class that extends the dict class to provide indexing like functionality, so I can find which key(s) map to a given value in the dict. It's pretty bare bones and there are a lot of things I haven't fleshed out like docstrings (will add these later when I have a final version), how to handle unhashable element...
I'm fairly new to HTML and CSS and I've put together a navigation bar. The purpose of the navigation bar is to be clean and mobile-friendly. I would appreciate some feedback on what I could do better within the code as I don't know what's best just yet. const navSlide = () => { const burger = document.querySelector...
I recently needed to run some command line applications from Python. Whilst this is fairly simple with subprocess.Popen. I wanted to be able to properly pipe the output. When running the programs from Python I want three things: The option to have a low memory footprint. This is possible with Popen by passing some, n...
Recently I was studying bitwise operators and bit-manipulation algorithms and I found out an algorithm to add two binary numbers. Pseudocode is as follows: function add(A, B): while B is greater than 0: U = A XOR B, where XOR = Bitwise XOR of A and B. V = A AND B, where AND = Bitwise AND of A and ...
Problem Given a set of formulas (AKA "Rules"), get a list containing every possible answer that does not break any formula. Formula variables can have a maximum equal to the number of characters. For example "ABC" can have a maximum value of 3, while "E" a maximum of 1. Example, given this set of Rules: {ABC + E} = 3...
For some database requests, I like to use raw ADO.NET. In the context of a web request, I have created a class which provides an open IDbConnection object. I use a Dependency Injection library ("DI") to do this, scoping the object instantiated from this class to a web request. So, disposal of the object is handled by ...
I am experimenting with cryptography and I was wondering if somebody has some suggestion how I could improve my code and methodology. I want my process to generate more securely the cryptography process if that is possible import java.security.GeneralSecurityException; import java.security.Key; import java.util.Base64;...
I am learning Python and I know that a lot of my future projects will be based on files and managing them. How does this look? Is anything in here redundant or overcomplicated? import os import zipfile import shutil from datetime import datetime as dt class File: def __init__(self, path, datetime=True): s...
Optimizing/parsing files into semi-complex data-structures more efficiently To preface, I'd like to say that this code is part of the Advent of Code 2019 solutions I have been working on. Particularly #14. --- Day 14: Space Stoichiometry --- As you approach the rings of Saturn, your ship's low fuel indicator turns ...
I have REST API written on laravel and front end on vue.js. It is a dashboard for an ecommerce store where you can connect to post shipment service API to upload order shipment data and get tracking number (with .png label). So after I receive tracking number label from post service API I need possibility to show it in...
Usually I have really noisy datasets, so peak detection is quite hard to do just with coding. However the human brain immediately sees what is just random noise. I decided to make a basic peak editing functionality with matplotlib. I added a toggle button to the navigation toolbar to switch on and off the recording. Th...
I have two methods I'd like to improve using optional and any other tool, @Override public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException { User user = userRepository.findByUsername(username); if (user == null) { throw new UsernameNotFoundException(Stri...
I am creating a package to be used in our company that adds the root of the project to the system path. I will add a source_root.config file in our root directory. add_root_path.py import sys import inspect from pathlib import Path from inspect import getsourcefile CUR_FILE = Path(getsourcefile(lambda:0)).name SOURCE...
For me, learning the basics of a new programming language is best done through some easy to intermediate challenges. Here's one that's rather well known and relatively simple - determine if a triangle is equilateral, isosceles, or scalene. Here's my try in Golang. Since I'm totally new to Go, I'm pretty sure this can b...
Is the single method printMaxDistance_a or the two methods printMaxDistance_b AND printMaxDistance_c better or respectively "more readable"? Thanks. public static void printMaxDistance_a(String s) { int first = 0; int second = 0; int max = 0; for (int i = 0; i < s.length(); i++) { for (int j = i...
I'm working on a project in which I have a backend in nodejs and from there I need to call external APIs, those APIs require authentication token which is valid for 15 minutes. So if response status from external APIs is 401 then I need to generate a new token then call the request. In my backend, I'm using request-pro...
I have an Oracle GIS database that has spatial tables. The records in the spatial tables have a geometry column that contains polylines. I've written a Python 2.7.16 script that calculates the midpoint of the polylines and inserts the midpoint information into parallel tables. The script will be run as part of a nightl...
AFAIK Octave still does not support enumerations, so I've done my best to write a workaround. The question is if there is something missing in code below, or maybe something can be improved? The reason for the enumConstructor method is that with Octave 4.2.0 I had errors when overloading the constructor. classdef Enum ...
This is an update to my earlier question From Q to compiler in less than 30 seconds. As with that version, this Python script automatically downloads the markdown from any question on Code Review and saves it to a local file using Unix-style line endings. For instance, to fetch the markdown for that older question, one...
I have a sorted list of materialized hierarchy paths: paths = ['10001', '1000100001', '100010000100001', '100010000100002', '1000100002', '100010000200001', '100010000200002'] I am getting the immediate children paths (nodes) for each non leaf node. steplen = 5 # size of each hierarchy step max_depth = len(max(paths, ...
I have tried to implement the Selection Sort Algorithm in two different ways, and I was just wondering if that is considered to be a valid implementation of that algorithm. Would that be also considered an efficient implementation of the algorithm, or are there different and more efficient ways? Here are my implementat...
This is a basic game asking for the common port number for a protocol used. I designed it with the intent on helping myself and others who are going after their Sec+ exam to memorize the ports needed. Any in cleaning up the code or better ways to process the lists would be most appreciated. import random import sys f...
I have the following code import time from flask import Flask, request from flask_restful import Resource, Api import threading app = Flask(__name__) api = Api(app) class A: def __init__(self): self.x = 5 def increment_x(self): self.x += 1 def get_x(self): return self.x def a_...
I have simulated balancing a scale by having each side total the same weight. The scale has two weights (left and right side) and some spare weights: weights = [3, 4] spare_weights = [1, 2, 7, 7] A maximum of two weights can be used from the spare weights to balance the scale. The spare(s) may be on a single side or s...
In order to improve UX (User Experience) in WPF for huge collections, I would like to load collection items in asynchronnous and staggered fasion. While the WPF UI is virtualized by default, there very little support for data virtualization. My goal in not to implement full data virtualization but rather to load all it...
I've stripped most of the code and comments from what follows. My question is about the style that it is written in, not about the correctness of the code itself. In particular, I've never seen anyone use this way of defining and initializing variables. The idea is to keep all the definitions together, but to attach an...
I am displaying the following information in angular 8 application. I need to display only the partnerName if it exists. <h1>Financial Game Plan<br>of <span>{{ name }} and {{ partnerName }} </span> for {{ currentDateString }}</h1> I have done the following. Could you let me know if it is correct? TS this.name = factF...
On Codewars, there is a challenge where the goal is to justify an str into a certain len. Here are the rules: Use spaces to fill in the gaps between words. Each line should contain as many words as possible. Use '\n' to separate lines. Gap between words can't differ by more than one space. Lines should end with a wor...
I am doing a college exercise and would like to know how to improve the execution of the idea. The idea is to create a program that converts temperature measurements. Main.java package app.cnv; public class Main { public static void main(String[] args) { Celsius celsius = new Celsius(37); System.out.println...
I've been using PHP labels in my Controllers for code folding. PHP labels are actually used with goto statements. But I'm using labels only because it's so much easier to fold my code in different IDEs using labels + curly braces, and I can use labels as titles for different sections of the code. Here's an example. Tak...
I've implemented the Conway's Game of Life in Java, including a GUI. Here's the code of the two classes I wrote: GameOfLife.java public class GameOfLife { public static void main(String[] args) throws InterruptedException { Gui gui = new Gui(); int [][] array = new int [71][71]; //Field...
I created this double-ended queue using list. I supported the standard operations such as push, pop, peek for the left side and the right side. I used an integer mid to track the midpoint of the deque. This way elements can be inserted to the left or to the right appropriately. Here is a list of efficiencies according ...
I am trying to find certain strings in MasterSheet and copy offset columns (3 columns) values in the specific columns in receiver sheet. So far i have this code doing exactly what i want to do Sub FindString() Dim MasterSheet As Workbook 'Master sheet where data is coming from Dim WSLHD As Worksheet 'Slav...
Another code clean up I am working on. I have been breaking up my code based on things I have learned here on CR. The code below all works and functions as expected, but I know it can be streamlined more and would like to see how this can be accomplished. The code below was combined into one code block here for ease...
I'm working on a tool that converts data between two systems. System 1 presents me with arrays of latitudes and longitudes as doubles. System 2 requires an input of that array as a single Hex string. I've been calling the following method to do the conversion, and then appending a string with the results, however I'm f...
I am trying to figure out how Factory pattern works. I implemented it with TypeScript in this github repo: https://github.com/emilecollin/factory_pattern Basically this is emulating spaceships gaming logic: the program will ask you to input in the terminal one of these options: "alien" or "zombie". With the provided in...
I have tried two different methods to find the sum of primes under a certain number. However both of these methods end up taking a very long time for large numbers. How can I optimise either of these two methods? Method 1 (Sieve of Eratosthenes): import time import math primes_in_range = [2] n = int(input("Enter the ...
This code I try to write based on last week codewars event that I joined which I can't figure it out during the event. The question is: T9 Autocomplete The file contacts.txt has names and phone numbers. The format is: column 1 = name column 2 = phone number Your program should receive a sequence of numbers and retur...
As part of the exercise in the book "Automate the boring stuff with Python" chapter 13 on Excel, I had the following exercise: Reads the data from the Excel spreadsheet Counts the number of census tracts in each county Counts the total population of each county Prints the results Here is the structure of the spreadsh...
I've implemented a Segmented Sieve of Eratosthenes that assumes each segment is about length \$ \sqrt{N}\$ for some upper limit \$N\$. I further optimized the function by skipping all the evens when sieving. I'd like to know if anyone has any views or advice on further optimizing my implementation. Note that there are ...
Background I am working on an e-commerce website, my web server is written in ASP.NET MVC (C#, EF6) and I am using 3 instances of MySQL DB. These DBs are in a cluster (Galera Cluster) and they are automatically replicated. The problem that I want to solve is load balancing the requests among these 3 instances of MySQL....
I have written a program for a user-defined binary data type in JAVA. It has static methods for purposeful usage methods for binary arithmetic methods for bitwise operations It's working as intended, but I feel the code is a bit too verbose. Any suggestions on how to shorten it? Also, can I make it faster? Beyond tha...
I am trying to search a json string(events) from a given list (eventSubscriptions).Here is what I have tried. import com.fasterxml.jackson.databind.ObjectMapper; private boolean isEventsOverlapping(String events, List<EventSubscription> eventSubscriptions) throws IOException { List<String> eventsList = ne...
I am in the process of using Java Builder design pattern to write a connector class that has optional member variables and need some suggestions. My question from here Standard practices for employing Java Builder design pattern has been updated and the code now presented is not psuedocode but is specific. public class...
I made a closure-based PHP structure that behaves mostly like a classical object. To change the object's state, one must derive a new copy by passing the altered state to the newCounter() 'constructor'-function. If you alter $state inside a method without returning newCounter($state), the original object won't be affe...
I wrote this piece of code to append index to any duplicate entry in List<T> like in the sample below. Input ["dupe", "not dupe", "dupe", "also not dupe"] Output ["dupe1", "not dupe", "dupe2", "also not dupe"] But the problem is it's O(n^2) in the second loop and I'm working on a large list (30+ items). I'm very new ...