All Questions

Filter by
Sorted by
Tagged with
32
votes
2answers
6k 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 ...
32
votes
2answers
32k views

Custom CursorAdapter Design

Here's the code which I use for my Android custom cursor adapter which I use to bind data to my list view. ...
32
votes
3answers
47k views

Entity framework with repository and Unit Of Work pattern and POCO architecture

This is my architecture to EF4 using repository pattern and unit of work pattern with POCO. I believe I made some mistakes. I have a solution with 5 projects: ...
32
votes
3answers
779 views

Factor script to change case of all filenames in a directory

In the absence of a full-fledged tutorial, I am teaching myself to program in the Factor language by writing a bunch of functions that I will eventually use in command-line scripts. One common ...
31
votes
10answers
14k views

Sorting large 1GB file with 100 millions numbers using merge sort

My task is to sort 1GB file with 100 million numbers using merge sort without recursion. My idea is to split file into 4 pieces, then to 2 and at the end to one file. ...
31
votes
10answers
13k views

Generating Even Random Numbers

I have this class which is used as part of a game. It needs to generate Random Even values, which is done by generating random numbers until the result is even. Is there a better way to do this? ...
31
votes
4answers
3k views

When “How To Ask” is too subtle

This is the first JavaScript code I've ever written, alert("hello, world!"); aside. This site is closing quite a lot of questions because people won't read the ...
31
votes
10answers
3k views

What are some indicators that I was over-thinking my solution to this problem?

This question is a cross between career question and a code review. I was uncertain where to ask, but since there is code involved I went with CodeReview. I’m going through the process of technical ...
31
votes
5answers
46k views

Brute Force Algorithm in C

This is a simple brute force algorithm that I have programmed in C. All the program does is print out every possible combination of the given alphabet for the ...
31
votes
2answers
5k views

Tic Tac Toe C++

I made this Tic Tac Toe game and I would like to know your opinion and what can be improved. I also want advice about making it check if someone wins. I'm 10th grader, so I still need to learn a lot. ...
31
votes
7answers
249k views

Select first value if exists, otherwise select default value

Given an instance of SQL Server, imagine there's a table named Configuration, which has three columns: ID, ...
31
votes
4answers
1k views

Standardly deviated Fibonacci

I'm new to C++ (about 4 weeks with no prior programming experience in other languages) and am writing a program that's supposed to do the following: Define an array of 100 sequential numbers of type <...
31
votes
3answers
13k views

Administration Elevation

I'm looking into Administration Elevation and I've come up with a solution that seems like it's perfectly sane, but I'm still in the dark about the professional methods to accomplish this. Is there a ...
31
votes
3answers
882 views

Advanced and Detailed Minesweeper Probabilities

In an earlier question, I showed my code for calculating the mine probability for each and every field in a Minesweeper board. But it doesn't stop there. In that very same Minesweeper Analyze project, ...
31
votes
3answers
14k views

Multiple indexes over an in memory collection for faster search

I have a big in-memory collection of following simplified class: ...
31
votes
1answer
16k views

Extension methods to make ConcurrentDictionary GetOrAdd and AddOrUpdate thread safe when using valueFactory delegates

The ConcurrentDictionary<T,V> in .NET 4.0 is thread safe but not all methods are atomic. This points out that: ... not all methods are atomic, ...
30
votes
7answers
3k views

Are these if-statements too fancy?

I just rewrote this: if (budgetRemaining != 0 || totalOpenInvoices != 0) { } Like this: ...
30
votes
8answers
8k views

PI Calculator, Interview Challenge

Greg Beech says here that he asks C# candidates to produce a formula that calculates PI Given that Pi can be estimated using the function \$4 * (1 - \frac{1}{3} + \frac{1}{5} - \frac{1}{7} + \dots)\$. ...
30
votes
7answers
8k views

Checking if a number is divisible by 9

I tried to develop a new way to check if a number is divisible by 9. I have written my code and it is working fine. I'm not allowed to use *,...
30
votes
7answers
6k views

Car crash reaction time

In physics class we are doing an investigation thing. Some of the numbers might seem plucked out of thin air but they aren't. The maths is right(I think) I just want some feedback on the code. ...
30
votes
7answers
53k views

Password validation in Java

I just wrote this password validation code function that checks to see if a password will be accepted in AD or not. I'm not sure this is the best way to do it, but for now it works fine. I would love ...
30
votes
6answers
6k views

Counting rows in a CSV file that correspond to a database row, each with a million records

I have two DataTables: dt: is populated from a CSV file with over 1.7 million rows dataStructure.Tables["AccountData"]: is ...
30
votes
5answers
7k views

Print an ASCII diamond

This takes a width specified by user and prints a diamond of that width. It uses only three for loops, but could I reduce that further? Is there a more elegant ...
30
votes
6answers
4k views

Unbreakable average program

I'm creating a program that averages four numbers - three from a file and one from user input. Simple enough. But the catch is, the professor is going to be deliberately trying to break the program. ...
30
votes
6answers
3k views

To 'this' or not to 'this'?

I was given a homework and I have 2 solutions: one that uses this and other one that doesn't. I tested both solutions on jsPerf but sometimes it says the version ...
30
votes
4answers
15k views

