40
7
This is the cop's thread. The robber's thread is here.
Write a code that takes an input n
and creates a n-by-n "snake matrix".
A snake matrix is a matrix that follows this pattern:
3-by-3:
1 2 3
6 5 4
7 8 9
and 4-by-4:
1 2 3 4
8 7 6 5
9 10 11 12
16 15 14 13
The exact output format is optional. You may for instance output [[1 2 3],[6 5 4],[7 8 9]]
, or something similar.
You must provide the language name, and a regex that fully matches your code. You can choose how detailed your regex should be. In the extreme, you can write a regex that matches every possible string, in which case it will be very easy to crack your code. You must also provide the output for n=4
, so that robbers know the exact format you have opted for.
You may use one of the regex-flavors that are available on regex101.com, or the Ruby flavor.
- PCRE (PHP)
- Javascript
- Python
- Golang
- Ruby
You must specify which one you are using.
Notes:
- You must support any reasonably large
n
. You may assume it won't overflow the datatype or memory. If the default datatype is 8-bit signed integers, then you can assumen<=11
, if it's unsigned 8-bit integers, then you can assumen<=15
. - The robbers have to match the submission's output format, except leading/trailing spaces and newlines, since that might have been stripped away by the SE formatting.
Winning criterion:
The winner will be the uncracked submission with the shortest regex, measured in number of characters.
If your post has remained uncracked for 7 days, then you may post the intended solution and mark your submission as safe.
5Seed, length 1,
.
. – user41805 – 2017-03-08T16:04:55.9831
Can I use one of the languages documented here? http://codegolf.stackexchange.com/questions/61804/create-a-programming-language-that-only-appears-to-be-unusable/62493
– None – 2017-03-08T16:09:46.333@YiminRong I've seen Brian and Chuck used, but it also has an existing online interpreter. – mbomb007 – 2017-03-08T16:44:43.287
2@KritixiLithos Except you have to release your original program to become safe ;-) – ETHproductions – 2017-03-08T17:50:09.510
Trying first puzzle so bit confused. Do you mean write a code and then provide the regex which cracks your own code . And then, someone shows you what your code would look like (so your code is cracked). – Deepak Agarwal – 2017-03-08T19:32:53.123
3@DeepakAgarwal - Write your code to generate a snake, then provide a regex which matches it. The robber's solution must be in the same language and match the regex as well. So one strategy is to provide a restrictive regex, to make it hard on the robber, but not so restrictive that you give the solution! – None – 2017-03-08T19:48:12.567
@mbomb007 - All the languages there have an interpreter as required in the challenge. Just wondering if I can use them? – None – 2017-03-08T19:50:41.607
Yeah, you can use them. – mbomb007 – 2017-03-08T19:53:29.087
Please clarify what is "a code". Does a snippet that assume
– kennytm – 2017-03-09T21:44:08.513n
is already declared and initialized (like this solution) count as valid? Do http://meta.codegolf.stackexchange.com/questions/2419/default-for-code-golf-program-function-or-snippet and http://meta.codegolf.stackexchange.com/questions/2447/default-for-code-golf-input-output-methods apply here? (these two meta questions are for [tag:code-golf] but here is not code-golf)No, that submission doesn't take
n
as input, so it should not be a valid submission as far as I can tell. The two meta posts apply here too :) – Stewie Griffin – 2017-03-09T21:51:38.0232
Is this meta consensus allowing unary I/O for sed, that has no data types, be valid for this challenge?
– seshoumara – 2017-03-10T14:42:12.333What about ECMAScript regex? – Matthew Roh – 2017-03-12T15:35:47.930
@seshoumara, this consensus is OK, but make it very clear in your answer how you call the function/program, and what the output looks like. Please include the output for both
– Stewie Griffin – 2017-03-13T10:08:33.020n=3
andn=4
, so that people can see how the format changes when there numbers increase.@MatthewRoh, I think the 5 different options should be sufficient, unless you have some very convincing arguments for why I should add it to the list. – Stewie Griffin – 2017-03-13T10:11:33.820
There's some uncertainty over what "fully matches" means. Do we need to surround our regexes in
^$
? – Brian McCutchon – 2017-03-13T17:29:22.300