///, 35 bytes
/I///,*/+,//+/I//**,/,A//*/A//,//,I
Try it online!
Takes input in unary using symbol *
, and output in unary using symbol A
. This is allowed for some specific languages, including /// (meta)
Because there is no way to take input in ///, input should be hardcoded:
/I/«put input here»//,*/+,//+/I//**,/,A//*/A//,//,I
for input = 4.
Explanation: (before reading, you need to know that the only syntax of ///
are /pattern/replacement/
, which replace every occurence of pattern
by replacement
; and \
for escaping; other characters is printed to output)
For n=4
:
/I/****//,*/+,//+/I//**,/,A//*/A//,//,I Start program.
/I/****/ Replace all `I` in the program by the input.
/,*/+,//+/****//**,/,A//*/A//,//,**** Remaining part of the program.
/,*/+,/ Use the `,` as a scanner, scan through `*` after it and convert to `+`.
/+/****//**,/,A//*/A//,//++++, Note that only `*` in the second group is affected.
/+/****/ Replace all `+` (which is just created) by `n` asterisks (from the first `I` group)
/**,/,A//*/A//,//****************, Now at the last of the program before the `,` there are `n²` asterisks.
/**,/,A/ Scan the `,` to the left to perform division by 2:
replace each `**` by a `A` as the scanner `,` pass through.
/*/A//,//,AAAAAAAA Remaining program.
/*/A/ If there is any `*` remaining (if `n²` is odd), replace it with `A`.
/,// Remove the scanner `,`.
AAAAAAAA Output the result.
1Welcome to the site. We do not do programming help but rather host programming competitions. This could certainly be an on topic programming competition but it would need a scoring criterion, probably [tag:code-golf]. – Post Rock Garf Hunter – 2017-10-02T08:30:17.717
Related – Arnauld – 2017-10-02T08:31:18.057
4So the Camel is to the Rook what the King is to the Queen? I.e. can only move orthogonally, and only one step at a time. – Adám – 2017-10-02T08:32:15.957
1Since the answer to this question is just a formula, it is not a good fit for a competition style site. – Adám – 2017-10-02T08:33:32.787
Yeah..I was just wondering if there was some method to solve this so that I could code it myself.I'll hence remove the code generation tag.Honestly amazed at how fast people respond!! – Sasha R – 2017-10-02T08:36:22.630
1More closely related. Or at least it would be if your description was matching the standard Camel definition. – Arnauld – 2017-10-02T08:38:02.447
The codes that people post for the code golf challenges..what kind of programming language is that?Again,this may be a very silly question..but am a beginner to programming,so please forgive my ignorance – Sasha R – 2017-10-02T08:42:58.850
1@SashaR A lot of people use dedicated golfing programming languages. Languages that, while often based on commonly used programming languages, have been modified to be a succinct as possible. – Adám – 2017-10-02T08:44:09.350
See here for more information about this site. – Arnauld – 2017-10-02T08:44:11.817
2@SashaR May I rewrite your question as a proper code golf challenge? – Adám – 2017-10-02T09:09:29.930
2Sure! That way I can also see how to word coding related questions in future – Sasha R – 2017-10-02T09:10:36.457
@SashaR There you go. – Adám – 2017-10-02T09:33:10.223
1
This is A000982.
– Shaggy – 2017-10-02T09:40:14.350@Shaggy Thanks. Added. – Adám – 2017-10-02T09:42:51.957
15
As a new user of this site, you've been very lucky this time. A lot of (off-topic) programming questions on this site has been permanently closed and downvoted, not edited as a challenge and upvoted like this one. As other people already explained, this site is for programming competitions only, not for asking homework. You can use the sandbox (at https://codegolf.meta.stackexchange.com/questions/2140/sandbox-for-proposed-challenges?cb=1 ) before posting a challenge to avoid common mistakes next time; and note that most users on this site, as you have seen, use "unreadable" languages.
– user202729 – 2017-10-02T14:52:26.710Related: my challenge asking a generalisation of the opposite (fewest pieces that can be arranged so no more can be placed).
– trichoplax – 2017-10-02T18:58:46.877@SashaR I attached a proof that this formula works to my answer.
– Lynn – 2017-10-02T20:48:57.48716
This question is pretty confusing in that the Camel is already the standard fairy chess name for a piece like a knight that makes longer jumps and the piece you describe already has a fairy chess name: Wazir.
– Mark S. – 2017-10-03T11:26:47.7032OTOH editing the question to the the standard name after answers have already been written using the name used in the question is also confusing. – Peter Green – 2017-10-04T08:40:07.617
Chess piece Queen is called "Vezir" in Turkish, I guess it is something close in Farsi and Arabic too. – Ege Bayrak – 2017-10-05T12:59:11.067