-
as seen on Stack Overflow
- Search for 'Stack Overflow'
Inspired by http://xkcd.com/710/ here is a code golf for it.
The Challenge
Given a positive integer greater than 0, print out the hailstone sequence for that number.
The Hailstone Sequence
See Wikipedia for more detail..
If the number is even, divide it by two.
If the number is odd, triple…
>>> More
-
as seen on Stack Overflow
- Search for 'Stack Overflow'
The Challenge
The shortest code by character count to display a representation of a circle of radius R using the *character, followed by an approximation of p.
Input is a single number, R.
Since most computers seem to have almost 2:1 ratio you should only output lines where y is odd.
The approximation…
>>> More
-
as seen on Stack Overflow
- Search for 'Stack Overflow'
The Challenge
The shortest code by character count to display a representation of a circle of radius R using the *character. Followed by an approximation of pi
Input is a single number, R
Since most computers seem to have almost 2:1 ratio you should only output lines where y is odd.
The approximation…
>>> More
-
as seen on Stack Overflow
- Search for 'Stack Overflow'
This is inspired by/taken from this thread: http://www.allegro.cc/forums/thread/603383
The Problem
Assume the user gives you a numeric input ranging from 1 to 7. Input should be taken from the console, arguments are less desirable.
When the input is 1, print the following:
***********
*********…
>>> More
-
as seen on Stack Overflow
- Search for 'Stack Overflow'
Post your shortest code, by character count, to check if a player has won, and if so, which.
Assume you have an integer array in a variable b (board), which holds the Tic Tac Toe board, and the moves of the players where:
0 = nothing set
1 = player 1 (X)
2 = player 2 (O)
So, given the array b…
>>> More
-
as seen on Stack Overflow
- Search for 'Stack Overflow'
What is the shortest way, by character count, to find prime factors in any number?
Example Input: 1806046
Example Output: 2x11x11x17x439
Example Calculator
>>> More
-
as seen on Stack Overflow
- Search for 'Stack Overflow'
I wrote a method that recursively finds prime factors. Originally, the method simply printed values. I am currently trying to add them to a HashSet to find the unique prime factors.
In each of my original print statements, I added a primes.add() in order to add that particular integer into my set…
>>> More
-
as seen on Stack Overflow
- Search for 'Stack Overflow'
I hate to have to ask, but I'm pretty stuck here.
I need to test a sequence of numbers to find the first which has over 500 factors:
http://projecteuler.net/index.php?section=problems&id=12
-At first I attempted to brute force the answer (finding a number with 480 after a LONG time)
-I am now…
>>> More
-
as seen on Stack Overflow
- Search for 'Stack Overflow'
Is it possible to do recursion with an Func delegate? I have the following, which doesn't compile because the name of the Func isn't in scope...
Func<long, long, List<long>, IEnumerable<long>> GeneratePrimesRecursively = (number, upperBound, primeFactors) =>
{
if (upperBound…
>>> More
-
as seen on Stack Overflow
- Search for 'Stack Overflow'
I've never really bothered with math programming, but today I've decided to give it a shot.
Here's my code and it's working as intended:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows…
>>> More