All Questions

Filter by
Sorted by
Tagged with
85 votes
5 answers
8k views

Guessing a number, but comments concerning

I always get marked down for my comments and I just wanted to see if these comments are acceptable or what I should include/where I should include them. ...
Eric Irwin's user avatar
57 votes
2 answers
60k views

Class for reducing development time

There are many PHP PDO classes out there, agreed. However I find they do not allow for flexibility. So I created one that helps reduce development time as little as it may be but it does the job (...
Yusaf Khaliq's user avatar
108 votes
2 answers
14k views

FizzBuzz in Brainfuck

Inspired a bit by a previous Brainfuck question and the recent fizzbuzz invasion, I decided to make FizzBuzz in Brainfuck. The code is entirely my own, except for the inclusion of the Printing a ...
Simon Forsberg's user avatar
13 votes
1 answer
4k views

My first implementation of a linked list in C++

This is my very first implementation of a full-fledged ADT, which could potentially be use-ready. Now, I'm still learning, therefore I would like to ask you what I can do to further improve the ...
ImQ009's user avatar
  • 133
52 votes
3 answers
15k views

List<T> implementation for VB6/VBA

Recently I decided VB6's Collection wasn't enough for my needs, so I decided to implement something like C#'s List<T>. ...
Mathieu Guindon's user avatar
86 votes
5 answers
25k views

SudokuSharp Solver with advanced features

Even though it's the first time I'm writing something this "big", it feels like I know C# quite well (it is very similar to Java after all). It's been nice to learn LINQ also and I am very impressed ...
Simon Forsberg's user avatar
72 votes
6 answers
4k views

infix_iterator code

I've previously posted this on Stack Overflow, and am considering submitting it to Boost for wider distribution, but thought perhaps it would be best to put it up here for peer review first, and see ...
Jerry Coffin's user avatar
  • 33.5k
62 votes
3 answers
4k views

Analyzing Minesweeper Probabilities

Calculating probabilities in Minesweeper might sound like an easy task, but I've seen so many probability calculators that's either incorrect, horribly slow, or with ugly code (or all of them) so I ...
Simon Forsberg's user avatar
37 votes
2 answers
8k views

Weekend Challenge - Poker Hand Evaluation

Weekend Challenge #2 - Poker Hand Evaluation Very early I decided to support the usage of wild jokers, even though I knew that this was going to lead to trouble more work. I also wanted to support ...
Simon Forsberg's user avatar
29 votes
4 answers
7k views

Sieve of Eratosthenes - Python

I've been doing a lot of Project Euler lately and just wanted to make sure my implementation was as good as it could be. Does anyone have any suggestions to speed this up? ...
Igglyboo's user avatar
  • 447
20 votes
5 answers
5k views

Stopwatch template

It's often useful to be able to time code, for instance, to evaluate alternative approaches to the same problem. Because this is a thing I use frequently, I have created this Stopwatch templated ...
Edward's user avatar
  • 66.4k
43 votes
4 answers
14k views

A lightning-fast StringBuilder

In the process of trying to build a serializable data structure, I found myself building large strings, which gets very slow because VBA copies a string every time concatenation is performed. To ...
Blackhawk's user avatar
  • 1,134
14 votes
4 answers
3k views

Materializing any ADODB Query

Following-up on Creating ADODB Parameters on the fly and pushing the "wrapping" of ADODB a step further, I have written two more classes that allows me to expose methods that don't require a ...
Mathieu Guindon's user avatar
75 votes
8 answers
14k views

Open, write and close a file

I have a small 10-liner function that writes some data to a file using an std::ofstream. I did not explicitly call .close() at ...
dreamlax's user avatar
  • 1,128
34 votes
5 answers
16k views

Creating ADODB Parameters on the fly

I have put together a small wrapper class to simplify creating parameterized ADODB queries with VB6/VBA. At this point I'm keeping things simple, so it's only supporting input parameters and from what ...
Mathieu Guindon's user avatar
17 votes
7 answers
4k views

Project Euler #3 - largest prime factor

I was going through the Project Euler problem #3 and made a program to solve it. The problem is as follows: The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor of the ...
user2040026's user avatar
6 votes
1 answer
393 views

A recursive_transform for std::vector with various return type

This is the follow-up question for A recursive_transform Function For Various Type Nested Iterable With std::variant Implementation in C++ and A get_from_variant function in C++. Thanks to G. Sliepen ...
JimmyHu's user avatar
  • 4,380
2 votes
1 answer
163 views

A recursive_count_if Function For Various Type Arbitrary Nested Iterable Implementation in C++

This is a follow-up question for A recursive_count Function For Various Type Arbitrary Nested Iterable Implementation in C++. Thanks to G. Sliepen's answer. Based on the mentioned suggestion, the ...
JimmyHu's user avatar
  • 4,380
84 votes
4 answers
22k views

Function to print command-line usage for a program [closed]

The following function works well to print out a help message for the program I have written. It prints a multi-line string message that describes the command line usage with some examples: ...
noisy's user avatar
  • 1,001
42 votes
4 answers
7k views

Rainfall challenge

About a year ago when I was applying to jobs for the first time, I had an interview at a company and they posed the following problem to me, which I preceded to bomb. A year later I actually came up ...
Hunter McMillen's user avatar
20 votes
3 answers
3k views

A CSharpish String.Format formatting helper

A while ago I implemented .net's string.Format() method in VB6; it works amazingly well, but I'm sure there has to be a way to make it more efficient. I'll start ...
Mathieu Guindon's user avatar
20 votes
1 answer
2k views

Compile-time sieve of Eratosthenes

There are many instances of prime number sieve implementation both here and other places on the web, but I wanted something a little different. In particular, I wanted to create a static array of the ...
Edward's user avatar
  • 66.4k
18 votes
1 answer
7k views

Plot timings for a range of inputs

When writing Code Review answers, it becomes often necessary to measure how long the modified code takes vs how long the OP's code takes. I needed a nice way to visualize this as a function of the ...
Graipher's user avatar
  • 40.9k
15 votes
1 answer
2k views

Comparing std::vector<bool> to std::vector<char>

A recent comment to an answer of mine here on Code Review brought up an interesting point. The comment was that one should use std::vector<char> over ...
Edward's user avatar
  • 66.4k
98 votes
9 answers
32k views

'100' is a magic number

Magic numbers are bad... I totally agree. But there's one magic number I find hard to fix: '100' is a magic number. Consider this code: ...
janos's user avatar
  • 111k
47 votes
1 answer
3k views

Charmander Brainfuck interpreter in Haskell

I just started learning Haskell and this is my first big project (ie not factorials, fibonacci or graphers). This is kind of a gift for somebody so the language is a bit different. The program works, ...
Ignis Incendio's user avatar
28 votes
5 answers
4k views

Automagic testing framework for VBA

Building on @RubberDuck's recommendations, I now have something I find... beautiful. I'm sure there's a couple of things left to polish - this site is about making great code out of good any code, ...
Mathieu Guindon's user avatar
23 votes
6 answers
14k views

Optimize Conway's Game of Life

I have coded up an implementation of Conway's Game of Life and I have a performance bottleneck in it which I wish to be optimized. The main logic is in the Universe ...
Adam Arold's user avatar
23 votes
5 answers
28k views

Split a string into chunks of the same length

Inspired by this question in chat Is there an easy way in .NET to split a string into an array by pulling chunks of the text in. I.e. I have an 18 character string I would like in 3 6-character ...
Heslacher's user avatar
  • 50.4k
20 votes
3 answers
4k views

Recursive and flexible approach to Tic-Tac-Toe

Description This is my code for the Weekend Challenge Reboot - Tic Tac Toe Ultimate. The game can be played here: http://www.zomis.net/ttt (along with some other variations that are also use the ...
Simon Forsberg's user avatar
17 votes
3 answers
957 views

Sieve31, my sieve of Eratosthenes returning IEnumerable<int>

This very fast, simple sieve quickly finds 31 bit primes. It uses a memory efficient BitArray for odd numbers. How a 32 bit int...
Rick Davin's user avatar
  • 6,267
12 votes
4 answers
5k views

Sound manager for Android

I created a singleton class for managing sound effects on Android. This class will only be instanced and loaded once at the beginning, and each activity will use the loaded songs. I don't know either ...
FR073N's user avatar
  • 231
12 votes
4 answers
1k views

C++ string Formatter

I had an uneventful afternoon, so I thought I might try and write a string formatter. This is based on the documentation I found here. ...
Martin York's user avatar
  • 94.6k
10 votes
0 answers
715 views

Sieve32FastV2 - A fast parallel Sieve of Eratosthenes

I’ve created a much cleaner, better designed version to my parallel sieve. I’ve implemented most of EBrown’s micro-optimizations but also revamped the code on my own (that is not in direct response ...
Rick Davin's user avatar
  • 6,267
9 votes
2 answers
284 views

Hand Coded State Driven Lexical Analyzer in C With Unit Test Part A

This code review is presented in 3 questions due to the amount of code: Part A (this question) contains the Lexical Analyzer and the main portion of the unit test code. Part B contains the lower ...
pacmaninbw's user avatar
  • 23.8k
8 votes
4 answers
17k views

Random walk on a 2D grid

The program assignment: A drunkard in a grid of streets randomly picks one of four directions and stumbles to the next intersection, then again randomly picks one of four directions, and so on. ...
user avatar
6 votes
1 answer
192 views

A Summation Function For Various Type Arbitrary Nested Iterable Implementation in C++

This is the follow-up question for A Summation Function For Arbitrary Nested Vector Implementation in C++. The following code is the improved version based on Zeta's answer. I am trying to enhance ...
JimmyHu's user avatar
  • 4,380
5 votes
1 answer
204 views

A recursive_transform Template Function with Unwrap Level for Various Type Arbitrary Nested Iterable Implementation in C++

This is a follow-up question for A recursive_transform Template Function Implementation with std::invocable concept in C++ and A recursive_transform Template Function Implementation with ...
JimmyHu's user avatar
  • 4,380
5 votes
1 answer
279 views

A Summation Function For Boost.MultiArray in C++

This is a follow-up question for A Summation Function For Arbitrary Nested Vector Implementation In C++ and A Summation Function For Various Type Arbitrary Nested Iterable Implementation in C++. I am ...
JimmyHu's user avatar
  • 4,380
3 votes
0 answers
145 views

A recursive_print Function For Various Type Arbitrary Nested Iterable Implementation in C++

This is a follow-up question for A recursive_transform for std::vector with various return type and A recursive_transform for std::array with various return type. Based on these discussion about the ...
JimmyHu's user avatar
  • 4,380
3 votes
2 answers
227 views

A recursive_transform Template Function with Unwrap Level for std::array Implementation in C++

This is a follow-up question for A recursive_transform Template Function with Unwrap Level for Various Type Arbitrary Nested Iterable Implementation in C++. I am following the suggestions proposed by ...
JimmyHu's user avatar
  • 4,380
59 votes
9 answers
14k views

Project Euler problem 1 in Python - Multiples of 3 and 5

I'd like suggestions for optimizing this brute force solution to problem 1. The algorithm currently checks every integer between 3 and 1000. I'd like to cut as many unnecessary calls to ...
Robert S Ciaccio's user avatar
57 votes
4 answers
35k views

Seed std::mt19937 from std::random_device

Many people seed their Mersenne Twister engines like this: std::mt19937 rng(std::random_device{}()); However, this only provides a single ...
Baum mit Augen's user avatar
50 votes
4 answers
7k views

ASCII table in Brainfuck

I made my first Brainfuck program today, which prints the numbers 0-255 and the corresponding character. I was wondering if I could improve my program, as I'm repeating myself a lot (e.g. 3 x copy &...
Tyilo's user avatar
  • 615
44 votes
2 answers
40k views

Balanced parentheses

Given an expression string exp, write a program to examine whether the pairs and the orders of "{","}","(",")","[","]" are correct in exp. For example,...
konijn's user avatar
  • 33.1k
29 votes
1 answer
5k views

Extensible logging

Whenever I need logging functionality in .net, I use a logging framework, such as NLog. Obviously there's no logging framework for vba, at least none that I know of. As much as I love using NLog, the ...
Mathieu Guindon's user avatar
26 votes
1 answer
50k views

Snake game using PyGame

I wrote a simple Python snake game which is about 250 lines of code. Can someone give me some advice on how I can refactor/make it better? game.py ...
Ryan's user avatar
  • 711
19 votes
3 answers
5k views

RPSLS Game in C#

I went with what I know and can use well, not what I know and can't figure the syntax out to make it look good. So please enjoy the code and prepare to school me (probably in the basics) in C# ...
Malachi's user avatar
  • 28.6k
15 votes
1 answer
8k views

A simple Thread Pool

A very simple Thread pool: Any work added to the pool will be executed. The destructor will wait for all work to be finished before letting the threads stop. We then join all threads before letting ...
Martin York's user avatar
  • 94.6k
14 votes
1 answer
2k views

VBA Class to persist and restore Excel Application properties

Very often on Stack Overflow, and even on Code Review, I've seen questions and answers that have code that begins by persisting Excel properties like DisplayAlerts ...
ThunderFrame's user avatar
  • 1,959

15 30 50 per page
1
2 3 4 5
132