What is the Sandbox?

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

See the Sandbox FAQ for more information on how to use the Sandbox.

Get the Sandbox Viewer to view the sandbox more easily

To add an inline tag to a proposal use shortcut link syntax with a prefix: [tag:king-of-the-hill]

• How are tags added to questions? – guest271314 Jan 9 '19 at 7:51
• @guest271314 You can use this markup to create a tag in a draft: [tag:code-golf] – DJMcMayhem Aug 29 '19 at 15:19
• Why no featured anymore? Can't we have it auto-added or something? – S.S. Anne Sep 26 '19 at 15:57
• @JL2210 We now have a permanent info box that links to the Sandbox, so the featured tag isn't necessary – caird coinheringaahing Sep 29 '19 at 13:43
• $y=mx+c+abcdef$ – Rebecca J. Stones Jan 4 at 3:14

Given the source code of a function or method to delete the first node having value x if existed, from a non-cyclic singly linked list, in a specific programming language. Write a program or function (not necessarily in the same language) to decide what kind of implementation it is.

You don't have to check for all the cases. But the more intelligent your code is, the better.

The possible implementations need to be checked are:

Pointer of pointers

(Spec and examples to be added.)

(Spec and examples to be added.)

Moving the data

(Spec and examples to be added.)

(And maybe some others.)

Possible winning criteria:

• Just .
• Something like where a submission is valid if no shorter programs can do all the things documented in the answer.

Would someone like to write a crontab puzzle?

I have just asked for a software that displays all times at which a cronjob runs. As I think more about it, this might be a nice golfing question.

Unfortunately I'm not too familiar with the crontab specification, especially when it comes to combining operators such as

*/15,34,49-52 * * * * /path/to/command


Is that suitable for code-golf at all? If someone or a group of people would define it as a puzzle, I'd be glad to see it.

Starting point:

The program

• takes a crontab line as input
• checks if it is valid or not
• if valid, from now on lists the next execution times
• limited to a user definable amount

E.g.

program -n 10 30 17 * * *


produces 10 lines of output (assuming today is 2015-10-22 18:00)

2015-10-23 17:30
2015-10-24 17:30
2015-10-25 17:30
2015-10-26 17:30
2015-10-27 17:30
2015-10-28 17:30
2015-10-29 17:30
2015-10-30 17:30
2015-10-31 17:30
2015-11-01 17:30


Word Game KotH king-of-the-hill

First of all, I don't know what this game is called (or if it even has a name), but it's a modification of a game I've played a few times on road trips, especially with my family. I'll be thinking of a better name.

Any suggestions at all are very welcome.

How It's Played

There are 51 bots playing per game. At the beginning of the game, they are given a collection of letters (which is not necessarily a word), for example "a" or "jet." The bots take turns in a predetermined order. When it is a bot's turn it is passed the current word(s) and has four2 options:

1. It can change a single letter to any other letter.
2. It can add a single letter to any position in the word.
3. It can swap any two letters in the word.
4. It can split the word at any point.

If you didn't infer already, these actions are allowed with the caveat that their result is a valid word or two valid words, if the bot chooses to split. The game ends when the combined lengths of all the words in play are 3 times the length of the longest word in the dictionary used (e.g. if "onomatopoeia" is the longest word, the max length would be 36 letters since it has 12) or when only one bot remains. The bots are scored on how many turns they last*, and the winner of the game is granted a bonus3.

*The turn they lose on is not counted, so if the bot were to lose on its first turn it would have lasted 0 turns.

A word is valid if it is both in the dictionary and hasn't been played before.

Bots should take a reasonable amount of time in making their plays (no more than a few seconds).

Available Methods

isValid(word) returns a Boolean value (whether the word is valid or not).

getDictionary() returns the entire dictionary as a single string.

getPreviousPlays() returns the words previously played as an array (one word per element).

Once any of the following methods are called, the bot's turn is over:

change(index,letter) changes the letter at that index to the letter provided. This method cannot change a space to a letter (to prevent stalling).

insert(index,letter) inserts the provided letter at the provided index.

swap(index1,index2) swaps the letters at index1 and index2.

split(index) splits the word into two by inserting a space at the specified index. Both of these words have to be valid4

If any of the calls to these methods are invalid, the bot is disqualified for that game (treated as a loss).

Author's notes

1. Basically a random number I determined; I don't know if it's too big or small.
2. Is four too few to make this challenge interesting?
3. This bonus is undetermined as of now, but I'd say 2 points tentatively. I'm also a bit unsure as to whether that is a good scoring method. Should it just be on victories or position in victory (i.e. first, second, third, etc. place)? I'm also worried that this might encourage users to submit bots that collaborate to last as many rounds as possible.
4. Would it be more interesting if this ignored validity? e.g. if you have candies dog as the two words, splitting candies into can and dies would be valid even if either of those words had been played before.

I haven't done a KotH submission before, so I'd love feedback as to how to improve this.

Unimplemented Portions

Controller

This is the big unimplemented portion: I want to get feedback on the idea as a whole before diving into programming out a controller.

Scoring

I'm still unsure as to how the games should be scored.

• I don't understand how the game starts. If I'm passed a bunch of random letters, surely the majority of the time I can't make a word and I lose immediately? – Peter Taylor Oct 24 '15 at 8:58

Create CHIQRSX9+ Analogue Program.

Your task is to create a program in same language, that when given a CHIQRSX9+ will print a that analogue. That analogue program will do similiar thing that CHIQRSX9+ program do. There's exception though. There's may be more than 1 instruction. Then it's meant to be executed

