555
\$\begingroup\$

This "sandbox" is a place where Code Golf users can get feedback on prospective challenges they wish to post to main. This is useful because writing a clear and fully specified challenge on your first try can be difficult, and there is a much better chance of your challenge being well received if you post it in the sandbox first.

Sandbox FAQ

Posting

To post to the sandbox, scroll to the bottom of this page and click "Answer This Question". Click "OK" when it asks if you really want to add another answer.

Write your challenge just as you would when actually posting it, though you can optionally add a title at the top. You may also add some notes about specific things you would like to clarify before posting it. Other users will help you improve your challenge by rating and discussing it.

When you think your challenge is ready for the public, go ahead and post it, and replace the post here with a link to the challenge and delete the sandbox post.

Discussion

The purpose of the sandbox is to give and receive feedback on posts. If you want to, feel free to give feedback to any posts you see here. Important things to comment about can include:

  • Parts of the challenge you found unclear
  • Comments addressing specific points mentioned in the proposal
  • Problems that could make the challenge uninteresting or unfit for the site

You don't need any qualifications to review sandbox posts. The target audience of most of these challenges is code golfers like you, so anything you find unclear will probably be unclear to others.

If you think one of your posts requires more feedback, but it's been ignored, you can ask for feedback in The Nineteenth Byte. It's not only allowed, but highly recommended! Be patient and try not to nag people though, you might have to ask multiple times.

It is recommended to leave your posts in the sandbox for at least several days, and until it receives upvotes and any feedback has been addressed.

Other

Search the sandbox / Browse your pending proposals

The sandbox works best if you sort posts by active.

To add an inline tag to a proposal, use shortcut link syntax with a prefix: [tag:king-of-the-hill]. To search for posts with a certain tag, include the name in quotes: "king-of-the-hill".

Get the Sandbox Viewer to view the sandbox more easily!

\$\endgroup\$
0

3926 Answers 3926

1
121 122
123
124 125
131
-1
\$\begingroup\$

Silly Sentence Generator

Your challenge is to input a sentence and find all words enclosed within angle brackets. (< and >)

Here is an example:

The <adjective> <noun> biked across the bridge.

Next, replace all <noun>s with a random noun, all <verb>s with a random verb, all <adjectives>s with a random adjective, and all <adverb>s with a random adverb.

According to the above rule, The <adjective> <noun> biked across the bridge. could become The daring monkey biked across the bridge.

Your program will input a list of nouns, verbs, adjectives, and adverbs.

Make sure the words follow capitalization. So if the random noun in <noun> <verb>ed is monkey, it should then become Monkey. Another rule is that if a verb (like slide) ends with e, and the bit after the <verb> is ing or s, (e. g <verb>ing) do not keep the final e. (e. g slideing becomes sliding).

Examples

