All Questions

Filter by
Sorted by
Tagged with
2
votes
1answer
25 views

Ranges of enum members that dwim

Inspired by this blogpost I decided to try and make it possible to have ranges of enum members that dwim, aka. that contain the actual members and not a stringified ...
3
votes
2answers
92 views

Implementation of tree with different node types and faux-polymorphism in C

I'm currently learning C by working on my first project. It's a calculator with a parser that transforms input into an operator tree. These trees consist of nodes of different types: Operators (inner ...
4
votes
0answers
23 views

User-focused timeline logging

I'm working on a small piece of my personal website. I'd like a timeline logging all of my relevant achievements in my career in Computer Science, in general. I'd like to implement a feature that ...
-1
votes
0answers
43 views

Longest palindrome substring [closed]

Can you help me calculate the time complexity of this code which calculates the longest palindrome in a given string? ...
1
vote
1answer
86 views

Way to check if a byte array contains another byte Array

I'm checking if an byte array contains a another Byte Array with this Code: ...
-3
votes
0answers
24 views

Can anyone test my python encryption program? [closed]

My name is Valentino, I am 14 years old and I have just created an encryption program. I haven't got many people to try it yet and wondered if anyone would try it and give me feedback for further ...
7
votes
2answers
159 views

LeetCode: Burst Balloons C#

https://leetcode.com/problems/burst-balloons/ Given n balloons, indexed from 0 to n-1, ...
3
votes
1answer
57 views

Check all permutations of generic type parameters

I have a function that takes an object ("token") and three additional parameters of different types ("obj1", "obj2", "obj3"). The object "token" has an 'IsSatisfied' method that may take none, 1, 2, ...
3
votes
1answer
44 views

Function to determine the effect of a lightning bolt on a game character using “abilities” [closed]

I'm writing my first game and would love some advice on how to get away from all this hardcoding I'm using... Each Character has "abilities" (all individual functions) but I can't seem to figure out ...
3
votes
4answers
181 views

Java creating augmented array of size 400,000,000

I was solving one competitive coding question having integer bounds 2^100. Fortunately, it was a dp question and I didn't need an array of that size. Practically we ...
2
votes
1answer
30 views

Shopify monitor that utilizes redis for caching each product

This is just a simple monitor for shopify products for an array of sites. It involves parsing the /products.json of the site, checking if each product ID is already stored as a key in redis and if it ...
11
votes
2answers
121 views

Segmented wheel Sieve of Eratosthenes in Python

Here is a new version of a segmented and wheel factorized Sieve of Eratosthenes. It currently uses mod 30 wheel factorization to eliminate multiples of 2, 3, and 5 in the sieve data structure to gain ...
-4
votes
0answers
77 views

binomial distribution [closed]

The code below was amended to handle more cases 0 probability of success for 0 number of successes 0 probability of success for n number of successes p probability of success for 0 number of ...
0
votes
0answers
21 views

Lee Algorithm related C++ code has a memory issue [closed]

Today, I've been trying to solve some exercises with queues and I've bumped into one that uses the Lee Algorithm for pathfinding. After testing it and seeing it ...
2
votes
1answer
94 views

Simulate Tic-Tac-Toe game in Python

Simulate a tic-tac-toe game Requirements A player is picked at random as a first player. The two players plays tic tac toe game. The game ends when the board is full or either one of the player ...
-3
votes
0answers
30 views

Is it okay to divide a single line of code into several lines using “ \ ”? [closed]

First , let's get a few things out of the way : first_name = input("What's your first name? ") last_name = input("What's your last name? ") This is a single line ...
-4
votes
0answers
21 views
2
votes
0answers
94 views

Split a string into valid words

I am trying to solve this LeetCode question: Given a non-empty string s and a dictionary wordDict containing a list of non-empty words, add spaces in s to construct a sentence where each word ...
1
vote
0answers
7 views

Command-line implementation of Mastermind (Ruby)

I just finished this command-line implementation of the Mastermind board game that allows two players to play against each other. I'm fairly new to Ruby, but I think I did a decent job with this. ...
-3
votes
0answers
20 views

Standard deviation calculation - am I following the right approach. How do we find SD percentage? [on hold]

I have a query which gives me below data. item_name, total_purchase_count_per_week, previous_day_purchase_count. For ex, ...
8
votes
2answers
124 views

My third game - Poker hand strength analyzer

I'm writting this poker hand evaluator and it's really coming along. But, as you can see I repeat myself many times and I would love to know what's your thought process when you're repeating yourself? ...
1
vote
0answers
10 views

Angular 6+ Conditionally Chained HTTP Calls

I have a number of async calls that get chained conditionally based on the previous data dependency. I.e. perform call A -> if the result is defined/not an error execute a side effect, if not perform ...
4
votes
1answer
42 views

Parsing and formatting var_export() string

I have this script to format var_export's result string. The information in the output is good, but I need know if the code performance is good or if it can be improved. https://wtools.io/php-sandbox/...
7
votes
1answer
49 views

Loading BitmapImages out of a Zip file

I'm working on a personal project to get better with C#, and as part of that I have a zip file with 20 or so images saved inside. I want to load those images out of the zip file and display them in my ...
1
vote
1answer
44 views

Tower of Hanoi, ASCII animation with ANSI escape codes

A few days ago I saw a nice video on YouTube with prof Thorsten Altenkirch about recursion and the Tower of Hanoi puzzle. Today I tried to reproduce the code from the video and came to this: ...
1
vote
1answer
36 views

Median-of-medians/quickselect filter in C

I wrote a quick-select filter in C on Wednesday. (The code is below.) It is a filter in the UNIX tradition: It reads from standard input k, the rank of the ...
1
vote
0answers
101 views

LeetCode: critical connections in a network C# (Tarjan's algorithm)

https://leetcode.com/problems/critical-connections-in-a-network/ Please review for memory and runtime performance. There are n servers numbered from 0 to n-1 connected by undirected server-to-...
2
votes
1answer
69 views

Populate an ArrayList of different instances of a class

First of all, here is an overview of my application. I want to create a multiple-choice app, on android, using data stored on a remote MySQL database. The DB has 100 questions that will appear in ...
3
votes
2answers
73 views

Two classes for avoid confusion when handling degrees and radians

Experimenting with operator overloading for the first time. Based on my reading, it appears to be a bit of a minefield. Have I fallen into any traps? ...
3
votes
1answer
39 views

Quick Sort implementation in python

Implemented the quick sort algorithm in python, It was just for learning it, now I want to port it to C. Thoughts on the quality of my python implementation? ...
2
votes
1answer
44 views

Given an array, find all its elements that can become a leader, after increasing by 1 all of the numbers in some segment of a given length

I was successful in solving a challenge in codility, but my solution failed performance tests. How can I improve my solution? Challenge: Integers K, M and a non-empty array A consisting of N ...
-1
votes
3answers
108 views

Heap sort implementation in Python 3

This code relies on Python3.7.4 I'm learning Heapsort in python 3. Please show me the errors in my code. Runs on my computer but tell me if Python rules or not. ...
1
vote
0answers
8 views

Setting the token for API client generated instances in an Angular application

The context I am developing an Angular application who also consumes an external REST API. I am also trying the OpenAPI generator using a TypeScript template. The OK path is the following: call a ...
0
votes
1answer
63 views

Aggregating recent trading data from Bitcoin derivatives exchange

As a component of some trading software, I wrote function parse_ticks(), as part of an Exchange class that models the Bitcoin ...
-1
votes
1answer
34 views

update field when others fields are motifed [closed]

I have a class Installment and a method executeTransaction. The field totalBalance ...
1
vote
0answers
24 views

Passing JSON files through an API - node async

I am writing a small program which reads some JSON files, passes the content to an API, then saves the response in some more JSON files. A pretty simple task, and the code works fine, but I have been ...
1
vote
0answers
28 views

Pipe ResponseSpec's Body

I'm writing a utility method which pipes given ResponseSpec's body and gives to the caller a change to read it. ...
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 ...
5
votes
2answers
98 views

Optimize depth-first search for sliding tile puzzle

My current code implementing a depth-first search works well for puzzle 1. But my code is too slow; I think I use too many loops and I am not sure I am using the right data structure. So I have a ...
8
votes
5answers
910 views

String Operation to Split on Punctuation

I've a function to split text on punctuation and leave the rest of the string (including whitespace in other items of the list): ...
4
votes
1answer
54 views

Android Java Splash Screen code

Here's my android splash screen. I am trying to figure out a better way to write it. It just moves the logo up to the center of the screen. It's my third time creating a splash screen for an android ...
1
vote
1answer
35 views

Using nullable properties in a base class for record selection in Table per Hierarchy - is there a better way?

I want to be able to list every Transaction associated with a Client in date order. ...
4
votes
1answer
45 views

C Garbage Heap aka simplest memory management tool

The idea is to init garbage heap in the beginning of main, use gmalloc, gcalloc and ...
7
votes
4answers
180 views

Code that reads/writes to bytes of an ascii-encoded hex string

Problem Statement Given a hexadecimal string (hascii) and its binary specification (a list of byte field names, their offsets, and byte lengths), design classes to parse all byte-fields, cast bytes ...
7
votes
2answers
79 views

Quick Sort Implementation with iterators

Most quicksort examples online use C-style arrays and indexes. I have written below quicksort implementation with STL style iterators. It looks fine to me, but I feel like I may be making more than ...
1
vote
0answers
68 views

Generics and aggregated evaluation of validation rules

I have a custom system for data validation; it handles anything from method parameters, return values, objects, etc. The core of this system is IValidationRule and ...
2
votes
1answer
71 views

Simple Password Generator in JavaScript

...
3
votes
1answer
66 views

Code dealing with files and separate lines in them

I have been using similar piece of code since a while. I have read some issues regarding treating mapped memory as a string. I am not sure about that though. So I just use ...
2
votes
2answers
60 views

SQL prepared statement to search songs by various text fields

As we know, using PDO and prepared statements, binding a table or column using bindParam is not possible. So for this, I've figured out to use function parameters ...
6
votes
0answers
107 views

Lazy Resource Loading class in C++

Recently I was studying about the benefits and uses of std::optional in C++17 (Bartek's Blog) and there I saw a line that said "...

15 30 50 per page