1. C => Read until empty line and print all entered lines, including empty line.
2. H => Print "Hello, world!"
3. I => Read input until a newline then return that analogue
4. Q => Print the analogue program source code. (Not the entered one)
5. R => Read input until a newline then print that string after doing ROT-13
6. S => Read comma separated number until newline and sort that.
7. X => For this, X have undefined behavior.
8. 9 => Print 99 Bottles of beer with correct pluralization.
9. + => Increment Accumulator.

Printing instruction(C, H, I, Q, R, S, and 9) begin in a new line. After everything is printed, accumulator count is written at new line. Final newline is optional.

Example

If there's program X written in Haskell, then

X
CH
>main=interact$(++"\nHello, world!\n0").unlines.takeWhile(/="").lines  Which when compiled (Example as W) will do that W This is a line This is another line >This is a line >This is another line > >Hello, world! >0  Another example for Q X Q >main=putStr(s++[';','s','=']++show s);s="main=putStr(s++[';','s','=']++show s)"  Yet another example X H+ >main=printStr"Hello, world!\n1"  Here is for indication of output. DO NOT print it. Sandboxing Question How about scoring. I want to reward short produced program. However, shorness of producing program is also counted. I guess just 10A+5B+C. Where A is length of original source code, B is length of "QQQQ" analogue program. C is length of "CHIQRS9+". • Well, please tell me what's wrong in my question? – Akangka Oct 24 '15 at 15:51 • 1. I think this is a source-source compiler, which might be a more recognisable title than "create analogue program". 2. The HQ9+ family has a very mixed reception here, so you should probably expect some downvotes. 3. Why does the scoring system include a weight for votes? – Peter Taylor Oct 25 '15 at 7:43 • 1. If it source-source compiler, Q will compiled to main=putstr"Q\n0" instead. – Akangka Oct 25 '15 at 13:10 • 2. What's wrong about HQ9+ except that it can be used to cheat at golfing. – Akangka Oct 25 '15 at 13:11 • 3. Just a tiny boost since "QQQQ" "CHIQRS9+" and original source code is already very big. Wait I'm writing it wrong. It must be subtraction. Else it will be penalty – Akangka Oct 25 '15 at 13:12 • Is that vote annoying? – Akangka Oct 26 '15 at 8:05 • Congrats on posting the 1600th answer in the Sandbox! – mbomb007 Oct 27 '15 at 15:57 Goal The goal is to stitch several ordered lists of numbers into a single list that contains each of those lists as a contiguous sublist, with the numbers in the same order without gaps. The resulting list should be as short as possible. Input n ordered lists of numbers between -2^63 and 2^63-1 Ouput A minimum-length list so that each input list appears within that list with its elements in the same order without gaps Example Input: [1, 2, 3] [3, -38, 23424, 292] [0, 1, 2] [-38]  Output: [0, 1, 2, 3, -38, 23424, 292]  The output contains each of the input lists: [0, 1, 2, 3, -38, 23424, 292] [1, 2, 3] [3, -38, 23424, 292] [0, 1, 2] [-38]  • Many languages have built-ins both for flattening a list of lists and for removing duplicates, giving them a straightforward solution. I think that makes this too easy overall. The removing duplicates part is like this challenge, though it uses characters and requires preserving order. – xnor Oct 30 '15 at 21:26 • But it is not only about removing duplicates, but also about finding the perfect combination of lists, so you have to figure out in which order you want to put the input lists together. Also it might be necessary to have duplicates in the output to be able to have all input lists in there. – Nitek Oct 31 '15 at 7:13 • Oh, my mistake, I didn't realize the lists had to appear as contiguous subsequences. Let me edit that to try to make it clearer. – xnor Oct 31 '15 at 7:18 • Out of curiosity, I found notes about this as an algorithmic problem, and it's NP-hard, so solutions are going to be exponential time. It would do good to include some test cases that a greedy algorithm would get wrong. – xnor Oct 31 '15 at 7:29 • Looks like we already have this challenge. – xnor Oct 31 '15 at 8:53 • Good catch. It's indeed the same problem. Thanks for pointing that out! – Nitek Oct 31 '15 at 9:03 Hello, World! Fitted in cases. Your task is to take a line of input and print Hello,world! multiple times fitted to length of input. The cases of that character is fitted to input in same position(except shifted from deletion). If the corresponding character is non-alphabeth, you must use default case(lowercase except for "h" that is uppercase). And for punctuations, if the corresponding character is not punctuation, it will deleted. And if the corresponding character is space, the the ouput is space but it doesn't skip the "Hello,world" writing. Example Hello, world! Hello, world!  About punctuation deletion and space insertion I have a dog. I name it Underdog. H ello w orld H ello wo Rldhellow  Explanation Ihaveadog.InameitUnderdog. Hello,worlD!hello,world!hellow Helloworld!hello,World!hellow HelloworldHello,wOrld!hellow HelloworldHellowoRld!hellow HelloworldHellowoRldhellow  Other examples .....&^&%&*%&(&)^$#()&#()&@#)*%)#1-
Hello,world!Hello,world!Hello,world

UPPERCASES
HELLOWORLD

lowercases
helloworld

Abdeg,fGhiJ.
Hello,wOrlD!


Example Program

Here is ungolfed version of example program in Python. If there is error, correct me.

