571
\$\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".

\$\endgroup\$
0

4636 Answers 4636

1
134 135
136
137 138
155
0
\$\begingroup\$

All permutations of range from \$1\$ to \$n\$

Given a positive input \$n\$, output all permutations of either \$\{0,1,\ldots,n\}\$ or \$\{1,2,\ldots,n\}\$.

Examples

Outputting permutations of \$\{1,2,\ldots,n\}\$.

Input Output
1 [(1)]
2 [(1, 2), (2, 1)]
4 [(1, 2, 3, 4), (1, 2, 4, 3), (1, 3, 2, 4), (1, 3, 4, 2), (1, 4, 2, 3), (1, 4, 3, 2), (2, 1, 3, 4), (2, 1, 4, 3), (2, 3, 1, 4), (2, 3, 4, 1), (2, 4, 1, 3), (2, 4, 3, 1), (3, 1, 2, 4), (3, 1, 4, 2), (3, 2, 1, 4), (3, 2, 4, 1), (3, 4, 1, 2), (3, 4, 2, 1), (4, 1, 2, 3), (4, 1, 3, 2), (4, 2, 1, 3), (4, 2, 3, 1), (4, 3, 1, 2), (4, 3, 2, 1)]

Standard loopholes are forbidden. The shortest code wins.

Questions

I was looking for this challenge, but I couldn't find it posted anywhere. Maybe because it's too derivative of a simple "output all permutations" challenge?

\$\endgroup\$
0
\$\begingroup\$

Hello, World! hashing

Implement a one-way hashing function that generates arbitrary strings which have a chance (obviously input dependent) of producing at least any of the printable ASCII characters when provided an input of at least 2 characters. This can be any mechanism you choose and could always output a fixed length if desired, however when your source code is used as input, the resultant output must be Hello, World!.