Recording audio in C

Please note there are newer revisions of this code, one here, and one here for continuous audio recording. This is a program I wrote as a .wav audio recording library for Linux. It was developed on ...
30
votes
3answers
3k views

“Compliment giver” mini-program

I'm fairly new to programming and I decided to make a small C# console program for practice. The program asks for user input and gives a random "compliment", it also has a small chance to give a bonus ...
30
votes
6answers
3k views

Aliens at the train

I solved this problem on SPOJ: The aliens have arrived to Earth and everything is in harmony, the two races can live together. However, one specific Female Alien does not want to see humans on ...
30
votes
3answers
2k views

Regex to parse horizontal rules in Markdown

I'm the current maintainer of Showdownjs, a markdown parser off which PageDown (stackexchange's markdown parser) is based on. Showdown uses the following regex to parse horizontal rules: ...
30
votes
5answers
26k views

Int overflow check in Java

I have a piece of code that takes a couple of integers and check if performing an addition on the inputs would result in an overflow. I was wondering if this code is SOLID: ...
30
votes
5answers
131k views

Modifying an array during a foreach loop [closed]

This question is always on my mind. I usually alter the array while looping through its keys, based on my gut feelings: ...
30
votes
1answer
4k views

Full-color clone of Conway's Game of Life, with a decent GUI

I wrote this to learn JavaFX, and as an excuse to re-make the Game of Life. This is the most complex GUI I've ever written, so I'd like feedback mainly on it, but I'll welcome any criticism! My ...
30
votes
1answer
6k views

JSON Serializer

Carrying on from: Yet another C++ Json Parser Yet another C++ Json Parser (Recursive) All the code is available from git hub: ThorsSerializer but only reviewing a small section here. The idea is ...
29
votes
3answers
6k views

Decide if the sum of three numbers is even or odd

Exercise from an Assembly course I'm enrolled into: Write a program that takes three numbers x,y,z as input, and returns: 0 if (x+y+z) is even. 1 if (x+y+z) is odd. (Note that ...
29
votes
1answer
6k views

100 gunmen in a circle kill next person

I am very happy because I solved this problem with very little code: ...
29
votes
7answers
7k views

100 gunmen in circle kill next person

The question is here. 100 people are standing in a circle with gun in their hands. 1 kills 2, 3 kills 4, 5 kills 6 and so on till we are left with only one person. Who will be the last person alive....
29
votes
7answers
64k views

Check for 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
4answers
3k views

Snowfall in HTML

I am a beginner and I have made Snowfall in HTML for my mom. I'm pretty sure it will not look that awesome to any developer out there, but hey, that's why I've posted it. I'd like a general review of ...
29
votes
4answers
9k views

Beginner object-oriented text-based RPG

I'm in the process of writing a text-based RPG in Java using object-oriented programming. I'm fairly new to programming and currently learning through CodeHS and coding this within their sandbox, any ...
29
votes
5answers
1k views

I have a problem …factory

I'm creating a system to generate math problems. As you know in mathematics, there are several different kinds of problems: Binary problems, fractions, decimals, comparating two numbers, etc. I'm ...
29
votes
2answers
3k views

A grid and a menu walked into a program

A program that creates a grid 10x10 and assigns a random number in each tile. It then asks you if you want to: create a new grid view the current one count how many of each number there are in the ...
29
votes
3answers
127k views

Update only modified fields in Entity Framework

I'm working on a website on ASP.NET MVC4 and EF5. I want to ensure that only modified values are updated in the database. I'm using a unit of work pattern and repositories for data work. Here's the ...
29
votes
2answers
6k views

Lexer+Parser code for my “Reedoo” programming language

I've been working on my own programming language, as a hobby for the past couple of months now, called Reedoo. It is implemented in pure C++ 11 and uses only the libraries that come with C++; no ...
29
votes
3answers
8k views

Using default None values in Python when assigning split() to a tuple

Let's say I want to parse audio track information into two variables like this: '2/15' -> track = 2, num_tracks = 15 ...
29
votes
3answers
38k views

Overlapping rectangles

I received the following question in a technical interview today (for a devops/SRE position): Write a function which returns true if the two rectangles passed to it as arguments would overlap if ...
29
votes
3answers
2k views

Small PHP Viewer/Controller template

I have written a small template Viewer/Controller esque library that I would like some critiques on. The library is located here If you are looking for where to start, check out ...
29
votes
3answers
53k views

Impossibly fast delegate in C++11

This legendary C++ delegate article can be easily converted into C++11, without the need for fancy preprocessor magic in the original. I'd like to know if I got all the necessary C++11 nuances right. ...
29
votes
2answers
328 views

Script to enter text in a box

Here's a little script that enters text into a document when activated. ...
29
votes
1answer
3k views

Yet another 'any' class implementation, named 'some'

This is a follow-up of 'any' class implementation. After posting my answer, I kept working on the code towards parameterizing with respect to memory management as I had promised. I ended up in some ...
29
votes
1answer
1k views

Using argparse module within cmd interface

I've created an application that uses a cmd interface. It has multiple levels, and the number of available commands and their complexity is growing. As such, I need to generalise argument parsing - of ...

15 30 50 per page