All Questions

60,277 questions
102 views

Lazy, Functional Parser Combinators

Parser Combinators are the amazingly elegant way to write parsers that has evolved over on the functional programming side of the world, but have been less available or accessible for imperative ...
42 views

whitelist for textarea and save input to file

I'm working with product codes, so a user can only scan these type of product codes into a textarea. I don't know if my code is best way and good performance. I'm using a whitelist solution for ...
10 views

Collect maximum fruits in two baskets of at most 2 types of fruits

The task is taken from LeetCode In a row of trees, the i-th tree produces fruit with type tree[i]. You start at any tree of your choice, then repeatedly ...
98 views

Optimal burger-eating challenge

Little history to give context to the problem: The Krusty-Burgers Homer Simpson is a smart guy who likes to eat Krusty-Burgers, and it takes m minutes for Homer ...
42 views

A recursive Boggle solver

`Boggle is a word game in which letters are randomly placed in a 4x4 grid e.g: A D Q P N L E M O S R T V K J H Words can be started from any letter and are ...
8 views

Print a Connect 4 grid based on some rules for each cell

In a game of Connect4: we start with an empty grid two players place pieces X and O on the grid the first player to achieve 4 pieces in a line wins! this is a text based console game Here is the ...
27 views

Modularized JavaScript event handler to increment counters

In the following code we use the function Incrementer (capitalized for clarity, despite that it's to be used without new), to ...
11 views

Is the code below an efficient way to get the zip file from the server? The code works fine but I'm wondering if I should throw some exceptions for the following conditions: ...
33 views

Function to parse a Javascript object and return a CSV

This function converts a Javascript Object into a CSV. ...
24 views

Binary Search Tree to store objects now with improvements

Objective: I'm trying to create a BST in order to insert Packet objects for search purposes. Packet holds information like partId, ...
78 views

A small PHP library for styling terminal output

I've attempted to make a small PHP library for styling terminal output using ANSI escape sequences. The repo is located here. To be honest, I am not really satisfied with the current structure of my ...
14 views

Compact command line argument parser : Revisited

This question is a follow up to my previous one which can be found here. The user dfhwze suggested me to look into compiler construction and recommended me to write a lexer and a parser that would ...
59 views

Initialize various commands for the SqlDataAdapter

This is my code for my SqlDataAdapter which is similar to the code example given in the docs: ...
53 views

Find 4 points which form a square with the biggest area

I have set of points on the coordinate plane. I need to find the 4 points which form a square with the biggest area. I'm new in JavaScript so I'd like to get any suggestions about code style, ...
50 views

Simple local cache that checks by date else get from db

I'm looking for feedback on how this can be improved. Basically what I'm trying to do is check if the cache has the object, else check from the database. I have a list of ids, then I separate them ...
59 views

Beginner Console Conway's Game of Life in C

For an Information System Security course I've applied to, I need to learn C and decided to start learning it yesterday. Conway's Game of Life has historically been a good project to start with, so I ...
36 views

Update a table based on other table

I created this simple macro that works fine for its purpose: allow the user to create a list of updates that need to be made based on groups in a target table (to basically do mass updates). However,...
474 views

“Nice Angles” - Code Eval challenge

Out of fun, I solved "Nice Angles" challenge on CodeEval in C# 4.0: CHALLENGE DESCRIPTION: Write a program that outputs the value of angle, reducing its fractional part to minutes and ...
89 views

Program for activity selection exceeds time limit

I've been trying to solve this problem for some while and the solution I have come up with exceeds the lime limit by 1-3 ms and 2 out of 10 tests get a memory issue error. Why is that? This is the ...
34 views

SQLite In-memory Database That Inserts Data Read From a CSV File

I wrote this program to make a simple in-memory database using SQLite and JDBC. Requirements I was trying to accomplish are below. It should consume a CSV file, parse the data, and insert it into the ...
64 views

Binary Search Tree to store objects by object ID

I'm trying to create a binary search tree that would be used to insert my Packet objects'. It holds information like partId, ...
106 views

Build WHERE clause for search conditions

Here is a set of classes that are used to build where clause for SQL Server and Oracle for different field types e.g. text, <...
31 views

Iterable hashtable implementation in C

I'm just finished my version of iterable hashtable. I want to review code in general (code style, data structures, remarks about the algorithms) and I have some questions: I don't know how to ...
324 views

Prime sieve in Python

I was trying to write Sieve for the first time and I come up with this code ...
29 views

Sodoku solver with arrays of bitsets

I wrote a quick sodoku solver as an exercise and am curious how to make it faster. Parsing and printing is largely irrelevant only there for readability. How can I make the code cleaner and faster? <...
14 views

Print out a number without knowing its length firstly in LC-3 Assembly language [on hold]

The picture above is my homework. I just don't know how to solve the problem when printing out a number when it contains a vary of numbers which can lead to 5,6 or 7 characters per number. I think we ...
1k views

Find the common ancestor between two nodes of a tree

Here is my code in Python for to find a common ancestor between two nodes in a particular tree. This is a question from Cracking the Coding Interview that I decided to implement on my own. No one has ...
94 views

Async concurrency prevention class

Because I'm quite naive regarding C#'s Task Asynchronous Programming and concurrency in general, and because it's so difficult to test, I'm concerned about the safety of this code. It's likely that ...
38 views

Simple PyQt5 Window

I have started learning PyQt5 and wanted to create a simple window to test my skills. So I have created this window and I want to receive reviews on any aspect of the code. ...
210 views

Regex version of strip() - Ch. 7 Automate the Boring Stuff

Here is a practice exercise — Regex version of strip() $-$ Write a function that takes a string and does the same thing as the ...
70 views

Performance issue with empty lists

Here's my updated version of the problem I posted at Calculating time windows for entities, adding in suggested changes as well as a change I did so that the Reflection is 'cached' in a ...
31 views

I'm trying to organize my gallery, and I have certain folders rife with copies. My daily work is mostly javascript and php, being your generic web developer. However I took this as an opportunity to ...
24 views

EEPROM-based filesystem, aiming for Misra C++ 2008 compliance [on hold]

I'm writing code for embedded systems (IAR compiler) and it should adhere to Misra C++ 2008. This limits the available features of the language quite a bit (no C++1x features, use of the standard ...
23 views

Parallel Miller-Rabin Prime Test in Haskell

I implemented a prime number finder using the Miller-Rabin prime test in Haskell and it seems to be working. You enter a number and it finds the next prime following that number. I also tried to make ...
30 views

Python adding partialmethods to a class at compile time

I am writing a class for delayed operations on variables which are resolved at a later time. I am using pythons operator overloading but my class definition seems very boilerplatey. Is there a more ...
26 views

Whiten black contours around a skewed image

I have this image: I want to whiten the black contours (borders) around it without affecting the image content. Here is the code I used: ...
716 views

Heavily limited premature compiler translates text into excecutable python code

My goal is to write a smaller compiler-like program, which allows me to draw geometric shapes into a 3D Diagram. There is no need for turing-completeness and the program should only be viewed as an ...
18 views

How can I use fetch to store both image and text at a same time? [on hold]

I tried using formData.append() to mix both image and JSon object, but it is not working... Only image goes to the server but not username,usereamil and userpassword, it shows empty for them This is ...
34 views

C++ wrapper around uniform mt19937 SequenceContainer [on hold]

With the following interface in mind EasyRandom<unsigned int> prng(a, b); auto x = prng(); // scalar auto v = prng(10); // vector I wrote the following ...
19 views

Best way to check if data exists in database using service, Unit of Work and Repository Pattern in c# [on hold]

What is the best way to check if an data exists in the database i am using service, unit of work and repository pattern I don't how check the data in present in database are not ...
38 views

Create a csv of file attributes recursively from a directory parameter in PowerShell

I'm a bit new to PowerShell and was wondering if there are any improvements I could make to the following script. Any suggestions for style, code, etc. are all welcome. I'm not sure if there is a ...
80 views

Typeclass-oriented example project with implicit classes

The following code will only be an example of a project that due to (nested) higher kinds heavily relies on typeclasses for its DSL. When reviewing the code keep in mind that this is an example ...
20 views

Elegant and secure way to create a dynamic query

I want to create a dynamic query to display: all the invoices if the user has moderator rank only his invoices if the user is a simple member code ...
685 views

Primes and SemiPrimes in Binary

I'm in the midst of re-learning python. My current effort is an implementation around prime factorization. I am attempting to reproduce something similar to the table found here (in binary): https://...
16 views

App growing ugly with multiple state components

A couple of weeks ago I started a little project, I was learning node/express/mongo and I though it was a good idea to start building some app so at least I could refresh my basic React knowledge. ...
55 views

Password validator making zxcvbn easy to use with Django

This is a translatable password validator for django, based on zxcvbn-python and available with ...
297 views

Calculating time windows for entities

I have made some code that operates on multiple entities and creates 'time windows' for them. Basically, the entities will contain states, usually in boolean or int. They will be timestamped and in ...
28 views

Using functional interface arguments in methods of services injected via Spring

Here is the working code for my Spring service: ...