instruction
stringlengths
71
95.1k
I want to check in my if and else if statement if the inputs form a square or a rectangle, now my if and else if statements seems to be unreadable, now I'm thinking of ways to improve it. /* input are angles in degrees, 1st side is parallel to 3rd side, 2nd side is parallel to 4th side*/ static void Main...
This is a Dockerfile which aims to create a complete environment for the bismon project. I have written it as an exercise and to make it easy for other users to begin with bismon. FROM ubuntu:latest MAINTAINER Niklas Rosencrantz (niklasrosencrantz@xyz.com) ENV DEBIAN_FRONTEND noninteractive RUN apt-get update RUN apt-...
I've been reusing an error class in Excel VBA projects for a few years now and I'd like to see if there are ways to improve it. Any suggestions for style, code, etc. are all welcome. The 2 procedures I'd like to focus on are: Error_Handler.DisplayMessage Error_Handler.Log The log file is usually written to a file se...
I have just begun learning functional programming and Haskell. This is my attempt to implement a solution to Graham Scan Algorithm in Haskell. Note that I am not even sure if this is indeed Graham Scan Algorithm, since I implemented this solution with only a few hints of the actual Graham Scan Algorithm. But I believe...
I want to create a program that can print the number of movies that was watched by more than 3 people (data stored in a nested list as below ). list_movies = [('Spiderman 3', ['John', 'jake','Ronald']),('Gravity',['james','jake','john','gerald']), ('Terminator',['Anne','Johnny','Peter','Ronald','Neville'...
I have a string like this: char buffer[] = "blablabla$GPTXT->SOME CODES HERE<-\r\n$GPRMCblablabla"; It is sent from an external device and changes every 1 second. The string length is over 1000 bytes and consisted of some standard sentences beginning with "$GPXXX" and ending with CRLF. I've written the following funct...
I have an interesting problem to solve and despite having a running solution, I was wondering where I could improve it. In a range from 1 to 1000, I want to create an array with different increments according to the current interval. So, from 1.0 to 2.0, the increment should be 0.01, from 2.0 to 4.0 it should be 0.02, ...
I have a method that converts characters to numbers. It expects a single alphabetical character and returns the equivalent number. For example, if A is provided it returns 1, for B it returns 2. If an array is passed, it returns the message "array not accepted". function characterToNumberCoverter(character) { if (Arr...
Background I have the below UDF that opens a workbook (this workbook has extracted data from a queue within another app). I get the used range from this workbook and assign it to an array (aExtractedRange). One of the elements in this array has the workbook name that I need to open and get Application Name for each ele...
I would like to know if there are ways to make this run faster. Not a big concern right now, but I would like to think long term, it might be important. This is C#, and I can not change the input parameters data types, but basically I have to make something like the SQL: SELECT returnCol FROM dt WHERE ColName = ColValu...
Consider the following dummy dataset: library(dplyr) set.seed(50) df <- data.frame(PERSON_ID = sample(1:5, size = 32, replace = TRUE), YEAR = sample(2000:2001, size = 32, replace = TRUE), VALUES = sample(c("APPLE 50", "GRAPE 20", "ORANGE 50", "BANAN...
I have the following method: public void test() { List<Integer> slopeChanges = new ArrayList<Integer>(); slopeChanges.add(0); slopeChanges.add(0); slopeChanges.add(1); slopeChanges.add(0); slopeChanges.add(1); List<Double> sixProbabilites = new ArrayList<Double>(); int count_neg10 = 0...
Intro I'm going through the K&R book (2nd edition, ANSI C ver.) and want to get the most from it: learn (outdated) C and practice problem-solving at the same time. For that reason, I'm trying to solve the exercises "hardcore" - without using any knowledge from the "future". I'll catch-up with it after I finish the book...
I have a huge Google Photos directory that is difficult to navigate - there are just too many files so I thougt I need to sort them somehow. I decided to make it simple and group them by date-taken. As I always wanted to learn python I thought I'll give it a try so this is my first take on it. There is no rocket-scien...
So I'm currently working on sort of an SDL engine (may be too ambitious I know). I'm seeking that it would be my first actual project and it's also the first time I'm seriously using classes. So I would like to know if there are any significant improvements I can make to this class to make it as good as it can be (havi...
Project Euler problem 378 says: Let \$T(n)\$ be the \$n\$th triangle number, so \$T(n) = {n (n+1) \over 2}\$. Let \$\mathit{dT}(n)\$ be the number of divisors of \$T(n)\$. E.g.: \$T(7) = 28\$ and \$\mathit{dT}(7) = 6\$. Let \$\mathit{Tr}(n)\$ be the number of triples \$(i, j, k)\$ such that \$1 ≤ i < j < k ≤ n\$ and...
I am looking to hide an email id name, by only showing first 4 letters of the email. The code works fine. Looking for opinion if I could make it better, more readable and maybe even more efficient if possible. I am using Commons lang library for this and wondering if that is an unnecessary overhead. Please look for th...
I recently updated Pandas and noticed that it is no longer possible to merge DataFrames with mismatched dtypes. I have a script which relied on merging and seemed to work in the past despite having mismatched dtypes. I need to display to the user which columns in two dataframes are causing problems, so the user can the...
I have been studying graphs/BFS/DFS. working on wrapping my head around the following problem Given a grid [m,n] where each cell has a value denotes a color, find the longest connected region that shares the same color (color is an int) I was able to come up with the following algorithm that uses a (BFS) Breadth Sear...
The functions below are from a class of slave function which interact with my mongo database. The purpose is to serve a Flask based API by responding with the appropriate data required along with the status code. The following 5 functions are Init Add Data Return/Fetch Data Search Data Delete Data The request is to...
I am working on the MAXSPPROD problem on interviewBit You are given an array A containing N integers. The special product of each ith integer in this array is defined as the product of the following: LeftSpecialValue: For an index i, it is defined as the index j such that A[j]>A[i] (i>j). If multiple A[j]’s are ...
I have a notification system. If someone posts a new comment to the topic you commented, then you get a notification. The problem is, that the code is looking awful. First I count how many notifications you have, so I can write it into the "notification bell", then I write the same code again, but this time to output t...
Can random string generation be faster in Java? Here is my current code import java.util.ArrayList; import java.util.List; public class FastestStringGeneration { private static final String ALPHA_NUMERIC_STRING = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; private static final char[] ch = ALPHA_NUMERIC_STRING.toC...
After I couldn't find any matching algorithm that would Interlace arrays I wrote this generic static function to combine arrays with variable segment sizes with n number of arrays. The theory of this algorithm is that one would specify the indices in order of the params arrays with a number to indicate the segment len...
I have a function that adds to a std::wstring some filler characters. The user gives a single filler character. They can also optionally given an initial filler sequence (std::wstring) and an optional final filler sequence (std::wstring) that start and end the padding. These will only be added however if they fit insid...
Problem: Given a vector of about 40 values m with normal error sd compute the weighted average of the values weighted by the chance that they are the maximum. I have come up with 2 different approaches to solve this. The first is numerical integration, the second is monte-carlo sampling. import numpy as np from scipy i...
I'm building a script where I pass in a text file of hostnames, and a text file of commands and each command will then be run against each host. To prevent this getting out of hand I'm also passing in a maximum thread count and trying to manage a maximum number of workers at any one time. The code I would like feedback...
I have a set of 1 million points in 128-dimensional space. Among all trillion pairs of the points in the set, I need to get a subset of 100 million pairs whose cosine distances are less than that of every pair outside the subset. I tried measuring cosine distances of all trillion pairs, sort them and get first 100 mill...
To learn the low-level API of Tensorflow I am trying to implement some traditional machine learning algorithms. The following Python script implements Principal Component Analysis using gradient descent. It finds component weights that maximize the variance of each component. The weights are constrained to be orthonorm...
I wrote this snippet: template <typename ContainerT> class ReverseIterator { public: ReverseIterator(ContainerT& iContainer) : m_container{iContainer} { } typename ContainerT::reverse_iterator begin() { return m_container.rbegin(); } typename ContainerT::reverse_iterator end() ...
I'm a beginner with Rails and am trying to figure out how to keep my controllers clean and thin, and how to work with service objects. I am building an internal tool to manage our SaaS customers, and the specific feature I'm building is to allow admins to change a customer's plan. In accounts_controller.rb, I have the ...
I'm programming on an 8-bit Z80 embedded system, and encountered a problem. The program needs to render some pixels to the screen. The color is stored as RGB565 format as a 16-bit unsigned integer, but the system color is encoded as BGR565, so I've devised the following code to swap the first and last 5 bits in a uint1...
I got a word count assignment and the requirements are shown below: INPUT The input contains words in several lines and in each line there could be more than one word. The input only contains English words, separated by space or line breaks. Words are case-sensitive. OUTPUT Print the words in alphabetic order with...
I made this little game to test if my Nokia 5110 screen can handle games. As in handle many frames per second/game loops. I am using a library made for this screen called Adafruit_Nokia_LCD These are the imports for some context, if needed: import Adafruit_Nokia_LCD as LCD import Adafruit_GPIO.SPI as SPI import threadi...
I am trying to fetch a group of images within a place in Firebase database ref. I then loop through each image adding it to an array which is then supposed to be added to a tableview cell. I was wondering if it could be more concise? am i doing anything unnecessary? func fetchAllUserFristImage() { Database.data...
The purpose of this program is to have one thread (main thread) working on I/O reading lines from a file and feeding it to a pool of worker threads whose job is to perform some processing on each line provided. In this case, the processing is running the String.contains() method. Please note that as test input, I used ...
I'm trying to add a new TabItem to a TabControl. The TabItem's content will be set to a new Frame, and the frame holds the actual Page. A new Tabitem is added each time the button is clicked, this is the code I've come up with. // initiates the tab item ang assign dumby values (REMOVE BEFORE RELEASE) T...
This is a question about some code I've written that works, but I'm not sure it's good code. I would like to get some comments on this or if possible hints to build a better solution. Background: This is a small program to calculate some data, connect these to a participant and store it in a JSON file. Here the already...
The logic of the code to build was as follows, two logical conditions; If the value of dictionary element matches in the list of dictionaries return the particular dictionary, and if no element matches in the list of dictionaries; append this new dictionary element. I have written in the below form for example. say_el...
Here is my problem statement. An excerpt: You are given an unordered array consisting of consecutive integers ∈ [1, 2, 3, ..., n] without any duplicates. You are allowed to swap any two elements. You need to find the minimum number of swaps required to sort the array in ascending order. For example, given the array ar...
The code consists in making a list of elements sortable (with the drag on the right) and selectable (click on the text). However it seems a little too complex. https://codesandbox.io/s/434p397p74 Would it be possible to simplify / improve? What are the missing good practices? PS: I am a beginner in React. I used a lib...
We have a modifyCoefficient(const char* name, int value) function that updates the value of a coefficient in a container. The names are known at compile time, they are read from an XML file in a pre-build step and stored in an array. Usage: data.modifyCoefficient("ADAPTIVE", 1); Compiler: MSVC 2017 v15.8 I would like t...
I have tried to write a test-spy myself. Just for getting more familar with the topic. Here's the code: // --------- SPY - Start ----------------------------------- class Spy { constructor(func) { this.func = func; this.returnValue = null; this.result = null; this.countFuncCalled = 0; } invoke(...
I'm building a date range selector, and while this works, I feel like I'm making it more complicated than it needs to be. Is there a more elegant way of writing this? Possibly using computed values or watches? <template> <form> <select @change="rangeSelection"> <option v-for...
I've written two classes that I use to create and manage a high score list. I plan to use this code for my own, larger project. I would like to ask if there is something to complain about my code. Were the language tools and the libraries of the language used meaningfully? Does my implementation meet the requirements o...
Consider this interview question: You have an array of integers, and for each index you want to find the product of every integer except the integer at that index. Write a method get_products_of_all_ints_except_at_index() that takes an array of integers and returns an array of the products. For example, given: [1,...
This is a class in my React app. This code works and displays an appropriate icon and question for every description. class myQuestion extends PureComponent { render() { const { description } = this.props.question; let icon = icon; let question = question; if (description === 'Happy') { icon = <...
I create simple Android timer application and I try to use MVP design pattern. I read some tutorials and after that I started writing code. My code is working correctly and as intended. There is really simple activity with 3 buttons (start, pause and stop) and text view with time to finish. I have always had problem wi...
Anyone know how I write this code shorter, with modulos maybe? I also want to add weeks and years do this code, but it kind of got too long for that. Maybe there is some smart algoritm? Something in a for-loop? public static String formatSeconds (long seconds) { if (seconds < 60) return seconds != 1 ? secon...
I added learning rate and momentum to a neural network implementation from scratch I found at: https://towardsdatascience.com/how-to-build-your-own-neural-network-from-scratch-in-python-68998a08e4f6 However I had a few questions about my implementation: Is it correct? Any suggested improvements? It appears to output a...
I was doing a simple mad libs game thing but I want to know if there's any more efficient or readable way to write the code as I don't know the best ways to structure code as I am just begginning. Before I write any more of them please can someone tell me if there's a "better" or more accpeted way to write any of the c...
This is my first "serious" project after learning python for a while. The purpose of this script is to scrape proxies and check if they pass HTTPS websites. The main functionality is: Get args and set (if there are any) Get links to scrape from Scrape for proxies and save them to a file Check the scraped proxies using...
Here is my code that I made for a school assignment (a work in progress). I'm a beginner at programming and I'll be glad if someone gives me a thorough review of my code. I've just switched from TurboC++ to Code::Blocks IDE using MinGW. #include <fstream> #include <iostream> #include <stdio.h> #include <stdlib.h> #incl...
I've implemented a C++ algorithm that moves elements satisfying a given unary predicate from one container into the other, deleting them from the input container. This is my implementation: /** * Moves all elements in the input container * that satisfy the given predicate * into the output container, * and erases ...
I wrote the following sample script for learning purposes: import requests import json import pyodbc import os import sys source_url = 'https://jsonplaceholder.typicode.com/posts/' query_posts_response = requests.get(source_url) if (query_posts_response.status_code == 200): posts = json.loads(query_posts_respons...
The data describes cycling activities (key1) and chunks of them (key2). In total there are around 1,000 key1 objects and arrays under key1 are 1-100 long. Is there a simpler, more semantic, faster, or otherwise better way than to use two nested map in step 1? I realise that step 3 is longer than it should be and there...
Over on EL&U Meta, someone raised the question of how many net migrations there are to/from our sister site, ELL. The following SEDE query calculates the net migrations by quarter (elu2ell - ell2elu). You can play with the query in SEDE here. -- migration prefix length DECLARE @mhpl INT, @mapl INT, @mhid INT, @maid INT...
Question: Implement a trie with insert, search, and startsWith methods. Source: https://leetcode.com/problems/implement-trie-prefix-tree/description/ The Trie object will be instantiated and called as such: obj = Trie() obj.insert(word) param_2 = obj.search(word) param_3 = obj.startsWith(prefix) Code: I have a Tri...
I am a Rust newbie and I am not familiar with all the iterator options. This is what I have so far. How can I make this better or at least avoid collecting twice into a Vec? let num: u16 = 0b0010001000100010; // input number let bin = format!("{:016b}", num); let parsed = bin .split("") .filter_map(|s| s.parse...
I just completed my pong game. I'm trying follow the CS50 Introduction to Game Design course. The course uses LUA and LÖVE, but I'm trying to just transfer the concepts to C++ and SDL2. The game is pretty straight forward. There are 2 paddles on each side, one controlled by the player, the other by an AI. there is a ba...
For our Django app running on AWS Elastic Beanstalk, we use a web-server/worker setup. The same code is deployed to the web-server and worker environments, and environment-specific configuration is achieved with .ebextensions config files, using the test option for container_commands, among other things. Now there are ...
I've written the following Python module to iterate over field values in the following two fields: "NAME_LABEL", "CATEGORY". I'm using regular expressions in the following function: "correct_invalid_char", to substitute characters over three expressions that are dependent on each other. The first expression replaces th...
I've developed a function in the Julia language, using the SymEngine library, which builds an equation. This function works quite quickly, returning a lambdified equation. The problem is, calculation of the value of this equation in the point takes too long time! And as the equation becomes longer, the calculation time...
So I got a project to refactor and I can't figure out what the best solution for this specific problem would be. I'm trying to reach some kind of elegant few-line-solution, but every idea I have seems to be a dead end. My brain does not work anymore... The original state: public SearchParameterSet(ProviderRequestParame...
Original Problem The original problem is parsing/generation of the transport header of the RTSP protocol, see RFC 2326 12.39 Transport, Page 60. The transport header is defined of multiple transport specs, at least one, and either comma separated or by repetition of the transport header. The transport specs are again a...
I have three methods to get the user details based on attributes: Find user details by id, Find user details by username, Find user details by email Here is the program class: using System; using System.Data; using System.Linq; using System.Data.DataSetExtensions; public class Program { public static void Main()...
I read quick sort algorhitm and implemented in like this: public List<Integer> sort(List<Integer> list) { if (list.size() <= 1) { return list; } int pivotalValue = list.get(list.size() / 2); List<Integer> left = new ArrayList<>(); List<Integer> pivotalValues = new ArrayList<>(); List<I...
I am doing some online exercises, and I came across this: "Your job is to write a program for a speed camera. For simplicity, ignore the details such as camera, sensors, etc and focus purely on the logic. Write a program that asks the user to enter the speed limit. Once set, the program asks for the speed of a car. If ...
Following code works and i am simply looking for ways to not repeat myself as well keep to code clean and readable. Would love to see what methods that can be utilized to make it prettier. const util = require("util"); const fs = require("fs"); const reader = util.promisify(fs.readFile); const simpleParser = require('m...
Recently I wrote a back_inserter with the same interface as the std::back_inserter just for supporting several containers in the constructor and doing push_back for each. The solution needs C++17. Please give me some feedback! Thanks. #include <iterator> #include <tuple> namespace stx { template <class Container, cla...
I made a rock climbing simulator game for fun. Below is a function from the program, which works. But I can't help but think it could be refactored or more pythonic. Namely, I open the data with csv.DictReader and read through the data, which add to a blank dictionary called route_info. Is this step necessary? The f...
This jQuery code submits a form using AJAX. The server response should return JSON. addNewOutreach = function(node) { var form = node.find('form'); var data = form.serialize(); $.post('ajax.php', {action:'addNewOutreach',string:data}, function(response) { if(response!=null && response.s...
In this program you have to solve 20 exercises. The time you need will be measured. If you break a record, you'll get an entry in the highscore list. The program can be downloaded here. You can only start it via command line, not by double-click. If I can improve my code to make it more readable, please tell me how. Ma...
I wrote the equivalent to the split() in python for C++. I would like to know how I can make it better: static constexpr auto whitespace = " \t\v\r\n\f"; static constexpr auto npos = std::string::npos; std::vector<std::string> split(std::string_view str, std::string_view sep = "", std::size_t maxsplit = std::numeric_...
Not much formal education in programming. One year in school. We did C++ classes for most user defined objects. I've written a few different class variations for matrices but wonder about how useful that really is. Array pointers vs. STL containers, all this wrapper around an array or std::<vector> or std::vector<std::...
I have ack (the searching tool) "installed" as a single file at C:\ack\bin\ack.pl on a Windows 10 machine and was wondering how to make it executable from the powershell window and other terminals. I wanted to do it ideally without touching the PATHEXT variable and associating an interpreter to the extension because th...
I've written a solution to the leetcode problem Median of Two Sorted arrays. The solution I anticipated coming up with initially was going to features some kind of binary search on both arrays based on the range of numbers (given that the question calls for a runtime of O(log (m+n))). Along the way, I thought of anothe...
I have a program that does some matrix computations using MPI (MPICH). Each rank has a slice of the matrix and does the computations on their slice to get a new slice of the matrix. Sometimes I need to synchronize the matrix on the manager for snapshotting, output, etc. so I need all ranks to send their current matrix ...
I have made this program to simulate polybar's bspwm module. So far, it works flawlessly; however, it consumes too much RAM and CPU (16-30%). I suspect it is the while loop causing the trouble, but what can be done to reduce resource usage? use strict; use warnings; use Switch; use List::MoreUtils qw(first_index); $SI...
I have been lurking on the C++ side of stack-overflow only long enough to know there are a lot of beginners and intermediate programmers baffled by multi-dimensional arrays. I've seen a lot of monstrosities : three-star programmers, cache-unfriendly implementations, vectors of vectors of vectors ..., etc. I thought to ...
This is a simple toy downloader using python's requests library. I’ve monitored the download process is slower on an ethernet connected box. The realtime speed is measured both on stdout, using get_net_speed() function, and conky. I’m using a 4Mbps connection. When downloading a file using wget, the downloading gets...
Given a list of numbers, place signs + or - in order to get the required number. If it's possible then return true, otherwise return false [1, 2, 3, 4, 5, 7]; 12 -> true, because 1 + 2 + 3 + 4 - 5 + 7 = 12 [5, 3]; 7 -> false, because 5 + 3 != 7 and 5 - 3 != 7 I came up with the following brute force solution: pub...
This is my java implementation based on the solution of Aasmund Eldhuset here. Please give your opinion on my code (correctness, efficiency and coding conventions): public static String longest2Str(String s){ int len; int i = 1; int subStart = 0; int nextGroupStart = 0; int longestStart...
I wanted to create a FizzBuzz in Java that is supposed to be open for extension. So the initial problem is the good old, if divisible by 3 print fizz, if divisible by 5 print buzz, if divisible by both print fizzbuzz, otherwise print the number itself. But I want to be able to change the numbers that we test against (...
Problem - Given a chess board and the position of only one queen piece in it, mark all the position where the queen can move with X. Kindly review this Scala code and suggest improvements. import scala.collection.mutable._ object ChessQueenAttack { val board = Array.fill(8)(Array.fill(8)('0')) def printBoard = { ...
Following code is solving n queen problem with c++ using backtracking. I saw other people solution they are very short like 20 to 30 lines. Is there way improve following code? #include <iostream> #include <vector> bool put_in(std::vector<std::vector<int>> &Board, std::vector<std::vector<int>> &Stack, int row, int col...
I wrote code to calculate PI to a user specified number of decimal places. It works fine. I wanted to add a progress indication so that the user doesn't have to stare at a flashing cursor for hours on end with no indication of progress. I got something working but it makes the code much, much too slow. In the code ...
My HTML: <div class="text-left pb-5"> <h6>Aantal</h6> <input type="text" class="calc" id="aantal" name="aantal" value="100" style="padding-left: 5px"> </div> <div class="text-left pb-5"> <h6>Kleur</h6> <input type="text" class="calc" id="kleur" name="kleur" value="5" style="...
A few months back, I posted a state machine for review. Thanks to the feedback, I was able to greatly simplify the implementation. I am posting the revised version, together with the Regex class which calls it. I think I'm mainly looking for feedback on structure. The relationship between my Node class and StateMachine...
I have many images and want to compute the GLCM properties for every image. Below my code that runs many hours to complete the task: import numpy as np from skimage.feature import greycomatrix, greycoprops ANGLES = [0., np.pi/4., np.pi/2., 3.*np.pi/4.] DISTANCES = [1,2] properties = ["correlation", "contrast", "homoge...
During an interview I was asked to design the menu for a coffee shop employee so that the employee would go and add different items to the menu. This is the design that I came up with. I just want to know what other things I'm expected to think of. Are there any problems/complexities that I haven't taken into account?...
I have made Connect 4 in C#. If you have never played Connect 4, it is like Tic Tac Toe, except the pieces fall to the bottom of the grid, and the grid is usually 6x7. This is the first big project I have made in C#, so I don't know if I wrote the program well. How can I improve my code? using System; namespace Connec...
$elements is an array, which may contain 'x' or 'y' keys, I want to check if they exist, otherwise assign a 0. I'm looking for a clean way to validate it. I'm new to PHP, so I want to make sure my code is created according to PHP best practices. Input array: Array ( [0] => Array ( ) [1] => Arra...
I have a function to check the leap year as follows bool IsLeapYear(int year) { if (year % 4 == 0) { if (year % 100 == 0) { if (year % 400 == 0) return true; else return false; } else return true; } else ...
I have the following method, which can be written in the following two ways: which one would you prefer, and why? # version with case...when def choose(value) case value when value < LOWER_LIMIT 'a' when value > UPPER_LIMIT 'b' else 'c' end # version with Hash#fetch def choose(value) { (value < L...
I query a database and pass the data for processing as a DataTable. After all computations (grouping, filtering, formatting etc.) I need to send it to a Web-Service as json that will generate emails. This means I need to convert it to a more json and html friendly structure because I need a header, body and footer part...
I needed to convert some custom icons that were in .png format to .svg format and did not want to use an online converter for it. I could not find an out-of-the-box solution online so I created my own with what I could find. Out of curiosity and a willingness to learn, as well as to maybe serve the needs of others try...
The code below takes an input and based on the input gives out a time, date or both. Please will you review me for this and tell me how I can improve this? By the way, I only started learning python. import datetime x = datetime.datetime.now() s = '/' c = ':' print("Welcome to Date and Time!") input = int(input("Pleas...
I'm trying to write as simple I/O library in x64 using linux syscalls section .text strlen: xor rdx, rdx .loop: cmp [rsi + rdx], 0 je .exit inc rdx jmp .loop .exit: ret ; value in rdx puts: ; string passed through rsi mov rax, 1 call strlen syscall
My goals for the algorithm were to use recursion, to avoid mutation, and to decouple the tree walking from the action that we take on each node. My sense is that the result uses mode code is reasonably readable but that it might be unconventional. Test Test Data const nestedPaths: TreeNode = { path: '/', children:...