All Questions

Filter by
Sorted by
Tagged with
1
vote
1answer
11 views

Updating NamedTuple members based on a function and previous value

I'm using a NamedTuple to represent the state of my game while it's running. The user can alter these settings using key presses, so in my PyGame key handler, I'm ...
2
votes
2answers
48 views

program options from command line initialize

I'd like to receive a CR for the following command-line program options' initializing using boost::program_options. I'd like to know if there is a better way of ...
2
votes
0answers
5 views

program options from command line initialize [v2 - after CR]

After getting a CR from @pacmaninbw and @ALX23z here, I want to share my new code, and to ask for better ways (which always exist) to improve the code, even with new libraries. The only thing that ...
1
vote
2answers
46 views

Breadth-first search(BFS) Implementation in Python 3

I have implemented a BFS. Does this look like a proper implementation of BFS in Python 3? And if you think something needs to be improved, say it. ...
1
vote
2answers
56 views

Palindrome and Reverse a String Problems (JavaScript, Python)

Problem 1 Given a string, the task is to reverse the string and return a reversed string. Problem 2 Given a string, return true if the string is a palindrome or false if it is not. Code Just for ...
1
vote
0answers
5 views

LeetCode: Diameter of Binary Tree

https://leetcode.com/problems/diameter-of-binary-tree/ Given a binary tree, you need to compute the length of the diameter of the tree. The diameter of a binary tree is the length of the longest ...
3
votes
3answers
98 views

C# Bowling Game interview test

I recently interviewed for a software engineering job that requires at least one year of C# and experience with the Microsoft stack. Even though I made it clear at the outset that I had zero ...
1
vote
0answers
9 views

leetcode 230: kth smallest element in a Binary Search Tree

Here is my implementation: the goal of the algorithm is to find the kth smallest element in a BST. ...
4
votes
1answer
75 views
+50

Splitting each word using longest substring that matches in a vocab/dictionary

This function takes in a string and a fixed list of vocab: splits a string into words by spaces for each word, check in the dictionary/vocab and find the longest matching substrings, if none matching ...
-4
votes
0answers
27 views

Can't replicate code with the same logic [on hold]

The code that gets the right value (Utility percentage) ...
5
votes
1answer
33 views

“Bigint” decimal to two's complement binary list of bytes in Python

I'm toying with the idea of writing a "bigint" library in 6502 assembler that would handle variable-length integers up to 255 bytes long. Since this would be unit tested using pytest, and to help wrap ...
5
votes
1answer
35 views

Log Text Messages In Google Sheets

This script sends and receives text messages and logs responses in a google sheet. Demo Gif here: https://github.com/RyGuy96/HealthTracker. I'm a self-taught beginner coder just starting my formal ...
-4
votes
0answers
21 views

Need help converting my program to M-V-C [on hold]

I'm currently doing a course in Object Oriented programming in Java, and we need to create a game using JavaFX and the Model-View-Controller approach for our last lab so my lab partner and me chose to ...
4
votes
1answer
30 views

Creating procfs entry on linux in Kernel Module

My Linux kernel version is Linux version 5.0.0-29-generic I'm currently learning how to write kernel modules for Linux and implemented this simple module which ...
2
votes
0answers
43 views

Checking an array is sorted in either order efficiently

Here is my code, it works fine, just wondering if there any anything to make it even better. ...
-2
votes
0answers
24 views

code works but shows wrong values [on hold]

Hi I am new to programming while trying to execute this script the input file has this form (in this case they are called nohd*.txt files) ...
1
vote
0answers
11 views

Monitoring Traces for Satisfaction of Temporal Logic Properties

I am trying to implement a monitor for a certain temporal logic. What this means is the following: There is some external source, from which a trace of items are coming. An item looks like a ...
1
vote
1answer
30 views

Is this PHP code for blacklisting and rewriting/redirecting URLs good?

We faced an issue where URLs had a wrong "subfolder" in its URL, so e.g. example.com/match1/randomgenerated should have been ...
1
vote
0answers
21 views

Message handling: Should a test/spec do it?

I am currently implementing an app that uses an architecture based on features & usecases and message sending. Features are created with message handler passed in. To test the feature, a handler ...
9
votes
1answer
3k views

Implementing my own signal slot mechanism using C++11

I programmed in C# and I used the Qt framework. Both of them have their own signal slot mechanism which are really powerful. I looked at several implementations in C++ and based on what I learnt from ...
4
votes
1answer
84 views

Random password generator that ensures diversity of character types and absence of confusing characters

I wrote the following password generator, to generate a password in which each character group appears at least at once. ...
7
votes
2answers
1k views

Compacting code for World's Hardest Game remake

I was wondering if someone could quickly skim over this for me really quickly and tell me if there's anything I could improve code-wise. What I have right now seems pretty big and clustered, and I'm ...
7
votes
4answers
1k views

Replacing each letter with the letter that is in the corresponding position from the end of the English alphabet

I wrote a small program for hyperskill/jetbrains academy to encrypt the message "we found a treasure!" and print only the ciphertext (in lower case) by replacing each letter with the letter that is in ...
5
votes
1answer
1k views

RSS parser for Node.JS

I would like someone to review this code and tell if it can be done better, or if the code is elegant and simple enough for the task at hand. I used code climate and I got 4/4 and my test coverage is ...
5
votes
4answers
109 views

Morse Code Converter in C

I'm learning C so I thought to apply it to miniproject on reddit. The smorse function takes in a string and spits out some morse code. It works if you supply the function with only lowercase letters. ...
3
votes
0answers
12 views