Rules

  • The input string will always be 2 characters or more (meaning your code must be at least two characters).
  • There are no other special requirements for any other input strings.
  • The output should not be exactly the same as the input (this might be unavoidable in some scenarios with well-crafted input, but you can't just output your input if the code Hello, World!, by some magic, in your language performs some sort of hashing).
  • It should be feasible to get at least any of the printable ASCII characters as output. You are however not limited to printable ASCII output and may output any combination of bytes (e.g. unprintables, UTF-8 sequences)
  • All characters of the input string should be taken into account when generating strings, not just the first 13 and should affect the output.

For meta

I'd really like to encourage answers that aren't a condition that just compares input with source and outputs Hello, World! in that instance, but as pointed out by @pajonk it's a non-observable requirement.

\$\endgroup\$
9
  • \$\begingroup\$ I think you can use tags code-golf, hello-world and restricted-source. Can you also explain what does "strings consisting of at least (but not limited to) the printable ASCII" mean? (That some strings have to contain printable characters or all strings have to contain printable characters?) Also does full input string have to be used to calculate hash? I expect some people might want to use just fixed part of input string to make this task easier. \$\endgroup\$
    – Jiří
    Aug 2, 2022 at 16:10
  • 2
    \$\begingroup\$ Suggested tag: self-referential. Be careful with non-observable requirements (like you must not have a special condition), as they are discouraged. Also, you may define what does most inputs should result in different output mean exactly (or drop it), as this may be considered too vague. \$\endgroup\$
    – pajonk
    Aug 3, 2022 at 7:12
  • \$\begingroup\$ @Jiří My intention with that wording is that the output you generate must at least have the possibility for any character in the printable ASCII range to be included, but may also output unprintables or higher byte value unicode chars for instance. The full input string must also be used, yes. So changing a character at the end of the string should change the value returned. I'll clarify that. Also, not entirely sure on restricted-source, but I'll check the wiki, thank you! \$\endgroup\$ Aug 3, 2022 at 12:24
  • \$\begingroup\$ @pajonk Yeah, that's a good point. I guess I didn't want an arbitrary hashing algorithm with a if input == source condition (which I think would be considerably easier). Good point about the wording on most inputs I'll clarify along with Jiří's suggestion of ensuring all characters are used and can affect the output, hopefully that covers that off. I'll look at self-referential too. Thank you! \$\endgroup\$ Aug 3, 2022 at 12:27
  • \$\begingroup\$ @pajonk I can't think of a way to make an observable requirement to avoid the simpler solution which makes me inclined to remove this as I think it trivialises the problem. Any idea on how to enforce that without having this blacklisted? \$\endgroup\$ Aug 3, 2022 at 12:34
  • \$\begingroup\$ @DomHastings remember that simple comparison input==source is not so simple, as requires a modified version of a quine. This may or may not be shorter than other possible approaches. \$\endgroup\$
    – pajonk
    Aug 3, 2022 at 12:45
  • \$\begingroup\$ Also I was thinking how I would write answer for this and came up with following idea: Sum all characters on input and then add this sum to ASCII codes of individual characters of string "Hello, World!" (%256). Would this answer be fine? \$\endgroup\$
    – Jiří
    Aug 3, 2022 at 13:08
  • \$\begingroup\$ @Jiří yeah, absolutely! \$\endgroup\$ Aug 7, 2022 at 13:26
  • \$\begingroup\$ @pajonk I guess so, I feel like modified quines aren't that interesting sometimes... But you're right, probably not trivial in every language. I guess the kinda of answer is love to see is a generic mechanism that is calculated to, based on the code as input, the exact string required, but that might be a big request! It's an interesting problem (to me at least) as it felt easier than I've found it upon trying to execute it! \$\endgroup\$ Aug 7, 2022 at 13:29
0
\$\begingroup\$

Generate a Kirkman triple system

\$\endgroup\$
0
\$\begingroup\$

Program a compiler compiler

Write a program, function, or likewise that takes in a BNF-like grammar specification(see below) and outputs a program or function in a language of your choice that takes strings as input and returns truthy if that string is parseable with the specified grammar, and false otherwise.

Meta-language:

The input to your program will consist of a number of bnf-like rules. Each definition will be on its own line, and will consist of a name (string of 1 or more characters [a-z0-9]), followed by the symbol ::= followed by a string of symbols(terminal and non terminal), terminals consist of [a-zA-Z0-9() ]. Nonterminals are denoted with a < followed by a string of characters [a-z0-9] followed by >; that string of characters refers to another definition. Each definition may have multiple alternatives, separated by |. Alternatives should be matched left to right. The first line of the input will share this same form, except that it will not have the name of the definition or the ::=. This is the "top-level" definition that the input to the outputted program will attempt to be matched against.

Input grammars will never contain left-recursion (ie. it will never be the case that there will be a rule of the form a::=<a>). You may additionally assume that your generated program will only be given as input strings that contain only those characters comprising valid terminal symbol([a-zA-Z0-9() ]). Additionally, your compiler-compiling program only needs to handle valid definitions.

Examples:

The following should be handled appropriately by your program:

binaryliteral
binaryliteral::=0<binaryliteral>|1<binaryliteral>|0|1

This means that the generated program should return truthy for any strings that match the definition of a binary literal, which is either the character 0 or 1 followed by a binary literal, or just 0 or 1. This would recognize strings

quantexpr
quantexpr::=forall <var>(<expr1>)|exists <var>(<expr1>)
expr1::=<expr0> and <expr1>|<expr0> or <expr0> |not <expr1>|<expr0>
expr0::=<var>|(<expr1>)
var::=x|y|z

and you do not need to handle the following:

x:=1
expr
expr::=x|<expr> plus <expr>

As usual, this is code-golf, so the shortest program per (implementation, output language) pair wins!

\$\endgroup\$
3
  • \$\begingroup\$ This could use a bit of cleanup but I'm totally behind this idea, so +1. Note: i think your terminal string regex is wrong, +-* expresses a range. in general i think it'd be worth considering simplifying what terminals are allowed, but thats just my onpinioin \$\endgroup\$ Aug 15, 2022 at 15:06
  • \$\begingroup\$ @thejonymyster good catch on that regex; I'll fix that. Is there anything else that needs to be changed pursuant to "cleaning up"? \$\endgroup\$
    – Benji
    Aug 15, 2022 at 16:57
  • \$\begingroup\$ sorry for the nondescriptive wording on my part; I just think the meta language description could be broken down into smaller sections, maybe with a small worked-out example or two. As is, it's fairly clear but just a bit densely packed. Additionally, I think you should link to something (maybe wikipedia) about BNF, for those entirely unfamiliar. :-) \$\endgroup\$ Aug 15, 2022 at 18:13
0
\$\begingroup\$

smallest number of steps for a knight in chess

\$\endgroup\$
1
  • 1
    \$\begingroup\$ I've edited this down to a stub now that it's been posted to save space \$\endgroup\$ Aug 20, 2022 at 1:07
0
\$\begingroup\$

Add numbers as fairly as possible

Given an array of integers \$X\$ and an array of positive integers \$A\$, figure out how to add the values in \$A\$ to the values in \$X\$ such that the variance of the updated values is as small as possible. (You can add more than one value from \$A\$ to a given value in \$X\$.)

[Explanation of variance]

If there are multiple solutions, you can output any of them. Output in any reasonable format.

Example

Suppose \$X = [4,5,6]\$ and \$A=[1,2]\$. The "most fair" way to distribute the value \$1\$ to \$4\$ and \$2\$ to \$5\$, making the updated array \$X' = [6,6,6]\$, which has a variance of \$0\$. Therefore, you should output something like [[2],[1],[]] or {4:[2],5:[1]}.

Test Cases

[TODO]

Questions

I am almost certain a question like this has been done before, which is why I'm not putting much effort into this post.

\$\endgroup\$
0
\$\begingroup\$

Contrasting Colors

When designing a website or poster or book it's important to make the graphical elements be distinct. A common mistake is to choose colors to similar to eachother. We must prevent this!

The goal of this challenge is simple: Given a initial color and a number of colors to generate, generate N colors that each have maximal contrast to each of the previous colors.

Contrast is defined as the sum of absolute differences. The contrast of a new color is the minimum of the distances to all previous colors. You do not need to consider gamma. Colors are a 3 tuple with each value a integer ranging from 0 to 255.

You must use a greedy algorithm. AKA you shouldn't consider the number or even existence of colors afterwards, just colors before. This is because in the design each subsequent color will be used significantly less.

In some cases, multiple choices are available. In this case you may pick any. Thus your results might not look the same as my test cases but still be valid.

You may chose whether to include the initial value in the output or not.

This is code golf, shortest answer wins.

Test cases

{
    [(255,255,255),5]: [(255, 255, 255), (0, 0, 0), (0, 127, 255), (63, 255, 64), (191, 0, 191), (254, 128, 0)],
    [(255,0,128),5]: [(255, 0, 128), (0, 255, 0), (0, 64, 255), (191, 255, 223), (32, 0, 32), (192, 128, 0)],
    [(128,128,128),10]: [(128, 128, 128), (0, 0, 0), (0, 255, 255), (255, 0, 255), (255, 255, 0), (32, 32, 223), (32, 223, 32), (223, 32, 32), (223, 223, 224), (0, 81, 111), (81, 96, 15)],
    [(7,91,7), 5]: [(7, 91, 7), (255, 255, 255), (89, 0, 255), (255, 0, 44), (0, 211, 217), (173, 255, 0)]
}
\$\endgroup\$
2
  • \$\begingroup\$ Do we need to include the initial color in the output? The text suggests no, but the test-cases do include it. Also, are the color values required to be integer? \$\endgroup\$
    – pajonk
    Aug 29, 2022 at 12:38
  • \$\begingroup\$ You may or may not include the initial value, your choice. Colors must be integers. I'll clarify \$\endgroup\$
    – mousetail
    Aug 29, 2022 at 12:42
0
\$\begingroup\$

The least amount a steps a chess pice can reach a position

I have previously posted a challange: smallest number of steps for a knight in chess. Now I would like to go a step further by adding the possibility to choose you piece.

If you place a pice on any square of a chessboard, what is the smallest amount of steps to reach every possible position?

Rules

  • It is an 8 by 8 board.
  • The given input is a coordinate (x,x) and the chosen piece. Explain in the answer how to input the piece of choice.
  • The piece starts at an arbitrary position, taken as input.
  • The pawn can not start at the bottom row, and can not move 2 steps (like when in the startposition).
  • point '.' will be placed if a pice cannot reach the square.

Example
With input 1, 0 for a knight, we start by putting a 0 in that position:

. 0

From her on we continue to fill the entire 8x8 board. For a knight the output will look like follow

3 0 3 2 3 2 3 4
2 3 2 1 2 3 4 3
1 2 1 4 3 2 3 4
2 3 2 3 2 3 4 3
3 2 3 2 3 4 3 4
4 3 4 3 4 3 4 5
3 4 3 4 3 4 5 4
4 5 4 5 4 5 4 5

For a pawn with input (1, 7) the output will look like follow

. 6 . . . . . . 
. 5 . . . . . . 
. 4 . . . . . . 
. 3 . . . . . . 
. 2 . . . . . . 
. 1 . . . . . . 
. 0 . . . . . . 
. . . . . . . . 

In the examples, I start counting from zero but it does not matter if you start from or one.

Challenge The pattern printed for a pice, as short as possible, in any reasonable format.

\$\endgroup\$
2
  • 2
    \$\begingroup\$ I'd recommend allowing the piece indicator to be any 6 distinct values, rather than requiring them to be 0,1,...,5 in a certain order. \$\endgroup\$ Aug 30, 2022 at 16:36
  • 2
    \$\begingroup\$ Also, a few typos: "stap" (step), "you pice" (your piece), "pice" (piece), "nummerate" (enumerate) \$\endgroup\$ Aug 30, 2022 at 16:39
0
\$\begingroup\$

Strategy: The cunning cousin witch

The wizard has a cunning cousin who is a witch. She looks down on the wizard, regarding him and his puzzles as mathematically naive. On reading his latest puzzle, she scorned him for always asking discrete problems with what she (unfairly) characterises as simple solutions, where the real, proper question should be continuous. To prove her point she poses the following version of the wizard's puzzle. (He reluctantly permits the partial plagiarism.)

Consider the following setup. An evil witch has a number line stretching from 0 to 10 which is hidden from you. Also hidden from you she chooses a random integer \$x \in \{0, \dots, 10\}\$ and places that many points onto the number line uniformly at random. To be more precise, she places each of the \$x\$ points independently and uniformly at random onto the number line. Your task is to prove that \$x = 10\$ and if you do the witch will grant you what she promises is a much better wish than what her cousin can provide.

In this game, you can at each step choose a floating point number \$y\$ and the witch will tell you the number of points on the number line with value less than or equal to \$y\$.

However the witch, being at least as evil as her cousin, will not let you choose a number larger than \$9\$. This might still be OK as you might still find 10 points and in fact the only way to be granted the wish is to have found all 10 points with values 9 or less.

The cost for choosing a floating point number \$\ell\$ is \$2^{\ell}\$ dollars. At any point, you can choose to give up on this set of points and get her to start the whole process again (with a new random \$x\$). Of course, if you choose the number 9 and you still have not found 10 points you have no choice but to give up and start again. But you might want to give up earlier too. Sadly you never get any money back so your costs just carry on building.

Your goal is to devise a strategy that will get you the wish at the minimum expected cost. You should report your mean cost.

Testing

Once you have chosen your strategy, you should run it until you get the wish 10,000 times and report the mean cost. If two answers have the same strategy, the one posted first wins. If two strategies have similar mean costs you may need to test it 100,000 or even more times to tell the difference. Of course if you can directly compute the expected cost, all the better.

Input and output

There is no input in this challenge. The output is just the mean cost to get a wish. To test your code you will need to implement both the witch and your strategy.

What's a naive score?

If you just choose 9 each time then it will take you \$\frac{1}{\frac{1}{11} \cdot \frac{9}{10}^{10}} \approx 31.5\$ tries to find 10 points. This will cost you approximately \$16152.4\$ dollars. How much better can you do?

\$\endgroup\$
2
  • \$\begingroup\$ I think it's more elegant if the values instead range from 0 to 1 -- the situation is exactly the same except that the values are scaled down. \$\endgroup\$ Aug 31, 2022 at 17:02
  • \$\begingroup\$ @Adam I thought about that. The problem is that \$2^9=512\$ is a nicer number than \$2^{0.9} \approx 1.87\$. \$\endgroup\$
    – user108721
    Aug 31, 2022 at 17:09
0
\$\begingroup\$

Persistence of a number

\$\endgroup\$
0
0
\$\begingroup\$

Set of all sets

Write a program or function which outputs all sets with a finite number of elements - but including sets that contain themselves (directly or indirectly).

These recursive sets will be represented using a system similar to De Bruijn indices: an element of a set which is a reference to an outer enclosing set will be represented by a positive integer indicating how far "outside" that set is. For example, the set that contains itself, \$ s = \{s\} = \{\{\{\dots\}\}\} \$, is represented by {1}.

Note that some of these representations are equivalent (represent the same actual set). For example, {{2}} directly represents \$ s = \{\{s\}\} = \{\{\{\dots\}\}\} \$, but this is equal to \$ s = \{s\} \$, and so {1} and {{2}} (and {{{3}}} etc.) are all equivalent.

Here are a few more examples of this representation:

  • \$ s = \{\{\}, s\} = \{\{\},\{\{\},\{\{\},\dots\}\}\}\$ = {{}, 1} (or {{}, {{}, 2}} etc.)
  • \$ s = \{\{\{\}\}, \{s\}\} = \{\{\{\}\}, \{\{\{\{\}\}, \{\dots\}\}\}\} \$ = {{{}}, {2}} (or {{{}}, {{{{}}, {4}}}} etc.)

Rules

Your sequence of sets may be in any order, as this is an question. However, your sequence may never contain the same set more than once. (This includes the same set represented in different ways, e.g. {1} and {{2}}.)

  • As with standard challenges, you may choose to either:
    • Take an input n and output the nth term of the sequence
    • Take an input nand output the first n terms
    • Output the sequence indefinitely, e.g. using a generator
  • You may use 0- or 1-indexing
  • This is , so the aim is to minimise your program's length in bytes

Meta

  • I really don't think I've done a good job of explaining this challenge; please feel free to edit it to be clearer
  • Does this representation have an existing name?
  • Other potentially interesting challenges involving this representation could be: (Which of these would make for good challenges?)
    • Is this representation fully simplified? (e.g. yes for {1}, no for {{2}})
    • Simplify this representation (e.g. {{2}} -> {1})
    • Do these two representations represent the same set? (e.g. {1} = {{2}}; {{}}{1})
\$\endgroup\$
1
  • 1
    \$\begingroup\$ You haven't defined when two sets are equal. Are {{1}} and {1} equal? How about {1} and {1,{2}}? You probably should pick a consistent set theory that denies the axiom of regularity and work from there. \$\endgroup\$
    – Wheat Wizard Mod
    Sep 20, 2022 at 17:44
0
\$\begingroup\$

(Inspired by https://codegolf.meta.stackexchange.com/a/25136/91213)

Quarter Precision Floating Point Numbers

We all love our floating point formats, floats and doubles. People who work in embedded may have used a even shorter format: The half precision floating point. However, what if you want a even smaller format? I present the quarter precision floating point number.

It is defined like this:

  • 1 bit: s The sign. 1 is negative, 0 is positive.
  • 3 bits: e The exponent -4. So 000 is 2**-4, 100 is 2**0 and 111 is 2**3
  • 4 bits: f The fraction f. A leading 1 bit is assumed.

Overall formula is (2-s*2)*2**(e-4)*f|16.

There is no 0, infinity, -infinity, NaN, or any subnormals.

Task

Your task is to produce a pair of programs, one to convert from quarters to floats and one to convert from floats to quarters. Your score is the sum of the length of both programs. Input will always be exactly representable.

Test Cases

These is a complete set of possible input values.

Quarters as:    Float Equivalent
bin      dec    
00000000 000    0.0625
00000001 001    0.06640625
00000010 002    0.0703125
00000011 003    0.07421875
00000100 004    0.078125
00000101 005    0.08203125
00000110 006    0.0859375
00000111 007    0.08984375
00001000 008    0.09375
00001001 009    0.09765625
00001010 010    0.1015625
00001011 011    0.10546875
00001100 012    0.109375
00001101 013    0.11328125
00001110 014    0.1171875
00001111 015    0.12109375
00010000 016    0.125
00010001 017    0.1328125
00010010 018    0.140625
00010011 019    0.1484375
00010100 020    0.15625
00010101 021    0.1640625
00010110 022    0.171875
00010111 023    0.1796875
00011000 024    0.1875
00011001 025    0.1953125
00011010 026    0.203125
00011011 027    0.2109375
00011100 028    0.21875
00011101 029    0.2265625
00011110 030    0.234375
00011111 031    0.2421875
00100000 032    0.25
00100001 033    0.265625
00100010 034    0.28125
00100011 035    0.296875
00100100 036    0.3125
00100101 037    0.328125
00100110 038    0.34375
00100111 039    0.359375
00101000 040    0.375
00101001 041    0.390625
00101010 042    0.40625
00101011 043    0.421875
00101100 044    0.4375
00101101 045    0.453125
00101110 046    0.46875
00101111 047    0.484375
00110000 048    0.5
00110001 049    0.53125
00110010 050    0.5625
00110011 051    0.59375
00110100 052    0.625
00110101 053    0.65625
00110110 054    0.6875
00110111 055    0.71875
00111000 056    0.75
00111001 057    0.78125
00111010 058    0.8125
00111011 059    0.84375
00111100 060    0.875
00111101 061    0.90625
00111110 062    0.9375
00111111 063    0.96875
01000000 064    1.0
01000001 065    1.0625
01000010 066    1.125
01000011 067    1.1875
01000100 068    1.25
01000101 069    1.3125
01000110 070    1.375
01000111 071    1.4375
01001000 072    1.5
01001001 073    1.5625
01001010 074    1.625
01001011 075    1.6875
01001100 076    1.75
01001101 077    1.8125
01001110 078    1.875
01001111 079    1.9375
01010000 080    2.0
01010001 081    2.125
01010010 082    2.25
01010011 083    2.375
01010100 084    2.5
01010101 085    2.625
01010110 086    2.75
01010111 087    2.875
01011000 088    3.0
01011001 089    3.125
01011010 090    3.25
01011011 091    3.375
01011100 092    3.5
01011101 093    3.625
01011110 094    3.75
01011111 095    3.875
01100000 096    4.0
01100001 097    4.25
01100010 098    4.5
01100011 099    4.75
01100100 100    5.0
01100101 101    5.25
01100110 102    5.5
01100111 103    5.75
01101000 104    6.0
01101001 105    6.25
01101010 106    6.5
01101011 107    6.75
01101100 108    7.0
01101101 109    7.25
01101110 110    7.5
01101111 111    7.75
01110000 112    8.0
01110001 113    8.5
01110010 114    9.0
01110011 115    9.5
01110100 116    10.0
01110101 117    10.5
01110110 118    11.0
01110111 119    11.5
01111000 120    12.0
01111001 121    12.5
01111010 122    13.0
01111011 123    13.5
01111100 124    14.0
01111101 125    14.5
01111110 126    15.0
01111111 127    15.5
10000000 128    -0.0625
10000001 129    -0.06640625
10000010 130    -0.0703125
10000011 131    -0.07421875
10000100 132    -0.078125
10000101 133    -0.08203125
10000110 134    -0.0859375
10000111 135    -0.08984375
10001000 136    -0.09375
10001001 137    -0.09765625
10001010 138    -0.1015625
10001011 139    -0.10546875
10001100 140    -0.109375
10001101 141    -0.11328125
10001110 142    -0.1171875
10001111 143    -0.12109375
10010000 144    -0.125
10010001 145    -0.1328125
10010010 146    -0.140625
10010011 147    -0.1484375
10010100 148    -0.15625
10010101 149    -0.1640625
10010110 150    -0.171875
10010111 151    -0.1796875
10011000 152    -0.1875
10011001 153    -0.1953125
10011010 154    -0.203125
10011011 155    -0.2109375
10011100 156    -0.21875
10011101 157    -0.2265625
10011110 158    -0.234375
10011111 159    -0.2421875
10100000 160    -0.25
10100001 161    -0.265625
10100010 162    -0.28125
10100011 163    -0.296875
10100100 164    -0.3125
10100101 165    -0.328125
10100110 166    -0.34375
10100111 167    -0.359375
10101000 168    -0.375
10101001 169    -0.390625
10101010 170    -0.40625
10101011 171    -0.421875
10101100 172    -0.4375
10101101 173    -0.453125
10101110 174    -0.46875
10101111 175    -0.484375
10110000 176    -0.5
10110001 177    -0.53125
10110010 178    -0.5625
10110011 179    -0.59375
10110100 180    -0.625
10110101 181    -0.65625
10110110 182    -0.6875
10110111 183    -0.71875
10111000 184    -0.75
10111001 185    -0.78125
10111010 186    -0.8125
10111011 187    -0.84375
10111100 188    -0.875
10111101 189    -0.90625
10111110 190    -0.9375
10111111 191    -0.96875
11000000 192    -1.0
11000001 193    -1.0625
11000010 194    -1.125
11000011 195    -1.1875
11000100 196    -1.25
11000101 197    -1.3125
11000110 198    -1.375
11000111 199    -1.4375
11001000 200    -1.5
11001001 201    -1.5625
11001010 202    -1.625
11001011 203    -1.6875
11001100 204    -1.75
11001101 205    -1.8125
11001110 206    -1.875
11001111 207    -1.9375
11010000 208    -2.0
11010001 209    -2.125
11010010 210    -2.25
11010011 211    -2.375
11010100 212    -2.5
11010101 213    -2.625
11010110 214    -2.75
11010111 215    -2.875
11011000 216    -3.0
11011001 217    -3.125
11011010 218    -3.25
11011011 219    -3.375
11011100 220    -3.5
11011101 221    -3.625
11011110 222    -3.75
11011111 223    -3.875
11100000 224    -4.0
11100001 225    -4.25
11100010 226    -4.5
11100011 227    -4.75
11100100 228    -5.0
11100101 229    -5.25
11100110 230    -5.5
11100111 231    -5.75
11101000 232    -6.0
11101001 233    -6.25
11101010 234    -6.5
11101011 235    -6.75
11101100 236    -7.0
11101101 237    -7.25
11101110 238    -7.5
11101111 239    -7.75
11110000 240    -8.0
11110001 241    -8.5
11110010 242    -9.0
11110011 243    -9.5
11110100 244    -10.0
11110101 245    -10.5
11110110 246    -11.0
11110111 247    -11.5
11111000 248    -12.0
11111001 249    -12.5
11111010 250    -13.0
11111011 251    -13.5
11111100 252    -14.0
11111101 253    -14.5
11111110 254    -15.0
11111111 255    -15.5
\$\endgroup\$
1
  • \$\begingroup\$ f = lambda x:(1-((x&128)>>7)*2)*(16|(x&15))*2.0**(((x&(16|32|64))>>4) - 8) \$\endgroup\$
    – mousetail
    Sep 22, 2022 at 13:39
0
\$\begingroup\$

An Optimally Suboptimal Solution

You have grown disillusioned by finding optimal policies for heavy-tailed distributions and their "skew you" attitudes. You decide that for this challenge you are putting your foot down and refusing to optimize your policy further if it means having unbalanced errors. In fact, you're so focused on balance that you will only consider median errors - it's the principle of the thing.

The Challenge

Generate a policy that searches for hidden points on a line segment, \$L\$, where \$L\$ is the interval \$[0, 1]\$. The number of hidden points on \$L\$ is randomly chosen from the set \$\{0, 10\}\$. The position of each point, \$p\$, (if there are any) is drawn randomly from the uniform distribution on \$\{0, 1\}\$. The points are indistinguishable.

The problem is episodic. In each episode you search the line according to your policy. At each step in the episode you may continue to search the line, or you may reset.

To search the line

  1. Choose \$x \in[0, 0.9]\$
  2. Accrue a cost of \$2^x\$
  3. Discover all points where \$0 \leq p \leq x\$

To reset

  1. Generate a new line segment
  2. Draw a new number of hidden points to place on the line segment
  3. If there are any hidden points, place them on the line segment

An episode ends when your policy has discovered 10 hidden points on the interval \$[0, 0.9]\$.

Note: Your policy may not use information about the number of hidden points, nor their locations. When resetting, you do not keep any points you have previously found, but you do keep all costs accrued.

This setup is adapted from @graffe's Cunning Cousin Witch problem.

Scoring

Define a false negative to be when a policy chooses to reset a line segment and there were 10 hidden points on the interval \$[0, 0.9]\$, i.e. it was possible to complete the episode but the policy resets instead.

Define a false positive to be when a policy searches the entire interval \$[0, 0.9]\$, and there were fewer than 10 hidden points on the interval \$[0, 0.9]\$, i.e. it was not possible to complete the episode but the policy searches the entire available line segment.

Your policy's score is the median absolute difference between the number of false negatives and false positives your policy incurs over one million episodes. The score should be minimized.

$$\text{Score} = median(\lvert FN - FP \rvert)$$

Where \$FN\$ and \$FP\$ are vectors of length one million, and the nth element of each vector is the number of false negatives / positives the policy made in episode n.

If two policies have the same score, the one with the lower median cost from searching lines will rank higher.


Meta

I'm hoping to encourage some custom optimization methods with this one by asking for solutions that are not optimal with respect to the cost function, and by making the objective multi-criteria (because the tie-breaking cost of searching is a function of FN and FP). I think that the way points are discovered prevents optimizing with the cost = x from being equivalent to solving this one, but I haven't exhaustively tested it.

I'd especially appreciate feedback on whether this is an interesting / productive variation on the original version, and whether or not the optimization task is equivalent to a trivial formulation.

\$\endgroup\$
0
\$\begingroup\$

Implement the Hamming algorithm

Hamming error correction is a form of linear error-correction code which can detect and repair small errors in its input. Your job is to implement a program that, given an input of a sequence of bytes, encodes them using Hamming error correction and outputs the results.

The algorithm

Taken from Wikipedia, with some slight modifications

  1. Number all of the bits, starting from 1
  2. Write these numbers in binary
  3. Every bit position that is a power of 2 (has only one 1 bit in its binary position) is a parity bit, with the remaining bits being data bits.
  4. Set every parity bit with the values of every data bit where the bitwise AND of the parity bit's position and the data bit's position is nonzero

You may choose any parity (even or odd) but must state it in your answer.

Examples

These will use hexadecimal to represent the data.

0x1234 -> 0x2a3a1
0x4321 -> 0x8b28e
0xbadf00d -> 0x2f5be8064
\$\endgroup\$
1
0
\$\begingroup\$

Cut along the lines

\$\endgroup\$
0
\$\begingroup\$

Which weekday was it?

\$\endgroup\$
5
  • \$\begingroup\$ what span of years do we have to account for \$\endgroup\$ Oct 3, 2022 at 13:40
  • \$\begingroup\$ only between 2000 to 2022. if you want it widened, i can do so \$\endgroup\$ Oct 3, 2022 at 13:40
  • \$\begingroup\$ I think I'll leave out the suggested algorithm as people will use their own ideas for sure. However, I'll add a sentence discouraging built-ins - sth like "if you're using a built-in, consider adding a non-buit-in approach as well". Regarding the year span, i think a narrow one is a good idea, as we avoid problems with changing calendars etc. \$\endgroup\$
    – pajonk
    Oct 5, 2022 at 6:45
  • \$\begingroup\$ Since you posted the question, the convention is to remove the content here and replace it with a link to the code golf post. \$\endgroup\$ Oct 5, 2022 at 14:30
  • \$\begingroup\$ Oh right, forgot that \$\endgroup\$ Oct 5, 2022 at 14:42
0
\$\begingroup\$

Minimum rotation to get the maximum value

\$\endgroup\$
2
  • \$\begingroup\$ Can you take the input as a list a b d c (or a c d b)? \$\endgroup\$ Oct 20, 2022 at 16:53
  • \$\begingroup\$ @CommandMaster Yes. \$\endgroup\$
    – oeuf
    Oct 21, 2022 at 1:07
0
\$\begingroup\$

Show a balanced binary tree

\$\endgroup\$
3
  • \$\begingroup\$ this is ascii-art tag. also, can we output via graphical-output instead? \$\endgroup\$
    – naffetS
    Oct 3, 2022 at 19:07
  • 1
    \$\begingroup\$ @Steffan I think that would be a meaningfully different challenge, so no. \$\endgroup\$ Oct 3, 2022 at 19:08
  • \$\begingroup\$ Suggested tag: open-ended-function \$\endgroup\$
    – DLosc
    Oct 10, 2022 at 21:11
0
\$\begingroup\$

Speed Checkers KOTH


For this King of the Hill challenge, your bot will play checkers against an opponent. However, you should be careful when making complex calculations, because both sides have a limited amount of time to play! Each side will start with 1,000,000 cycles [or 1 second, depending on what I use for the API] to spend during their turn, and if this runs out they will lose the game.



This is my attempt at making a KOTH challenge where your runtime matters.

Before I do the rest of the write-up, is the concept good? Is the amount of time given right? Should I use a simpler game? Should the API be in an assembly language, or in a Java runner?

\$\endgroup\$
2
  • \$\begingroup\$ I'm not certain but I thought checkers (draughts) was solved. It might not fit well in an answer, but once could just hardcode every possibility and play perfectly instantly. I think you need to pick a slightly more complicated game to make this work. \$\endgroup\$ Oct 27, 2022 at 17:57
  • \$\begingroup\$ Yes, it's solved, but you're not going to fit the entire move table in an SE answer. Solving it took I think years of calculation, so that's also off the table. \$\endgroup\$
    – RamenChef
    Oct 27, 2022 at 19:03
0
\$\begingroup\$

Subleq image decoder

^^ edited 2022.11.03.

\$\endgroup\$
6
  • 4
    \$\begingroup\$ Welcome to Codegolf, and thanks for using the Sandbox! As it is, this isn't a great way to present your challenge. There is no way for the reader to know what they should be optimising for without downloading your archive and reading through the source code. There are a few other points of confusion: does the submission have to work for any image or just the reference, what incentive is there to compress the image if the score is code-golf, and are we supposed to submit a compression and a decompression program? \$\endgroup\$ Oct 31, 2022 at 19:42
  • \$\begingroup\$ @FryAmTheEggman thank you for your feedback. 1. Task is exactly as I presented it: make smallest image.slif file, which is approved by test program. Nothing more. 2. I know that style of my challenge is unusual, it is made intentionally: it is part of the task to understand how to make such file. Test program is only 104 lines, I think it will be easy to undertand what it is doing. Even if reader do not know C#. 3. As I said, reference.bin should not be changed, original image is part of test program in other words. \$\endgroup\$
    – Vort
    Oct 31, 2022 at 19:54
  • \$\begingroup\$ @FryAmTheEggman I modified text to make it more clear what is needed to be done. \$\endgroup\$
    – Vort
    Nov 1, 2022 at 5:38
  • \$\begingroup\$ @FryAmTheEggman regarding tags: should I change code-golf to code-challenge? I still think that my challenge is more related to code-golf category, but at the same time I do not want to upset people who like competition between languages (which my challenge do not allows). \$\endgroup\$
    – Vort
    Nov 1, 2022 at 10:58
  • 3
    \$\begingroup\$ Based on what you've said, you should make this code-challenge and highlight the scoring more explicitly. I still think this would be much better received if you explained what constituted a successful compression. Just because you've done it intentionally doesn't mean it improves the challenge. \$\endgroup\$ Nov 1, 2022 at 13:16
  • \$\begingroup\$ @sʨɠɠan, @ fryamtheeggman, @ lyxal, @ mousetail, @ xnor, @ kevin-cruijssen, @ arnauld, I removed part of the challenge because of your requirements. Are "details or clarity" problems resolved now? \$\endgroup\$
    – Vort
    Nov 3, 2022 at 6:46
0
\$\begingroup\$

A Number Sequence with Everything

Work in Progress

Watch Numberphile's video featuring Neil Sloane to learn more.

...

This is sequence A342585 in the OEIS.

If you like the oddly self-referential nature of this sequence, check out Van Eck's/Look and Say sequence (insert CGCC and Numberphile links here.)

This is one of those unconventional self-referential sequences. If you're intrigued, check out Van Eck's/Look and Say sequence (insert CGCC and Numberphile links here.)

$$ \begin{align} & 0_0\\ & 1_0 \quad 1_1 \quad 0_2\\ & 2_0 \quad 1_1 \quad 2_2 \quad 0_3 \\ & 3_0 \quad 2_1 \quad 4_2 \quad 1_3 \quad 1_4 \quad 0_5 \\ \end{align} $$


$$ 0_0 \;\cdot \;1_0 \quad 1_1 \quad 0_2 \;\cdot\; 2_0 \quad 1_1 \quad 2_2 \quad 0_3 \;\cdot\;3_0 \quad 2_1 \quad 4_2 \quad 1_3 \quad 1_4 \quad 0_5 $$


$$ 0^0 \;\cdot \;0^1 \quad 1^1 \quad 2^0 \;\cdot\; 0^2 \quad 1^1 \quad 2^2 \quad 3^0 \;\cdot\;0^3 \quad 1^2 \quad 2^4 \quad 3^1 \quad 4^1 \quad 5^0 $$

Rules

\$\endgroup\$
2
  • \$\begingroup\$ In the OEIS community, the name "inventory sequence" has been introduced for this sequence. This should also be stated in the description. The A-number of the sequence should be given as a link. The name is inappropriate in my opinion. "with everything" is more appropriate for a pizza order, and in the now more than 350,000 OEIS sequences there are many more candidates that could be considered for such an attribute depending on the viewer's taste. \$\endgroup\$ Nov 13, 2022 at 9:31
  • \$\begingroup\$ You're absolutely right. It is called the inventory sequence, and not only within OEIS. That was the other name I was considering for the question. The "with everything" name comes verbatim from the Numberphile video. I agree that it's dramatic and clickbaity, and I'm open to changing it. I think this name is appropriate too, though, since it's meant to attract the people who watch that Numberphile video and come looking for the sequence. I think there's a sizable overlap as whenever there's a new sequence video on Numberphile, we have a corresponding CGCC challenge posted within 24 hours. \$\endgroup\$
    – AviFS
    Nov 16, 2022 at 8:43
0
\$\begingroup\$

Lengthy numbers type C : remove one occurrece at time

A non negative integer number is a lengthy number type C if it can be erased by repeatedly removing only one occurrence of the length of the number from it.

  • Erasing means cancel all the digits.

For simplicity and allowing different approaches we restrict the input to a number up to 11 digits length or in other words in the range [0..98765432111]

  • Numbers less than 13 digits are guaranteed to have only one possible outcome while from 13 digits they require branches during the process because there can be overlaps.
    For example a 13 digits number 1139138765421 require to test both 13's in it because removing one instead of the other will give different results.

  • Numbers less than 12 digits are permutations of all the lengths in each step ( if they are lengthy C ) while from 12 digits there can be embedded lengths, for example 112087654321 has 12 inside 10.

Examples

123  -> remove 3
12   -> remove 2
1    -> remove 1 -> erased

133  -> remove 3
13   -> no 2 -> not a lengthy C

302  -> remove 3
02   -> remove 2
0    -> not a lengthy C

Test cases

Truthy

1, 12, 21, 123, 132, 213, 231, 312, 321, 1234, 4321, 42513, 635241, 3476251, 743986215, 3657211084, 11123456789, 11987654321

Falsy

0, 2, 3, 10, 11, 13, 20, 103, 133, 300, 301, 302, 303, 310, 322, 399, 1233, 1240, 3419, 4000, 632644, 1111111, 80000001, 1010101010, 10987654321, 1008765432, 11108765432, 11098765432, 11111111111

This is , standard rules apply.

  • Input can be given by any convenient method.

  • Output any two different values telling if the number is a lengthy number type C or not.

\$\endgroup\$
0
\$\begingroup\$

LS, Part 1: Ana Gram

Warning: Wouldn't you rather answer a challenge about ponies?1


If you have read The Hostile Hospital, you would know that the Baudelaire orphans, from one of the scraps of paper recovered from the Quagmire's notebooks, they discover a name, "Ana Gram". Later on, they realize that means the word "anagram", not a name. And that information helps them in finding out who Count Olaf disguised Violet Baudelaire as (Laura V. Bleediotie). They have to search through the entire hospital list, but trace the correct person down. However, what if they lived in a time where YOU helped them? Not personally, but with a program?

So your task today is simple. Given a string a and an array, return a smaller array that contains all the possible anagrams of a.

Rules:

  • This is , so shortest answer wins
  • Make sure to lowercase everything in the array and the string
  • Two strings that are the same are not anagrams
  • Make sure to watch out for initials! You should also remove them
  • There may be multiple possible anagrams. Output them all

Test cases:

String, Array 
-> Array

"Violet", ["Veilo","Efh", "Telvio","veliot"]
-> ["Telvio","veliot"]

"Krotasmon", ["Krota","Monsakrot", "Trokasmont","KROTASMON"]
-> ["Monsakrot"]

"Laura V. Bleediotie", ["Violet Baudelaire", "Violet. Baudelaire", "VIOLeT BAUDELAIRE", "BUADELIAR VIOLETM", "Laura V. Bleediotie"]
-> ["Violet Baudelaire", "Violet. Baudelaire", "VIOLeT BAUDELAIRE"]

META:

Does the array part still qualify this as a dupe?

1: Inspired by the "all rights reserved" page of LS: The Unauthorized Autobiography

\$\endgroup\$
1
  • \$\begingroup\$ There are a few other anagram challenges, but most of them seem to be just comparing two strings: 1, 2. Your rule about two strings being the same not being an anagram is pretty surprising. You should probably have a test case that includes that behaviour, or remove the rule. \$\endgroup\$ Nov 17, 2022 at 17:16
0
\$\begingroup\$

Implement Casio's M

Posted

\$\endgroup\$
3
  • \$\begingroup\$ You should probably have a test case where double-digit (or more) numbers are used and require proper parsing. For your case, only reading the 0 in each number will still give the correct answer. \$\endgroup\$ Nov 17, 2022 at 15:42
  • \$\begingroup\$ Additionally, I realised you don't have a case using M- properly, or an output that is negative. Also, what happens if the input is something like 9M+9MM+? Or 9M+MMM+? \$\endgroup\$ Nov 17, 2022 at 15:50
  • 1
    \$\begingroup\$ @FryAmTheEggman Thanks! I have updated the test cases and the specifications. As for those two test cases, I have tested them on my dinosaur Casio machine and while 9M+9MM+ is valid, but 9M+MMM+ is not because of MM, so I have changed specs to let both of them be valid. \$\endgroup\$
    – oeuf
    Nov 18, 2022 at 0:44
0
\$\begingroup\$

Intermediate Boolean Algebra Calculator

\$\endgroup\$
0
\$\begingroup\$

Minimum Overlapping Points in Continuous Line Drawing

A contour drawing is a type of drawing that is made of only one continuous line, meaning that the drawing utensil cannot leave the paper until the drawing is done. For the purposes of this challenge, we will only be using horizontal and vertical lines for the drawing utensil's movement from start to finish.

Your task is, given an 8x8 image representing a continuous line drawing, output the minimum number of overlapping points needed to draw the image continuously.

For example, for this image:

The minimum number of overlapping points needed is 2 because it can be drawn like this, with the red points marking overlapping points:

There is no way to draw it without overlapping points twice or more.

Rules

  • You can take the input in any convenient format, including as a matrix, list, image file, or ASCII art. You will need to specify what this expected input format is in your answer.
  • Output can be in any convenient format.
  • For every "step" of the drawing, the drawing utensil can only go left, right, up, or down for the purposes of this challenge.
  • Points that are overlapped on more than once are counted as extra overlapped points. (Thus the first test case outputs 3, not 2 for overlapping on the center twice)
  • You may assume that the input is valid and can be drawn with a continuous line.
  • Standard loopholes are forbidden.
  • This is , so the shortest code in bytes wins.

Test Cases

Input Output

........
..@.....
..@.....
..@.....
@@@@@@@.
..@.....
........
........
3

........
...@....
...@....
..@@@@@@
...@....
...@....
...@....
........
3

@@@@@@@@
@......@
@......@
@......@
@......@
@......@
@......@
@@@@@@@@
0

@@@@@@@@
@......@
@......@
@......@
@@@@@@@@
@......@
@......@
@@@@@@@@
0

@@@@....
@..@....
@..@....
@@@@@@@@
...@...@
...@...@
...@...@
...@@@@@
0

..@@@@@@
..@....@
@@@@@@.@
@.@..@.@
@.@@@@@@
@....@..
@....@..
@@@@@@..
1

........
.@@@@@..
.@.@.@..
.@@@@@..
.@.@.@..
.@@@@@..
........
........
4

@@@@@@@@
@.@@@@.@
@.@@@@.@
@@@@@@@@
@@.@@.@@
@@....@@
@@@@@@@@
@@@@@@@@
0

........
..@.@...
.@@@@@..
..@.@...
.@@@@@..
..@.@...
........
........
7

Meta

  • Are there any similar questions to this?
  • What would be some good tags to add?
  • Should I make the task to only find whether the input is possible without any overlapping?
  • Should there be an animation as explanation for the minimum overlapping points for each test case?
\$\endgroup\$
0
\$\begingroup\$

Getting over it with the space Cabbage, Wolf, Goat

Posted!

\$\endgroup\$
4
  • 2
    \$\begingroup\$ Why are you using smart quotes instead of normal ones? That will make the examples very hard to copy paste \$\endgroup\$
    – mousetail
    Nov 19, 2022 at 8:24
  • \$\begingroup\$ @mousetail. I’m sorry, but what are smart quotes? \$\endgroup\$ Nov 19, 2022 at 19:16
  • 2
    \$\begingroup\$ The fancy quotes instead of the normal straight ones. You can see the left and right ones are different. Most programing languages have difficulty parsing text that contains special quotes. \$\endgroup\$
    – mousetail
    Nov 19, 2022 at 19:17
  • \$\begingroup\$ @mousetail Oh, I see. My iPad just does that, will fix \$\endgroup\$ Nov 19, 2022 at 23:39
0
\$\begingroup\$

1 to N column and row sums

\$\endgroup\$
0
\$\begingroup\$

Lengthy numbers type B : remove some occurrences of length

Given a non negative integer number tell if it can be erased by repeatedly removing some non overlapping occurrences of the length of that number from it.

  • Like lengthy numbers type A erasing means remove all digits.
    For example the number 4440 is not lengthy B because after removing three 4's you obtain 0 which cannot be erased.
    Neither the numbers 50022 and 50044 are lengthy B because you first remove 5 obtaining 0022 and 0044, which cannot be erased because of leading 0's.

Example with selection of some matches

151151599995515 has 15 digits and 4 15's in it  
xx115xx99995515 if you remove 1st and 3rd 15's  
11599995515 : remove 11  
599995515 : remove 9's
55515 : remove 5's
1 and finally remove 1

You can choose to remove almost all combinations of 2 15's but if you remove the 2nd and 3rd 15's you get stuck.
151151599995515
15199995515 -> 11 is no more available!

If you remove a number of 15's different than 2 you get stuck too.

Example with overlapping

44441111111 -> falsy because you can remove only 3 11's and not all 1's like you could if removing overlapping matches were allowed.

44411111111 -> falsy because if you remove all 11's you get 444.
If instead you remove 3 11's you get 44411 which is falsy too.

Test cases

Truthy

1, 12, 21, 22, 123, 321, 322, 331, 333, 4441, 4444, 12345, 987654321, 3610106226, 1010101010, 11111111111, 11131111311, 151151599995515, 10812816208148888188, 82428208832101683082414123828341883888, 1515515551555515555515555551555555155555155551555155151, 999199999915999991599999999915999915999999919399999999991915999999999999999999999915999999929999999, 10121111011011011011011011011011011012110110110121101110110121111011123101101101101121011011110110111, 15101251011012229752519101110101010101010111111101101101101101111011011011011110111101101101101101915, 2020220202202022020220202232020220202202022020223220232020222220220222202202202202202202202202202202202220223202202202202202202202202222022022022022022022222202202202202202222022022022022022023876543213

Falsy

0, 2, 9, 10, 11, 23, 100, 233, 444, 1224, 4440, 50022, 50044, 1101010101, 4444111110, 44441111111, 44411111111, 121666626162, 181811818128181818, 127271272722672224724122727122712242722472727272722472727272247272127272, 3919555395539111955255533922519455392511539551925395511,   
 1001023010023100160010010010010061110250100123001001001230061001010100102370100610016001001001110230, 1241242212412241241241241241241241241241241241141624124114241241241242612412412416241222412411424221241244124142412412144124, 108484298442981044294284942984429844294291042942942942849429429484284948429484842942942984104842984429429844298448429429429429429429429428494294294842942942948429428484942942942942984429429844284948429428494842849484284942942942942942984484294294284942942942942942942942942942910429429484294294

This is , standard rules apply.

  • Input can be given in any convenient method.

  • Output any two different values telling if the number is lengthy B or not.

\$\endgroup\$
3
  • \$\begingroup\$ Not a comment on the challenge itself, but could you use a full-size header (the same formatting as you have for the test cases header) for the challenge title moving forward? It makes Sandbox easier to browse and doesn't give the OSP bot trouble with automatic parsing. \$\endgroup\$ Nov 27, 2022 at 1:49
  • 1
    \$\begingroup\$ @Unrelated String how it works now? \$\endgroup\$
    – AZTECCO
    Nov 27, 2022 at 11:18
  • \$\begingroup\$ Yep, that's perfect! \$\endgroup\$ Nov 27, 2022 at 21:35
0
\$\begingroup\$

Cistertian Numerals

Cistercian numerals are a method of representing any integer from 1 to 9,999 in a single "glyph".

Input

Any Integer, 1..9999

Output

An image or binary array (any standard accepted format) of the glyph representing the Input, in the form shown on the Wiki article - e.g. image

Examples

If using an array, it seems to me that all combinations should fit into a 6hx5w grid - e.g:

9999:

xxxxx
x x x
xxxxx
xxxxx
x x x
xxxxx

5555:

xxxxx
 xxx
  x
  x
 xxx
xxxxx

7643:

  x
 xxx
x x x
  x
x x x
xxx x
\$\endgroup\$
2
1
134 135
136
137 138
155

You must log in to answer this question.

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