p=readline()
h="Hello, world"
i=0
k=""
for a in xrange(len(p)):
if p[a]==" ":
k=k+" "
continue
if isUpper(p[a]):
if isAlpha(h[i]):
k=k+upper(h[i])
i=i+1
continue
if isLower(p[a]):
if isAlpha(h[i]):
k=k+lower(h[i])
i=i+1
continue
k=k+h[i]
i=i+1


Sandbox Question

This language is surely need to be fixed.

How am I doing?

My boss is a flashy sort of fellow. He likes all things animated.

He's asked me to write a progress bar to show the completeness of our super-secret project.

Now with me being me, I'm getting you to write this for me and showing the best one to my boss.

• Output a progress bar to stdout.
• Whenever a newline is sent to stdin, increase the percentage on the percentage bar by 1%
• If not already enabled and if possible in your language, set the terminal mode to non-echoing (stdin doesn't automatically get shown, think like when your typing in your password for sudo)
• You may not assume the cursor is in a certain position, it must produce a progress bar relative to where you started the program (no absolute jumps)

To help you, you may use ANSI escape codes, ANSI colour codes and any UTF-32 unicode points.

The winner is the entry with the most upvotes.

Sandbox Notes:

• Is this too broad? - I'm sticking to ANSI only but I'm not saying anything else about what it looks like.
• Anyone care to say why this is worth a downvote? – Blue Nov 2 '15 at 17:12
• Popularity contests tend to attract them (even the good ones). – trichoplax Nov 3 '15 at 19:47
• This doesn't seem very tightly defined. Generally, the broader a popularity contest is, the more I expect it to gather downvotes. – trichoplax Nov 3 '15 at 19:48
• Also, a simple requirement means most of the popularity of an answer will come from optional extras rather than meeting the spec. See the line between art and programming for other's thoughts on this. – trichoplax Nov 3 '15 at 19:50
• Thanks for the link, I think I'll just let this question die here (I'm not sure if I should delete it or not, I'm going with not deleting it unless someone else says otherwise) – Blue Nov 3 '15 at 19:57
• I usually delete my challenges once I know for certain I will not post them, but for ones I (or someone else) might be able to salvage in future I leave them around. – trichoplax Nov 3 '15 at 19:59
• I don't think this one is ready for main, but remember that here (as on main) a lone downvote doesn't really mean anything. It could be anyone for any reason - rational or otherwise. – trichoplax Nov 3 '15 at 20:00

Kaprekar Transformation

Kaprekar Transformation is an transformation a number by following that instruction:

1. Take n-digit integer.
2. Sort it anscending and descending.
3. Subtract the largest number and smallest number.

Your program have to do this:

1. Take 1 number, x.
2. Output all possible cycle and fixnums for doing repeated x-digit Kaprekar Transformation on all possible input. Rotation is considered same. So it is invalid to print:

[00],[09,81,63,27,45],[81,63,27,45,09]

The output is a list consisting of list representing the cycle. You may using any style of list and even intermix it with restriction that it should not be ambigous. For example, comma separated item with item using comma separated item with enclosing bracket is OK, but not comma separated item with item using comma separated item without enclosing bracket.

Example:

8
>[00000000],[43208766,85317642,75308643,84308652,86308632,86326632,64326654],[63317664],[64308654,83208762,86526432],[97508421]


Or

>[00000000],[[43208766,85317642,75308643,84308652,86308632,86326632,64326654],[63317664],[64308654,83208762,86526432],[97508421]]

• I'm afraid this is a duplicate: codegolf.stackexchange.com/q/2762/8478 ... also, for future reference, requiring one specific list format is bound to put an arbitrary set of languages at a massive advantage (those which can just use their native string format), while all others may have to do some non-trivial string processing which distracts from the (interesting) core of the challenge. – Martin Ender Nov 2 '15 at 12:56
• @MartinBüttner No, it is the generalization. You have to handle arbitrary digit this time. And you have to detect cycle and find all cycle given a digit. Btw, there is typo. 2 39 is different example. – Akangka Nov 2 '15 at 13:04
• Task one seems to be identical. The fact that the other challenge only has to work with 4-digit numbers doesn't seem substantial. I'm pretty sure almost any answer there can be adapted to a variable number of digits in a couple of bytes. As for Task 2, I did overlook that. You could simply reduce the challenge to just task 2 (I'm not even sure why you'd combine two independent tasks into a single challenge?). Even task 2 can be solved by simply looping the solution to task 1 over all possible X-digit numbers, but there might be other ways to golf this one. – Martin Ender Nov 2 '15 at 13:07
• @MartinBüttner Then, why it isn't duplicate of codegolf.stackexchange.com/questions/1255/hitting-495-kaprekar ? – Akangka Nov 2 '15 at 13:14
• Because it has been overlooked, I suppose. Fixed. – Martin Ender Nov 2 '15 at 13:15
• @MartinBüttner Maybe add time limit make this different enough. – Akangka Nov 2 '15 at 13:15
• I don't know. Since you have to output the entire list anyway, there is not much you can optimise beyond actually applying the transform until you hit a cycle. If you limited the challenge to the second task, a time limit might make more sense, but then again the second task might be different enough not to be a duplicate in the first place. – Martin Ender Nov 2 '15 at 13:17
• @MartinBüttner Then remove task 1 and it won't be duplicate? And add speed limit. – Akangka Nov 2 '15 at 13:29
• I don't even think a time limit is necessary for part 2. – Martin Ender Nov 2 '15 at 13:30
• @MartinBüttner Is Task 1 still have to deleted. And please, don't discuss in the Chat, because I can't access that. Better use my email: christianirwanhw@gmail.com – Akangka Nov 2 '15 at 13:57
• As I said above, I don't see why you would want to squeeze both tasks into a single challenge in the first place. (How would you score answers? Sum of the two solutions?) And if you split them up, then the first answer is certainly a duplicate, but the second is fine (and if you didn't split them up, I don't see why you'd redo the same challenge as part of another challenge either). – Martin Ender Nov 2 '15 at 13:59
• The cycle identification is borderline duplicate of codegolf.stackexchange.com/q/26578/194 – Peter Taylor Nov 2 '15 at 14:32