Passing around context.Context in Golang

I am currently "gracefully" handling HTTP server net/http shutdown which works perfectly fine (I am not asking you to review server shutdown). As seen in the code ...
6
votes
4answers
2k views

Find the closest enemy

I'm currently creating a 2d game in python. I have to calculate the closest enemy so the player knows which one to target. I have the following function to accomplish this task: ...
2
votes
2answers
106 views

Brute-force ID reversal search

EDIT The random number generator in this code is a blackbox for a similar algorithm that isn't publishable for privacy concern. The algorithm works in similar way, in that it takes in a seed value ...
1
vote
1answer
173 views

Computational verification of Collatz conjecture using OpenCL

This code review request follows my previous request Computational verification of Collatz conjecture. Unlike the previous program (which was designed for the CPU), this code should run on modern GPUs....
0
votes
1answer
45 views

Python - 'if name in dict:' OR 'try:/except:' [on hold]

I'm writing some OO Python and I would like to know which of these methods is more pythonic, or which is generally better, or faster. This is an accessor for an attribute which is a dictionary. ...
9
votes
3answers
5k views

Take previous element from array if condition on current element matches

Any ideas to simplify this beauty; I would prefer a LinQ expression if possible: ...
-2
votes
0answers
28 views

2 player dice game, assistance needed [on hold]

The players roll two 6-sided dice each and get points depending on what they roll. There are 5 rounds in a game. In each round, each player rolls the two dice. The rules are: The points rolled on ...
5
votes
0answers
938 views

B+ Tree Visualization in LaTeX/TikZ

I have written a LaTeX package to visualize B+ trees. The main purpose is to provide a simple but powerful package which provides a convenient interface. However, this is my first LaTeX package and ...
9
votes
4answers
16k views

Splitting URL query string to key-value pairs

I have a URL query string "key={value}&key2={value2}&key3={value3}" and have to produce a key-value pair of the string by splitting ...
1
vote
0answers
25 views

Size out of limits in array made with malloc [on hold]

I'm applying what I learned in statistics class to a program to calculate everything automatically, but encountered an unexpected 'mistake' in my code. I say unexpected, because it's not the first ...
1
vote
0answers
4 views

Changing opacity of KML file (with icon linked) fetched in the Leaflet Map

I have a solution for making the .kml file transparent in the Leaflet Map. The working code looks like this: ...
4
votes
2answers
55 views

C# Cryptography Interface

C# lacks a common off-the-shelf encryption and decryption interface for dependency injection. Nearly every codebase I've ever opened has a couple of extension methods for hashing strings and so on. ...
2
votes
2answers
156 views

Simple menu with descriptions

If one menu-item is clicked then the description with the same data-filter attribute should be shown. I added a class to the description elements to associate each one with the affiliated menu item. ...
4
votes
1answer
1k views

Elevator code for a game called ROBLOX

Are there any ways I could improve speed and less code? The elevator that uses this script works fine. Could anything be better? ...
-2
votes
0answers
9 views

TCP reassembly not happening with windows APIs in WINDOWS APPLICATION .NET [on hold]

I refereed to your answer on : "Always stay connected" mechanism for socket connection ...
4
votes
1answer
52 views

99 beers song in Rust

I'm learning Rust. I find it sometimes confusing when compared to other programming languages, especially when dealing with strings and slices. Her's an implementation of the 99 beer song that I've ...
-2
votes
2answers
15 views

Implement state eraser for NIST DRBG and other crypto primitives using macro

As a spare-time personal project, I'm implementing a set of symmetric-key cryptographic primitives. One thing I've left vacant for a long time, is the key/state eraser, which I decide to add right ...
4
votes
2answers
63 views

Target Sum leetcode

I am trying to solve this problem You are given a list of non-negative integers, a1, a2, ..., an, and a target, S. Now you have 2 symbols + and -. For each integer, you should choose one from + ...
19
votes
4answers
2k views

Matrix class in C#

I've been learning C# during my free time in the past months; before that, I was mostly writing Java, so the transition hasn't been too hard, but I've never had my code reviewed or read by someone ...
8
votes
1answer
1k views

Python CSV to XML converter

I'm creating an application that reads in data from a CSV file and creates an XML file using LXML. The below code works as expected. However, before I develop it further I would like to refactor it ...
2
votes
1answer
33 views

d3.js canvas performance

I've just rewritten this code (a simple gravitational restricted n-body simulation) to display using canvas, rather than SVG. The reason being that I'd like to be able to run it with many thousands of ...
-4
votes
0answers
22 views

How to find the Area of an Irregularly Shaped Room [on hold]

I'm having trouble figuring out how to solve this. Remember the formula for finding the area of a rectangle is length * width and the area of a right triangle is 0.5 * the base * height. Sample run ...
5
votes
1answer
33 views

Simplified Blackjack in Python

I just started learning python a couple of weeks back from and like many others here, I too seek feedback on my simplified Blackjack game. I would like to know if the code could have been more elegant/...
7
votes
1answer
296 views

Truth table generator for an arbitrary function

Summary: This function generates a truth table for a boolean function of variable number of arguments. The name of the function passed and its arguments are deduced outside of the computable function ...
7
votes
2answers
62 views

Simple VGA driver for a toy kernel

I learn about OS development and follow the tutorial Bare Bones on OSDev. And I did some extra tasks from the Moving Forward section. I would like to get any suggestion about code improvement, ...

15 30 50 per page