Note that these examples assume the nouns are monkey and ai, the verbs jumped and sliding, the adjective daring, and any list of adverbs (since the examples don't use them.)

The <noun> was <verb>ed by the <adjective> <noun>. => The monkey was jumped by the daring ai.

<verb>ing <noun>s play together. => Sliding monkeys play together.

Shortest code wins!

\$\endgroup\$
6
  • \$\begingroup\$ I would suggest replacing the "Test cases" section with "Examples" to show some possible outputs. \$\endgroup\$ Sep 17, 2021 at 17:44
  • \$\begingroup\$ @AaronMiller Added some test cases and additional rules. \$\endgroup\$
    – Bgil Midol
    Sep 17, 2021 at 17:53
  • \$\begingroup\$ You don't specify in these cases whether you want to be including the propagation of the word lists, etc. into the code golf challenge. If this is a requisite that the population of the lists be included in the bytes, this is going to make every 'golfed' solution pretty huge, even with small word lists you've provided. \$\endgroup\$ Sep 17, 2021 at 18:15
  • \$\begingroup\$ @ThomasWard Edited. \$\endgroup\$
    – Bgil Midol
    Sep 17, 2021 at 19:00
  • \$\begingroup\$ I think it would be better to instead take the lists of words as additional inputs \$\endgroup\$
    – Mayube
    Dec 1, 2021 at 18:33
  • \$\begingroup\$ It's still not clear if we're hardcoding the words or not \$\endgroup\$ Dec 1, 2021 at 18:34
-1
\$\begingroup\$

Output sequence from a name

You are given a sequence of numbers(0-9) which you have to convert to its literal form.

Example

Input : 1246
Output : 26666

We interpret the input as one 2 four 6, thus giving the output 2 one time and 6 four times

Testcase

Input Output
1234567809 2444666668888888
2345 335555

P.S.

  1. Is this descriptive enough?
  2. Would it be fun to do?
\$\endgroup\$
1
-1
\$\begingroup\$

Can I obtain this Minecraft item?

Given a list of items I have access to, determine if I can obtain a certain amount of some other item via crafting, mining, trading, and some other actions.

Actions

This is a list of all actions which may be performed, and what items they involve

Crafting:

  • Log × 1 to Planks × 4
  • Planks × 2 to Stick × 4
  • Dirt × 2, Gravel × 2 to Coarse Dirt × 4
  • Glass × 6 to Glass Pane × 16

Mining:

The following require a wood pickaxe, or above:

  • Stone × 1 to Cobblestone × 1
  • Coal Ore × 1 to Coal × 1

The following require an iron pickaxe, or above:

  • Diamond Ore × 1 to Diamond × 1
  • Emerald Ore × 1 to Emerald × 1

The following do not require a tool:

  • Coarse Dirt × 1 to Dirt × 1
  • Gravel × 1 to Flint × 1

Smelting:

Smelting requires fuel, see below. These are the items that can be smelted:

  • Cobblestone × 1 to Stone × 1
  • Sand × 1 to Glass × 1
  • Coal Ore × 1 to Coal × 1
  • Iron Ore × 1 to Iron Ingot × 1
  • Diamond Ore × 1 to Diamond × 1
  • Emerald Ore × 1 to Emerald × 1
  • Kelp × 1 to Dried Kelp × 1

(unfinished)

\$\endgroup\$
-1
\$\begingroup\$

Biggest 25 byte number

You are allowed 25 bytes of source code.

With these you have to calculate the biggest finite number possible, assuming infinite number precision[1], runtime and memory.

You will not be taking input and do not have to output the final result.

You are not allowed to use a String representation, so "9".repeat(BIG_NUMBER) is disallowed.

Scoring will be based of the final number, bigger numbers ranking higher.

[1]: This means that for example in java you do not need to use BigInteger to represent big numbers, but using an int would be sufficient. Over- and underflows are ignored as if the int had infinite precision.

\$\endgroup\$
-1
\$\begingroup\$

[1], [2], [1, 1], [3, 2] Sequence

Challenge:

The sequence starts with [1]

And multiply by the reversed indices plus one.

And make an extra list containing 0 length of the list times.

If the number is greater than reversed indice plus two, then modulo by indice plus two, add number integer divided by indice plus two to extra list (Previous indice).

Then the next list will be the list plus an extra list.

Example (step-by-step)

RETURN [1]
[1]
[2] [0]
[2] [0]
RETURN [2]
[2]
[4] [0]
[1] [1, 0]
RETURN  [1, 1]
[1, 1]
[3, 2] [0, 0]
[3, 2] [0, 0]
RETURN [3, 2]

Test cases

TODO

Meta:

  • Suggestions?

  • Which test cases I should add?

\$\endgroup\$
2
  • \$\begingroup\$ Adding more step-by-step examples would be nice. After [3, 2], I can get to [9, 4], but I'm not sure what to do with [1, 0] ([9, 4] modulo 4) and [2, 1] ([9, 4] div 4). Also, test cases in a sequence challenge are just a list of first X terms (20 terms would be enough here I think). \$\endgroup\$
    – Bubbler
    Dec 28, 2021 at 1:51
  • \$\begingroup\$ I think a reference implementation (even in pseudocode) would be helpful. \$\endgroup\$ Jan 10 at 12:49
-1
\$\begingroup\$

Mahjong Checker

\$\endgroup\$
4
  • \$\begingroup\$ As a real mahjong player I can tell you that it may not be enoigh to have four sets and the eye pair – flowers and animals may be needed to win. \$\endgroup\$ Feb 6 at 9:48
  • \$\begingroup\$ flowers and animals are excluded in this case, makes it a little more tricky to add more possiblities to the challenge \$\endgroup\$
    – DialFrost
    Feb 6 at 9:53
  • \$\begingroup\$ I know, but this is just for your information. \$\endgroup\$ Feb 6 at 9:54
  • \$\begingroup\$ ah ok lol thx anyways i rarely play mahjong in the first place \$\endgroup\$
    – DialFrost
    Feb 6 at 10:15
-1
\$\begingroup\$

Zhiwei Sun Squares

Given a positive integer n, find the number of ordered tuples (a, b, c, d, e) over non-negative integers for which a² + b² + c² + d² = n and b + 3c + 5d = e².

Note: A conjecture by 孙智伟 (Sūn, Zhìwěi) states that this count is always at least 1.

For example, if n is 9, there are 3 solutions, namely:

(0, 0, 3, 0, 3)
(1, 0, 2, 2, 4)
(3, 0, 0, 0, 0)

Test cases:

9 -> 3
4 -> 2
24 -> 1
25 -> 5
144 -> 3
128 -> 1
365 -> 9
366 -> 21

Scoring:

This is code-golf, so shortest code wins!

Credits to this puzzle

\$\endgroup\$
-1
\$\begingroup\$

The travelling sales man problem

The travelling salesman problem (TSP) asks the following question: "Given a list of cities and the distances between each pair of cities, what is the shortest possible route that visits each city exactly once and returns to the origin city?"

In this puzzle not necessarily the shortest route is the answer but an approximation using a greedy algorithm (which in fact could be the shortest route as well).

This greedy algorithm starts at the first input given and always chooses the nearest point from the current point. This continues until no points are left and the last point is connected to the first point.

Use the Euclidian distance, i.e. sqrt(deltaX^2 + deltaY^2), as the distance between two cities. If there are points with the same distance, always pick the one occurring first in the list.

In general, the greedy algorithm does not find the optimal solution, but nonetheless a greedy heuristic may yield locally optimal solutions that approximate a global optimal solution in a reasonable time.

Input & Output

  • You are given an integer n and on the next n lines, you are given the x and y coordinate of the city

Test cases

5
9 12
24 15
12 30
4 3
13 27
->
71

5
25 2
5 9
22 12
15 19
0 1
->
69

12
4 5
12 80
65 18
39 29
99 11
84 31
9 9
54 49
16 27
31 67
0 71
60 0
->
403

Others

  • You are allowed to take in the input as a list of n integers

Scoring:

This is code-golf, so shortest code wins!

Credits to this puzzle

\$\endgroup\$
-1
\$\begingroup\$

Draw an Erlenmeyer flask

Given the level of liquid in the Erlenmeyer flask L in the range 0-6. Your program should draw the following ASCII art.

When L=0:

      __________
     |_        _|
       |      |
       |      |
       |      |
       |      |
       |      |
       /      \
      /        \
     /          \
    /            \
   /              \
  /                \
 /                  \
/                    \
\____________________/

When L=1:

      __________
     |_        _|
       |      |
       |      |
       |      |
       |      |
       |      |
       /      \
      /        \
     /          \
    /            \
   /              \
  /                \
 /  %%%%%%%%%%%%%%  \
/  %%%%%%%%%%%%%%%%  \
\____________________/

When L=6:

      __________
     |_        _|
       |      |
       |  %%  |
       |  %%  |
       |  %%  |
       |  %%  |
       /  %%  \
      /  %%%%  \
     /  %%%%%%  \
    /  %%%%%%%%  \
   /  %%%%%%%%%%  \
  /  %%%%%%%%%%%%  \
 /  %%%%%%%%%%%%%%  \
/  %%%%%%%%%%%%%%%%  \
\____________________/

You can change the character % to any other (excluding space), it's up to you. Trailing spaces are allowed.

This is a code-golf challenge so the shortest solution wins.

\$\endgroup\$
-1
\$\begingroup\$

Implement a complex search engine


Your job is to implement a search engine. The search engine should come with a few extra features to ensure that users can obtain the most relevant results.

Input, part 1

Your program will take a string as input. The string is composed of a bunch of words separated by spaces. Parsing the string is part of the task, so inputting as a list of words will not be allowed.

What's a word?

A word is composed of one or more lowercase letters. There may be a minus at the start of the word. If there is no minus, then there can be a double-quote at the beginning and/or end of the word. Double-quotes are closed, so "abc de is not a valid input because the double-quote is never closed, but "abc def" is valid because the double quote is closed.

The minus

A minus at the beginning of a word tells the search engine to not return results that contain that word.

Double-quotes

Double-quotes around strings tell the search engine to only return results that contain that string exactly.

Extra rules

There will never be any minus words contained within a quoted string. The minuses and quotes will never contradict, so -abc "abc" will never be given (it tells the search engine to exclude results containing abc while telling it to return only results containing abc).

The string contains only minus signs, quotes, spaces, and lowercase letters. There is at least one word that is not excluded by means of a minus.

Input, part 2

The second input will be a list of strings from which the search engine will search. The strings contain only lowercase letters and spaces. You may take a newline-separated list of strings or a list of strings in your language's native input format, or any other reasonable method to input strings. (Lists of words are not allowed.)

Output

Return all results matching the input. Your output format can be a newline-separated list of strings, or a list of strings in your language's list format. Lists of words are forbidden.

Any results that it returns must:

  • contain all of the unquoted words that do not have a minus, but not necessarily in the given order;
  • contain all quoted strings exactly;
  • not contain any excluded words indicated by a minus.

Testcases

Search query: abcdefg
List of strings: [abcdefg, abcdef, bcdefg, abcd efg]
Output: [abcdefg]

Search query: blah blah blah
List of strings: [blah, blah blah, blah blah blah, bla hbla h]
Output: [blah, blah blah, blah blah blah]

Search query: "blah blah" blah
List of strings: [blah, blah blah, blah blah blah, bla hbla h]
Output: [blah blah, blah blah blah]

Search query: my name is -not ophact
List of strings: [my name is ophact, my name is not ophact, my name is op, ophact is indeed my name]
Output: [my name is ophact, ophact is indeed my name]

Search query: "oh please help" me or "otherwise someone else"
List of strings: [oh please help me or otherwise someone who is else, oh please otherwise someone else, help me or otherwise oh someone else, or]
Output: []

Search query: -remove -all -the -most -common -words but keep "everything else"
List of strings: [guide how to remove an item from a list, words are the rest, keep everything else but not that, remove all the most common words but keep everything else]
Output: [keep everything else but not that]

This challenge is , so the shortest code, measured in bytes, wins.


Any feedback? Clarification needed? Other tags are suitable? Wrong testcase?

\$\endgroup\$
-1
\$\begingroup\$

Fort-Defense KoTH

There are two teams, red and blue. Each team has a fortress, and if one team's fortress is destroyed, (health reaches zero) the other team wins.

The red team attacks the blue team first, blue attacks red, red attacks blue, and so on until one team's fortress is destroyed. Every team has half of the total number of bots. (For an odd number of bots, one team has one more bot.)

The grid looks like this:

FBBBBB|BBBBF
FBBBBB|BBBBF
FBBBBB|BBBBF
FBBBBB|BBBBF

where B is a bot, F is the fort, and | as the border between the two teams.

\$\endgroup\$
9
  • \$\begingroup\$ What would the attacks be like? Right now it doesn't seem like much strategy is involved. \$\endgroup\$ Apr 26 at 19:14
  • \$\begingroup\$ @RadvylfPrograms i know, it isn't finished yet. \$\endgroup\$
    – Bgil Midol
    Apr 26 at 19:16
  • \$\begingroup\$ Are you planning on a 2D grid or for attacks to just be an action? If the first option, it would probably make sense for the defenders to be able to "send out" some bots to fight the attackers while others man the fort. If not, the strategy probably has to come from designing your team to work together well and to decide how many resources to allocate to fighting vs. how many for defense. \$\endgroup\$
    – Romanp
    Apr 26 at 19:20
  • \$\begingroup\$ @Romanp 2d grid \$\endgroup\$
    – Bgil Midol
    Apr 26 at 19:26
  • \$\begingroup\$ You also can choose between real-time and turn-based strategy. There haven't been many RTS KoTHs that I have seen, but it seems like an interesting idea. \$\endgroup\$
    – Romanp
    Apr 26 at 19:35
  • \$\begingroup\$ @Romanp Ooh yeah, RTS would mean writing performant bots is a major goal, something that hasn't really been explored. I've proposed an RTS KotH before, but never really did anything with the idea. \$\endgroup\$ Apr 26 at 19:45
  • \$\begingroup\$ Now I want to make a RTS game, but I'm still running my current KoTH and am planning on a fix/reboot of King of the Ziggurat (if I can get permission)... \$\endgroup\$
    – Romanp
    Apr 26 at 20:01
  • \$\begingroup\$ @Romanp whats a RTS? \$\endgroup\$
    – Bgil Midol
    Apr 26 at 20:57
  • \$\begingroup\$ Real time strategy. Pretty much, all the bots are moving at once (probably with floating point numbers) and everything is continuous. The bots probably have position/velocity values which automatically move them every tick, that sort of thing. \$\endgroup\$
    – Romanp
    Apr 26 at 20:59
-1
\$\begingroup\$

Roman Numerals... But With A Twist

I'm assuming you have some knowledge of roman numerals, but more is at Appendix A.

Fine. What's the twist?

I want it short

So, I don't want to express 1 as IIIIIIIIIX, I want it I.

And we are not Romans, come on...

Instead, you will create a program that takes in, either as a function parameter or from STDIN:

  • A dictionary to represent Roman Numerals. You can take it in any (reasonable) format, for instance: {"I":1,"V":5,"X":10,"L":50,"C":100}, "I1 V5 X10 L50 C100", or even "0111 1011 0010 0010 0100 1001 0010 0010 0011 1010 0011 0001 0010 1100 0010 0010 0101 0110 0010 0010 0011 1010 0011 0101 0010 1100 0010 0010 0101 1000 0010 0010 0011 1010 0011 0001 0011 0000 0010 1100 0010 0010 0100 1100 0010 0010 0011 1010 0011 0101 0011 0000 0010 1100 0010 0010 0100 0011 0010 0010 0011 1010 0011 0001 0011 0000 0011 0000 0111 1101". You may cast any assumption on the input format, for instance, the letters must be in increasing order, or the odd numbers come first (even though, come on, why?) Assume all numbers to be positive.

  • The number to represent. For instance, 128724235. Assume all numbers to be positive. The number will be guaranteed to be accomplishable. For instance, for the dict {"A":10,"B":58}, 2 might be given (which your program should output).

Your output would be the shortest Roman Numeral representation for the given numeral and mapping.

Example Program:

Up later...

Appendix A

  • The mapping of letters to characters is {'I':1, 'V':5, 'X':10, 'L':50, 'C':100, 'D':500, 'M':1000}

  • Every letter is added or subtracted from a total

  • The total is the value of the numeral

For the adding or subtracting, we create the following standards:

  • If there is a character that stands for a higher value at the right, for instance an X on the right of the V, the value of V will be subtracted.

  • Else, it will be added. for instance, VV is 10 and V is 5, as there are no higher numbers at the right.

Let's just keep things clear by giving an example:

10 is X, 5 is V, 1 is I, 6 is VI, 4 is IV, 2 can be IIIV, 19 is XIX, 4 can also be expressed as IVX. Note the last three.

To make things even clearer this is a decoder:

def roman_to_integer(numeral,mapping=None):
 if not mapping: mapping = {'I':1, 'V':5, 'X':10, 
  'L':50, 'C':100, 'D':500, 'M':1000}
 result = 0
 for index, character in enumerate(numeral):
  if index+1==len(numeral) or \
   mapping[character]>=max(map(lambda x: 
   mapping[x], numeral[index:])): 
    result+=mapping[character]
  else: result-=mapping[character]
 return result
\$\endgroup\$
2
  • \$\begingroup\$ I suggest specifying clearly with some words (maybe in several bullet-points) the algorithm you use for your definition of Roman numerals. \$\endgroup\$
    – pajonk
    Jun 6 at 6:37
  • \$\begingroup\$ Oh OK good point \$\endgroup\$ Jun 6 at 6:39
-1
\$\begingroup\$

Left and Right, Spsp Style

WARNING

This question is written by the Spsp language creator TvoozMagnificent` and might includes severe advertising.

Spsp

What's Spsp? Spsp is designed to be a 2D fourth generation golfing language.

What are the commands?

Good question, it is in developement, and if you want to help me, come (here)[https://chat.stackexchange.com/rooms/136645/superior-simple]. Thank you.

But three commands have been kept in Spsp and is likely to stay that way. For the Spsp in this challenge, we have simplified things.

The commands are L, R, and S, which stand for left, right, and stop. You will be given a program, for instance this: (You would probably take it as a list instead, for instance [[' ','R','S'],[' ','L','S'],['L','S',' ']]) Assume the lines to be padded to the same length.

+-+-+-+
| |R|S|
+-+-+-+
| |L|S|
+-+-+-+
|L|S| |
+-+-+-+

The IP, which stands for the Instruction Pointer, Starts out at the top left cell, pointing right, so let's draw it as >. Thus, the current map looks like this:

+-+-+-+
|>|R|S|
+-+-+-+
| |L|S|
+-+-+-+
|L|S| |
+-+-+-+

Now the IP tries to advance. It hits an R block, so it doesn't advance, and turns right. Now it points down:

+-+-+-+
|v|R|S|
+-+-+-+
| |L|S|
+-+-+-+
|L|S| |
+-+-+-+

Now the IP can advance:

+-+-+-+
| |R|S|
+-+-+-+
|v|L|S|
+-+-+-+
|L|S| |
+-+-+-+

Now the IP can't advance again, so it turns left. This is because it points towards an L, the L at the side has no effect:

+-+-+-+
| |R|S|
+-+-+-+
|>|L|S|
+-+-+-+
|L|S| |
+-+-+-+

And turns left again to point upwards:

+-+-+-+
| |R|S|
+-+-+-+
|^|L|S|
+-+-+-+
|L|S| |
+-+-+-+

It advances:

+-+-+-+
|^|R|S|
+-+-+-+
| |L|S|
+-+-+-+
|L|S| |
+-+-+-+

If the IP hits a wall, it raps. (Pun Intended) So if the IP advances, he would end up on the L marked X on this map:

+-+-+-+
|^|R|S|
+-+-+-+
| |L|S|
+-+-+-+
|X|S| |
+-+-+-+

And thus the pointer turns left:

+-+-+-+
|<|R|S|
+-+-+-+
| |L|S|
+-+-+-+
|L|S| |
+-+-+-+

And the pointer advances and hits the S:

+-+-+-+
| |R|X|
+-+-+-+
| |L|S|
+-+-+-+
|L|S| |
+-+-+-+

Thus the pointer stops. Your chllenge is to output the ending coordinate in some way, whether it is the mathematical coordinate system (2,2) or the index [1,3] or [0,2].

There's a small twist however. What does this program do?

+-+-+
| |R|
+-+-+
|L|S|
+-+-+

Well, the IP turns right, and then turns left, and then... yikes, that's an infinite loop! What do we output then? Well, don't output anything, but terminate the program instead of running forever. It is easy to know that if the same IP state is achieved twice, then a loop will happen.

Or, take this:

+-+
| |
+-+
|S|
+-+

The IP just wraps around and loops on the first line.

\$\endgroup\$
-1
\$\begingroup\$

Minimal number of moves needed by a knight


Given an \$N × N\$ board, what is the minimum number of moves needed by a knight to reach every square (on any given square)?

In other words, the A232007 sequence from OEIS.

Input/Output can be taken in any reasonable format, taking the size of the board and returning the number of moves (you don't need to handle 2, and 3 because the knight can't travel all of the \$2 × 2\$ and \$3 × 3\$ board)

Testcase:

8 -> 6
5 -> 4

This is , so shortest answer (in bytes) wins!

\$\endgroup\$
3
  • 2
    \$\begingroup\$ I'd suggest removing the -1 output, and not requiring answers to handle those inputs. Adding edge cases like this tends to make the challenge quite boring to golf, because a lot of the code gets taken up by them \$\endgroup\$
    – pxeger
    Jun 6 at 17:43
  • \$\begingroup\$ Do you mean minimum or maximal? \$\endgroup\$
    – tsh
    Jun 7 at 10:31
  • 2
    \$\begingroup\$ I think this may be too simple, as it is just ceiling(2n/3) per the OEIS page. \$\endgroup\$
    – pajonk
    Jun 8 at 9:04
-1
\$\begingroup\$

The prime frog 🐸 -- Integrated.

From the original question, we make the following changes:

The "prime frog" is a strange animal that jumps between integers*, until it arrives on 3 or 19...


Your program should accept an integer n as input and output the result of the below algorithm (3 or 19).

For a given integers n > 1 and b > 1:

  1. Let f be the position of the frog. It is initially set to n
  2. if f has been hopped on: return the smallest lilypad hopped after and including the f hopped on last time
  3. if f is prime : the frog jumps to the position b×f+1. Go back to step 2.
  4. if f is composite : let d be f's biggest prime divisor. The frog jumps to the position f-d. Go back to step 2.

Examples:

An example with n = 5, b = 4:

5 > 21 > 14 > 7 > 29 > 117 > 13x8 > 13x7 > 13x6 > 13x5 > 13x4 > 13x3 > 13x2 > 13 (I'm a bit lazy there) > 53 > 213 > 142 > 71 > 285 > 14x19 > 13x19 > snip > 38 > 19 > 77 > 66 > 55 > 44 > 33 > 22 > 11 > 45 > 40 > 35 > 28 > 21 (loop), returns 7. 

Thus the program should output 7.

Another example with n = 23, b = 3:

 23 > 70 > 63 > 56 > 49 > 42 > 35 > 28 > 21 > 14 > 7 > 22 > 11 > 34 > 17 > 52 > 39 > 26 > 13 > 40 > 35 (loop), returns 7. 

Again, the program should output 7.

Test cases:

Coming up later

Meta: is it possible for a number to go up infinitely?

\$\endgroup\$
1
-2
\$\begingroup\$

Every number is interesting

We know that every number is interesting but how?

You should write a program or function which:

  • takes a list of N positive integers (>0 and <2^31)
  • outputs N lines each of them showing how the corresponding input number is interesting
  • is not longer than 1024 bytes
  • uses no more than 1 second per number
  • doesn't use external sources

Examples

172: 444 in base6
5776: 76*76
9801: 9 * 1089 (reverse)
68101: no 11 in base2 (10000101000000101)
491033: 317 * 1549 (product of 2 big primes)
467808816: no digit 5 from base6 to base10

Inputs

You should include the output for the following input in your post:

58 92 120 224 358 490 912 1578 7812 222008 1645060 19796411 550453633 

If you care to run your program on a bigger sample and share the result with us use this input data (2500 numbers). (You can upload your output to e.g. pastebin.)

This is a popularity-contest so highest voted answer wins.

Tags: popularity-contest, number

\$\endgroup\$
6
  • 1
    \$\begingroup\$ What sort of criteria are necessary for defining a number as 'interesting'? I see things like square numbers, other bases, etc. But are there any specifics? I'm interested in this challenge (but worried it might be closed as too broad). \$\endgroup\$ Apr 7, 2015 at 13:18
  • \$\begingroup\$ @ASCIIThenANSI There wasn't a clear definition. That's part of the reason why I abandoned the challenge. \$\endgroup\$
    – randomra
    Apr 8, 2015 at 1:55
  • 1
    \$\begingroup\$ Would you mind if I tried taking it up? I would have to post as a new answer, because I can't directly edit. \$\endgroup\$ Apr 8, 2015 at 2:00
  • \$\begingroup\$ @ASCIIThenANSI Not at all. \$\endgroup\$
    – randomra
    Apr 8, 2015 at 2:01
  • \$\begingroup\$ @ASCIIThenANSI Where did you post it? \$\endgroup\$
    – wizzwizz4
    Jul 24, 2019 at 13:33
  • \$\begingroup\$ @ASCIIThenANSI I am also curious \$\endgroup\$
    – MilkyWay90
    Aug 27, 2019 at 23:41
-2
\$\begingroup\$

Create a Drawing Guide for a Polygram

Poor old Jim, he's just terrible at drawing polygrams, and he's asked you to create a "drawing guide" for him - an ascii polygram with numbered edges, so he can follow the instructions.

Challenge

Write a program to produce an ascii polygram with P <= 10; each edge of the polygram should be made of a single digit 0-9, showing the order in which the edges should be drawn.

Input

Your program should receive (via STDIN, as function arguments, or some other language-appropriate method): P, the number of edges/vertices of the polygram, and Q, the spacing. In the notation as per the Wikipedia link, you'll be drawing a {p/q} polygram.

Output

Either print to STDOUT or return (or something else language-appropriate) a multiline string showing the drawing guide for the given polygram. The string can be any size you like, as long as it's large enough to display a clear polygram.

Notes

Your code should be able to handle compound regular polygons as well as regular regular polygons, and also inputs of q > p/2 (poor old Jim doesn't realize that the polygram for {p/q} is the same as for {p/p-q}).

Example Output for {10,3}

              5              
             5 4             
                4            
     21     5        888     
     2 11115     8888  7     
     2    5111888 4    7     
     2     888111  4   7     
     2  888      111   7     
     8885           4117     
  8882               4 711   
 8   2 5               7  111
     25               47     
 9   5                 7    0
  9  2                 74  0 
    52                 7  0  
   9 2                 7 4   
  5 92                 7 04  
     9                 70  4 
 5   2                 7     
5    29                7    4
6666 2 9              07   33
    666              0 7333  
     2 696           337     
     2   9666     333  7     
     2    9  66633 0   7     
     2      333 666    7     
     2   339       666 7     
     2333   9    0    67     
             9  0            
               0 

Scoring

This is code-golf, so shortest in bytes wins. Tiebreaker goes to the most votes.

\$\endgroup\$
2
  • \$\begingroup\$ I have a python solution to this which is ~600 bytes, so it's definitely doable, and it's not easy... \$\endgroup\$ Apr 27, 2015 at 4:31
  • 5
    \$\begingroup\$ I think the spec needs to be more prescriptive for this to make a good question, especially since the example seems to indicate that you're not currently even prohibiting the lines from having gaps. At a minimum I would say that you should require the lines to be equivalent to those produced by Bresenham's algorithm, and specify how overlaps should be handled; at the extreme, you could tie it down so tightly that it becomes a parameterised kolmogorov-complexity. \$\endgroup\$ Apr 27, 2015 at 9:34
-2
\$\begingroup\$

Pointer to pointers to pointers to pointers

You should choose a language supporting pointers like C. And your task is simple: demonstrate a legitimate use of the most level of pointers.

You should justify your code by describing an algorithm that:

  • Has only plain text, number or an array of those as input and output.
  • You think it will make things easier to write those code as a part of the implementation of this algorithm.
  • This implementation would have optimum memory usage (only declared variables and parameters, explicitly allocated space, and the return addresses for recursive functions count).

Other rules:

  • They must be pointers to pointers directly, i.e. a pointer to an object containing a pointer doesn't count. It's better if nobody using this code will want to extend some pointer to an object later.
  • Each pointer must have a different type (if your language can somehow make them the same type).
  • You should create at least one pointer, and either dereference or compare two non-null pointers once in each level.
  • Using pointers as arrays is only half as interesting.
  • Iterators, etc, are considered in essence pointers and allowed in this challenge. But you can't define new types implementing iterators for this purpose.

\$\endgroup\$
3
  • 3
    \$\begingroup\$ Could you specify "legitimate"? This sounds a bit like code bowling (and seems to have the same issues). With enough imagination I'm sure I can justify any depth of pointers. \$\endgroup\$ Apr 30, 2015 at 17:43
  • \$\begingroup\$ @MartinBüttner Edited but, basically, it is subjective. \$\endgroup\$
    – jimmy23013
    Apr 30, 2015 at 17:57
  • \$\begingroup\$ @MartinBüttner Added a restriction to have optimum memory usage. I'm not sure whether it works. \$\endgroup\$
    – jimmy23013
    Apr 30, 2015 at 18:19
-2
\$\begingroup\$

Winning Tic-Tac-Toe lines

For a given tic-tac-toe board of size N**D (for example, a normal tic-tac-toe game is 3**2), the number of winning lines of length N is given by the expression:

$$ 2^{D-1} + \sum_{S=1}^{D-1}2^{S-1}DN^{D-S} $$

(Basically, you are summing the number of lines in each S-dimensional slice of the board.)

The challenge:

Given N and D, your answer should output a list of D-dimensional coordinates for each winning line. Input and output are any reasonable format. You can assume that both N and D are positive integers, with N > 1. (Degenerate cases of N=1, D>1 not included.)

Since this is , fastest answer wins. Please explain your algorithm!

\$\endgroup\$
7
  • \$\begingroup\$ How do you intend to determine which of two answers is fastest? \$\endgroup\$ May 12, 2015 at 19:37
  • \$\begingroup\$ yes, @randomra made the same point on chat. i'll edit this in, but i guess... i'll put together some test cases and then time them? i dunno, i was going back and forth between this and code-golf, but i'd prefer interesting and readable algorithms. \$\endgroup\$ May 12, 2015 at 20:10
  • \$\begingroup\$ i posted this here because i really want the answer, and i hate coming up with brute force solutions... :D \$\endgroup\$ May 12, 2015 at 20:16
  • 2
    \$\begingroup\$ Um. Given that you're asking people to enumerate an exponentially large set, in what sense will the answers not be brute force? \$\endgroup\$ May 12, 2015 at 20:28
  • \$\begingroup\$ well, there's brute force and then there's brute force. but really it's because i don't want to do it myself, haha. \$\endgroup\$ May 12, 2015 at 20:34
  • \$\begingroup\$ also, making use of symmetry can severely reduce the computation. \$\endgroup\$ May 12, 2015 at 20:40
  • 1
    \$\begingroup\$ I imagine that the runtime in any such algorithm will be basically proportional to the number of things you print, so there won't be any good way to improve by algorithm and the speed will be very platform-dependent. \$\endgroup\$
    – xnor
    May 12, 2015 at 23:40
-2
\$\begingroup\$

Ayn Random number generator


Inspired by xkcd 1277:

enter image description here

Write a random number generator that takes no input and generates a random integer between 1 and 100. When run less than 200 times, the frequency of all numbers needs to be between 0 and 2, but when it's ran 50 000 times, the number 42 (obviously) should have a frequence that's more than 4 standard deviations higher than the mean.

Format is code-golf. Your score is the bytecount of your code.

\$\endgroup\$
8
  • 1
    \$\begingroup\$ 1. I think it's difficult to decide objectively whether a PRNG appears to be fair at first sight. 2. The term more often should probably be quantified. \$\endgroup\$
    – Dennis
    May 18, 2015 at 21:49
  • \$\begingroup\$ I see lots of C rand()%1000 and the like incoming... \$\endgroup\$
    – rorlork
    May 18, 2015 at 22:05
  • \$\begingroup\$ @Ypnypn I have changed the criteria to have much lower numbers so they're easier to verify. \$\endgroup\$
    – Nzall
    Jun 6, 2015 at 13:04
  • 1
    \$\begingroup\$ @Dennis I have rewritten the question to clarify what "being fair" is and what "more often" actually entails. \$\endgroup\$
    – Nzall
    Jun 6, 2015 at 13:05
  • 1
    \$\begingroup\$ 1. Are you thinking of a standalone program that you run multiple times or a function that is allowed to keep a state? In the first case, not even a perfect RNG will, with overwhelming probability, satisfy the first condition. 2. Do you mean the mean and standard deviation of a perfect, uniform RNG or the one the code implements? \$\endgroup\$
    – Dennis
    Jun 6, 2015 at 23:44
  • \$\begingroup\$ @Dennis I'm thinking of just a function AynRandom() that gets called. The frequency of numbers with a small number of iterations is subject to change, maybe from 0 to 4. The mean and Standard Deviation must be the one the code implements. \$\endgroup\$
    – Nzall
    Jun 7, 2015 at 9:49
  • \$\begingroup\$ between 0 and 2 ? so print 42 would be a valid program ? \$\endgroup\$
    – Falco
    Jun 11, 2015 at 15:32
  • \$\begingroup\$ @Falco No, because 42 would appear more than 2 times (unless you only run it twice). The problem is that I need a way to indicate that the RNG is fair with a low iteration count, but unfair with higher iteration counts. The only way I can make it work is by stating that with low iteration counts, all numbers should appear about equally often, which is either 0, 1 or 2 times. \$\endgroup\$
    – Nzall
    Jun 11, 2015 at 15:36
-2
\$\begingroup\$

Please nitpick this. If there's anything that wouldn't work or would be inconvenient, however small of an issue it is, tell me about it!
Also, suggestions for [adjective] are more than welcome.


Determine how [adjective] a number is ()

A number would be considered [adjective] if 0 is the result of multiplying its digits together, then multiplying the digits of the resulting number, then repeating until a single-digit number is produced. The more steps it takes to reach 0, the more [adjective] the number is; if the resulting number is not 0, though, the number is not [adjective] regardless of how long it took to finish.
The formula used to determine [adjective]-ness is 10-10/T where T is however many numbers it took to reach 0 (including 0 and the initial input)

Your goal is, as the title says, to write a program or function that determines how [adjective] a number is, and prints every iteration along the way. Here are some example inputs/ouputs:

in: 879
out: 879    <-       (T=1)
     504    <- 8*7*9 (T=2)
     0      <- 5*0*4 (T=3)
            <- optional newline
     6.6... <- 10-10/3 (repeating decimals can be expressed in any way you want)

in: 2468
out: 2468   <-  T=1
     96     <- (T=2) 2*4*6*8
     54     <- (T=3) 9*6
     20     <- (T=4) 5*4
     0      <- (T=5) 2*0

     8      <- 10-10/5

in: -888
out: -888  
     -512   <- -8*-8*-8
     -10    <- -5*-1*-2
     0      <- -1*0

     6.6... <- 10-10/3

in: 1344
out: 1344
     48
     32
     6

     0    <- did not produce 0, so the prog/func returns 0

Your program must follow these rules:

-Takes input from STDIN.
-Throws an "error" (printed to STDOUT) and halts immediately after input if the input has one or more 0s in it or if it's less than three digits in length. The error must be a string, and as it's supposed to be printed to stdout, cannot be one generated by the language itself (eg 1/int(min(input())) to check if it's zero). Lastly, the error message has to clearly define what the error is; ERR:0 and ERR:LEN, for example, would suffice.

Bonuses/Penalties:

-25 if it properly handles decimals. For instance, an input of 99.22 would first turn into 9*9 + 0.(2*2), or 9*9 + 0.4, and so on.


This is , so the shortest answer in bytes wins.

\$\endgroup\$
7
  • 4
    \$\begingroup\$ I don't like the +15 penalty. Whether strings are used is vague in some languages. The constant amount +15 is too little deterrent for some languages but huge for very concise ones. The fact that you've found a short solution you don't like is sign you should rethink the problem, not try to plug the hole. \$\endgroup\$
    – xnor
    Jun 17, 2015 at 7:48
  • \$\begingroup\$ @xnor that's reasonable. I suppose it is a valid way of doing it, anyway, so I removed all mention of strings in that section. Should I also inc/decrease the bonus for decimals? \$\endgroup\$
    – user39326
    Jun 17, 2015 at 22:29
  • \$\begingroup\$ The programming languages I know either don't allow throwing user-defined errors or print them to STDERR. Now, if you just want us to print a message and exit immediately... \$\endgroup\$
    – Dennis
    Jun 17, 2015 at 23:32
  • \$\begingroup\$ ...and should be printed to STDOUT. I had a feeling that wasn't clear; I edited it, is it better now? \$\endgroup\$
    – user39326
    Jun 17, 2015 at 23:33
  • \$\begingroup\$ It's the word throw that throws me off (no pun intended). To throw an error usually means something rather specific. Print an error message to STDOUT (or closest alternative) would be less confusing in my opinion. Also, since this is code golf, I think you should require specific error messages. There's no fun in losing a contest because you chose ERR:LEN and somebody else got away with EL. \$\endgroup\$
    – Dennis
    Jun 18, 2015 at 3:16
  • 5
    \$\begingroup\$ Remove bonuses altogether. It's in the list of things to avoid. \$\endgroup\$
    – mbomb007
    Mar 1, 2016 at 21:31
  • \$\begingroup\$ The error if the input contains a zero seems like a separate challenge. It may be better received if there is only one challenge. There is community support for avoiding Chameleon challenges. \$\endgroup\$
    – trichoplax
    Aug 10, 2016 at 11:40
-2
\$\begingroup\$

Wrong tool for the task

Task

Write two full programs in the same programming language that solve the following two tasks:

  1. Read two positive integers from STDIN and print their sum to STDOUT.

  2. Read two positive integers from STDIN and print their product to STDOUT.

Additional details:

  • Given enough time and memory, your programs has to support arbitrarily large integers.

  • All integers (input and output) use standard decimal notation, have no leading zeroes and are followed by a single linefeed.

Scoring

The first task is code golf, so your objective is to make your program as short as possible.

The second task is code bowling, so your objective is to make your program as long as possible.

Your score is defined as follows:

score formula

The highest score wins!

Robbing a language

There's a catch! Only the submission with the shortest program in a particular language will be considered valid for task 2, so there can only be one valid answer per language.

This means that you cannot deliberately write a huge program for task 2; you actually have to pick the "wrong tool" for the task.

Additional details:

  • Task 1 exists merely to provide the proper denominator for the score (and robbers have no moral anyway), so byte-per-byte copies of somebody's program for task 1 are allowed.

  • If two answers use the same language and have programs of the same length for task 2, the answer that achieved that length first will be considered valid.

  • If somebody invalidated your answer, you may attempt to golf your answer to revalidate yours and invalidate his.

\$\endgroup\$
8
  • \$\begingroup\$ I suspect this will come down to people writing code in unary and disagreeing on what input/outputs formats are valid for such a language. \$\endgroup\$
    – xnor
    Jul 20, 2015 at 20:17
  • \$\begingroup\$ @xnor I'm not sure I understood your comment. The format for I/O is purposedly restrictive, so an answer's validity should be clear-cut. \$\endgroup\$
    – Dennis
    Jul 20, 2015 at 20:25
  • \$\begingroup\$ @feersum I think the log scoring does benefits unary. Say (making up numbers) task 1 takes 100 chars of BF and task2 takes 150 chars. Then, those are translated to 300 chars and 450 chars of binary, and so 2^(300) and 2^(450) chars of unary, giving a score of 1.5. In comparison, if the tasks take 20 chars and 50 chars in another language, that's about a score of 1.3. I guess this is surmountable though (20 and 100 gives 1.5). \$\endgroup\$
    – xnor
    Jul 20, 2015 at 20:33
  • \$\begingroup\$ Are the inputs decimal numbers? For a language like BF, can the numbers be taken as byte values rather than characters? What separator should be used between the numbers? Are leading zeroes OK in the output? I think you'll have to be pedantic and precise about everything given how much of the character count may depend on details, but it's doable. \$\endgroup\$
    – xnor
    Jul 20, 2015 at 20:35
  • \$\begingroup\$ Yeah that's right, it is only for Unary. \$\endgroup\$
    – feersum
    Jul 20, 2015 at 20:37
  • \$\begingroup\$ @xnor All integers (input and output) use standard decimal notation, have no leading zeroes and are followed by a single linefeed. \$\endgroup\$
    – Dennis
    Jul 20, 2015 at 20:42
  • \$\begingroup\$ @Dennis Wow, you anticipated everything and I missed it. I take it then that input must be as a string of numerical characters? Also, do I understand right that you have to print a newline for output (say, print a+b,"\n" in Python)?. \$\endgroup\$
    – xnor
    Jul 20, 2015 at 20:45
  • \$\begingroup\$ @xnor Yes to both. The newline is required and you have to use numerical characters. I'd specify the exact character range, but I don't want to exclude non-ASCII languages.I'll think of a way to make it clearer. \$\endgroup\$
    – Dennis
    Jul 20, 2015 at 20:51
-2
\$\begingroup\$

GitHub Gist command-line client

Create a command-line tool that publishes a list of files as one public GitHub Gist.

Specification

The following bullet points describe the behavior of the program. If a bullet point has "must", you must implement that point. If a bullet point has "can optionally" or "should optionally" you can implement that point on your own volition.

  1. It must be a complete command-line program.
  2. It must use the GitHub Gists API.
  3. It must post an anonymous Gist (that is, not as a GitHub user).
  4. Gisted files must use the filename provided on the command-line.
  5. The command-line must accept multiple positional arguments.
  6. If no arguments are specified, it must print this usage to STDOUT: gist: usage: <file> [file...] verbatim then exit with code 0.
  7. If something else goes wrong, it must print this message to STDERR: gist: unable to gist =( verbatim then exit with code 1.
  8. If everything is successful it must print the Gist's HTML URL to STDOUT.
  9. It can optionally accept a flag for description -d <description. floor(score * .9)
  10. It can optionally accept a flag for private gisting -p. floor(score * .9)
  11. In the case that a description flag is not used or implemented it must set the description to an empty string.

Example Input/Output

The number before the prompt is the exit code of the previous command.

0 $ gist
gist: usage: <file> [file...]
0 $ gist no-such-file.txt
gist: unable to gist =(
1 $ gist hello.txt
https://gist.github.com/anonymous/1e645596ce7bceeb1ec9
0 $

Scoring

This is a so shortest answer wins. As stated above, the following multipliers are in effect:

  • (9): score = floor(score * .9)
  • (10): score = floor(score * .9)
  • Both (9) & (10): score = floor(floor(score * .9) *.9)
\$\endgroup\$
8
  • \$\begingroup\$ What's up with the Example Input/Output code snippet? The editor's preview displays it correctly. \$\endgroup\$
    – Winny
    Jul 27, 2015 at 20:17
  • 2
    \$\begingroup\$ For the usage, should those literal strings be used regardless of the name and invocation of the program, or should it substitute the correct invocation for the leading gist? I'm thinking particularly of cases like Java, which doesn't support hashbangs. \$\endgroup\$ Jul 27, 2015 at 20:32
  • \$\begingroup\$ Literal string, I think. \$\endgroup\$
    – Winny
    Jul 27, 2015 at 20:34
  • \$\begingroup\$ That's a good point about Java. I think I'll remove the item about shebangs since it's unfair. \$\endgroup\$
    – Winny
    Jul 27, 2015 at 20:41
  • \$\begingroup\$ If both bonuses are done, is it floor(score * .9 * .9), or floor(floor(score * .9) * .9)? \$\endgroup\$
    – Maltysen
    Jul 27, 2015 at 23:48
  • \$\begingroup\$ Also, if the bonuses are done, do we have to make the usage string reflect that, or just print it verbatim? \$\endgroup\$
    – Maltysen
    Jul 27, 2015 at 23:50
  • \$\begingroup\$ Output strings verbatim. And floor(floor(score * .9) * .9) for both. I'll update the question momentarily. \$\endgroup\$
    – Winny
    Jul 28, 2015 at 2:07
  • \$\begingroup\$ I'm curious why this challenge is being downvoted. \$\endgroup\$
    – Winny
    Jul 28, 2015 at 2:28
-2
\$\begingroup\$

Golf these arrays

Your task is to output these 128 arrays: http://pastebin.com/UeBMJfv7

Gzip base64: (too long, will be added if I'll post this question).

Rules

  • You don't have to output them all. And you can output the arrays in any order. But the order of items in the arrays must be kept as is.
  • You can print other arrays, which wouldn't be counted towards your score. The number of arrays you print must be no more than 10,000, and the total number of arrays, subarrays and numbers must be no more than 10,000,000.
  • You can use any convenient format to represent the arrays (and the list of outputted arrays).

Scoring

If your program or function has n bytes, and it printed k distinct arrays from the above list, your score would be n*(128/k)2. Lowest score wins.


Problems

It looks too boring.

\$\endgroup\$
1
  • \$\begingroup\$ It also looks too broad. \$\endgroup\$ Aug 8, 2015 at 7:55
-2
\$\begingroup\$

The Perfect Keyboard

Back in the 1970s, keyboard designers respected the needs of programmers and languages. For example, see the IBM 2741 keyboard, designed for APL (from Wikipedia):
enter image description here

Today, sadly, most code golfers are forced to struggle with standard keyboards, which are badly suited to the needs of their language. This has to change!

The challenge

  1. Choose a programming language.
  2. Design a keyboard, which would best suit the needs of a developer (or specifically a code golfer) in said language.
  3. Post the keyboard layout as an answer.
  4. Explain how your keyboard enhances the programming experience.
  5. Start counting votes for 7 days, until I acceopt the winning answer (the answer with most votes).
  6. Optional - if you are the winner, start a Kickstarter project to build the thing.

Expected Answers

This section is, of course, for the sandbox only.

I don't really expect a keyboard design which would actually improve functionality of programs in an actual serious language. I'd expect fun answers, where the keyboard design highlights soemthing fun/interesting/absurd about the language. But my expectations don't matter so much, because it's not me rating the answers, but the other users.

Example (not very good ones):

  1. A Brainfuck keyboard with only 4 keys.
  2. A Lisp keyboard where half the keys are parentheses.
  3. A Piet keyboard - I'm sure someone will come up with something nice.

\$\endgroup\$
13
  • 6
    \$\begingroup\$ I'm note sure if it's a valid challenge since there is no programming actually involved in answering this \$\endgroup\$
    – Fatalize
    Sep 3, 2015 at 9:28
  • \$\begingroup\$ @Fatalize, You're right, but it is a programming-related challenge. It requires knowledge of programming languages and people may find it interesting or amusing. I may be pushing the boundaries, I don't know. \$\endgroup\$
    – ugoren
    Sep 3, 2015 at 9:45
  • 2
    \$\begingroup\$ I would personally be ok with that challenge but I don't know if other, more prominent users would find this challenge off-topic. \$\endgroup\$
    – Fatalize
    Sep 3, 2015 at 9:48
  • 2
    \$\begingroup\$ Judging from this Meta post, there seems to be a fairly clear consensus that a question must involve programming to be on topic, not merely be programming related. So this question is fairly clearly not valid. \$\endgroup\$
    – isaacg
    Sep 3, 2015 at 10:08
  • \$\begingroup\$ You could always include programming the driver or some kind of special interface for the keyboard \$\endgroup\$
    – Beta Decay
    Sep 3, 2015 at 10:28
  • \$\begingroup\$ @BetaDecay, This challenge is about crazy creative answers. Requiring a driver implementation seems to me like a way to kill this creativity. \$\endgroup\$
    – ugoren
    Sep 3, 2015 at 11:01
  • \$\begingroup\$ @isaacg, trichoplax writes "I judge it by whether the answers to it demonstrate skill and determination, or just aesthetic style" - I think a good answer to this challenge requires undestdanding a language and designing something that relates to its properties. Does it qualify as "skill and determination"? I can't say I'm sure. \$\endgroup\$
    – ugoren
    Sep 3, 2015 at 11:06
  • 1
    \$\begingroup\$ The art/programming debate was specifically about popcon questions where the answers were programs. There's no doubt whatsoever that a popcon where the answers are just images would be an art question rather than a programming question. On the same basis, this is not a programming question, and does not belong on this site. \$\endgroup\$ Sep 4, 2015 at 13:58
  • \$\begingroup\$ @PeterTaylor - I don't think it's an art question. The challenge isn't to get a pretty picture of a keyboard, but to design something that suits the language in an interesting way. But I posted it here to get the communities opinion, and it seems quite clear what it is. \$\endgroup\$
    – ugoren
    Sep 5, 2015 at 19:00
  • \$\begingroup\$ Since I wrote that meta answer the rules on popularity contests have been tightened up, and I think that is a good thing. I stand by my answer, but I think it is right that popularity contests be judged strictly, to reflect the fact that it is very difficult to write one that is a good fit for the site. \$\endgroup\$
    – trichoplax
    Sep 4, 2016 at 11:56
  • \$\begingroup\$ Although it's possible someone will come up with an ingenious approach to designing a keyboard, the challenge itself seems to lean towards "make me laugh" rather than "impress me". This is why I don't think this is a good fit for the site. \$\endgroup\$
    – trichoplax
    Sep 4, 2016 at 12:03
  • \$\begingroup\$ I'd love to see what keyboards the community comes up with, but I think it would need to be hosted somewhere other than main. For things which are appealing to the PPCG community, but not quite a fit for main, there's Code Golf Chat. People often post "mini challenges" which aren't well specified enough to be challenges on main, but can end up inspiring people to write a full challenge. \$\endgroup\$
    – trichoplax
    Sep 4, 2016 at 12:06
  • \$\begingroup\$ I think it's important to keep testing the boundaries of existing winning criteria, and to try to come up with new ones. The people who put the effort into this will have a long run of rejections, but I really hope these don't come across as "don't try". \$\endgroup\$
    – trichoplax
    Sep 4, 2016 at 12:19
-2
\$\begingroup\$

This and this gave me an idea, but I'm not quite sure if this can be done at all, or if it is trivial. If it is, maybe point out how it could be changed to be interesting.

Anti golfing - Write the longest program not repeating any character

Well, it's just what the title says. Finally you're allowed to use as much bytes as possible.

Conditions

  • The code of the program or function should not use any character that is used in the code before.

  • Your program should print some sort of result to stdout, or into a file or return a value. You're not allowed to output or return the empty string or only a newline.

  • Other than that your program might do anything. Read input, print lots of output, or what you can think of, but you have to explain what it does, of course.

  • Only characters in the ASCII range [32 .. 126] and newlines are allowed, which limits the maximal code length to 96 bytes.

  • Variable names are only allowed to consist of a single character

  • String literals or the like are forbidden. They could be used to hold the unused characters (though they would need two " in most languages anyway).

  • The same rule applies for similar literal constructs like blocks or what else is there in some languages.

  • Even if the length of a string literal would be used to generate a number, it is forbidden.

  • Variables can not just be declared and never be used. They have to be reflected in the output somehow.

  • If you've read and understood the above rules and still found a loophole and used it, you should go and stand in the corner for a while, thinking about what you've done.

So all in all, only use characters for actual code that does something generating the output, might it be calculating a value or formatting. And don't put unused characters somewhere in your code as a literal. Numbers are an exception, but I guess it's no problem to use them anyway.

I guess you should have a pretty good idea of what would be considered cheating here.

Example in awk

BEGIN{gsub(a,9);print $j-13+d^c/4*5678%20}

It prints 15.5, score is 42.

It replaces the empty string a with 9 in $0, which is the empty string in the beginning. So $0 becomes 9.

Then it prints the result of 9-13+1/4*5678%20.

($j is $0 (==9), because j is not defined

d^c ist 1, because c and d are not defined)

Please don't invent languages for this ;)

The longest code in bytes wins.

\$\endgroup\$
10
  • 1
    \$\begingroup\$ Are you sure you want to allow ASCII 127? That's the unprintable<DEL> character. The main problem with this challenge is "only use characters for actual code that does something". This is essentially unenforceable, because there may be arbitrarily complicated no-ops in the code. It's also why most code-bowling challenges fail to be popular/interesting. \$\endgroup\$ Sep 14, 2015 at 7:32
  • \$\begingroup\$ Well, I thought about making it a "most votes win" challenge, but I guess that would be unfair for less known users. I don't know what could be done with what you are pointing out. \$\endgroup\$
    – Cabbie407
    Sep 14, 2015 at 7:51
  • 2
    \$\begingroup\$ I don't think this is a good candidate for a popularity contest. Popularity contests shouldn't be used as a cop out if the actual spec is a bit vague. They work best for challenges where the actual scoring criterion can be well specified but is more easily judged by humans than machines (e.g. "visually approximate a given image with these constraints..."). \$\endgroup\$ Sep 14, 2015 at 7:54
  • \$\begingroup\$ Yeah, it's hard to formulate the rules for this. But I think it's not always about finding a winner anyway. Thought this might be fun. Resolved the character 127 situation btw.. \$\endgroup\$
    – Cabbie407
    Sep 14, 2015 at 7:57
  • \$\begingroup\$ How could I change that rule? I'm thinking about "only use code that contributes to the generation of the output" \$\endgroup\$
    – Cabbie407
    Sep 14, 2015 at 8:02
  • 2
    \$\begingroup\$ How do you define "contribute"? E.g. this GolfScript program prints the length of the block in {...} which is a convenient way to stuff all characters except in '"# in there. Do all those random characters actually contribute? In Slashes everything which isn't an unescaped slash is printed to STDOUT, so as long as I put \/ together, I can put any characters I want there and they'll all contribute. \$\endgroup\$ Sep 14, 2015 at 8:07
  • \$\begingroup\$ Hmm, I thought this would be covered by forbidding string literals.. might think about extending that rule to blocks. Well, I'm not that fluent at esolangs. \$\endgroup\$
    – Cabbie407
    Sep 14, 2015 at 8:10
  • \$\begingroup\$ It's trivial to use all possible 96 bytes. Trust me. If you really want to see the program I'm thinking of, I suppose I could write it, but I'm pretty sure it can be done. \$\endgroup\$
    – mbomb007
    Sep 16, 2015 at 18:34
  • \$\begingroup\$ Yeah, I guess you're right. i have no idea how it would be done, but alright. \$\endgroup\$
    – Cabbie407
    Sep 16, 2015 at 20:10
  • \$\begingroup\$ Not to mention this is pretty much a duplicate of codegolf.stackexchange.com/questions/30159/… \$\endgroup\$ Aug 6, 2017 at 12:52
-2
\$\begingroup\$

Technologic - Now what's THAT command do??

Daft Punk's song "Technologic" is all about actions that a user or computer does when it's working and being used. You goal is to write a program that has one command we will call the Technologic Command. This command will executes all of the actions like "buy it", "lock it", "code it", and "write it" in the order the lyrics are written on 'it'. What 'it' is is up to you, but you gotta let me know.

Rules

  • Any language can be used.
  • The song refers to an 'it'. That can be a block a memory, algorithm, function, file, or anything else a computer can manipulate directly or indirectly.
  • You must specify what 'it' is you will be performing these actions on. If you don't, you can only earn a maximum of 160 points.
  • Points will be deducted otherwise if a command is not used.
  • I'm not aware of any 'buy' command, method, function, subroutine or instruction so use a thesaurus and find the closest word you can actually program. I don't expect the program to actually buy or snap anything. Other words like mail and fax are possible, but not recommended.
  • If you have to use a synonym, you are not allowed to use that command again
  • Encompassing multiple objects into one artifact does not count. For example, taking the command "name it" literally means you won't be able to name an array of bytes, but you can name a file. Creating an object that holds both a file and an array of bytes is not allowed. That would make this too easy to get the maximum amount of points.

Scoring

  • There are 16 commands with a total possible score of 190 points.
  • 10 points for executing a command on the specified 'it' of your choosing (160 total)
  • 2 points for executing each command consecutively that references your 'it' (30 total)
  • 5 points for executing a command on something other than your 'it'
  • -3 points for every command skipped.

Command List

lyrics

Buy it, use it, break it, fix it,
Trash it, change it, mail - upgrade it,
Charge it, point it, zoom it, press it,
Snap it, work it, quick - erase it,
Write it, cut it, paste it, save it,
Load it, check it, quick - rewrite it,
Plug it, play it, burn it, rip it,
Drag and drop it, zip - unzip it,
Lock it, fill it, call it, find it,
View it, code it, jam - unlock it,
Surf it, scroll it, pause it, click it,
Cross it, crack it, switch - update it,
Name it, rate it, tune it, print it,
Scan it, send it, fax - rename it,
Touch it, bring it, pay it, watch it,
Turn it, leave it, start - format it.

\$\endgroup\$
3
  • \$\begingroup\$ This conversation has been moved to chat. \$\endgroup\$
    – Dennis
    Sep 17, 2015 at 21:06
  • \$\begingroup\$ I count way more than 16 commands here. There are 16 lines each with several commands on them. If we cound the hyphenated commands as two, there are 16 x 4 = 64 commands. \$\endgroup\$ Sep 22, 2015 at 22:01
  • \$\begingroup\$ @steveverrill A slight oversight. haha. I must've counted the lines knowing there were 4 commands on each line and didn't multiply the two together. \$\endgroup\$
    – Luminous
    Sep 23, 2015 at 12:31
-2
\$\begingroup\$

Just Golf 2016

(Related: A Kingdom Hearts VGM challenge) Sandbox note: potential duplicate?

Just Dance 2016 is coming out soon, and I know I'm definitely excited! However, let's take a quick trip back to 2009, when the original Just Dance was released. There are a lot of great songs, but I don't know who sung half of them!

The Challenge

Write a program that accepts a Just Dance song name from input and outputs the song's artist (as credited in-game.)

Here is the list of all songs and artists from Just Dance 1:
list pending

Rules and Assumptions

  • You may assume that the song will always be valid.
  • The song's title and artist must be properly capitalized.
  • You may not read any external files - the song data must be hardcoded.
  • If a song is covered (which several have been for various reasons), the program should return the cover artist (as they are credited in the game.)

Test Cases

Input: Eye of the Tiger
Output: Survivor

Input: Fame
Output: Irene Cara

Bonuses

  • Each game has had one song everyone was really excited about. This year, it's Ievan Polkka by Hatsune Miku. You get a bonus of -50 points if you accept this song as valid input.

  • Just Dance is fun, but why should we stop there? If you additionally accept songs fron the rest of the main series (Just Dance 2, 3, Greatest Hits/Best Of, 4, 2014, and 2015, not including DLC and skipping over any duplicates), you get a whopping -2009 points. Here is the full list for those games:
    list pending

    • Note that this doesn't include Just Dance 2016 songs.
    • This can be combined with the other bonus to get a total of -2059 bytes.

Meta Questions

  • Are the bonuses too big? (I'm mainly talking about the -2009 point bonus for including every song.)
  • Has anything been left out?
  • Is this enough of a challenge?
\$\endgroup\$
6
  • 1
    \$\begingroup\$ This looks like a dupe of codegolf.stackexchange.com/q/53678/194 . \$\endgroup\$ Sep 24, 2015 at 20:24
  • \$\begingroup\$ @PeterTaylor I would say it isn't, that one asks for input in the form of a game and boss and returns a song, mine asks for a song and returns an artist. That one also has different scoring rules, and mine requires all items to be implemented. \$\endgroup\$ Sep 25, 2015 at 13:51
  • \$\begingroup\$ They're both "golf this given map / dictionary / associative array". Why would the techniques used be any different? \$\endgroup\$ Sep 25, 2015 at 15:22
  • \$\begingroup\$ @PeterTaylor According to this meta post, the main qualification for duplicates is "Can answers from one question be copied over to the other with little or no modification and still be competitive?". I looked at the answers for the question you linked, and it doesn't seem like either would do very well if those techniques were used in this challenge. \$\endgroup\$ Sep 25, 2015 at 15:35
  • \$\begingroup\$ Would this be kolmogorov-complexity? \$\endgroup\$ Sep 26, 2015 at 17:16
  • \$\begingroup\$ @LegionMammal978 Yes. \$\endgroup\$ Sep 27, 2015 at 14:48
-2
\$\begingroup\$

Literally just printing the source code

Wait a second. We already have a contest where you print the source code. Right? Wrong.

The challenge

Print out the source code. Not to STDOUT, but to a physical printer.

The rules:

  • You must write a complete program that prints out its own source code with a printer connected to the computer.
  • No STDIN (or input of any kind), STDOUT, or STDERR.
  • No standard loopholes (includes no file input). No using lp(r/d) or similar commands.
  • The printed code should be a reasonable size (between size 8 and 18) and a legible font (pretty much means no wingdings).
  • You may assume that the user doesn't cancel the process and answers affirmatively to any system print dialogs.
  • You can assume that the printer works, is ready, doesn't need new ink/paper, etc.
  • If the language doesn't support printing, it is ineligible.
  • This is so shortest code, in bytes, wins.
\$\endgroup\$
2
  • \$\begingroup\$ This is a trivial extension of the quine challenge. All you have to do is say you're running it on Unix/Linux and pipe the output to lpr. \$\endgroup\$
    – user45941
    Nov 1, 2015 at 22:21
  • 1
    \$\begingroup\$ This needs a much tighter spec on the hardware. E.g. I assume you would consider it cheating to post an ordinary quine and say "On this computer, all console output is also logged to a continuous print spool", but there are computers which are configured like that for audit reasons. \$\endgroup\$ Nov 2, 2015 at 14:39
-2
\$\begingroup\$

Restricted "Hello, World!"

The task is very simple, output Hello, World! to STDOUT. The thing that makes this different are the rules:

  • You need to provide a full functioning program, taking no input and outputting via STDOUT.
  • The program must not write anything to STDERR
  • The maximum amount of bytes you can use is 50
  • The program may only contain printable ASCII characters. Programs using CP437 and other encoding systems are not allowed
  • If a programming language is already used, you cannot use this same language again.
  • You cannot use any character of the prohibited character list. This is the twist:

Prohibited character list (PCL):

The prohibited character list is a list full of characters, which cannot be used in the following programs. For example:

If the list was: He\., you need to create a program, without the characters H, e, \ and .. These are not case-sensitive.

If you succesfully manage to write a program that doesn't use any characters, you may add new one character to the prohibited character list.

e.g.

If the old PCL was He\., and you managed to write a program that doesn't use any of these characters, you may add a new character to this list. For example (whitespace). The new PCL will be He \. (notice that the whitespace character is added).

Posting Snippet:

This might help you wit posting your submission:

#[Language Name], N bytes

 [code]

 (explaination etc.)

 Added character: [char]

 New PCL: [list + new char]

In the beginning, the PCL is empty. The last person who managed to create a program without a new program made in 2 days, wins!


I'm not really sure if it is flawed or not. If you have any suggestions or comments, feel free to post them below in the comment section :)

\$\endgroup\$
1
  • 2
    \$\begingroup\$ Already exists. \$\endgroup\$
    – Arcturus
    Nov 22, 2015 at 23:38
1
121 122
123
124 125
131

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .