instruction
stringlengths
71
95.1k
This was the first game I made not too long ago (2018), and while I'm working on another, more complex version, I want to know how good or bad I did this one and what can be improved. Note: the change of players and detection of free spaces are the things I did with help of a friend, everything else I did it myself. #i...
Suppose my goal is to add elements to list in python if they pass a conditional. There are many ways to do this and I show some. Would it be possible if you could review each block and describe its performance in context of the other blocks? Additionally, if possible, can you provide some performance heuristics for the...
Best rational approximations is a technical term and not subjective. The best rational approximations are the convergents of a value plus it's semi convergents that are closer to the original value than the previous convergents. Hi everyone, I've written some quick code in Python that is my tool for exploring various a...
I am designing this nice form handling in React/Redux/Saga and I am quite afraid it might not be optimised. So I decided to ask you what you think :) First of all, I won't get into details how I normalise the json-s to get to this structure, because this post will get huge, so this is how my redux state is being initia...
This is program that computes the minimum of the function \$y=(ax+b)^2\$. The program will find the value of \$x\$ that gives the minimum \$y\$. It will start with an initial value \$x\$ that you assign. #include <stdio.h> #include <stdlib.h> int main() { int a, b, i; float threshold, xt1, xt0, l_r, x, min_y;...
How can I speed up this code? coin=[50000, 20000, 10000, 5000, 2000, 1000, 500, 200, 100, 50, 20, 10, 5, 2, 1] def matrix(coins, kerdes): # it create a metrix tabla = [[0 for m in range(kerdes + 1)] for m in range(len(coins) + 1)] for i in range(kerdes + 1): tabla[0][i] = i return tabla def change...
Rate limiter has to comply with the spec: Every request comes in with a unique clientID, deny a request if that client has made more than 100 requests in the past second. Would be happy if you review: import java.util.HashMap; import java.util.TreeSet; import java.util.Map; public class RateLimiter { private ...
I am trying to perform optimization using a surrogate model instead of the real function and for that, I need the gradient of my LSTM model with respect to the input. In this case, I have 3 features that vary over time. The LSTM calculates from the initial value of these 3 features the following 100 time steps hence th...
I'm writing a code generation library, I've exposed a couple of methods and of course in order to define a member you need to specify it's type, the easiest way is to use typeof(Type), which I later format so that it it's compilable and I can insert it as a code chunk e.g. System.Int32, which for non-generic types is b...
You can set any size of the field, you can set how much you need to put in a row to win. I think I got a pretty flexible program. What do you think about the code? I would like to know if I made mistakes in program design. skeleton: public class Main { private static String[] turn; private static int hmInARowT...
This code checks user permissions for uploading file, and if user can upload, then the file undergoes a check to see if it exists in SharePoint. If so then the file is pulled and uploaded to S3 bucket. This all works fine, but I have been told all these catches create callback hell. I've been trying to implement promis...
I am trying to solve this question on HackerRank (problem details below). Naive solution This solution implements the problem as described and produces the correct solution. It is not very efficient, however, and produces time-out errors on the predefined tests for larger sized arrays of A, e.g. big_A (see below). big_...
I have a server and client application. In the client application, there are HttpRequestException class exceptions on requests. As it seems to me - these exceptions happen in isolated cases and not always speak about a connection problem. So I decided to do a repeat of the queries with a small amount of time: private s...
I have a bare-bones example of how I plan to load excel sheets into pandas data frames. However, the code runs unexpectedly slow. I'm open to suggestions on ways I can speed this up, even converting the source files to a different file format. Anything to make it snappier because I will need a loop to do this several t...
I need to build something that is not very complicated, but efficient. I don't have much time to debug. I don't know if this method is strong enough to encrypt a data to be displayed in a Qr code. It will be compiled in Qt. #include <botan/botan.h> #include <botan/aes.h> #include <botan/kdf.h> #include ...
I have solved the designer pdf question with haskell. The code works. I am posting the code here to know how I could have done it better. First line contains the weight of each alphabet Second line contains the word. Sample input 1 3 1 3 1 4 1 3 2 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 7 zaba Output 28 Explanation each...
Problem I have a DI scenario where I have multiple classes that implement a common interface (IModelService). I'm using a generic framework class (PredictionEnginePool<,>) that has options injected (PredictionEnginePoolOptions<>). This has a property (ModelLoader) that must be set using AddOptions in Startup.ConfigureS...
We need to tunnel certain applications over a VPN at work. Ideally we would use a dedicated firewall/network appliance for this but the only permanent infrastructure we have are Mac Pro's running Squid. This means that if our VPN connection drops or anything happens to the link, we have to manually click "Connect VPN" ...
I'm trying to build an API wrapper class, that sends requests in a JSON format. the sample request format is something like this: { "items": [ { "brand": "brand", "idCategory": "idCategory", "idItem": "idItem", "attributes": [ { "idUda": "idUda", "price": "price...
This snippet uses a string as an output. As we iterate through the input string, I just keep appending a character to the string and I know this just pretty much creates a new string everything I add a new character since strings are immutable in Python. def snake_string(s): res = '' for i in range(1, len(s), 4...
I'm reading Structure and Interpretation of Computer Programs. In the first exercise, I came across a programming problem to add the squares of the 2 bigger numbers out of 3 numbers. I came up with the following procedure: (define (sum-of-larger-two a b c) ( if (> a b) (if (> b c) (+ (* a a) (* b...
You can set any size of the field and any number of bombs. I think I got a pretty flexible program again(Tic tac toe game for the console). What do you think about the code? I would like to know if I made mistakes in program design. skeleton: public class Minesweeper { public static void play(){ final int H...
Given multiple sorted integer vectors, the goal is to merge them into a single vector and eliminate duplicate values. We've already achieved some improvements over the most simple approaches, but overall the operation is still very expensive and we're not sure if we're missing something, there must be a way to perform ...
Here is the task description for the codility's stonewall problem. I would like to get a feedback on my code, and I specify at the bottom what the title states. (I had to make the figure by hand, because I couldn't paste the site's one for some reason, but it can be seen here, if mine doesn't look right) Task descript...
I have a tableView, which auto locates back at indexPath after user has dragged it. In other words, bouncing the tableView back into its bounds, after user dragged it out. Here is the code: // ... var tracking = false var currentPath = 0 @objc func updateRecorder(_ timer: Timer){ currentPath = somethingCalculate...
Some background: The counter was first made as a joke because we have a lecturer who repeats the 9 phrases found in the program over and over during lectures and I thought it would be funny to create a program that (using user input) would count the number of times the lecturer said these phrases. Two days later (and ...
I'm trying to have one WPF application to communicate with an other application when something change on the UI. For example : a slider changes and I send the new value or a textbox input change and I send the new input value. The second application is listening and receive those changes to use them in some way, doesn...
I've built this little C++ program just to take some rust off my coding skills since it's been ages since the last time I coded something. The purpose is to organize my music, so I've built the classes 'song' and 'playlist' with some methods which could come in handy - maybe - such as printing on file the list of songs...
I have a complex array function that takes way too much time to calculate, which is why I'm looking for ways to make it more efficient. Basically, I have a transaction sheet in which I list all goods sold in a bunch of different stores. The formula that I've written picks the last stock amount in the list where a speci...
Somehow this code looks messy to me: var results = query.GroupBy(x => x.ProductStatusId == ProductStatus.Sold || x.ProductStatusId == ProductStatus.OnHold ? "Delivered" : x.ProductStatusId == ProductStatus.Shiped ? "Shiped" : x.ProductStatusId == ProductS...
I am having severe problems with performance on a WEB API helper method, the performance is simply dreadful, 1-2 connections / second, I am trying to make 40k API calls and 5 hours later it is still going. I added and set the proxy property of the request to null as per other answers on SE but it doesn't seem to help m...
Here is the part of working code: function SelectPoints(lat,lon){ var dist = document.getElementById("miles").value; xy = [lat,lon]; //center point of circle var theRadius = parseInt(dist) * 1609.34 //1609.34 meters in a mile //dist is a string so it's convered to an Interger. selPts.length =0; //Reset the arr...
I finished Python Principles and this is my first program I've done (mostly) from scratch since, having to get some outside help on the loop to repeat the program, and I saw a nifty thing about using modular math to figure out the results so I did that to save a bunch of lines. I'm just looking for any comments, improv...
I wrote a brute-force algorithm which shall find all possible combinations of ASCII-values that can sum up to a specific value (int hashval). The algorithm is derived from a recursive algorithm that could print all binary numbers that are possible within a specific length characters. I modified it, so it now iterates ...
I'm asked to print the sentences from the corpus containing the word(s) with the greatest number of distinct tags. I already got the top 6 words with most distinct tags (5 tags). My questions are: I don't know how to get the words without using "len(cfd[key])>4"? Because I've tried using max() function but it doesn't ...
Original inspiration was by this Python beginner, and it prompted me to rewrite a bunch of stuff with my flair and my Python experience: First attempt: Python Rock Paper Scissors Okay, so I looked at the aforementioned post, and was bored and needed to kill an hour at work. So I killed an hour - I took their RPS gam...
I have unstructured input-output data, f=f(x). I want to estimate the range of f as a function of x, given limited sampled. So, I tried to discretize the data use small bins in x to estimate the variance of f associated with that bin. After a lot of work, I cobbled together a working code. But, I'm sure there must be a...
My lead developer has commented that the code I write is hard to understand and that I "overcomplicate things". I'm willing to accept this and improve but I'm not sure if this is genuinely the case or if his personal preferences are seeping into his judgement. A red flag for me was the following situation: We're receiv...
For my first CodeReview, I would like to present my FizzBuzz solution in C#. My design has all of the rule logic about when to display what in separate classes through an interface. This design should be able to handle the common follow-up changes (ie. mod 7 instead of mod 3, bazz, etc.) for this problem by simply addi...
I've seen a few TTT related posts recently, and thought I might learn something or be reminded of certain techniques from attempting my own rendition. Here is that attempt! Hopefully any new coders can benefit from this as well. Any improvement suggestions are welcome, and numpy, scipy & bitwise operations are open to ...
What's up smart people. A little backstory for context: I'm a completely self taught dev, and the only person ever looking at my code for the past 6 years is myself. I realize that's not the best idea moving forward, since I now know that this is what I love doing, and what I want to make a career out of. I'd like to f...
Update: The code below has some obvious problems, and it is not allowed to revise code in the original question, so I have to post a new question, the revised code is here. std::shared_ptr has the potential problem that two pointer point to the same object but to different control blocks. And its atomic operation is pu...
std::shared_ptr does not stop you from having the same resource managed by multiple control-blocks (and thus independent sets of shared-pointers), even though it is illegal and leads to double-deletes. Additionally, atomic reference-counts don't have any advantage in single-threaded environments but are still more expe...
I've reproduced the example of this video where dependency inversion principle is explained by Tim Corey based on C# I had some trouble understanding the scope of the Logger and MessageSender properties and how to set them with the Create function inside the Chore class Also: With Rubberduck inspections I receive Pr...
I am interesting in the topic of finite automata, so I started over by implementing a parking machine from this video: Computers Without Memory - Computerphile to understand conceptions. Didn't do much of an error checking - have made a minimal working version. Short description of the task, but for better understandin...
I am making a Trello clone just for personal project and I wonder if my implementation on mutating the state is good. My state is basically shaped like this: boards: [ { id: Number, title: String, tasks: Array, columns: Array, columnOrder: Array } ] I want to mutate the ...
I wrote cat program in x64 FASM and I would like to know if there is anything that can be improved. This implementation of cat supports: Reading from stdin. Multiple arguments. I checked few cases and program behaves exactly like original cat command. Is there anything I could do to improve performance of this progra...
In Kotlin comparison operators can be used instead of compareTo method: a > b // a.compareTo(b) > 0 a < b // a.compareTo(b) < 0 a >= b // a.compareTo(b) >= 0 a <= b // a.compareTo(b) <= 0 It's convenient and makes comparisons a lot more readable. However, these operators cannot be used if there is no suitable co...
How is this Implementation of a list in C? Please tell me whether it is good or please mention any problems. It is a singly linked List and I tried to do it recursively. #include <stdio.h> #include <stdlib.h> #include <conio.h> struct node{ int value; struct node *next; }; void add(struct node *lst, int num){...
This function determines which images should be loaded based on which image is currently in the viewport (array index), what direction the user is scrolling, and if the image has yet to be loaded. It has a bias for what direction the user is scrolling, and proximity to the current image in viewport (delta). It attempts...
I'm not quite sure I understood thread-safe correctly. I built the following registry: @Service public final class EntityDefinitionRegistry { private static final Logger logger = LogManager.getLogger(EntityDefinitionRegistry.class); private final HashMap<String, EntityDefinition> definitions = new HashMap<>()...
After a relative hiatus of around two years, I've decided to start delving back into the programming world; to start, I've appropriated one of my older projects, CLIGL, and have made a solar system simulator that runs exclusively within a console interface. There are several classes of importance, whose purposes and fu...
Update: see also version 2 The Service This code uses two API's. List https://LokiAstari.com/sample/list https://LokiAstari.com/sample/list?token=<continuation Token> This API returns a JSON object. The first version starts a list and will return an array of user ID (not all of them). The second version takes a tok...
I am working on an e-commerce website. What I need to do is to save an advertisement. The ad has some properties and some photos... properties should be save to DB and photos should be saved to file system (I am using an amazon S3 bucket for photo storage). So, in order to simplify the process of saving an ad, I have c...
As part of my college class, I have to write a program that returns the "smallest" letter in the string. Input is assumed to be a non empty string. "Smallest" is defined as: The smallest decimal value of the character, pertaining to this chart. The range of acceptable values is 0 <= x <= 127 I would like to get feedb...
I just finished writing the core for my WPF application and because I'm still a very beginner at software design I wanted to get some feedback about the design decisions I've made. I've uploaded the project to Github and I'll post the most important parts here (the project is to big to be posted as a whole). To see t...
The following code is an experiment that I ran to play with the advantages of multi-threading in C++. Given a number 10000000000 it calculates how many numbers are even, divisible by 5, divisible by 8, divisible by 10 between the range 1 to 10000000000. First, it runs single-threaded function followed by a multi-threa...
I am building a digital clock in C# after watching a tutorial. The code in the tutorial I need help understanding looks like this: if (hh < 10) { time += "0" + hh; } else { time += hh; } time += ":"; Can anyone explain to me why hh < 10? Should it not be at least 12? My end game is to make a timer that starts...
Can someone help me in optimizing the code here? This is the original question Given an array of integers, return indices of the two numbers such that they add up to a specific target. You may assume that each input would have exactly one solution, and you may not use the same element twice. Question link: http...
i have a pagination library in php. i want to know: how can i make it more efficient when passing large arrays into the constructor how can i add db support paginator.php public function __construct($options = []) { $this->items = $options['data']; $this->limit = $options['limit'] ?? 10; $...
namespace DataStructures type Queue<'T>() = let mutable _list : List<'T> = [] let mutable _count : int = 0 member this.Enqueue value = let revList = List.rev _list _list <- List.rev (value :: revList) _count <- _count + 1 member this.Dequeue = match _list with ...
Continuing from: Part 1 I was not convinced this was true (see comment): std::async([&users, job = std::make_unique<ListJob>(apiList)](){job->run(users);}); // This will not return until all async jobs have completed. So I rewrote it to make sure that I waited for all child work. This means collecting and then waiting...
I am using minimax algorithm (for now without alpha beta pruning) for AI in tic tac toe game in Python and Numpy. It's working, but very slow, so I would like to optimize it. A few rules for current purposes: Board is 4x4 square, Player wins when he has 3 symbols (X or O) in row, column or diagonal, Empty field is rep...
I am new to Python and would like to get helpful tips and suggestions on this code. Would be awesome if you provide info if anything is fundamentally incorrect, improve the algorithm, and any room for further improvements. class Game: def __init__(self): self.board = ["0", "1", "2", "3", "4", "5", "6", "7", "8"] ...
Quick review: I've been writing API code which receives user input that can come as either an object or a value type - a problem outlined here. In order to write an unknown data type to a variable, I first came up with this: Public Sub LetSet(ByRef variable As Variant, ByVal value As Variant) If IsObject(value) The...
I am working on a login/register system and want the register and log in process as smooth as possible. One way of making it smoother is in my opinion to make a multi-step login/register. What I mean: If a user want's to log in, he first have to type in his username and if this username exists, he can type in a passwo...
How does this Pygame code look? Is the run loop usually in a class? I'm a beginner and was wondering what the best format and structure is for using OOP in Pygame. import pygame pygame.init() win = pygame.display.set_mode((500, 500)) pygame.display.set_caption("Game") class Game: def __init__(self): se...
I made a simple code to improve the results for WordPress related posts area and it works fine , but because my experience in coding is low , my code is very long and i believe that there is a way to make simple and better here is the code :- $cat = get_the_category(); $cat0 = $cat[0]; $cat1 = $cat[1]; $cat2 = $cat[2];...
I'm working with an input array, which is 3 levels deep, and creating error message strings accordingly in a separate output array. Below is the code. $e['invalid']['key'][] = 'a123'; $e['invalid']['key'][] = 'a456'; $e['invalid']['color'][] = 'red'; $e['missing']['key'][] = 'b72'; $e['missing']['color'][] = 'blue'; $...
Let me preface this by detailing some of my design philosophy. The intent is to view the board from the perspective of the active player. Player moves are also factored into the design. When determining move logic, all that needs to happen is comparing against '0'. For checking the whiteness or blackness of a piece, or...
I just built a simple calendar app using angular 8. I would like to get some suggestions for improvements in the project. any feedback will be appreciated. I would like to know what I could have done better in the application in terms of both typescript code and overall app design. this is the github link for my projec...
Please review my code where I want to handle the timeout errors and send parsed JSON response if any. There are times when a POST request does not ALWAYS return JSON code. def use_service(branch: str, relative_url: str, request_type: str = 'GET', data=None, retry=1): """ :param – relative_url – the relative url...
I'm trying to do some task scheduler and worker. Tasks are added to the queue from which worker retrieves and processes them. Tasks from one queue must be executed sequentially. Tasks from different queues are executed in parallel. When the worker has completed all the tasks in the queue, he waits for a while and finis...
I'm doing a Java software engineering team project in school and my team has decided on a Finance Tracker application, which contains the main components of Expense, Budget, Statistics, Suggestions and GUIPanels. Currently, the application only allows actions(add, delete, edit) on an expense to revolve around a primary...
I've written a small script to calculate Collatz sequences. For background, read here about the Collatz conjecture. Largest number I've tried so far in my implementation is 93571393692802302 (which wikipedia claims is the number requiring most steps below 10e17), which needs 2091 steps. Apparently I count different fro...
How to open an input file programmatically (javascript) in a reliably way? The most modern versions of internet browsers prevent the opening of input files programmatically (javascript) under certain circumstances. For this reason I opened this thread to define a way to open input files so that we have no problems - or...
I begun to work for a company which do not have enough time to practice code review. As a beginner programmer I would like to improve my skills on real working cases. I have been asked to facilitate translations on "tableau workbook" files (those are just XML files) by replacing french text with English one. I work in...
Follow-up from: Back to Basics - Tic Tac Toe Again, any optimizations and critique is welcome! I'm particularly interested if it involves numpy, scipy | bitwise operators. import numpy as np from random import randint def print_board(board): print(""" +---+---+---+ c | {} {} {} | + + + + b | {} ...
I've translated an implementation of strlen in x86 assembly to C and added alignment checking: #include <strings.h> #include <string.h> #include <stdint.h> #define NOT_HIGH_MASK 0x080808080 #define HIGH_MASK 0x7f7f7f7f #define LOW_MASK 0x01010101 #define mul4(x) ((x) << 2) #define div8(x) ((x) >> 3) size_t strlen(con...
I need to find a root of strictly monotonic function f (only raising or only lowering). There is only a one root of a function. If given range from a to b doesn't contain root (fabs(f(a)*f(b) is not lower or equal than 0), we need to change range, since the assumption is that there is a one root, so we need to move on ...
This is my implementation of the suffix tree using the O(n^2) naive algorithm recursively. It is also my first big project in which I've used all the knowledge I have acquired about C++ so far. I would appreciate any advice on how to improve my code and make it compatible with the modern C++ best practices. SuffixTree....
As an exercise, I want to rewrite a C++ program to import measurement files (and later create excelsheets, reports ...). The measurement files split in 2 files, a binary file, and a xml-file. Because I can't control how the vendor might change the file structure or the names for data, I thought up a way, to put them as...
I made a SHA256 hash bruteforcer as my first program in Rust. It's very specific to what I'm trying to bruteforce and I'll probably never find it. I translated it from Python to make it faster, but can I make it even faster than this? // Disable snake case warning #![allow(non_snake_case)] extern crate crypto; extern...
My code picks a value from a too large csv file (~300MB.) at a given index i and j (assuming the csv as 2D array because it contains just data without headers), it works but it is slow. Is there other method to pick a value from csv file faster? import java.io.BufferedReader; import java.io.InputStreamReader; import ja...
It is a usual pattern when creating a new component, to load references to other components of the same GameObject. Here is an extreme case: [RequireComponent(typeof(Animator))] [RequireComponent(typeof(SpriteRenderer))] [RequireComponent(typeof(Stats))] [RequireComponent(typeof(Hunger))] [RequireCo...
I have been building my data access layer and performance is key for the project I am working on. I have chosen to use Dapper and dotnet core 3. I want to make use of the latest and greatest async features in dotnet core and Dapper to allow for smarter resource allocation under heavy load, however there is not much do...
I am working with a library that has a base class Base, and three class descending from it Destination, Amenity and Landmarks. The Base class looks something like this public class Base { public Integer id; public String externalId; public Base() { } public int getId() { return this.id; ...
I've written a simple unconventional calculator application using Python and tkinter. It's unconventional because you use the "modes" (+ - * /) to add to the current sum, instead of entering in a statement and doing that calculation. Because of this, 0 is not included. The main part of my program I would appreciate bei...
I recently got some help from Stack Overflow on my Tic-Tac-Toe code for the win conditions, but I think it could be optimized a little more. Any tips? moves = [["1", "2", "3"], ["1", "2", "3"], ["1", "2", "3"]] acc = 0 def win(letter): for i in range(3): if ((moves[i][0] == moves[i][1] == move...
The following code is greatly inspired on this question and this answer. That answer works quite well for a specific case, but I was looking for a solution that: could be used more generic (so I can put this in a base library and never have to think about it anymore). got rid of the Find() and replace it with a O1 dic...
I started learning Haskell a while ago and now I am in this dangerous state where I can produce code that does things but which probably makes experienced developers hit their heads against the wall :) So I thought I'd try posting it here and get some feedback. The problem I'm looking at is the "Longest Substring Witho...
I hacked a way to print a christmas tree, to use it in the usual seasons greetings email, you know the drill. Next Step is to integrate a multi lines of text in the border left side of the tree. For this i like to use an offset to the TREE['center']. """ Seasons Greeting mail - ascii Christmas Tree """ import pprint im...
I have a class MassiveDTO that contains lists. At some point in the project, I need to generate an object of this class, that will contain some hardcoded data. I would like to know if there is a better way (or a design pattern) to populate those lists with known data. With the method generateLists I populate them and...
I was doing this algo on leetcode: https://leetcode.com/problems/subtree-of-another-tree/ Question: Given two non-empty binary trees s and t, check whether tree t has exactly the same structure and node values with a subtree of s. A subtree of s is a tree consists of a node in s and all of this node's descendants. The...
I am getting used to how things should be written/thought about in (idiomatic) Haskell. I wrote a FizzBuzz program that prints to the console. I wanted to generate things from the core info of the divisors and the strings that go with them, and an array of such rules to be processed. This is in some sense a port of my ...
I've tried with: dictionary.TryGetValue("MoreDetails", out bool MoreDetails); but if the key is not present it defaults to false, and I need it to default to true. Else I have this working implementation: Dictionary<string, bool> CheckNullsSectionsVisibility(Dictionary<string, bool> dictionary) { bool Summary = tr...
Of the languages that I use, I have the most experience with C++. I am looking to sharpen my skills with C, so I wrote this small calculator program. What I have here is a sample of how I would probably write larger programs. #include <stdio.h> #include <string.h> int getSumInteriorAngles(const unsigned int numSides...
I am given a short int. I need to print the bits of it into two bytes. My code is as follows: #include <stdio.h> union info{ short z; struct data{ unsigned a:1; unsigned b:1; unsigned c:1; unsigned d:1; unsigned e:1; unsigned f:1; unsigned g:1; un...
Follow up to: Printing Command Line Unicode Chess Board A couple people from the previous question mentioned looking into coloring the command line with ANSI escape sequences. In Python, colorama seems to handle this quite nicely. Below is my attempt at using it for printing out a chess board. from enum import Enum f...
Currently, I'm going over the CTCI, I'm working on the problem removing the middle node. I'm using Ruby to go over these problems. I have the following solution. def remove_middle_node node = @head count = 1 while(node = node.next ) count += 1 end # reset node to point to head node = @he...