0
\$\begingroup\$

Writing questions for programming puzzles is tiring and takes many minutes to do. This is where you come in. Your job is to write a program that randomly generates plausible-sounding (but not necessarily interesting) code golf questions.

Input: None

Output: One sentence code golf question (see sentence structure)

Guidelines: No hardcoding. The questions don't have to be valid, solvable, or nontrivial. Creativity is encouraged. Voting is based on variety and bonus to programs that can create interesting problems.

Samples:

Find the sum of every even number from 1 to 100.
Create a funny sentence without punctuation.
Draw a picture of a cat in 3D.

Sentence structure:

[verb] [noun goal] [of] [noun specific] [preposition] [noun restriction]
\$\endgroup\$
11
\$\begingroup\$

NetLogo

to go
  type one-of [ "Print" "Calculate" "Find" "Determine" "Output" ]
  type " the "
  type one-of [ "sum" "mean" "average" "median" "standard deviation" "product" "geometric mean"]
  type " of all "
  type one-of [ "prime" "composite" "even" "odd" "perfect" "abundant" "deficient" "square" "triangular" "cubic" "lucky" "friendly" "strictly non-palindromic" ]
  type " numbers from "
  type random 100
  type " to "
  type 100 + random 10000
  type one-of [ " (inclusive)." " (exclusive)." ]
end

Sample output (obtained randomly):

Find the product of all friendly numbers from 60 to 3112 (inclusive).
\$\endgroup\$
1
\$\begingroup\$

C

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main() {
    srand(time(NULL));
    printf("Find the sum of every even number from 1 to %d.\n", rand());
    return 0;
}

On my computer it can generate 2147483648 different challenges.

\$\endgroup\$
  • \$\begingroup\$ Hahaha. I love the simplicity (laziness?) of this one. Also, you can golf it so it's 50% #includes: delete int and return 0, NULL---> 0, text "sum of even numbers 1<x<%d?" \$\endgroup\$ – Level River St May 28 '14 at 16:31
0
\$\begingroup\$

Python

from random import randint as r
print "Draw a picture of a cat in %iD" % (r(2,4))
\$\endgroup\$

Not the answer you're looking for? Browse other questions tagged or ask your own question.