Show How a Regex Is Matched

What your program or function should do:

1. Accept input of two strings; let's call them r and s.
2. Determine whether r is a valid regular expression (you can use any common definition of regex for this purpose, or any common definition of regexes but with lookahead and lookbehind removed; indicate which you're using). Otherwise, don't output.
3. If so, determine whether s matches r as a regex. Otherwise, don't output.
4. If so, output/print, in order, the part of r matched by each character of s, and also the part of s that matches it.

Note: You may use your language's regex-matching library for this.

Example:

Using PCRE; my inputs and outputs are r first and then s.

^.el*(o.*)*d\b and Hello, world!
^.ello......d\b and Hello, world

.\1\W and 800-555-1212
..\W and 00-

\b and a
\b and empty string

\d and a
no output (it doesn't match)

First floated in chat.
Not a dupe of Compile Regexes (which asks you to match regexes whereas this allows you to use the resources of your language to do so).

• 1. It sure looks like a dupe to me: what's your argument for it not being a trivial transformation of the previous question? 2. In your examples, you seem to try to draw a distinction between outputting the empty string and not outputting anything. How does that work? 3. What exactly is the output format? E.g. the first example and the second example don't seem to be consistent in their treatment of metacharacters. – Peter Taylor Nov 5 '15 at 22:49
• @PeterTaylor 1. It's not a dupe at all: the older question asks you to match regexes whereas this allows you to use the resources of your language to do so; also, the older question outputs a means of determining matching, without regard to how it's matched, whereas this requires an output of the latter. 2. This question is OBE because of the edit I'm doing to fix #3. 3. Yeah, I messed up an example: I'll fix that immediately. – msh210 Nov 5 '15 at 23:05
• 1. With respect to the second half, see "simple transformation". But the first half is relevant, and worth editing in to the "Not a dupe" sentence. 3. I still can't figure out the output format from the examples. Obviously you want to ensure that it's not as trivial as asking the regex engine for group 0, but I think you need to first write a clear spec for the output and then write the examples (or, better, write a reference implementation to generate the examples). – Peter Taylor Nov 6 '15 at 7:27
• @PeterTaylor, yeah, I'll have to work on it some more. If anyone else has ideas, please chime in! – msh210 Nov 6 '15 at 9:24

Python assembler

Python is a hybrid interpreted language. It first gets compiled into byte-code and then gets interpreted.

What does this byte-code look like you may ask? The dis module disassembles python code. Source code for dis module here

print "Hello, World!"


Gets disassembled into the following assembly.

  1           0 LOAD_CONST               0 ('Hello, World!')
3 PRINT_ITEM
4 PRINT_NEWLINE
8 RETURN_VALUE


The output is divided in the following columns:

1. the line number, for the first instruction of each line

2. a labelled instruction, indicated with >>,

3. the address of the instruction,

4. the operation code name,

5. operation parameters, and

6. interpretation of the parameters in parentheses.

The disassembly of a basic for loop

for i in range(10):
print i


gives

  1           0 SETUP_LOOP              25 (to 28)
9 CALL_FUNCTION            1
12 GET_ITER
>>   13 FOR_ITER                11 (to 27)
16 STORE_NAME               1 (i)

22 PRINT_ITEM
23 PRINT_NEWLINE
24 JUMP_ABSOLUTE           13
>>   27 POP_BLOCK
31 RETURN_VALUE


Given some python code that has been disassembled, recreate the original code object as close as you can. You can take the disassembled code through any method you chose.

Your program will output all the arguments to recreate a python code object

That is to say your program will output the following

0,
0,
nlocals,
stacksize,
0,
codestring,
consts,
names,
varnames,
"a string here",
"another string here",
0,
lnotab,
(),
()


You can work out the variables listed above but you have to output it all, even the constants.

• nlocals - The number of local variables
• stacksize - The maximum number of values held on the stack at once
• codestring - A binary containing all the opcodes and their arguments
• consts - A tuple of constants
• names - A tuple of global variables
• varnames - A tuple of local names (length of nlocals)
• lnotab - A tuple containing a map of bytecode positions to line numbers

You may use the following code to disassemble a .pyc file:

import sys, dis, marshal

with open(sys.argv[1], "rb") as code_f:
code_f.read(8) # Magic number and modification time
dis.dis(code)


This is code-golf, the shortest code in bytes wins

Sandbox notes

Wow that was a long one. Perhaps too long?

Is the spec completely tight?

Should I explain anything further?

Am I making it too hard for non-python entries to take part?

Should I only make it a requirement to reassemble code without any functions/classes? I'm pretty sure dis doesn't show all that.

• For one thing, yes this looks very hard for non-Python entries to me. For another, I think there's too much going on at once (there's a lot to output), and you don't explain much about how to output each specific component (ideally the post should be self-contained enough to work out what to do without knowing too much about Python/dis) – Sp3000 Nov 9 '15 at 15:41

Vigenère Cipher

Write a program that is capable of breaking a text encyripted using Vigenère cipher encyription.

Goals:

• Take encripted text from STDIN and write plaintext to STDOUT.

Limits

• Keyword will always be 3 letters in length.
• Plaintext will always be in between 5-10 letters in length (inclusive).
• All Plaintexts, Keywords and Encyripted Texts will be in English.

Scoring:

This is a . Shortest code in bytes wins.

I'm not sure if this is a valid and solvable question, so any suggestions are welcomed.

• Dupe – Mego Nov 10 '15 at 18:19
• I'm not sure this can actually be done without having a big dictionary for such a short piece of text. (Also, what does "encrypted texts will be English" mean?) – Paŭlo Ebermann Nov 15 '15 at 15:01
• @PaŭloEbermann It means they will only contain english characters, no special letters from other languages. – goodguy Nov 15 '15 at 15:12
• Then write "consist of the letters A-Z" instead (or similar if you allow spaces and punctuation – though that needs more specification). – Paŭlo Ebermann Nov 15 '15 at 15:14
• For Vigenere, in general you can either try a "plaintext dictionary attack" (which means you'll have a list of valid plaintext words, like in the question linked by Mego – that would be a plain duplicate), or you try analysis of character frequencies or repetitions, which need a lot longer ciphertext in order to analyze anything useful. (Or you just output all possible plaintexts, and let the task of recognizing the correct one to some human.) – Paŭlo Ebermann Nov 15 '15 at 15:19

List Style Converter

[code:golf]

Given a list, format it into list of the choice of the input. The list will be list of item defined below, but it can be multidimensional.

List Styles

There is 2 list separators:

1. Space
2. Comma

For one dimensional list, only one separator is accepted. Space and only space between item is considered as separator. It is impossible to have more than 2 dimension without enclosing list of second dimension or third dimension. when parsing list, comma takes lower precedence and it is parsed with least dimension as possible. Space is optional between ] with [; } with {; and ) with (

There is 3 list enclosure:

3. [...]

4. (...)
5. {...}

Closing bracket must be present.

Item

There is 2 types of item, another list or those following regex [0-9a-zA-Z]* or everything enclosed with single quote or double quote. If enclosed with single quote, it can contains double quote and vice versa. There is no zero-length item

Here is valid non-list item

98Az
Helloworld
"Hello, world!"
"It's house."


Here is the list

Hello, World!
Space then it is list
()


Here is invalid item.

Winner

The winner is the one with the fewest bytes of code that produces the correct output.

• In the example output, I'm not sure why for the first input the output is newline-separated, but for the second it's space-separated. I also don't understand the second paragraph in the section "The environment". – Peter Taylor Nov 27 '15 at 21:30
• @PeterTaylor In quiddler you can have multiple words per possible solution. I'll add a second example to demo. – HSchmale Nov 27 '15 at 21:53
• So is this basically a variant on Countdown where the dictionary is amplified by including its Cartesian power? – Peter Taylor Nov 28 '15 at 8:08
• @PeterTaylor: Pretty much, except I did not know that existed. Also, for each answer you can only use each answer once. – HSchmale Nov 28 '15 at 16:43

Ancient Language Translator

<insert a silly story here>

Write a program that takes an English sentence and translates it into the Ancient Language. You have to implement at least 42 words. For the purpose of this challenge, you do not have to care about special rules such as "(may be shortened to al when used as a prefix, as in albitr)".

Input:

An English sentence.

Output:

A translated version of the input, simply replace the English words with the Ancient ones.

Scoring:

Suggestions?

• This might be considered as too broad as there is no specific words to implement. For scoring a code-challenge might work with the score being something like the sum of the length of all words implemented. code-golf might also work. Kind of related challenge. The title is also possibly misleading, so I'd suggest putting "Ancient Language" in quotes – Downgoat Nov 29 '15 at 16:55
• I think this would be uninteresting just because it's just replacement, not actual translation. – cat Nov 30 '15 at 3:07
• @sysreq Translating English into the "Ancient Language" is just replacement as far as I know... – Stefnotch Nov 30 '15 at 17:24
• @Downgoat Oh, ok! So, what words should have to be included? A selection of) the most common words: en.wikipedia.org/wiki/Most_common_words_in_English – Stefnotch Nov 30 '15 at 17:26

The goal of this challenge is to complete a list of consecutive nested header numbers when given a start and an end. When given 1.1.1 and 1.1.5 you should generate 1.1.1, 1.1.2, 1.1.3, 1.1.4, 1.1.5

Specific Rules

1. Your entry must take in a start, end, and multiple optional range parameters. Parameters can be taken form STDIN (or nearest equivalent) or a file.
2. Your entry may assume valid input
3. Input will be of the following format:
1. start and end will be strings of . delimited integers of the same length
2. start and end will have three segments; (1) set values, (2) iterator, (3) trailing values.
• The iterator is the first value which differs between start and end.
• The set values are the values before the iterator. These values never change
• The trailing values are the values after the iterator. These values iterate up as determined by the range parameter(s). All trailing values will be 1.
3. range will be a list of integers with a length corresponding to the number of trailing values. When there are no trailing values, range is not specified. The value of range corresponding to each trailing value determines the inclusive upper bound which that entry iterates to.
4. Output will be to STDOUT (or closest alternative) and will show each value separated by at least one delimiter. Delimiter can by any character or string of characters, but it must be consistent. Output must be sorted correctly

Examples

start = '1.1.5.1', end = '1.1.6.1', range = [5]
Output: 1.1.5.1, 1.1.5.2, 1.1.5.3, 1.1.5.4, 1.1.5.5, 1.1.6.1
^
previous value is iterated
only when iterating value
limit set by range

start = '1.1.5.1', end = '1.1.7.1', range = [5]
Output: 1.1.5.1, 1.1.5.2, 1.1.5.3, 1.1.5.4, 1.1.5.5, 1.1.6.1,
1.1.6.1, 1.1.6.2, 1.1.6.3, 1.1.6.4, 1.1.6.5, 1.1.7.1

start = '1.5.1.1', end = '1.6.1.1', range = [5,2]
Output: 1.5.1.1, 1.5.1.2, 1.5.2.1, 1.5.2.2, 1.5.3.1, 1.5.3.2,
1.5.4.1, 1.5.4.2, 1.5.5.1, 1.5.5.2, 1.6.1.1


This is code golf so shortest code by bytes wins.

Bonuses

1. Allow trailing values to be values other than 1 in end parameter - 12.5% off
2. Handle incorrect number of values in range parameter - 12.5% off
3. Handle end less than start by producing list in reverse - 50% off

Count the Connect Four Positions

Connect Four is a two-player game on a rectangular board. The board is m spaces wide and n spaces tall, and players alternate placing pieces in columns. A placed piece always fills the lowest empty space in a column, and a player may not move in a full column. In the standard game, m=7 and n=6.

The game ends when one player completes a row of four pieces vertically, horizontally, or diagonally, or all m columns are full. The edges of the board do not wrap.

Challenge

Write a program or function to determine the number of distinct, legal m by n Connect Four boards after p plies. (A ply is one move by one player.) A legal position is one reachable from the empty board through a sequence of moves in which no player had already won. (A position in which one player has just won is legal.)

Rules

You may assume that 0<=p<=m*n, m<=8 and n<=8.

As usual, hardcoding is not allowed.

Your code should be at most 1024 bytes in length, and use at most 16 GB of memory.

Related: Determine winner of Connect 4

Compile from Brainfuck

The professors at Brainfuck University realized their jobs are horrible, because all they do is discuss quantum mechanics using Brainfuck, so they decided to take their programs and compile them to a better language. Because of the randomness of quantum particles, their program needs to be small so it has a smaller chance of being disrupted in the Higgs Field.

Your task is to get a Brainfuck program from any input and output that program transcompiled into another language. Here is an example:

++-->><<

Compiles to the C program:

#include <stdio.h>
#include <stdlib.h>

int main(int argc, char **argv) {
unsigned char *cell = calloc(30000, 1);
unsigned char *cells = cell;
if (!cell) {
fprintf(stderr, "Error allocating memory.\n");
return 1;
}
//actual program
++*cell;
++*cell;
--*cell;
--*cell;
--cell;
--cell;
++cell;
++cell;

free(cells);
return 0;
}


Score

Bonuses

• Dupe – Mego Dec 5 '15 at 9:55

Logic Puzzle Solver/Inference Engine

Your goal is to take the clues and other facts given in a grade-school logic grid puzzle such as these and solve the puzzle. To keep things simple, your program will only solve specific logic problems about which it can make the assumptions you wish to hard-code in, but the program need not perform any checks to see if those assumptions can be made.

You may not use:

• A declarative language
• Any function provided - by an external dependency - for the solving of a logic puzzle.

Input

Your program will take input from the command line. After gathering assumptions, the program will ask for facts written as such:

subject.verb object


for all true facts. For false facts:

!subject.verb object


Chad.bought donuts


If he didn't:

!Chad.bought donuts.


If Nancy's last name isn't Wesley,

!Nancy.is Wesley.


Output

Your program will output its conclusions as such:

subject verb object.


So, if your program determines that Chad bought donuts and Nancy's last name is Wesley, then it will output:

Chad bought donuts.

Nancy's last name is Wesley.

• The "these" link goes to a login page. I'm not going to create an account on some random site just to find out what the spec is. – Peter Taylor Dec 15 '15 at 22:24
• "You may not use a declarative language" :-( – Fatalize Dec 16 '15 at 12:59
• Does "is" always refer to someone's last name? If not, how can our code know the difference between Nancy.is Wesley and Nancy.is chef? – Luke Dec 16 '15 at 14:49

New user to Programming Puzzles!

I would like a king of the hill challenge for bots playing the game of spades. Spades is a card game. The rules are shown on wikipedia.

Scoring rules:

• Nils allowed, with 50 points for completion (not 100). -50 for losing.
• 10 points a hand, with sandbagging allowed.
• Partnership Playing
• Sum of all four players hands cannot equal 13!

Winner is first to 500 points. The bot will be paired with all other bots entered into the competition. The pair of winners will be crowned with +10 meta-points (Mpoints), losers will get -1 Mpoints. Whoever has the most Mpoints wins - ties based upon sum of points earned in the games.

Gameplay:

• The bot with the lowest Mpoints bids first. Bidding proceeds from down until reaching 4th slot, then goes back to first slot and continues. Play starts with this player.
• The bot will be given a string of cards - AS for Ace of Spades, JC for Jack of Clubs, 2D for 2 of Diamonds, 8H for 8 of hearts, randomly dealt from a single 52-card deck. Each will be comma separated: AS,JC,2D,8H,4C,5S,8D,3D,3S,JS,10S
• The bot will get the bids from the other bots before making the bid.
• Upon winning a hand, the bot gets to continue making plays until someone else wins the hand.
• Hands are scored at the end using the scoring rules. If a team's score is less than 500, gameplay continues with a new hand.

Unfortunately, I do not know how to setup the servers or any of that stuff. I just think the challenge will be interesting. If anyone can help with that, run with it. I like to watch these challenges unfold - but I'm too much of an engineer and not enough of a programmer to make these kinds of programming happen.

• You should fully list out the rules in the body of the question - it's considered poor form for challenges to require exterior resources to be fully understood. – Mego Dec 22 '15 at 22:56

I was thinking about a challenge on wrapping time.

I am a member here for 34 days now. I would have expected for the date to wrap to 1 month.

Rules:

• starting with hours from the joining date to now.

• first wrapping happens when you go over 24 hours, the count will be in days now.

• second wrapping happens after reaching 30 or 31 days, you can decide, to months.

• third wrapping really wraps when a year is reached, it shall be displayed as i.e. 2 years 3 month.

• round to neares full unit, i.e. 43 days = 1 month, 50 days = 2 month

• take either a build in function to get the current time or hardcode it to ´2015-12-19-11´ <- time when challenge will be posted. If hardcoding it is shorter you may take the bytecount from the hardcoded version.

• Dates after the current or hardcoded date can do whatever.

Input

The joining date and hour like ´YYYY-MM-DD-HH´ the delimeter does not have to be a - choose whatever you like.

Output

The time according to the rules above.

Example:

In: 2015-12-10
Out: 9 Days

In: 2015-10-28
Out: 2 Month

• I believe I saw a challenge about wrapping 24-hour time that may be related, but not a duplicate. Also, what date are we calculating the difference from? – ASCIIThenANSI Dec 18 '15 at 17:05
• that would be the date right now or a set date if no build in is available – Eumel Dec 19 '15 at 8:19
• I think it should be either a built-in date or another date given from input for all languages, to make things fair. – ASCIIThenANSI Dec 19 '15 at 16:02
• I wanted it to be non input, how would you suggest doing that? – Eumel Dec 19 '15 at 20:01
• Use a built-in date such as 01-01-2015 (or 01-01-2000, depending on what the date range should be). The program should not be required to accept dates before that. – ASCIIThenANSI Dec 20 '15 at 21:14

Browser identifier

There are three major browsers at the moment, Internet Explorer, Google Chrome and Firefox. Sometimes, the JavaScript engines inside of these browsers work a bit differently, and that can break some applications. Therefore, we need a way to identify what browser the user is currently using!

Your answer should be a JavaScript program or function, that when run on the latest version of a browser, should output a string representing that browser. The string outputed could be anything, as long as it stays the same every time you run it. Output should go to a HTML paragraph with id O, console.log, or as return value.

Please put your answer in a snippet, along with <p id="o"></p> in the HTML section if your answer uses it.

(scoreboard snippet goes here)

• I believe Javascript has a builtin for this. It may be best to forbid using it. – SuperJedi224 Dec 22 '15 at 17:34
• @SuperJedi224 Well, I did some searching before, and I found this thread on SO, and the highest voted answer was a big mess, and no answer was very short and reliable. There is this other thread, and it has some that could be golfed a bit, but there isn't really one function / builtin that checks the browser. – Loovjo Dec 23 '15 at 2:56
• You might need to freeze the version numbers of the 3 browsers, or else require that answers specify version numbers. – trichoplax Dec 29 '15 at 15:54

Parse a tree for pruning

Windows supplies users with tree: a neat little tool that converts a directory tree to ASCII-CP437 art. It's a very human-readable format. However, it's a bit useless if you want the directory tree of an entire drive, or even just the Windows folder, as it's very hard to prune the parts you don't want. Hence this challenge.

Your task is to produce a function or program that will convert the tree from one or both of the input formats into one or more of the output formats. The smaller your code, the more of a head start you have.

Input

There are two types of input that you might be given:

CP437

This is the default.

Folder PATH listing for volume Main Drive
Volume serial number is 00F3-F586
C:\WINDOWS
│   explorer.exe
│   virus.dll
│   WLXPGSS.SCR
│   write.exe
│
├───Boot
│   │   BootDebuggerFiles.ini
│   │
│   ├───DVD
│   │       your.txt
│   │
│   ├───EFI
│   │       pc.txt
│   │
│   ├───Fonts
│   │       has.txt
│   │
│   ├───PCAT
│   │       been.txt
│   │
│   └───Resources
│           wrecked.txt
│
├───System
└───System32
cmd.exe
conhost.exe
winlogon.cmd
winlogon.exe


ASCII

This will be easier to parse for many languages.

Folder PATH listing for volume Main Drive
Volume serial number is 00F3-F586
C:\WINDOWS
|   explorer.exe
|   virus.dll
|   WLXPGSS.SCR
|   write.exe
|
+---Boot
|   |   BootDebuggerFiles.ini
|   |
|   +---DVD
|   |       your.txt
|   |
|   +---EFI
|   |       pc.txt
|   |
|   +---Fonts
|   |       has.txt
|   |
|   +---PCAT
|   |       been.txt
|   |
|   \---Resources
|           wrecked.txt
|
+---System
\---System32
cmd.exe
conhost.exe
winlogon.cmd
winlogon.exe


Output

There are several possible types of output you can return, each suited to a different type of language.

Array / List hierarchy of strings

The first element of each array / list is the name, the rest are the contents. Files should be represented by strings, empty folders should be represented by a single-length array containing one string. Note: This should be returned from a function as an array / list, not printed as a string.

["C:\WINDOWS", "explorer.exe", "notepad.exe", "virus.dll", "WLXPGSS.SCR", "write.exe", ["Boot", "BootDebuggerFiles.ini", ["DVD", "your.txt"], ["EFI", "pc.txt"], ["Fonts", "has.txt"], ["PCAT", "been.txt"], ["Resources", "wrecked.txt"]], ["System"], ["System32", "cmd.exe", "conhost.exe", "winlogon.cmd", "winlogon.exe"]]


Object / Dictionary

Similar to array / list, but a little more intuitive. Folders should have the value of their contents as another object / dictionary. Files should have the value "FILE".

{"C:\WINDOWS":{"explorer.exe":"FILE","notepad.exe":"FILE","virus.dll":"FILE","WLXPGSS.SCR":"FILE","write.exe":"FILE","Boot":{"BootDebuggerFiles.ini":"FILE","DVD":{"your.txt":"FILE"},"EFI":{"pc.txt":"FILE"},"Fonts":{"has.txt":"FILE"} [...] } [...] } [...] }


Lisp-style string

Similar to array / list, where the head of the list is the directory name and the tail is the contents. An empty directory is a list with no tail, and a file is a string.

No WAY am I putting an example. No way. I've spent half the time on this question creating the examples. No way. Ok, maybe later.


Bonus

If you satisfy none of these bonuses, your submission is still valid. But its score shall infinite, so it is non-competitive.
These bonuses are to multiply your score by. Bonuses stack by multiplication. These bonuses must all be achieved consistently to be awarded.

• 100% Allow at least one input mode and output mode
• 50% Allow both input modes
• 90% Output in exactly two ways
• 50% Output in one of two ways depending on parameters
• 80% Output in exactly three ways
• 25% Output in one of three ways depending on parameters

Identifying spies in "Resistance"

This is still very rough, but I think it has the makings of an interesting challenge. Please help me improve it. What do I need to add? What do I need clarify?

Resistance is a party game that pits "resistance members" against "imperial spies" on a series of missions. A very important aspect of the game is that the resistance members do not know who the spies are, whereas the spies do know who is who.

How the game works

Challenge

your challenge is to write a program that takes as input the details of every round and outputs who it thinks is a spy after each round. There are 5 rounds (missions) in a game of resistance, so the program/function will take in all the data for the first round, which includes

1. Each proposed team to go on the mission
2. Each public vote following each proposal
3. The final team to go on the mission
4. The outcome of the mission (i.e. how many passes and how many fails)

It will then output who it thinks is a spy. It will then do the same for each subsequent round.

Important Details

We will be playing resistance for (6?) people, A, B, C, D, E, and F.

Input format is flexible. It may be done round by round or all at once. However, since ach submission is outputting something for each of the five rounds, the submission may not use information from future rounds (if all information is given at once) in judging the current round.

Here is an example of possible input format:

Since the first mission requires two people, and person A is the first mission planner, the only thing input would be two letters in {A,B,C,D,E,F} indicating his selection. Then the votes of each person, in order, would be input. This continues until a mission team is accepted. Then the votes given on the mission would be input, in no/any particular order. The program would then output the letters of the two people it thinks are spies (there are 2 spies in a 6 person game). Here is an example

A B              # A selects A and B for first mission
P P P F F F      # Everyone votes, mission team is not accepted (lacks majority pass)
B F              # B selects B and F for first mission
P P P P P F      # Mission team is accepted (majority pass)
P F              # Mission fails (there is at least one fail vote). Note that the order does not matter here.


The bot would then output two people, the people it thinks are most likely to be the spies based on all the information it has up to this point.

B F              # Any two person subset is acceptable


Input then continues for the next 4 rounds, until the game is over.

Scoring

I will write several hundred test cases (from actual games played online). Then each output will be scored in the following way:

• 1 point for each correctly guessed spy.
• 1 point for guessing both spies correctly.

The submission's total score will be the sum of all scores on all rounds in all games. The program will never be told who is a spy (unless it is used to self-score and does not factor into the actual guessing) but this information will be available with the test cases for scoring purposes.

Tie break is code golf.

Meta: I think I'm going to remove output after the first round, because very rarely do people ever fail the first mission. So it will likely just be pure chance.

Nth Regex

This challenge('s explanation) is simple: given a number n and a regex r, output the nth string that matches r!

The regex r uses the syntax used in Python, described here. The regex will be for the whole string, meaning the regex will be implicitly wrapped in ^\$.

The only valid strings are printable ASCII characters, and they count up like base 95 (ASCII codes 32-126).

To prevent people from brute-forcing it, I was thinking of making it .

• I still think you mean "bijective base 95". otherwise, there are no strings with leading spaces (because if count up in base 10, there are no numbers with leading zeroes). – Martin Ender Dec 29 '15 at 14:09
• I'm not a fan of using a specific real-world flavour, because that gives an advantage to Python over all other languages. I also think it contains way too many features to be fun to tackle (which don't really add anything interesting to the challenge). I think the challenge would be interesting and hard enough for a simplified regex flavour containing only simple quantifiers, alternation and character classes. – Martin Ender Dec 29 '15 at 14:11
• I'm quite sure that some regexes are hard to solve. codegolf.stackexchange.com/questions/39829/… – Element118 Dec 29 '15 at 15:54
• I absolutely don't get the challenge, any example input/output ? – Tensibai Dec 30 '15 at 14:31
• Do you mean nth string lexicographically? – xnor Dec 30 '15 at 18:45