Skip to main content

All Questions

3 votes
1 answer
414 views

Rock Paper Scissors without arrays and if-statements, how to reduce

As working on a little private programming challenge, I tried "Rock Paper Scissors" without arrays or if-statements. It works as intended, though, I am sure this can be done a little bit more ...
Caspar Kleijne's user avatar
6 votes
4 answers
263 views

All your Base - Exercism.io

This is an exercise on the website Exercism. I am self taught trying to learn C# and C++. This is the information from the readme. Convert a number, represented as a sequence of digits in one base,...
Milliorn's user avatar
  • 620
4 votes
1 answer
524 views

Solving a linear system with two variables

Background: Equation 1: 2x-y=6 Equation 2: 4x+3y=22 Because 1 is ax-by=c and 2 is dx-ey=f y=(a * f - c * d) / (a * e - b * d) and x is simply (c - (b * y)) / a) What I am trying to do: ...
kizzer's user avatar
  • 41
3 votes
4 answers
8k views

C# Code to Find all Divisors of an Integer

I made this so I can feed it integers and return an array with all the divisors of that integer. I put checks in in case the integer is less than 2. Order of integers in the array must be smallest ...
Milliorn's user avatar
  • 620
7 votes
3 answers
3k views

Calculator of combinations without repetition

I am interested to find an absolute value (not an approximation) of "combination without repetition" for given \$n\$ and \$k\$, or \$\binom{n}{k}\$. The brute force solution would look like this <...
pgs's user avatar
  • 922
6 votes
4 answers
612 views

Pascal Triangle calculation with BigIntegers

On a well known programming challenges website(CW) there is a Kyu2 eggs height problem that can be solved utilizing a variation of Pascals Triangles properties. The problem asks to solve ...
Miguel_Ryu's user avatar
4 votes
1 answer
645 views

Method to return center items in a 2D array

I wish to have code that returns the center items of a 2d grid. Because I need an average value. The code I came up with does what I want (see the unit tests beneath it). But I think the code is ugly ...
Mike de Klerk's user avatar
2 votes
2 answers
672 views

Convert a double to a string containing rational and surd

First off, code: ...
Happypig375's user avatar
10 votes
2 answers
248 views

Resizing a discrete uniform CSRNG distribution

I have a requirement to generate a uniform distribution of cryptographically secure random numbers. To generate these numbers I only know of the ...
Peilonrayz's user avatar
  • 43.4k
7 votes
2 answers
182 views

Sum of the reciprocals of whole numbers adding to one

I have written some code which works out which sums of reciprocals of whole numbers sum to one, e.g: \$\frac 12 +\frac 13 +\frac 16 =1 \$ \$\frac 17 +\frac 18 +\frac 19 + \frac1{10} + \frac1{11}+ \...
user124568's user avatar
2 votes
1 answer
4k views

Generating Pandigital Numbers

A Base10 Pandigital Number is a number which uses all the digits 0-9 once: 1234567890 2468013579 etc... My naive solution was just to use a bunch of nested loops to do this but it's quite slow. And ...
Eoin Campbell's user avatar
4 votes
1 answer
2k views

Truncating an integer from left to right and right to left

Project Euler problem 37 says: The number 3797 has an interesting property. Being prime itself, it is possible to continuously remove digits from left to right, and remain prime at each stage: 3797,...
Eoin Campbell's user avatar