instruction
stringlengths
71
95.1k
I am new to RxJava and have the following code which I use to search YouTube videos via the API and ultimately display them in a list. private fun showYouTubeSearchView() { val youtubeSearchView = viewFactory.getYouTubeSearchView(null) val contentView = youtubeSearchView.rootView youtubeSearchView.subscri...
I wrote an splay search tree using the algorithm description and debug and now I want to find out how I can optimize it, maybe I have some obvious errors and I will be glad if someone shows them to me. Java code: private final class SplayTree{ private Node root; private void keepParent(Node v){ if(v.l...
During some running process, a histogram of values shall be build up. When done, the CDF shall be derived from it and used to get the quantiles for some values. My current implementation looks as follows: import java.util.* import kotlin.math.max import kotlin.math.min import kotlin.math.roundToInt import kotlin.random...
I have a web component that is rendering a list of items and I have this method for filtering these items based in a filterBy object that is being updated by other events and stored in the same component class. filterBy = { comment: '', // string rating: [] // array of numbers } filterFeedback(items) { let...
This is a real live chatroom that I have made with Tkinter I posted a question before about making a chatroom but the problem that I had with that one was that only one user could connect to the server so I restarted and have made this one. I just want suggestions on how I can improve it. All suggestions will be greatl...
I have some enum classes for units, like Weight units (KG and LB). I am translating the code to Qt C++ from Java, and I'm wondering what the best way to do this is as enums cannot have constructors in C++ that same way they do in Java (as far as I know). Here is the Java class: public enum WeightUnit { LB(WEIGHT_UNI...
I wrote a server-side Battleship game simulator in nodeJs/Javascript: A random player who begins is chosen. Both players place their ships. Software recognizes if they are placed correctly. One of the players shoots at a position on the 10×10 field. If it's not the current players turn, the program recognizes it; if ...
I wanted to write an After Effects plugin which generated a shade of colors based on harmonies such as Complementary, Split-Complementary, Triadic, Square, etc. And Tint, Tone, Shade, Saturate operations based on a Lua code which I had on my hard drive since 3 years ago. So my code is basically a Lua to C++ translation...
I just finished a simple script for Node that will delete all the folders and files inside a specified folder ID through Box's API. It works by getting a list of items inside a folder, then generating a list of File IDs and Folder IDs, then making parallel calls to Box's delete file and delete folder endpoints. This s...
Lately I have been playing a game called Dirty Bomb. I like it very much, and since I was taking a rest of basic C++ OpenGL, i tried to make a simple console utility for it. What i wanted to achieve is that, when I pressed a key (representing an in-game character) the program would, after a specified delay depending on...
import sys class Node: def __init__(self, value): self.left = None self.right = None self.value = value def __str__(self): return f"{self.value} " class Sum: def __init__(self, val): self.s = val def getS(self): return self.s def update(self, va...
I would like to see suggestions if my code could be more improved. In my controller I have a line: self.bool_value = False # for testing which in my opinion should not be there, because I put it there only for testing purposes, but I did not find any way around. In addition I would like to know whether you guys test ...
I have been trying to figure out how to meet space and time complexity requirements for the following leet code question. I have come up with two versions, one that meets the time requirements and another that meets the space requirements. Both versions fail on the same test case (the last test case shown below). Can a...
I was searching for a long time how to write multi-page TIFFs with the JPEG encoding. TIFFs support JPEG encoded frames but the built-in encoder in .NET Framework does not have JPEG as a compression option. The code is based on the answer to this question: https://stackoverflow.com/questions/14811496/tiff-with-jpeg-co...
It's a user alert script. It worked in every browser I tested. But the function itself looks very messy/repetitive. Is there any way to make this cleaner? function message(text) { var alert = document.createElement('div'); var alertText = document.createTextNode(text); var alertCloseButton = document.create...
I want to create a pytest with a fake utcnow, but also I need to preserve the functionality of all other datetime methods. Simple example here: import datetime as dt class FakeTime(dt.datetime): fake_time = None @classmethod def utcnow(cls): return cls.fake_time def str_2_time(str_dt: str) -> d...
Kata: https://www.codewars.com/kata/range-extraction/python A format for expressing an ordered list of integers is to use a comma separated list of either individual integers or a range of integers denoted by the starting integer separated from the end integer in the range by a dash, '-'. The range includes all int...
I am really new to programming, and I made this simple tic tac toe app in python and C++. Please tell me what can be improved Code: import os toDraw = ["1", "2", "3", "4", "5", "6", "7", "8", "9"] turnsPlayed = 0 playerTurn = 1 def reset(): global turnsPlayed turnsPlayed = 0 global toDraw toDraw = ["...
We have been learning C++ the previous semester and I made this simple TicTacToe game at the end of it. We haven't yet covered topics of vectors, classes, objects, exception handling etc. so with this code I mostly wanted to practise use of arrays. I would like to hear from you on suggestions on how to make this code m...
I am really new to programming, and I made this simple Tic Tac Toe app in C++. Please tell me what can be improved. #include <iostream> #include <vector> #include <algorithm> using namespace std; vector<string> toDraw{"1", "2", "3", "4", "5", "6", "7", "8", "9"}; // NOLINT(cert-err58-cpp) void reset(); void reDrawB...
I am learning about one of the hardest parts of Audio development: the synchronization between the audio thread and the GUI thread. Per the discussion here https://forum.juce.com/t/timur-doumler-talks-on-c-audio-sharing-data-across-threads/26311 and here: https://stackoverflow.com/questions/15460829/lock-free-swap-of-...
TL;DR I'm self teaching VBA, learning about functions and passing arguments from a subroutine into the function and want to know if my very basic function to define a range is optimal and follows correct referencing/standards/practices. I'm teaching myself VBA (mostly in MS Excel) as a starting point into programming i...
I am working on this HackerRank problem but running into time constraint issues. Basically, given two arrays, we need to determine if the ith element of the second array is reachable by the ith element of the first array, where edges are determined by whether or not the gcd of the two node values is greater than some t...
I have implemented a simple binary search tree class in C++ using std::unique_ptr objects to hold the pointers to each node. In doing this I have come across a situation that is somewhat questionable in the Delete method. Since I can't copy the unique pointers, but I need a way to traverse the tree with a "temporary" p...
I'm creating an online calculator to get the average grade of different tests my students take. I wonder if you see any problems in the following code or any way to improve it: document.getElementById('calculator').addEventListener('click', function() { var physicsTests = document.getElementById('physics').getEleme...
I want to split a song into multiple parts, given the song duration and number of parts. My code achieves that, but it feels a little "stupid" and I would like to learn a more sophisticated - and shorter - way. Particularly, I feel that the marker variable is a little overkill. I would welcome any suggestions. song...
I'm using a database that has a library for access to it. Connection is done synchronously, it's blocking and I do not have a way to abort it. To connect, I have to write: var _loader = new DatabaseDriverLoader(); DatabaseDriver _driver = _loader.Connect(connectionString, login, password); I wanted to improve it: Be ...
Let's say I have a Binary Tree that looks like + 2 * 5 8 I've written a function to traverse inorder to solve it as 2+5*8 Is there a better way? Using eval seems a bit hacky and perhaps I can just have a function calculate the total sum on either side and then do a left + right instea...
I am really new to programming, and I made this simple tkinter app in python. Please tell me what can be improved and how to use classes correctly in combination with tkinter. Github to clone if you want #!/usr/bin/env python # --------------------------------- # @author: apoc # @version: 0.1 # -----------------------...
I am implementing an algorithm to solve the following problem: Given a sorted (increasing order) array with unique integer elements, write an algorithm to create a binary search tree with minimal height. The solution of this problem using recursion is quite straightforward: class Node: def __init__(self, value): ...
Problem: We have a Google Custom Search function that replaces the input placeholder attribute and it works okay. Would you be so kind and help me with reviewing it, and if possible, provide an efficient function to replace this function with (also hoping that it would work with older version of IE and other browsers,...
I am working on problem where I need to decode a string: A message containing letters from A-Z is being encoded to numbers using the following mapping: 'A' -> 1 'B' -> 2 ... 'Z' -> 26 Given a non-empty string containing only digits, determine the total number of ways to decode it. Example 1: Input: "...
I'm working on learning C++ coming from python. I'm doing some projects to help me out understanding the language a bit more. My code works I just want to know if there is anything that I can improve on it or best practices in C++, maybe something that I should have done differently. // Ceaser Cipher implementation #i...
I have multiple products that all have sizes and I need to find the cheapest configuration that meets the minimum required size. For example, John needs a minimum of 10 litres of storage - it can be more, but not less. There are 2L, 3L, 5L, 8L and 10L options (but this can change). As an example, it might be cheaper ...
I have implemented a binary search tree using templates and unique_ptr in C++ 11. At present, only insertion and deletion are implemented. Please provide your feedback for improvements. #include <iostream> #include <memory> template<typename T> class Btree { public: void insert(T data) { _insert(root,...
I'm learning more about PHP, so I've decided to create a simple login/create account system. Entering information for creating a new account sends the data to my localhost machine, using MySQLi and the web server MySQL. I'm looking for feedback about security, efficiency, and overall code. I would like to kick old habi...
Python beginner here. Building an OOP bank account program with SQLite and starting to struggle a bit with its design. From a design standpoint I have a file (bank) which calls ATM. ATM simulates an ATM, and is the file which then calls bank_account or credit_card depending on the account data passed in from bank. To i...
I am learning Python and I wrote a script that counts how many coins you would need for an amount in dollars. I was wondering if I could make any improvements to it. def change(): amnt = float(input("Enter an amount in USD: ")) quarters = divmod(amnt, 0.25) print("Quarters: ", quarters[0]) amnt = round(...
I am working through this problem on project euler. Basic purpose of the code: /* if n is even n -> n/2 if n is odd n -> 3n + 1 which starting number under 1 million produces the longest sequence? */ The trouble with the code is that when I implement concurrency as I have, the program runs considerably more slowly tha...
Am making a pure .net library with helper functions (GitHub). However I wanted to have a thousand separator for all number types and here is what I am currently doing using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Avo { public static c...
I'm refactoring my scheduler and for one of its triggers I need an endless counter that would automatically restart. Since this is a simple and very common task I don't want to ever have to implement it again so I encapsulated it in such a way that it hopefully can be reused everywhere else. The counter is represented...
I have this method rated B on Scrutinizer (direct link: https://scrutinizer-ci.com/g/sineverba/domotic-panel/inspections/76996c9f-543f-43b4-9475-c64fe810a278/code-structure/operation/App%5CHttp%5CControllers%5CApi%5CPublicIpController%3A%3Aupdate) public function update() { try { $data = array(); $u...
Kata: https://www.codewars.com/kata/find-the-unknown-digit/train/python To give credit where credit is due: This problem was taken from the ACMICPC-Northwest Regional Programming Contest. Thank you problem writers. You are helping an archaeologist decipher some runes. He knows that this ancient society used a Base 10...
I'm currently learning some javascript and I've been getting up to scratch with ES6. I have learned the basics and continued to build things that I've wanted to build in Javascript for a long time. I am looking for someone to review the code, and to hopefully aid me in becoming a better developer in learning from mista...
In C#, 64bit Windows, .NET 4.5 (or later), and enabling gcAllowVeryLargeObjects in the App.config file allows for objects larger than two gigabyte. That's cool, but unfortunately, the maximum number of elements that C# allows in an array is still limited to about 2^31 = 2.15 billion. Testing confirmed this. To overcome...
I have a struct which nests other structs like following: #[derive(Debug)] pub struct Rankings { conferences: Vec<Conference>, } #[derive(Debug)] pub struct Conference { divisions: Vec<Division>, } #[derive(Debug)] pub struct Division { teams: Vec<Team>, } #[derive(Debug, Clone)] pub struct Team { na...
This is an updated version of my previously posted "Blackjack game made in Python 3". I think I did almost everything @Austin Hastings recommend me to do and I hope you like it. from random import shuffle import os def shuffled_shoe(): shoe = ['2', '3', '4', '5', '6', '7', '8', '9', '10', 'A', 'J', 'Q', 'K']*4 ...
I have implemented a thread safe vector, based on std::thread and std::vector. I am new to many of the patterns used in threading and was wondering if there's a more efficient way the locking can be implemented? Also I'm not sure what the best name is to give variables that just get stored right away (i.e. in). Here is...
I need to search a large repository of files for a specific resource, and return it only if it is used or not. It is working as expected, but it is very time consuming. To search for 50 resource names takes around 200 seconds. I have many more than 50. I found this question that helped a bit, but I was wondering if t...
# Standard multi choice question template def multiChoiceQuestion(options: list): while True: print("\nEnter the number of your choice - ") for x in range(len(options)): print(str((x + 1)) + ". " + options[x]) print("\n") try: answer = int(input()) exc...
I have a csv parsing method in my Windows App that reads headers and information from the subsequent lines. I am not sure if I am doing in an efficient way. Please comment. public List<(string IPN, string FPTech)> GetIPNFPTechFromCSV(string filePath) { List<(string, string)> IPNFPTechPairs = new List<(strin...
I've been making this pet project of mine which is an implementation of a HashTable for a very specific purpose: storing huge amounts of objects in-memory (think Redis). I ended up with this implementation in C++ which is in my opinion a very basic and generic Java-inspired HashTable using buckets. I'd like to hear a...
This website has been created for a student organization that is focused on engineering solutions for people with disabilities. With that in mind, I would like this code to be as accessible as possible, so reviews focusing on that will be appreciated. Besides that, optimizations/simplifications to the CSS or HTML that ...
I have written a pair of programs in Python that can be used to encrypt, decrypt, and crack Caesar and Vigenere Ciphered text. I am fairly new to Python and I wrote these programs largely to try and test myself on what I had learned so far with a practical problem, although I cannot claim that every line of these progr...
I've written a function to prettify a json object, as if it were using JSON.stringify. I'm only focused on strings and other objects, nothing else. Is there a better way of doing this? perhaps using a data structure? const exampleJson = {"name":"Jon","facts":{"car":"Ford","address":{"city":"New York"},"watch":"Casio"...
I made myself a smallish template for practice writing some characters, see below. The objective for me was to have an easy way to enter a couple of characters, set the parameters (how many pre-drawn characters, how many columns, etc.) and then get a print-ready PDF. It's written against TikZ and LuaLaTeX (I'm not su...
I have some data which I want to filter. I have a collection of things to include and a second one of things to exclude. Currently I'm looping my data and filter once for the including and a second time for the excluding. Example coding: #[derive(Debug)] pub struct Dataset { pub data: Vec<String> } fn main() { ...
I have the following class for 2D points: class Point { private: double _x, _y; public: Point(double x, double y) : _x(x), _y(y); double x() const { return _x; } double y() const { return _y; } }; I wanted to add a few comparison functions that compared objects of this class in different ways. One of...
In the last couple of days I've tried to play around with some scraping using XPATHs and Python to consolidate my knowledge (since it's been some time). I did this on a simple website which doesn't provide an API. Scope: Get all the information about every product on crlaurence without using Scrapy (which I know would ...
I have a Spring Boot application and I wrote a piece of code to manage relationships between two entities. The code consists mostly in these two methods: @Override public void associateDocumentsToPersonRecord(Long personRecordId, AssociationDTO associationDTO) { PersonRecord personRecord = personRecordRepos...
Problem 27 The Goal of the problem is to find the quadratic (n^2+an+b) that can generate the most consecutive primes, such that |a|<1000 and |b|<1001 So I decided to brute force it using python. However, the script I wrote it quite slow. What did I do wrong and how can I improve it? primes=[] #prime list prime_multiple...
The problem I'm referring to is available here. In quick summary, the problem gives a list of lists such as [[2],[3,4],[6,5,7],[4,1,8,3]] and we must find the minimum path sum: 2 + 3 + 5 + 1 = 11. I took the obvious DP approach: def minimumTotal(self, triangle): # make a memo with n rows and i columns # where i...
I stumbled on the idea of a Forest Fire simulating cellular automata, and decided to try making a version using a full Seesaw UI (a Clojure wrapper over Java's Swing). A short sample of it running is above. It ended up being fairly straightforward; although I've written a fair number of CA's before, so this was more j...
I profiled a library I'm writing that uses vector transposes and found that I am spending a good bit of time doing the following transpose. I am using a std::vector of std::vector<double>s to represent the column vectors. What are some ways to optimize this function? std::vector<double> transpose_vector(const std::vect...
Inequality Given n inequalities about X, how many of them can hold at the same time at most? The inequalities are in the following forms: X < C X <= C X = C X > C X >= C input First line with an integer n. Following n lines, each line with an inequality. Data Limit: 1 ≤ N ≤ 50, 0 ≤ C ≤ 1000 output One lin...
I am trying to stop an executing runnable instance after the run method has been called. I have come up with the below approach public class StoppableWorkflowTask implements Runnable { volatile Thread runner = null; @Override public void run() { runner = Thread.currentThread(); ...
I have binary files containing sparse matrices. Their format is: number of rows int length of a row int column index int value float Reading each row with a single struct call instead of looping through each row with single struct calls gave me roughly a 2-fold speedup. I'm parsing 1 GB sized matri...
After learning some basic concepts of ReactJs I tried to create a form. Now I'm not sure if I'm using props the way they are intented so here is sample of my relevant code: <Input type={"text"} placeholder={"Username"} id={"registerUsername"} class={"input"} /> <Input type={"password"} placeholder={"Password"} id={"reg...
I have a business logic layer class for creating and updating work orders, it also retrieves existing work order details from the database and displays it to the user on a form. The business logic layer class uses DTOs defined in a separate Class Library Inspiration for using DTOs was found here, although I am sticking...
Below is my Python 3.7 code for a Tic-Tac-Toe game I made as a programming challenge. I want to know if I could make this code less janky, more readable or improve it in any way. # Defining Main Game Functions, variables, etc. board = [0,1,2, 3,4,5, 6,7,8] win_con = [[0,1,2],[3,4,5],[6,7,8], ...
I am wondering if it's possible to avoid looping. I want to make the function faster. The function is to find how many times a particular value is lower in the overall data. For example: Value <- c(0,10,5,1,0,0,11,0,0,7,3,2,5) # length =13 The 1st value is 0 and 0 is NOT lower in any of the values. Therefore the value...
For an assignment to study up on an incoming exam, I have to make these little functions. These are review style functions that make sure we know the algorithms and code necessary to do well on the test. I'm looking for anything I can improve upon in my code, so I can get the best grade possible. Write a method calle...
I made a simple and non recursive Android Java Sudoku solver implementing Algorithm X with links inspired from dancing links. The code is on Github (start with the Solver class and the SatsNodesHandler class). The "dancing links" implementation seemed to me too tricky as it implies a lot of unlink and relink operation...
Consider the following crossfilter / dc.js app (screenshot): <!DOCTYPE html> <html lang="en"> <head> <title>Data Exploration Tool MVP</title> <meta charset="UTF-8"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHA...
<div id="form-0"> <a class="remove-form-0">X</a> form 0 </div> <div id="form-1"> <a class="remove-form-1">X</a> form 1 </div> <div id="form-2"> <a class="remove-form-2">X</a> form 2 </div> <div id="form-3"> <a class="remove-form-3">X</a> form 3 </div> I would like to hide the parent div, when it clicks on the remov...
I wanted to design a state machine with a few goals in mind: Encapsulate state logic within individual classes to keep them decoupled. (I'm very curious what the community thinks about this in particular.) Support multithreading, allowing a thread to fire up a stateful but blocking series of steps and watch them progr...
I chanced upon this question and came up with the following algorithm, looking for criticisms and advice on how to improve my algorithm efficiency. You are given 3 arguments: A & B are integers within the range (0 to 100,000) M is an array of integers within the range (0 to 2) Return an output (as a string) that des...
I'm trying to reword the code below to avoid using the Select and Selection terms. I tried to Range("S"...).Copy instead of .Select but that didn't work for some reason. Does anyone know a way I can reword this to avoid Select and Selection statements and why my change .Select to .Copy wouldn't have worked? The code ...
Review for optimization, code standards, missed validation and dependency checks. Review version 3. What's new: apply previous code review input arguments and validation MySQL management (optional) install option (.desktop file), what allows some input values be predefined attempt to install dependency when no choice ...
New to Python, learned a couple things. I'm trying to make a text based game and was told to come here for a review. Any tips would be appreciated to improve my code. I would like to expand this the more I learn. import time import random def game(): #intro text print('******************************') pri...
I am looking to get some feedback on Python 3.6+ project. Specifically I'm looking to improve my skills and make myself a more attractive prospective employee. I plan to use my Github repo(s) as a demonstration of my skills and knowledge. Summary: It's a 'bot' which connects to the Twitch.tv IRC, retrieves a list of t...
I wanted to ask if this project is valid to state on a resume for entry-level python developer and if the code is presentable to say a job interviewer. github link: full project (If this is not the place to ask this, I will remove above part of this post. By all means let me know) The code needing most attention is a m...
The interview question is: Write a function isMatch (without using java.util.Regex) that takes two strings as arguments: s (a string to match), and p (a regular expression pattern). It should return a Boolean denoting whether s matches p. p can be composed of alphabetic characters and '*' (denoting that the previous...
Note: If you googled this by the title of this question, don't use this script unless you know what it is supposed to do. This is a script in bash 3+ that I have used for long for preventing rm * and rm -rf * from accidentally invoked and removing important files by mistake. I put it in my ~/.bash_aliases. alias rm='se...
So yet another Sieve of Eratosthenes in Python 3. The function returns a list of all primes smaller but not equal max_n. The motivation is, as a practice, a simple implementation of the algorithm that is faithful, short, readable and transparent, while still getting a reasonable performance. def primes(max_n): """...
What is best way to implement thread-safe LRUCache in java? Please review this one. Is there any better approach which can be taken here? package cache; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.locks.Lock; import java.util.concurrent....
Sometimes I have the date as part of the file name. And then when Emacs autocompletes the file name, it puts the part of the date. In these situations I have to write the rest of the date manually. Here is a solution, so that I can press Super+d and the suffix of today's date is written in the buffer. For example, ...
I work in the training department of a captioning agency, where I spend a lot of time grading trainee's dictation transcripts. We receive the transcripts of trainee's dictation of test audios and then compare them with Microsoft Word to the original transcript, highlighting incorrect words yellow, omitted words blue, a...
I created a Java Swing Minesweeper, for which I would like some feedback. Note : I'm just in high school so please excuse any 'dumb' ways I may have coded certain segments. Any tips or books on how to improve the general quality of the code, or any information that will help me become better are deeply appreciated. Ap...
This is a 2nd follow-up to my previous one about a Scheduler built with observables. Although the last one was working correctly, it was only possible to see this in LINQPad which I didn't like very much. I prefer to have proper tests so I've redesigned it a little bit to make testing possible. Core The Scheduler itse...
I am learning Go and as an exercise I did this challenge from Code Golf (without the golfing), where an ASCII art snowman is drawn from a combination of body parts, based on an 8-digit code taken as command line argument. For example: $ ./snowman 12431312 _===_ (-.O) <( : )\ ( : ) As a minor extension I decided...
Kata: https://www.codewars.com/kata/linked-lists-sorted-insert Description Write a SortedInsert() function which inserts a node into the correct location of a pre-sorted linked list which is sorted in ascending order. SortedInsert takes the head of a linked list and data used to create a node as arguments. SortedInse...
I often work on embedded system projects in which I have a number of documentation files, such as microprocessor datasheets, schematics, bills of materials, etc. I find it convenient to create a simple little HTML file that contains the file descriptions and a hyperlink to each file. I used to create these all by han...
Original Question. So I rewrote the code for the problem described in the original question, but someone had already answered that question, and my rewrite would have invalidated their answer, so I just posted a new question. Updated Solution def sorted_insert(head, data): tmp = Node(None) tmp.next = head n...
I know this has been done before, but I needed to brush up my Python skills. Also, I intend to publicly share this code on a blog post sometime in the near future. This is also an attempt to improve my previous code. So here's everything: File Structure (project root) | +- simplesubstitution | +- Cipher.py +- ...
HTML <div id="form-0"> form 0 </div> <div id="form-1" class="add-form"> <a class="remove-form-1">X</a> form 1 </div> <div id="form-2" class="add-form"> <a class="remove-form-2">X</a> form 2 </div> <div id="form-3" class="add-form"> <a class="remove-form-3">X</a> ...
I'm printing a diamond shape in Java. It's working fine, but is there a way to re-write this code to make it faster? Scanner sc = new Scanner(System.in); int n = sc.nextInt(); sc.close(); String ns = String.valueOf(n); int z = n/2; int k = n%2; for (int j = 0 ; j<n;j++) { for (int i = 0; i < z; i++) ...
Kata: https://www.codewars.com/kata/linked-lists-insert-sort/train/python Description Write an InsertSort() function which rearranges nodes in a linked list so they are sorted in increasing order. You can use the SortedInsert() function that you created in the "Linked Lists - Sorted Insert" kata below. The InsertSort...
I'm creating an online calculator to get the average grade of different tests my students take and also the final grade. I wonder if you see any problems in this update or any way to improve it: var inputs = document.getElementsByTagName('input'); var i; function calculateAverage(tests) { var total = 0; var coun...
I'm trying to implement a fixed sized array that uses versioned keys for dangling safety. This structure is similar to a slot map data structure, with the exception that this does not automatically compact and rearrange the data array. I have no need to iterate over this structure, and so compaction isn't necessary. ve...