instruction
stringlengths
71
71.9k
This is an iterative review. The previous iteration can be found here. The next iteration can be found here I've now been programming in python for all of 4 hours. At 70 lines it's rather verbose for a FizzBuzz. If you can suggest a more pythonic way to structure it, that would be awesome. FizzBuzz.py def print_fizz_...
Here is a game of tic-tac-toe I created to run in python 2.7. I am still learning and feel 400+ lines of code is a bit lengthy for such a small application. However, trying to get some feedback on how I could have put the game together better (and shorter), while still retaining full functionality. Any and all feedback...
I have control with RadioButtons. Each RadioButton represent some state of document. Each document have a lot of labels, buttons and another trash. I need to collapse different labels, buttons, other... In different states. I think that I am building big crutch. What is the better way to implement this functionality? ...
I have the following query which tries to get all the cheapest products linked to my recipes and it takes 10 seconds to return from the database: SELECT PRODUCTOS.id, PRODUCTOS.titulo, CONCAT (INGREDIENTES.titulo," ", CONCAT(RECETA_INGREDIENTE.cantidad * $pers, "", PRODUCTOS.medida)) as ingrediente , precio, precio_med...
I have to display a cache layer on the whole viewport (to then display a kind of dialog box). Without surprise I create a <div> element with {position: fixed; top: 0 left: 0; width: 100%; height: 100%: background-color: #...; opacity: ...}. But I faced the issue that I may encounter pages where some elements have a z-i...
I am trying to populate a table like this in Excel. I came up with a bunch of loops to do this. I feel like this is a brute-force approach and may not work well when populating bigger tables. Any other ways to populate values in Excel? Sub Fill_SLA_priority() Dim SLAbyPrior As Worksheet Dim wsAssignedTix...
Here is the problem description from hackerearth.com: Rohan loves Palindromes. Palindrome is a string that read same forward and backward. For example abba is a palindrome while abca is not. Rohan is forming a palindrome of length lesser than or equal to \$n\$, with first \$k\$ characters of lowercase English lett...
This program calculates the 7th digit of a GTIN-8 barcode and calculates the validity of an 8 digit GTIN-8 barcode. Could I simplify my code any further? import math def roundup(x): return int(math.ceil(x / 10.0)) * 10 def doMaths(number): count = 0 total = 0 for n in number: n = in...
The disposable wrappers worked exactly as intended... and that turned out being a huge mistake: That's because the .net runtime creates a Runtime Callable Wrapper per-type, not per-instance*; it took a number of refactorings and adjustments just to be able to get the project to build and run, and then over 900 tests w...
Cryptopals challenge 1 Using binary strings to convert from hex to binary felt kinda hacky. I'd like to hear if there are better ways to do that. I used memcpy() and pointer to the end of the string instead of strcat() to avoid the Shlemiel the Painter problem. EDIT: follow up question #include <stdio.h> #include <asse...
My code sample for finding the mean for the case of pairs is: import numpy as np Data =[] with open('testdata.txt') as my_file: for line in my_file: Data.append(line) psize = Data.size*Data.size p_avg =zeros(psize,float) for i in range(0,Data.size): for j in range(0,Data.size): if i != j: ...
I have a repeated pattern throughout my app that looks like this: <div class="form-group floating-label <%= f.object.errors[:to].any?? "has-error has-feedback" : "" %>"> <% if f.object.errors[:to].any? %> <%= f.label f.object.errors[:to].join(", ") %> <% end %> <%= f.email_field :to, class: "form-control" %> ...
This is an exercise from Think Python: How to Think Like a Computer Scientist Here's its description: In a large collection of MP3 files, there may be more than one copy of the same song, stored in different directories or with different filenames. The goal of this exercise is to search for duplicates. Write a pr...
I've got my own website! Woo! It's got HTML and everything! But after struggling for a while with HTML and keeping my navbar consistent across pages, I gave up and wrote a program which: Searches for every markdown file in the given root directory or below. Parses it into HTML with mistune, which thankfully only needs...
I'm working on implementation insert operation for a btree, and would like to know if there is any way to optimise the inserting operation to make it go faster. The code seems really long so I'm wondering if there is anything that can be shortened and also to make the operation run quicker. /** * Operation which inser...
Purpose of Code: To simulate scraping the web and updating a db, by, presently, adding randomly generated numbers to a "database". Have I wired up the followin async code properly? Is there a simpler, more composable way to pass objects around? Or some more idiomatic way? I have added comments to self-explanatory code ...
Problem Solve correct flips to sort given input with pancake sort. Example input (input size and values): 8 6 7 2 5 1 4 3 8 solution (number of flips and how many elements to flip per operation): 6 2 7 4 5 3 4 2 -> 7 6 2 5 1 4 3 8 7 -> 3 4 1 5 2 6 7 8 4 -> 5 1 4 3 2 6 7 8 5 -> 2 3 4 1 5 6 7 8 ...
<?php // Read all lines of the CSV file into an array // The "file" function in PHP returns an array of all the lines in the file listed $lines = file('passes.csv',FILE_IGNORE_NEW_LINES); // Counter variable for line number $i = 0; //Iterate ove...
The goal is described here: basically, it is to compute the number of numbers below \$10^n\$ such that its digits are either increasing or decreasing (like 112 or 211, but not like 121). The original version: -- f computes the number of numbers with increasing digits. -- digits >= k and the number of digits is n f :: ...
I'm working on a problem in which I have an input array, sorted positive unique integers, and have to try to find all possible triples \$(x,y,z)\$ which satisfy \$x+y>z\$ and \$x<y<z\$. For example, \$(1,2,3)\$ is not a valid triple since \$1+2\$ is not \$> 3\$, and \$(3,4,5)\$ is a valid triple since \$3<4<5\$ and \$3...
I have created this function in my DetailsScreen.cs, but I have no idea if this is the correct file to put this kind of code in, or if coding it this way is the correct approach. I know that it works because I have tested it. My application generates a questionnaire based on selected (cyber security) standards. I have ...
I've written a simple permissions system that I need to be rather fast, yet useable by other developers who primarily use Java. Is a bitwise permissions system with properties a good compromise. Any suggested speed improvements would be greatly appreciated. class AppliancePerms(object): """Permissions for the Appli...
I've created a simple application for mobile users, they can login using provided API but must have limitation on the devices, so the requirement is simple : User cannot login using more than 2 devices I'm building the API using laravel for mobile apps, so I've created the function and it works correctly and wrote t...
I know a lot about Java, PHP and stuff, but I'm fairly new to ruby. I've written this script to look into the current working directory, get two parameters from the command line and then resize and rename all jpegs it can find. To all rubyists, what could I have done better to make things ruby-ish? require "rmagick" re...
In a game that I am making, I have a look in my game which goes through an array, and lists the things in the array public void listOpen() { ArrayList<String> open = main.getOpenable(); for(int i = 0; i < open.size(); i++) { String value = open.get(i); textWindow.append(value + "\n"); er...
This is an iterative review. The previous iteration can be found here. I've now been programming in python for all of 6 hours. This is probably my last iteration of FizzBuzz. Thoughts? FizzBuzz.py from utilities import ask_something from utilities import ask_yes_no def print_fizz_buzz_output(start_num, end_num, pai...
So I made this simple program that allows users to construct points and lines and then return the smallest distance between a given point and a line. In doing so I have used some OOP concepts and operator overloading (both of which are fairly new territory for me). As such, I would really appreciate feedback. Furthermo...
I'm having some trouble isolating the parts of my code enough for unit testing to make them simple and easy to maintain. The code I'm writing feels like an integration test because most of what I'm doing in the test. I'm curious on how I can both make this code better and more unit-testy. This is just a single unit tes...
I'm doing a coding challenge for fun and to work on my skills - some of you may remember the Advent of Code challenge from last December, I'm working through that. I've got this code as the solution to one of the problems, which works, but it's uselessly slow. inp = "1113122113" def iterate(num): pos = 0 new =...
This is the second review of these code blocks. I made major changes and updates to the functions during my refactoring and I would like a follow up review. The original review can be found here VBA Function Reads Active Live Data Feed and Translates Product Codes. To reiterate: efficiency is absolutely key. I attem...
I have a macro which seriously needs to optimised. I have changed the nested loop, but it takes off only a few minutes. The entire macro runs for about 14 minutes. I think the logic needs to be changed? Or perhaps I am missing something completely.I thought about hard coding the columns. But the data columns are update...
I'm currently working on an header for some homepage. It should be responsive. When enough width is available a floating header is displayed (logo on the left / menu on the right). With less and less existing width the logo/menu-font get's smaller until the header structure changes into a centered version (centered log...
I recently found a static C function on Stack Overflow which returns a UIViewController reference from a containing subview using the responder chain: static UIViewController *viewControllerForView(UIView *view) { UIResponder *responder = view; do { responder = [responder nextResponder]; } whil...
I am new to python so I decided to write a script that parses a json array and writes data in a file. I wrote the code that does that but I think it can be done way better, So I was hoping to get feedback on how this code can be enhanced and more inline with python best practices. from urllib2 import urlopen import jso...
I recently came across this problem that asks you to print the number of leaves not eaten by the caterpillars: As we all know caterpillars love to eat leaves. Usually, a caterpillar sits on leaf, eats as much of it as it can (or wants), then stretches out to its full length to reach a new leaf with its front end, ...
This is now an Iterative Review. Next Iteration Nowhere near a full game yet. Just a basic overview and initialisation of a Snake() class. Thoughts? Snake.py import numpy ''' Game Board: X by Y array of numbers Derived from Snake Object and base parameters (height, width, obstacles?) Board Values: 0 - E...
I want to check a string by using multiple search patterns and split the string at every occurrence. I'm using RegEx and it works fine. But I'm worrying about efficiency and performance. struct StringPart { let text : String var matched : Int // index of pattern let pos : Int init(searchText: ...
I am in the process of creating a brain-computer interface, and one task is to stream electroencephalograph (EEG) data into a Python script for real-time analysis. Included in this question are two Python scripts: (1) to generate and stream fake EEG data (32 random floating points for testing purposes), and (2) to rece...
I wrote code to determinate ranges of char,short int and long variables,both signed and unsigned.Please help me to improve my code :) Here is the code: #include <stdio.h> //function declerations... long power(int base, int power); int main(void) { //From 2^(N-1) to 2^(N-1)-1 (Two's complement) int intmin = po...
I needed to create a basic JDBC helper class for our JDBC connection and wanted to know if my design is appropriate or needs cleans up? Just a basic JDBC utility class which helps reduce the boilerplate code that JDBC has. public class JDBCUtils { /** * Retrieves a connection from the given pool. * ...
I have a spreadsheet where I control my shift hours. In such spreadsheet I input the date, the start time, time left for lunch, time back to work, end time and sometimes the overtime. After that I have created a couple of functions to calculate the amount of time worked, the difference against the 8-hour shift expected...
I'm writing a console blackjack game. To hold all the possible moves a player can make, I have a map that maps a keyboard key to a move keyword: (def move-map {\s :stand \h :hit \p :split \d :double}) Splitting and doubling are only available options during the first move t...
I just now got around to implementing a full snake game in Pygame. The player can move his snake with the arrow keys and as in the original, the snake continues to move in the direction of the last key pressed. Dark Green : Snake Head Light Green : Snake Body Red : Fruit The player can adjust the snake speed based o...
I have a moderate size sub-procedure where I am calling multiple functions to feed values into other functions. I feel there may be a better or more concise way to present and run this module, but have refactored the code as far as I can see. Public Sub CompareArrays() Dim matchCell As Range Set matchCell = Th...
I have a 9-dimensional signal (as a csv from this Gist) that looks like this: A signal peaks every 30 steps. I want to get the maximum values of the peaks in that 30 second window. Here's what I've hacked together so far, where sig is the signal loaded from the csv file and max_res is the desired result: trial_num = 8...
I'm currently using a PHP shopping cart, and finally decided to implement a search suggestion feature. There are some already available solutions out there, but I wanted to gain control over how mine is implemented and how it functions. I'm asking for some assistance here and code review on two things: Can anyone spot...
For a given binary tree and a sum, I have written the following function to check whether there is a root to leaf path in that tree with the given sum. /* //A binary tree node struct Node { int data; struct Node* left, * right; }; */ bool hasPathSum(Node *node, int sum) { if(!node) return sum==0;...
I am only a beginner when it comes to programming, but after reading tons of tutorials on and offline, I have been able to create this simple math quiz. It does work as intended, and I'm really just fishing for someone to yell at me for doing something glaringly bad practice in the code below. using System; namespace ...
Link to original question: Successful use of strtol() in C After getting excellent feedback from the code review community I attempted to redo my string to long conversion program! I believe I enhanced it significantly(Most ideas from answers on my last post) but I did add my own 'style' to it and am looking to see if ...
Recently I came across this problem , A despotic king decided that his kingdom needed to be rid of corruption and disparity. He called his prime minister and ordered that all corrupt citizens be put to death. Moreover, he wanted this done quickly. The wily prime minister realised that investigating every citizen...
The following function computes a the last element in a Fibonacci sequence in Go language. package main import ( "fmt" ) type Element struct { Next *Element Value interface{} } type Stack struct { Top *Element Count int } func (stack *Stack) Push(value interface{}) { el := Element{ ...
I'm not sure if this is the right subsite of stackexchange because it's not only about code review but a bit about design eihter. I'm currently developing a network application. I need to connect a (java) server with a tcp socket. I implemented two different variants of my client. One uses a blocking socket with thread...
The function of this program is repeatedly prompting a user for integer numbers until the user enters 'done'. Once 'done' is entered, print out the largest and smallest of the numbers. Suppose all input is proper, so we do not need to check whether the input value is illegal or not. largest = None smallest = None whil...
hey guys how you all doing, I built a spider that crawls through a house price website and stores houses address and transactions on it, through a bunch of functions, and I was wondering if anyone could help me refactor it, possibly pointing me in the direction of an OOP spider, so it would be easier for me to make an...
(See also the next iteration.) I have implemented NBA* (New Bidirectional A*) in Java and compared it against conventional A* and Dijkstra algorithms. The results may be as optimistic as this: Seed = 8900460676230 Created the graph data structures in 2989 milliseconds. Source: 80939 Target: 72799 A* in 120 millisec...
Task: Write a program that presents the user w/ a choice of your 5 favorite beverages (Coke, Water, Sprite, ... , Whatever). Then allow the user to choose a beverage by entering a number 1-5. Output which beverage they chose. ★ If you program uses if statements instead of a switch statement, modify it to use a...
I'm new to computer vision and numpy. I wrote a simple script to seperate red, green and blue colors from the original image by using the kNN algorithm. After reading through some numpy tutorials, I'm under the impression that the performance of my script can be improved heavily. So here are my questions: Is there a ...
I've written a very revised and developed version of the game of Runes. The major changes are listed: Convert runes to use curses. Add color-coding to the pieces. Change the board to use the alternate character set (box-drawing characters) Use a struct to hold game data Enforce all rules (can only move a certain piece...
I have built a single header-only memory class (just a C++ wrapper around a dynamically-allocated pointer and a size) that supports copy and move semantics (I hope I implemented them correctly) for a game I'm building. Its use case is to wrap the raw contents of assets imported (from any source) before processing them....
I have been working on a project for some time and have let one Python file grow into a huge file that tries to do everything. The structure is pretty flat and I don't like it. I've used other programming languages like Java and C# and have had pretty structured code, but for some reason in Python I always let it turn ...
Zeckendorf's theorem states that all positive integers can be represented uniquely as the sum of one or more distinct Fibonacci numbers in such a way that the sum does not include any two consecutive Fibonacci numbers. So given the input 10, the Zeckendorf set would be [8,2]. This is my working code that was for Reddit...
I thought this question was particularly interesting DailyProgrammer 284: Wandering Fingers so thought I'd have a pop at it myself. See the other question for the nitty gritty but the brief problem statement is: You'll be given a string of characters representing the letters the user has dragged their finger over. For...
This script checks if parentheses are balanced. I wonder if there is something that can be improved here including ES6 features. function isBalanced(str) { var stack = []; const allowedSymbols = '()[]<>'; for(let i = 0, l = str.length; i < l; i++) { var c = str[i]; var isOpen; var s...
This collects user's guesses for the word. The user has 8 guesses, a correct guess and a repeated guess does not affect the guess count. def getAvailableLetters(lettersGuessed): ''' lettersGuessed: list, what letters have been guessed so far returns: string, comprised of letters that represents what letters...
I would like to get the current user's timezone name so it can be used with the PHP date_default_timezone_set(). After looking up a few things I've finally managed to come up with a solution for this. I'm not great with code though so any code checks/help will be appreciated. As long as it is a fair guess of the user's...
I am a bit new to programming. I have some edits on my form, and for each edit completed it will have to do a procedure. Currently, I use this code that works perfectly, but I am looking for a better way to accomplish this task. If I add another edit not have to repeat all the code. string rgxExpr = @"(\w+)\s([\w\s]*)"...
I made a Perl script to analyze CSV files. However, it is running a little slow. Is there anything that I can change to make it more efficient? #!/usr/bin/perl -w use strict; use warnings; use Time::Piece; use List::Util qw( min max ); use List::MoreUtils qw(first_index); use Tk; use CGI; my $current_file=(); my $mw...
I had previously written a very simple CMS in PHP, but it wasn't very good looking so I decided to rewrite and improve it using the PHP standards. Have I done this well, and what areas can be improved? <?php class ContentManager { private $db; public $websiteInfo = array(); public $pageInfo = array(); p...
This is my attempted solution to cracking the coding interview exercise 3.5. Looking for any feedback on coding style or the algorithm anywhere I can improve really. The problem specification is as follows. Write a program to sort a stack such that the smallest items are on the top. You can use an additional temp st...
The intent is to update an existing Drupal web page with content based on text entered into a textbox. The existing page displays data from a database in a table. This code gets JSON formatted data, compares it to data in the table, and appends pertinent data in a hidden "td". After doing this, the user may enter text ...
Here is the formula for the deBroglie wavelength of an electron versus its kinetic energy: $$ \lambda(E_k) = h\left/\sqrt{\frac{(E_k+m_eC^2)^2-m_e^2C^4}{C^2}}\right.$$ and here is simple script that prints a CSV with plot data: #!/usr/bin/python import csv from scipy import constants as spc import numpy as np vev = n...
Overall logic: determine number of days in a month. Loop through table (wsUploadTable) and increment value if condition is met. Loop to next day in month and repeat. For example: 10/1/2016, loops through table for date match and increment value. Next date, 10/2/2016 loop table for match... until last day of month 10/31...
I've written a server in Node.js that listens to http requests via Express.js and forwards requests to a Neo4j server. It's my first time working with Neo4j and Express.js. The code runs as intended but is an eyesore to read. The Database has the following Nodes and Relationships: (:User)-[:RANTED]->(:Rant) (:User)-[:U...
I am currently learning C++ and have learnt about inline functions and how they can give a performance benefit. How could this be improved? #include <iostream> #include <chrono> #include <ctime> long fibonacci(unsigned n) { if (n < 2) return n; return fibonacci(n - 1) + fibonacci(n - 2); } inline long fib(un...
I'm wondering if there is more I can do to incorporate more idiomatic scala and functional programming principles. I know the maze itself is mutable but i didn't see an easy solution to making it immutable. Also, if there is anything I can do to improve my algorithm, that would be great too. The reason I have the trait...
I am currently in the process of creating a website which requires it to work with and without JavaScript enabled. All callbacks to the server with JavaScript enabled will be made through Ajax callbacks. In order to keep my code very DRY, I wanted to reduce the amount of views that was required to be created. For that ...
I recently came across this problem: It is Lavanya's birthday and several families have been invited for the birthday party. As is customary, all of them have brought gifts for Lavanya as well as her brother Nikhil. Since their friends are all of the erudite kind, everyone has brought a pair of books. Unfortun...
I need to return private collection and avoid calling code modifying them avoiding copying overhead if possible So I thought of returning copy-on-write arrays, hashes, and sets. I couldn't find any implementations of these, so I tried my own. require 'delegate' require 'set' module Cow end class Cow::Base < SimpleD...
I wrote this sparse linked list insert function, and there are nine return statements. Is this a code smell? Is this badly implemented? I fear that it's hard to read, or hard to maintain. /* NOT BUGS, TESTED AND WORKS CORRECTLY * insert an element into a list * list is ordered using pos * if position pos is already ...
I'm hoping to get some feedback on a function with variadic templates that parses a format string and fills in some parameters whose order and types are based on the characters in the format string. Kind of like scanf(). (For the curious, I am trying to make a typesafe version of this function, documentation here.) I'm...
Question: The old system stored a list of letters per score: 1 point: "A", "E", "I", "O", "U", "L", "N", "R", "S", "T", 2 points: "D", "G", 3 points: "B", "C", "M", "P", 4 points: "F", "H", "V", "W", "Y", 5 points: "K", 8 points: "J", "X", 10 points: "Q", "Z", The shiny new scrabble system instead stores the score per...
private String sort(String word) { char[] content = word.toCharArray(); Arrays.sort(content); return new String(content); } private boolean isPermutation(String s1, String s2) { s2 = s2.toLowerCase(); if (s1.length() != s2.length()) { return false; } if (s1.equals(s2)) { r...
Here is my crappy clone of Atomas, a puzzle game where you combine small atoms into more valuable ones. # Pytomas (an Atomas build for Python) # Author: Qwerp-Derp from random import randint # Initial variables element_table = [] atom_range = [1, 3] specials_list = ["+"] * 6 + ["-"] * 3 + ["B", "C"] carry_over = " " ...
The exercise I wanted to solve is from here. Copying from that page: public static int dayOfYear(int month, int dayOfMonth, int year) { if (month == 2) { dayOfMonth += 31; } else if (month == 3) { dayOfMonth += 59; } else if (month == 4) { dayOfMonth += 90; } else if (month == 5...
Here's a very small and basic script that sends commands over SSH to another computer on my network: #!/bin/python import sys, os commands = "" for i in sys.argv[1:]: commands += " " + i; if len(sys.argv) <= 1: os.system("sshpass -p VerySecrectPassword ssh pi@172.16.0.141") else: os.system("ss...
Question: http://qa.geeksforgeeks.org/9744/vinay-queried-interesting-problem-optimization Input The first line contains N denoting the length of Target String. This line is followed by the Target String. The Target String is followed by an integer Q denoting the number of queries asked. After this Q lines follow...
I've recently released my first ever Qt application, and would be glad if someone will look into it and tell me if there are some flagrant anti-patterns and likes. This grabs some screenshots (paths) from the user and copies them to respective Steam directories, converting them to JPEG if necessary. After the copying i...
This is my take on this problem. I don't pre determine the distances, it's not suitable for the application I'll use it for. I'll use it in shool to determine some a mean total distance and how to setup a the poles of a power grid. from random import sample from random import random from random import uniform from ra...
This is more of an exercise for me to get use to Pandas and its dataframes. For those who didn't hear of it: Pandas is a Python package providing fast, flexible, and expressive data structures designed to make working with structured (tabular, multidimensional, potentially heterogeneous) and time series data both...
I've been working on a class(2 actually) that wraps around the array data structure of PHP. It doesn't bring anything new to the table, it simple makes the function somewhat more abstracted with the possibility of method chaining. It's made mostly for fun and practice purposes, I don't expect(nor encourage) anybody to ...
I just started doing the Project Euler challenges and right now I'm on Challenge #3 - The largest prime factor of 600851475143. I wrote some code and tried to optimize it based on some other Stack Overflow users' advice. What I got is this code which does its job, but I think it takes longer than it should - calculatin...
I wrote a function in Clojure to solve quadratic equations using the quadratic formula The function (defn solvequadeq [a b c] (let [D (- (* b b) (* 4 a c))] (if (< D 0) #{} (let [sqrtD (Math/sqrt D) x1 (/ (+ (- b) sqrtD) (* 2 a)) x2 (/ (- (- b) sqrtD) (* 2 a))] (...
Goal My goal is to merge directories. Whenever a file has the same name in two or more directories, then only the one that has the highest number of lines should be kept. If both files have the same number of files and differ then an error message should be thrown. Note that files having more lines are also bigger (in ...
I recently wrote a small INI parsing library. The code is also on GitHub, with documentation. I would like to have opinions, suggestions, and critiques. confini.h /** @file confini.h @brief libconfini header @author Stefano Gioffr&eacute; @copyright GNU Public License v3 @date ...
This code is for a Telegram bot I created. Basically if the user types in Whats the news,Whats the technology news,Whats going on in Syria, Whats happening in New York City, etc it will retrieve 4 articles from google news related to the users query. This uses CoreNLP to analyze the sentence. Just by the way I am only ...
So this is my very first time in this site. I have written this very basic Python code with PyQt5 to create a Memory Game. As I am not very familiar with OOP (but I'm trying to be!), I hope somebody could point me to where I could improve my game. As it stands, the whole thing is working but it lacks of a pretty templa...
I'm trying to understand the strtod() function, and how I can handle any user input given to the function. I assume I tested for everything, however I am hoping for a review to make sure and to catch anything I missed. (I know I should separate everything into functions, however, I am just trying to understand the natu...
Here is the problem on HackerRank. I want to know how I can improve this code. I am mainly trying to improve the following skills: Documentation, functional programming (top-down approach), accurately estimating Big O Complexity, Space Complexity, doc-testing, and readable code. Sometimes I feel that my code is simply ...
I am trying to write a simplify the algorithm of finding the number of nodes in a binary tree by using good object oriented design. I have been into good OOP style recently and found it really compelling in way that it can simplify the mental load by proper polymorphism. Having said that, I don't know if it's a right s...
Recently I came across this problem which instructs me to find the longest substring which is a palindrome: As we all know, a palindrome is a word that equals its reverse. Here are some examples of palindromes: malayalam, gag, appa, amma. We consider any sequence consisting of the letters of the English alphabet t...