instruction
stringlengths
71
71.9k
My program gets some input values and outputs Fibonacci values. Generally, I'm adding single numbers from the right to left, and I'm saving it in the sum value and get rest of it and add to string. (The value of "second" will always be larger than "first"). Is there some way to speed up my code? #include <iostream> #in...
I have implemented the Stack using two Queues q1 and q2 respectively as shown below in the code. I would like to get you reviews on whether it's an efficient way of implementing it or now. For Pop operation : I will keep on removing elements from the Queue q1 and adding it to Queue 2 until only one element remains in ...
In this code, I am creating a COM object to programatically access internet explorer. In order to access this object's properties and methods, I am writing wrapper functions like navigate or setVisible. Is there a cleaner or easier way to use COM objects from C? Moreover, can you point out things that I could have done...
I have this slightly popular Swift library called IJReachability up on Github. It checks the network connection status. Due to my office workload I've been very busy in the past few months so I couldn't attend to the project and keep in touch with the folks who are contributing. Now I'm back and hoping to dust off the ...
How efficient is this program? How could I make it more efficient? package main; import java.math.BigInteger; public class Ackermann { public static void main(String[] args) { System.out.println(ack(BigInteger.valueOf(4),BigInteger.valueOf(2))); } public static BigInteger ack(BigInteger a, BigI...
I designed this file after learning from this awesome answer from user2407038 on Stack Overflow. The idea of the module is to replace code like: test0 = print $ foldr (+) 0 [0..100] test1 = print $ foldr (:) [] (sequence [[0..10],[0..10]]) test2 = mapM_ print $ do j <- [0..10] i <- [0..10] return (i,j) Whi...
I'm newbie in Python and I wrote a tool called Caesar Encryption Tool. At the moment it only encrypts. It takes a plain text and a key from the user then encrypts the plain text using the key. How can this code be improved? # This is version 1.0 Caesar Encryption Tool and it will be improved. # This tool is written by ...
How could I optimize this binary search tree? #include<stdio.h> #include<stdlib.h> struct NODE { int info; struct NODE *right; struct NODE *left; struct NODE *parent; }; typedef struct NODE node; node *createnode(node *temp,int number) { temp=(node*)malloc(sizeof(node)); temp->info=number; ...
I am new to object oriented design with JavaScript and am trying to make a PublicGame class with some methods that puts itself in a map of games. It calls killGame on itself if there aren't enough players. I feel like my design is way off. I won't be able to test my design though until the rest of my group members fini...
I'm starting just now with CoffeeScript and I found out that I can't solve problems like looping and recursives with just one line. I would like to improve the code that I just wrote using built-in CoffeeScript helpers. 'use strict' file_system = require 'fs' Types = require './types' Extract = each_file: (in...
The goal of the following code is to be able to use an Xbox Controller in a Java program, it works with the jinput library. Unfortunately this library is rather old, has little to no documentation and uses a polling system. There are some existing event-based (xbox) controller input systems, but most of them are embedd...
Why Codility detects my solution for Tape Equilibrium to have complexity of \$O(n^2)\$. How can I make my code better? import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.stream.IntStream; class Solution { public int solution(int[] A) { ...
One of the tasks I find myself doing repeatedly is to filter the incoming inputs that will be stored in models. Examples of this include trimming, removing repeated or unnecessary pre/suffixes, commas or dashes in numbers, etc. This is similar to validation, but Laravel's built-in Validator does not appear to have this...
The original question Given two binary trees, return true if they are structurally identical, and false otherwise. Are AVL trees equal? Are AVL trees equal? - revision 2 This revision on GitHub In this revision: equals() is documented. Two trees are equal if they are structurally identical. AvlTree has a type para...
These two classes are part of a networking layer module that I am building: public abstract class BaseRequest { protected RequestCreator mCreator; public BaseRequest() { setupRequestCreator(); } private setupRequestCreator() { mCreator = new RequestCreator.Builder() .heade...
I have been lately working in my C++, and I finished up this trie, and I want to know how my C++ is looking so far. Node.hpp #pragma once #include <memory> static const int ALPHABETSIZE = 26; struct Node { bool isEnd; int prefixCount; std::shared_ptr<Node> child[ALPHABETSIZE]; }; Trie.hpp #pragma once ...
This code is used to deep overlay saved state (as an object) over a template object, which is the current model, this model can change (e.g have new attributes added), and a simple _.clone call will not cut it since that does a shallow copy, and will copy nested arrays/objects byref. This code works, and I'm curious if...
I was recently working on a game using the SFML library, Later on, I experienced performance issues due to collision detection. I have been told to use a QuadTree structure to optimize the collision detection. I have implemented the basic of the QuadTree functionality and it seems work fine in my game. The full project...
I recently found my first program I wrote using Logo and was wondering if it could have been improved: to gnome repeat 180 [bk 1 rt 1] repeat 180 [bk 1 rt 1/4] rt 97 repeat 180 [bk 1 rt 1/4] pu lt 90 fd 50 lt 90 fd 25 rt 90 pd repeat 90 [fd 1/2 rt 1/4] repeat 180 [bk 1/2 lt 1/4] pu rt 60 fd 50 pd ...
Recently, I added this 'batch' based rendering system in my game engine, which takes care of rendering Spatials (those are actually wrappers for a mesh and a transform) by giving it an environment parameter (taking care of uniform values, like light, fog, environmentMaps, ...). I would like to ask your advice on how I...
I need help with optimizing a piece of code I've written in C#, which is very sloppy right now. I needed to write code that tracks the amount of money a hospital has made at the end of the day, depending on the amount of patients. Here are some conditions and details: Code has to display the cost for the patient and t...
I really want to have a nice design pattern for my Node.js project. This is my state diagram. As I'm coding this, I'm wondering if it's better to separate state logic from the class? So instead I would only have my class be responsible for initial construction and then emitting state changes which get handled elsewhere...
I am a semi-beginner in C++ and I have a project in C++ to convert a hexadecimal integer into decimal equivalent, but I extended it and now this program can also convert a fractional part. Logic I have used: First the whole program is inside a do-while loop so that the user can convert a number as many time as desired...
I have the following simple program which calculates and returns the nearest power of 2 of a given number. Because I use increments and decrements to find the closest power, this takes a very long time when working with higher numbers. Is there any way to reduce the run time of the program when working with larger numb...
I wrote the following code for Slick Slider, which changes the content below based on the current slide data-index. I just wonder if there is a more efficient way to do it? http://codepen.io/pjmtokyo/pen/JYyjew $('.slider').on('afterChange', function(event, slick, currentSlide, nextSlide){ var elSlide = $(slick.$s...
Project Euler Problem #4: Largest palindrome product: A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99. Find the largest palindrome made from the product of two 3-digit numbers. I got the correct answer for the problem, but I want...
What is the best way to conditionally use an operator? All 3 methods seemed acceptable to me, and the last 2 better. If you're curious: I've got a list which is unsorted, and many other lists which may or may not contain a smaller selection of sorted indices referencing the unsorted list. Processed data is being ident...
Problem: Find a multiple of a given decimal number \$N\$ that looks like a binary number. The input will consist of at most \$ 2 \times 10^5 \$ lines, each line consist of an integer \$N\$ (\$0 \lt N \lt 10^{12} \$). Find its described multiple \$M (\ne 0\$), this number \$M\$ must be less than \$10^{12}\$. If there is...
This is my implentation of Bucket Sort, but I see myself using way too many for loops, is this necessary? public static void bucketSort(Student[] students) { final String[] courses = { "IB", "IG", "IN", "IS", "IT" }; final int amountOfBuckets = courses.length; final int n = students.length; if (n == ...
Given two input directed graphs \$G_1 = (V_1, A_1)\$ and \$G_2 = (V_2, A_2)\$, the problem of isomorphism asks whether the two directed graphs are isomorphic, or in other words, whether the two input graphs have precisely the same structure. Formally, two input graphs \$G_1\$ and \$G_2\$ are isomorphic if and only if t...
1. Description 1.1. Functionality The objective of these types is to provide type erasure for any function while maintaining the ability to provide a return value through a combination of std::promise<T> and its associated std::future<T>. 1.2. Motivation This is useful for any sort of dispatch manager, a thread pool th...
When reviewing questions here on Code Review SE, I sometimes find my self wanting to test different functions in order to do a performance review. However since I'm inherently lazy, I wonder what is the most effective or best practice for doing timing of functions in Python? To make this an apt question for Code Review...
For my planned Sudoku with Handicap challenge over at codegolf.SE, I need a driver program. I've decided to write it in Python, for learning purposes. Since I've got no Python experience, I thought I put it here to see whether it can be improved. The code is intended to implement the rules as written in the the linked ...
I'm following a YouTube video and am wondering if there are any other efficient ways of doing this. Is it possible to do it with an interface too? using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Learning { class Program { sta...
For quite a while now I've been writing a bit of Ruby code, but so far I still don't think it was good idiomatic Ruby. But there's been a new requirement and I tried my best writing it better, more cleanly compared to my previous code. One of the things I did is read another code base that I though was well written (ca...
I'm reading through the chapter on inheritance from C++ Primer 5th Edition. It asks Organize the following type into an inheritance hierarchy: (b) Geometric primitives (such as box, circle, sphere, cone) Identify some of the likely virtual functions as well as public and protected members. I was hoping this is a suit...
I would like to concatenate a series of strings populated from an XHR response. So, I've chosen to do it like this: $.post('/API',null,'json') .done(function(response){ if (response.status === 'success') { location = response.data.city + ', ' + response.data.state; } }) .fail(fu...
Can this Python code be written in a more Pythonic way? ''' This scripts ask a user for the capital city of Peru, South America ''' question = 'What is the capital city of Peru?' answer = 'Lima' # Ask question print question # Game continues as long as question is not answered # Game ends after 3 failed attempts end...
I am studying the merge sort algorithm and implemented it. In the mergeSort function, I am allocating two new vectors. Can I do it without allocating extra memory? Are there any other suggestions? #ifndef MERGE_SORT #define MERGE_SORT #include <vector> template<typename T> void merge(std::vector<T>& array, std::vecto...
I'm pretty new to the world of lock-free programming and would love some feedback on this code. I have been testing the queue with multiple producers and consumers, and with no unexpected output (yet). Is there anything I could have missed or should improve? template <typename Type, std::size_t Capacity = 100> struct c...
I'm a computer science student who's just starting out with algorithms and their implementation. I wrote this code for a dynamically morphing square. I was wondering if I could get a review on it. I apologize if the comments are excessive, this is how I submitted on it at school. import time #imported the time module...
The following code works, but is it a good idea to call another method in a setter? public TypeSignalDTO SelectedTypeSignal { get { return _selectedTypeSignal; } set { _selectedTypeSignal = value; RaisePropertyChanged(() => SelectedTypeSignal); UpdateExtremitiesLosses(); //This reall...
When I am scraping from a web page I need a way to open and read it. Previously, I used two functions, one for requests and one for Selenium def read_page_w_requests(url): try: headers = {'User-agent': 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.1) \ Gecko/2008071615 Fedora/3.0.1-1...
I've started writing a fully functional Database program in C# that allows a user to access a HR system (with more systems planned in the future). I have come over to C# from Java around two weeks ago, whilst I understood MVC in Java I have been recommended to use MVVC in C#, something I am struggling to understand. Cu...
public class SimpleRandomCount extends RandomCount { /** * Generate an array containing elements in a random order * * @param size the size of the array to be generated */ public SimpleRandomCount(int size) { super(size); } /** * Randomise the array */ protected void randomise() { int[] copy = new int[array().le...
I've been learning Scala and I'd love to get your feedback in order to improve. As an exercise I made a simple framework for creating command-line user interfaces. Gist package com.ronyhe import java.util.Scanner import scala.collection.Set /** A framework for creating command-line user interfaces */ package object ...
I have written code to solve the prime generator problem. I am given an input which contains in the first line the number of test cases, and for each test case, I am given a range and I have to print the list of prime numbers in that range. However, it doesn't pass and says that time limit has exceeded. I tried optimiz...
I am building an app that currently allows the users to have 3 different roles: Consumer Merchant Admin I have three tables: user (Name, email, password etc with a status=0/1) user_role (The list of roles available) user_user_role (The table joining users to user roles in a many to many relationship. Also a status c...
I'm working on a Python script to migrate a MySQL database into a PostgreSQL database with a different Schema (different table structures, different datatypes and so on). I'm a sysadmin and unfortunately I don't code very often. So I'm having some doubts about this initial programming phase. I begin with the tables t...
Earlier today I asked a question as a guest (whoops) regarding my Database program. I could not comment nor post again asking for further advice from the people that answered my question. I have worked on the advice given to me in that answer which can be seen here; Database Connection Program With HR Functionality I a...
I'm working through Coffeescript implementing simple algorithms (started with Prim's as reviewed in this previous post) and wrote out Kruskal's algorithm as below, with a few helper functions. I'd appreciate any and all feedback, especially on making this script more idiomatic. # # graph information # nodesDir = 0 :...
I have implemented a thread safe inventory system. The Product is bound to a location in a warehouse. I have a Product class and a Location class. In the Product class constructor, you will pass the Location. Further, I have an Inventory class which will read from input file to build the inventory in a ConcurrentHashMa...
I thought I would give this months community challenge a try. This is my first time using Python. It does take quite a while to run and it's not very colourful but it works. from PIL import Image, ImageDraw img = Image.new("RGB", (2400, 2400), "white") draw = ImageDraw.Draw(img) max_count = 200 width = img.size[0] he...
I'm working with the Perforce command line client. I want to check for the case when a user tries to unshelve an unsubmitted changelist that has a valid changelist number, but...
I had this homework assignment: Create on the desktop a folder with your name. Copy from your account XYZ@xyz.com two files, "plik1.pdp" and "plik2.pdb". Combine them to make a new file, "plik3.pdb", but they have to be in special order. The second file should be first, and then the first one. Write down from the conn...
Disclaimer: This is live, production code for my hobby project: LSML (GitHub). Due to the size of the code I'm unable to include everything in this review. The application is a tool for configuring loadouts for an online mech game. Brief summary of the problem domain A mech has 8 components: Head, Lt/Rt/C Torso, Lt/Rt ...
To preface this post a little bit, I'll explain a little bit of the "backstory" here. The Stack Exchange site, Gaming.SE, also known as Arqade, often has a large influx of bad questions about the popular video game, Minecraft. Many of these questions are either easy to find on a search engine, horribly unclear, have be...
This program runs the game tic-tac-toe within the console. The players, X and O, take turns placing their character onto the 3x3 grid. When a player successfully makes 3 in a row, either vertically, horizontally, or diagonally, they win. If no winner is decided upon all squares being filled, it is a stalemate. I'm wond...
I am designing two methods to be used in a Java implementation of Yahtzee. For those not familiar with the game: Players take turns rolling dice and acquire points based on the face up values of a roll. 5 6-sided dice are rolled per turn. There are 13 categories that determine a score, which are listed here. H...
Code Review is running rampant with an infection. A zombie infection. Everywhere posts are becoming rapidly mutated into slobbering, green freaks of nature. But the citizens of Code Review are not running. No; they are fighting! These CRitters are shooting the zombies left and right to keep Code Review a safe and heal...
Is this the most robust and fastest way for finding the min and max out of an array without using STL functions? How can I improve it? #include <stdio.h> #include <stdlib.h> int main(int argc, char const *argv[]) { system("clear"); int c=9,n[10],max,min,i; while (c>=0) { n[c]=random()%100; printf("%d\n",n[c]); c--;}c=1...
I'm trying to create an alarm function with Python3. The below code does work but it doesn't seem like this is the most optimal way of achieving something like this. Is there a more pythonic way? #!/usr/local/bin/python3 import os import time def alarm(): os.system('amixer -D pulse sset Master 30%') # >> Set ...
Push a button and an LED lights up1 and sends a signal to another computer that plays a song. First project on the Raspberry pi, really simple but definitely fun and educational to implement. Also, second time using python and sockets so I'd especially appreciate input on anything I do inefficiently.2 Mostly feedback ...
I needed a node app that: reads a list in text file format from URL parses the rows on the list. (fields: id, name, longitude, latitude) finds names of the people who live maximum 100 kms away from a set location. sorts the list by user id Could you take a look and let me know what I could have done better here? T...
I am a beginner and I wanted to make programs that would help me while I learnt Java. I made a program to help me in my assignments. Any suggetions? Main method public class MirrorFormula { public static void main(String[] args) { Scanner keyboardInput = new Scanner(System.in); double u =0; dou...
I have been experimenting around with generating all the n-combinations of an array. This code quickly generates all \$\text{k-combinations}\$ of a given array. I am testing my own implementation because of some restrictions in coding competitions (also, knowing the basics never hurts). """ Generates 3-combinations of ...
This question is a follow-up of a previous question of mine: Genetic Drift Simulator. Following the advice given in the last question, and some more general improvements, the code has been slimmed down a bit. The major one was implementing Underscore.js, which slimmed down a few of the loops into functions. The config ...
I'm wondering whether anybody would be willing to review this code for a game I'm working on with my friends. I feel quite confident with Python but am wondering whether there are some places that it could be made more efficient or errors I haven't spotted. # Copyright 2015 Wet Ferret Studios # Initialize Player Stats...
I created a little wrapper for one of my JavaScript libraries to enable Angular functionality. Are there any pitfalls I should be wary of with my code? angular.module("signalR.eventAggregator", []) .run([ "$rootScope", function($rootScope) { function createScope(scope) { scope.$on('$dest...
I've got the following code. I want to loop through my dataset (which is a matrix) in steps of let's say 50.000 and perform biglm on it. lengthdata <- 100340 stepsize <- 50000 for (i in seq(1, lengthdata, stepsize)){ if(i+stepsize > lengthdata){ ## call function (i, lengthdata) print(paste(i, " - ", lengt...
I've build simple application that allows me to generate all numbers that have desired length and start with prefix. For example if I specify 12 as prefix and set desired length to 4 it will generate numbers from 1200 to 1299. I'm storing all generated numbers in List<int> then using shuffe method from Jon's answer I'm...
I'm trying to solve this challenge on CodeEval. Quoting: For example, you can put pieces together and get the original text: evil pl vil pla il plan The answer is ‘evil plan’. Your task is to print out the original text. Due to repetitions in the text, you will sometimes get identical pieces. Your program should accep...
Routine to merge two linked lists together and return a new merged list. One optimization I can think of is passing by reference instead of value. Any other suggestions ? Is there a shorthand to make lines 4 and 5 single/shorter? template<class t> Linkedlist<t> merge(Linkedlist<t> firstList, Linkedlist<t> secondList) {...
I tried to implement following class which should handle connecting to a server, as well as sending and receiving data. Your feedback is welcome. Please note I am beginner in .NET and don't give too advanced feedback. I tested it and it seems to work. So in case you see some major problems please let me know, otherwise...
This is code I'm writing for an android game where I want to be able to randomly generate small planet sprites. It seems like the best way to do this is to have a set of small PNG textures that can be layered onto each other. I found code for recolouring a drawable programmatically here that was very helpful. The idea ...
The purpose of the below code is to return different types of job objects based on an argument named "jobType." The original code for the below methods was implemented as a switch statement. I refactored the code removing the switch statement, and in place creating different classes representing different types of job...
I had a job interview take home test where I was asked a series of questions on object inheritance. In addition to answering the questions, I created the following application to demonstrate inheritance among different objects. The first piece of code are different shape classes. Some inherit from an IShape interface. ...
I maintain an application that has a method in a class for saving uploaded files to filesystem and I want to run asynchronously as it saves multiple files in a single request. I don't know if it's best to use Task.FromResult or Task.Run, but I've modifed the code to use Task.FromResult. public class AttachmentProcessor...
Here is my backpack system. Please critique and give me advice on the best practices. // #include <iostream> #include <string> using namespace std; void backpack() { string item1 = "item 1"; string item2 = "item 2"; string item3 = "item 3"; string item4 = "item 4"; string item5 = "item 5"; cout << item1; cout <<...
For an assignment I have to make a HashTable using double hashing, but for the hashing part I am not allowed to use Object#hashCode(), so I have to write my own. So far I have the following code and I am looking for feedback if I am on the right track or if I should go for a different approach (see hash and hash2 meth...
My code accesses an FTP server, downloads a .zip file, pushes the file contents as .gz to an AWS S3 bucket. import boto3 import ftplib import gzip import io import zipfile def _move_to_s3(fname): host = 'some_host' user = 'some_user' passwd = 'some_password' tmp_dir = '/tmp/' tmp_fname = fname.spl...
My input consists of a list of lists (not necessary of the same length), like [ ['a', 'b', 'c', 'd', 'b'], ['a', 'd', 'e', 'b'], ['f', 'a', 'g', 'e', 'b', 'h'] ] and I would like to have a matrix / dictionary that contains the co-occurences. The keys of the dictionary are the elements of the original m...
I'm working on class Striped_polyline which represents a closed poly-line filled with equidistant horizontal lines1: stripedpoly.cpp: #include <iostream> #include <vector> #include <algorithm> #include "Graph.h" #include "Simple_window.h" #include "stripedpoly.h" int main(){ Point tl(x_max()/2,0); int width =...
I've been working on Bill of Materials mini schema for a while. At first I had single Part table where I've referenced itself. I was told it would be better to have separate table because we'd need to have info like quantity and that quantity is not part of Part itself. Here's the script... CREATE TABLE Part ( ID I...
I recently was given a task to capitalize the first character of a string provided the string does not begin with a non-alphabet. Below are the requirements and my implementation. Just want to know if there is a more efficient way to implement this. Requirements Please implement this method to capitalize all first let...
I have a functional script that converts polar coordinates to Cartesian coordinates and then matches a value in a separate array to the coordinates. It works well, but I find that it takes a long time to run due to the length of the matrices being processed. Each file has four columns and 2,880,000 rows which means tha...
I used gradle-js-plugin to lint and minify my JavaScript, and wrote some tasks to automate uploading the scripts via FTP. Any feedback is welcome, but specifically I am concerned that: The tasks I wrote myself like viewJshintResults are all imperative and not declarative The section after the /********/ feels like sho...
I read many comments on this question that one really shouldn't use local classes for functionality like which my code provides, but I couldn't really put things into perspective and decide what better alternatives are there, if any (in terms of solving the problem locally). Some mentioned lambdas, although they also p...
Excel renders scientific notation in the engineering fashion, e.g. “4.2E-5”. That’s OK, but when you are writing a scientific paper, it’s likely that you want it to look like this: “4.2×10⁻⁵”. I have come up with a Scala script that does the job perfectly well: import java.awt.Toolkit import java.awt.datatransfer.{Stri...
I have an array called viewObject.terms. This array can contain up to 3 items, I need to iterate through this array and save the values into a data object. ie: data.term_id_1 = viewObject.terms[0].term_id data.ticker_1 = viewObject.terms[0].its_ticker This is what I first tried, but I get the error: Cannot set proper...
I have a corrupted png image. I checked and the crc32 checksum of the first chunk (size ~65k) does not match with the one I get. I am sure of this. Also, I have identified the 4 bytes that have the wrong value. I am sure of this. My question: Is there an efficient way to calculate the values of these 4 bytes, in order ...
I'm making a program that compares multi-key sequential search and Interpolation search in a sorted array by the number of array accesses for my assignment. /* * A program that compares Multi-key sequential search and Interpolation search in a sorted array by the number of array accesses. * * TODO: * - make Except...
I am trying to determine the number of factors of a large number efficiently. I have written this function but how can it be improved upon? long numOfFactors(long long n) { long i=0,num=0; for(i=1;i<=n/2;i++) { if(n%i==0) num++; } return num; }
I've spent my fair share of time criticizing other people's code on this site; but I'm finding out I'm kind of a hypocrite. Almost everything I've written so far has been some program whipped together to do some task for me. I have little experience actually starting out writing maintainable code. Then today I decided ...
This is for a single producer and single consumer wait free ring buffer. The writes need to be wait free for sure. It pre-allocates messages slots and uses a claim strategy to capture a buffer for write or read. For writes, it uses a ping pong strategy if the buffer is full which means if it find a read happening in th...
I was bored, and looking to do something that involved anonymous functions, and it was suggested by @Quill, that I create a summation function. I decided to also include a product function as well to top the whole thing off. For those who don't know, a summation is usually defined like this: $$\sum_{n=a}^{b}f(n)$$ An...
I'm working on an XNA project that loads several resources that are packed into a single file. XNA can take a WAV file stream and turn that into a SoundEffect (seen below in "case ".wav""). Since WAV files are large, I want to enable MP3 audio as one of the resources, so I found MP3Sharp, a cross-platform library that...
I recently took a test on HackerRank, and submitted my answer for the following question. I passed all the test cases but company told me that the answer is not efficient, and they are not moving forward with my candidacy. I don't have a screenshot of the question, so I will explain as much as possible. Question: We ha...
I have the following code to get the prime numbers between a range of numbers. Is this the best and fastest method? int[] numberCollection = Enumerable.Range(startNum,Count).ToArray<int>(); string primeNumbers = string.Join(",", from number in numberCollection where (IsPrime(numb...
I'm building a Markov text poetry generator. The main method, which is attached below, performs a depth-first search through the Markov chain, which is implemented as a NetworkX digraph of Word objects, which have methods for determining whether e.g. a Word rhymes with another Word instance. At each level of the searc...