All Questions
6,494
questions
84
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.
...
56
votes
2
answers
59k
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 (...
107
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 ...
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 ...
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>. ...
85
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 ...
71
votes
6
answers
3k
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 ...
61
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 ...
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 ...
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?
...
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 ...
43
votes
4
answers
13k
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 ...
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 ...
2
votes
1
answer
152
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 ...
74
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 ...
33
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 ...
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 ...
6
votes
1
answer
350
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 ...
83
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:
...
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 ...
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 ...
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 ...
18
votes
1
answer
6k
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 ...
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 ...
99
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:
...
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, ...
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, ...
23
votes
5
answers
27k
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 ...
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 ...
20
votes
3
answers
3k
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 ...
17
votes
3
answers
938
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...
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.
...
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 ...
10
votes
0
answers
698
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 ...
9
votes
2
answers
247
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 ...
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. ...
6
votes
1
answer
174
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 ...
5
votes
1
answer
258
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 ...
3
votes
0
answers
142
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 ...
58
votes
9
answers
13k
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 ...
53
votes
4
answers
34k
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 ...
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 &...
43
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,...
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 ...
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
...
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#
...
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 ...
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 ...
12
votes
1
answer
176
views
YAuB - Micro Benchmark Follow-on
Following some great advice here from Simon, I realized that I had over-engineered things, and that the Task builder methods were a horrible Java8 abstraxction. In Simon's words: "From a usability ...
12
votes
3
answers
6k
views
Project Euler Problem 12 - triangle number with 500 divisors
I've just done Problem 12 of Project Euler:
What is the value of the first triangle number to have over five hundred divisors?
The \$N\$'th triangle number is the sum of all natural numbers ...