541
\$\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 needs more feedback, but it's been ignored, you can ask for feedback in The Nineteenth Byte. It's not only allowed, but highly recommended!

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

Other

Search the sandbox / Browse your pending proposals

The sandbox works best if you sort posts by active.

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

Get the Sandbox Viewer to view the sandbox more easily!

\$\endgroup\$
1

3642 Answers 3642

1
109 110
111
112 113
122
0
\$\begingroup\$

Universal Command Sequence

Posted

\$\endgroup\$
4
  • \$\begingroup\$ Very related: Shortest universal maze exit string \$\endgroup\$
    – xnor
    Jan 6 at 8:59
  • \$\begingroup\$ I feel like answers to this will be very hard to test. Probably the golfiest way to do this, if it's valid, would be not to code anything with mazes, but just to produce some massive random-looking sequence of directions. If the length is a fast-enough growing function of n, with overwhelmingly high probability works on every maze for every n. Like, "output 3^3^3^n in base 4". \$\endgroup\$
    – xnor
    Jan 6 at 9:06
  • \$\begingroup\$ @xnor This question is actually from a Russian math olympics problem :D that problem is to prove the existence of the sequence. The proof states that the sequence can be generated by following a certain rule (a certain rule of concatenating sequences, to be exact). And I think I do have written a testing code for it; see section "Test Code" (sorry but English isn't my mother tongue, but now I know it is called a "validator", isn't it?) \$\endgroup\$ Jan 6 at 15:42
  • \$\begingroup\$ Ah yes I rembered, it's 1998 All-Russian Math Olympiad, Grade level 9, Day 1, Problem 4. Original problem is 8x8 grid, but the proof can be generalized to nxn. \$\endgroup\$ Jan 6 at 16:02
0
\$\begingroup\$

Generate Fmbalbuena Numbers

\$\endgroup\$
6
  • 1
    \$\begingroup\$ so both the second step and last step need to be true? \$\endgroup\$
    – Razetime
    Jan 6 at 11:35
  • \$\begingroup\$ @Razetime 2nd and last step need to be true. \$\endgroup\$
    – Fmbalbuena
    Jan 6 at 11:36
  • 1
    \$\begingroup\$ combine step 1 and step 2 into "Check if the number of digits is a multiple of 3", and change "N/3 digits" to something like "Length / 3 digits" (to me "N/3" reads like the original number divided by 3). \$\endgroup\$ Jan 6 at 14:22
  • \$\begingroup\$ "equals the last digits" → "equals the last digits modulus 10" \$\endgroup\$
    – Adám
    Jan 7 at 0:01
  • \$\begingroup\$ You should state clearly that having a digit count that isn't divisible by 3 is enough to make a number not be a Fmbalbuena number. \$\endgroup\$
    – Adám
    Jan 7 at 0:02
  • \$\begingroup\$ What is the goal of the challenge? decision-problem for a single given number (I recommend that) or generating the sequence up until a limit, or maybe the first n number, or "infinitely" spitting out more? \$\endgroup\$
    – Adám
    Jan 7 at 0:04
0
\$\begingroup\$

Generate Matching Regexes

Write a program that takes two lists of strings and generates a javascript regex that fully matches all the strings in the first list and matches none of the strings in the second list.

To be specific when for all stings in the first list str.match(\[your-output]\) must produce a match for the full string and for all strings in the second list str.match(\[your-output]\) must produce no matches.

Scoring

Your score is the average length of the regexes you produce not the length of your program. Your regexes should be tested against this file: https://pastebin.com/9iNZvGJC. Take the file in blocks of 20 lines and run your program with the first ten lines to match and the second ten to not match. Average the lengths of your program's output for all of the blocks in the file. This is your score.

Rules

  • Do not output the \ for the regex
\$\endgroup\$
4
  • \$\begingroup\$ I'm guessing this is a Sandbox for this closed challenge, and that you're aiming to improve the existing one? I'd suggest clarifying the scoring system, I'm not fully sure how exactly it works? \$\endgroup\$ Jan 15 at 22:46
  • \$\begingroup\$ Yes it is. Could you clarify what you find confusing about the scoring system? \$\endgroup\$
    – user197974
    Jan 15 at 23:06
  • \$\begingroup\$ "Take the file in blocks of 20 lines and run your program with the first ten lines to match and the second ten to not match." Seems like it would be simpler to just provide the lines to match and the lines to not match, rather than doing the line splitting bit \$\endgroup\$ Jan 15 at 23:10
  • \$\begingroup\$ You would have to split it into blocks anyway so that doesn't really seem easier? \$\endgroup\$
    – user197974
    Jan 15 at 23:17
0
\$\begingroup\$

Help Bob split his apples

Bob has a lot of apples, and he wants to split his apples with his friends evenly. (Including Bob.) However, every \$k\$th friend already has a lot of apples and does not need apples. Bob, however, is kind so he gives each \$k\$th friend the number of apples the friend already gives floor divided by three.

Given the input format below, a number \$k\$, and a number \$a\$ for the number of apples, output the number of apples that each person receives.

Test Cases

[0, 0, 80, 0, 0, 45, 0, 0, 12] 3 100 => [10, 9, 26, 9, 9, 15, 9, 9, 4]
\$\endgroup\$
1
  • \$\begingroup\$ Could you try to clarify a bit more? \$\endgroup\$ Jan 19 at 13:46
0
\$\begingroup\$

Move the next greater number, with fewest fails to take everything

Your task is to move the next greater number, with fewest fails to take everything

A fail counts if a step is the lower number (not counting equal)

The starting point is the top left corner

Example:

1234

Can do like this

>>>

Because moves to right, the next number is greater than previous

But

124
435

Is impossible so the fewest fails are:

>>v<<

1 > 2 > 4 > 5 < 3 > 4

So this has 1 fail

Test cases:

The output is not exact, there are multiple possible solutions

Input:

123
245
175

Output:

>>vv<<^>

Input:

123456789

Output:

>>>>>>>>

Input:

987654321

Output:

>>>>>>>>

Input:

123
456
789

Output:

>>vv<<^>

Input:

123456789
987654321
123456789

Output:

>>>>>>>>v<<<<<<<<v>>>>>>>>

Meta:

  • Any feedback?
\$\endgroup\$
2
  • \$\begingroup\$ I like the idea but I think the explanation could include the definition of a "fail". \$\endgroup\$ Jan 19 at 16:28
  • \$\begingroup\$ @Wezl-yizl Added \$\endgroup\$
    – Fmbalbuena
    Jan 19 at 16:31
0
\$\begingroup\$

Animate finding the middle (hypercube edition)

Given a multidimensional array of integers where all dimensions are the same length, animate finding the centre of it.

Simply output the array, then remove the first and last items of every array within it and output it, until it has less than 3 elements left.

For example, with this 2-dimensonal array:

[ [7, 2, 3, 6, 4], 
  [2, 4, 9, 9, 8], 
  [7, 3, 1, 9, 8], 
  [9, 1, 7, 6, 9],  
  [4, 3, 4, 8, 5] ]

You'd output the array, then remove the first and last of each to output this:

[ [4, 9, 9], 
  [3, 1, 9],
  [1, 7, 6] ]

And finally output just this:

[ [ 1 ] ]

Output format can be as an array of multidimensional arrays, each array printed separately, etcetera.

Testcases

[[[4, 6, 7], [1, 6, 8], [3, 3, 4]], [[9, 2, 8], [4, 9, 4], [6, 3, 9]], [[3, 7, 8], [4, 3, 6], [2, 8, 2]]] -> 
[[[4, 6, 7], [1, 6, 8], [3, 3, 4]], [[9, 2, 8], [4, 9, 4], [6, 3, 9]], [[3, 7, 8], [4, 3, 6], [2, 8, 2]]]
[[9]]

[[[6, 5, 9, 4], [8, 8, 5, 1], [9, 3, 1, 6], [1, 7, 7, 9]], [[8, 3, 7, 2], [6, 6, 9, 4], [5, 6, 8, 3], [2, 1, 9, 9]], [[4, 9, 6, 9], [6, 9, 3, 7], [3, 6, 8, 2], [7, 5, 8, 6]], [[8, 6, 2, 1], [3, 5, 9, 5], [2, 6, 1, 3], [3, 6, 3, 9]]] ->
[[[6, 5, 9, 4], [8, 8, 5, 1], [9, 3, 1, 6], [1, 7, 7, 9]], [[8, 3, 7, 2], [6, 6, 9, 4], [5, 6, 8, 3], [2, 1, 9, 9]], [[4, 9, 6, 9], [6, 9, 3, 7], [3, 6, 8, 2], [7, 5, 8, 6]], [[8, 6, 2, 1], [3, 5, 9, 5], [2, 6, 1, 3], [3, 6, 3, 9]]]
[[[6, 9], [6, 8]], [[9, 3], [6, 8]]]

[[[[[5, 1, 6], [8, 2, 9], [9, 2, 4]], [[7, 1, 8], [1, 1, 5], [6, 9, 4]], [[3, 6, 6], [9, 9, 9], [4, 2, 5]]], [[[9, 9, 8], [7, 2, 7], [1, 2, 6]], [[3, 1, 8], [1, 7, 9], [6, 9, 2]], [[6, 6, 1], [6, 8, 8], [2, 5, 6]]], [[[9, 5, 3], [3, 6, 9], [8, 8, 7]], [[4, 6, 4], [8, 7, 9], [8, 6, 7]], [[2, 4, 1], [4, 5, 2], [8, 7, 8]]]], [[[[8, 1, 6], [1, 4, 4], [7, 6, 6]], [[9, 9, 9], [8, 1, 7], [9, 2, 4]], [[9, 5, 7], [1, 4, 8], [3, 8, 1]]], [[[3, 8, 1], [8, 7, 6], [1, 5, 7]], [[8, 5, 1], [7, 2, 1], [7, 1, 3]], [[1, 2, 6], [4, 3, 7], [1, 1, 1]]], [[[8, 1, 1], [7, 5, 2], [9, 3, 6]], [[2, 1, 5], [1, 3, 3], [5, 5, 2]], [[7, 6, 2], [9, 5, 7], [3, 8, 1]]]], [[[[5, 8, 9], [7, 2, 5], [3, 9, 7]], [[7, 8, 7], [3, 4, 1], [4, 1, 3]], [[3, 8, 6], [7, 7, 9], [8, 4, 8]]], [[[7, 5, 4], [8, 1, 7], [9, 9, 1]], [[1, 1, 8], [2, 3, 7], [9, 5, 4]], [[2, 2, 6], [8, 8, 2], [1, 3, 6]]], [[[7, 2, 7], [1, 7, 3], [8, 3, 9]], [[6, 1, 4], [8, 3, 8], [8, 9, 5]], [[5, 7, 2], [9, 7, 6], [1, 3, 4]]]]] ->
[[[[[5, 1, 6], [8, 2, 9], [9, 2, 4]], [[7, 1, 8], [1, 1, 5], [6, 9, 4]], [[3, 6, 6], [9, 9, 9], [4, 2, 5]]], [[[9, 9, 8], [7, 2, 7], [1, 2, 6]], [[3, 1, 8], [1, 7, 9], [6, 9, 2]], [[6, 6, 1], [6, 8, 8], [2, 5, 6]]], [[[9, 5, 3], [3, 6, 9], [8, 8, 7]], [[4, 6, 4], [8, 7, 9], [8, 6, 7]], [[2, 4, 1], [4, 5, 2], [8, 7, 8]]]], [[[[8, 1, 6], [1, 4, 4], [7, 6, 6]], [[9, 9, 9], [8, 1, 7], [9, 2, 4]], [[9, 5, 7], [1, 4, 8], [3, 8, 1]]], [[[3, 8, 1], [8, 7, 6], [1, 5, 7]], [[8, 5, 1], [7, 2, 1], [7, 1, 3]], [[1, 2, 6], [4, 3, 7], [1, 1, 1]]], [[[8, 1, 1], [7, 5, 2], [9, 3, 6]], [[2, 1, 5], [1, 3, 3], [5, 5, 2]], [[7, 6, 2], [9, 5, 7], [3, 8, 1]]]], [[[[5, 8, 9], [7, 2, 5], [3, 9, 7]], [[7, 8, 7], [3, 4, 1], [4, 1, 3]], [[3, 8, 6], [7, 7, 9], [8, 4, 8]]], [[[7, 5, 4], [8, 1, 7], [9, 9, 1]], [[1, 1, 8], [2, 3, 7], [9, 5, 4]], [[2, 2, 6], [8, 8, 2], [1, 3, 6]]], [[[7, 2, 7], [1, 7, 3], [8, 3, 9]], [[6, 1, 4], [8, 3, 8], [8, 9, 5]], [[5, 7, 2], [9, 7, 6], [1, 3, 4]]]]]
[[[[[2]]]]]

[[[[1, 8, 1, 7, 8], [2, 6, 6, 2, 8], [9, 4, 2, 3, 3], [1, 9, 5, 8, 5], [6, 3, 9, 2, 2]], [[8, 2, 5, 5, 3], [3, 3, 8, 6, 6], [3, 3, 5, 6, 6], [4, 2, 5, 3, 6], [2, 2, 5, 5, 4]], [[4, 4, 1, 9, 7], [4, 3, 4, 3, 8], [3, 7, 1, 7, 7], [1, 2, 7, 5, 6], [5, 6, 5, 4, 6]], [[7, 8, 9, 7, 2], [9, 4, 9, 9, 2], [3, 1, 9, 2, 9], [3, 5, 8, 4, 7], [3, 3, 5, 9, 9]], [[5, 6, 2, 4, 3], [2, 9, 6, 6, 1], [6, 8, 2, 9, 7], [5, 2, 1, 8, 4], [7, 7, 9, 6, 1]]], [[[2, 2, 8, 1, 6], [3, 6, 9, 9, 9], [9, 7, 6, 8, 7], [9, 6, 3, 5, 6], [9, 1, 8, 5, 6]], [[2, 4, 2, 7, 3], [8, 9, 8, 7, 1], [1, 6, 1, 8, 4], [9, 9, 8, 8, 2], [5, 5, 7, 9, 5]], [[6, 4, 3, 1, 2], [6, 4, 4, 7, 6], [7, 7, 6, 1, 3], [8, 7, 1, 4, 7], [4, 7, 1, 1, 2]], [[1, 7, 7, 5, 3], [7, 8, 4, 1, 1], [8, 5, 7, 5, 3], [6, 9, 1, 9, 6], [5, 9, 7, 3, 1]], [[6, 3, 7, 1, 5], [1, 9, 4, 8, 2], [9, 6, 5, 9, 5], [2, 9, 4, 4, 6], [8, 3, 6, 7, 4]]], [[[2, 4, 7, 7, 8], [4, 2, 9, 4, 8], [5, 4, 2, 1, 3], [1, 6, 8, 1, 1], [4, 7, 4, 9, 5]], [[4, 9, 1, 3, 7], [3, 3, 7, 6, 4], [4, 6, 7, 4, 5], [7, 3, 2, 7, 6], [5, 5, 7, 9, 3]], [[7, 6, 7, 4, 1], [8, 3, 4, 7, 3], [1, 9, 9, 2, 4], [2, 7, 2, 8, 1], [5, 1, 4, 8, 8]], [[3, 5, 4, 8, 2], [1, 2, 7, 4, 5], [1, 7, 2, 2, 9], [8, 4, 2, 1, 4], [4, 9, 2, 3, 5]], [[1, 1, 9, 7, 8], [4, 8, 1, 7, 5], [3, 5, 2, 2, 7], [8, 6, 3, 2, 1], [6, 9, 9, 1, 3]]], [[[2, 8, 5, 5, 6], [6, 3, 4, 6, 4], [2, 3, 5, 7, 9], [2, 6, 1, 1, 2], [6, 4, 9, 8, 5]], [[8, 4, 7, 2, 1], [6, 5, 4, 8, 7], [7, 8, 3, 6, 8], [2, 2, 4, 7, 2], [2, 3, 6, 4, 4]], [[5, 2, 8, 4, 8], [6, 7, 2, 8, 7], [8, 2, 1, 9, 2], [2, 1, 1, 7, 2], [9, 6, 1, 5, 2]], [[3, 2, 9, 2, 2], [9, 4, 5, 1, 2], [9, 1, 6, 3, 7], [8, 8, 7, 1, 8], [3, 4, 8, 9, 6]], [[8, 6, 1, 6, 9], [1, 9, 6, 9, 4], [6, 6, 6, 9, 6], [2, 5, 3, 6, 5], [6, 6, 9, 5, 7]]], [[[2, 4, 3, 6, 1], [6, 8, 2, 8, 8], [5, 2, 9, 7, 7], [1, 3, 5, 6, 2], [5, 3, 5, 7, 9]], [[5, 3, 8, 8, 5], [2, 7, 5, 3, 7], [2, 5, 1, 6, 6], [5, 7, 1, 4, 2], [5, 1, 4, 5, 2]], [[1, 6, 2, 5, 3], [3, 8, 1, 9, 4], [3, 9, 6, 7, 1], [8, 5, 3, 7, 1], [3, 8, 8, 1, 4]], [[3, 1, 2, 1, 9], [5, 7, 1, 4, 2], [1, 8, 5, 7, 3], [2, 5, 8, 2, 1], [9, 9, 6, 9, 7]], [[4, 8, 3, 5, 6], [5, 6, 4, 2, 3], [2, 5, 3, 1, 6], [2, 9, 4, 9, 4], [4, 6, 8, 2, 2]]]] ->
[[[[1, 8, 1, 7, 8], [2, 6, 6, 2, 8], [9, 4, 2, 3, 3], [1, 9, 5, 8, 5], [6, 3, 9, 2, 2]], [[8, 2, 5, 5, 3], [3, 3, 8, 6, 6], [3, 3, 5, 6, 6], [4, 2, 5, 3, 6], [2, 2, 5, 5, 4]], [[4, 4, 1, 9, 7], [4, 3, 4, 3, 8], [3, 7, 1, 7, 7], [1, 2, 7, 5, 6], [5, 6, 5, 4, 6]], [[7, 8, 9, 7, 2], [9, 4, 9, 9, 2], [3, 1, 9, 2, 9], [3, 5, 8, 4, 7], [3, 3, 5, 9, 9]], [[5, 6, 2, 4, 3], [2, 9, 6, 6, 1], [6, 8, 2, 9, 7], [5, 2, 1, 8, 4], [7, 7, 9, 6, 1]]], [[[2, 2, 8, 1, 6], [3, 6, 9, 9, 9], [9, 7, 6, 8, 7], [9, 6, 3, 5, 6], [9, 1, 8, 5, 6]], [[2, 4, 2, 7, 3], [8, 9, 8, 7, 1], [1, 6, 1, 8, 4], [9, 9, 8, 8, 2], [5, 5, 7, 9, 5]], [[6, 4, 3, 1, 2], [6, 4, 4, 7, 6], [7, 7, 6, 1, 3], [8, 7, 1, 4, 7], [4, 7, 1, 1, 2]], [[1, 7, 7, 5, 3], [7, 8, 4, 1, 1], [8, 5, 7, 5, 3], [6, 9, 1, 9, 6], [5, 9, 7, 3, 1]], [[6, 3, 7, 1, 5], [1, 9, 4, 8, 2], [9, 6, 5, 9, 5], [2, 9, 4, 4, 6], [8, 3, 6, 7, 4]]], [[[2, 4, 7, 7, 8], [4, 2, 9, 4, 8], [5, 4, 2, 1, 3], [1, 6, 8, 1, 1], [4, 7, 4, 9, 5]], [[4, 9, 1, 3, 7], [3, 3, 7, 6, 4], [4, 6, 7, 4, 5], [7, 3, 2, 7, 6], [5, 5, 7, 9, 3]], [[7, 6, 7, 4, 1], [8, 3, 4, 7, 3], [1, 9, 9, 2, 4], [2, 7, 2, 8, 1], [5, 1, 4, 8, 8]], [[3, 5, 4, 8, 2], [1, 2, 7, 4, 5], [1, 7, 2, 2, 9], [8, 4, 2, 1, 4], [4, 9, 2, 3, 5]], [[1, 1, 9, 7, 8], [4, 8, 1, 7, 5], [3, 5, 2, 2, 7], [8, 6, 3, 2, 1], [6, 9, 9, 1, 3]]], [[[2, 8, 5, 5, 6], [6, 3, 4, 6, 4], [2, 3, 5, 7, 9], [2, 6, 1, 1, 2], [6, 4, 9, 8, 5]], [[8, 4, 7, 2, 1], [6, 5, 4, 8, 7], [7, 8, 3, 6, 8], [2, 2, 4, 7, 2], [2, 3, 6, 4, 4]], [[5, 2, 8, 4, 8], [6, 7, 2, 8, 7], [8, 2, 1, 9, 2], [2, 1, 1, 7, 2], [9, 6, 1, 5, 2]], [[3, 2, 9, 2, 2], [9, 4, 5, 1, 2], [9, 1, 6, 3, 7], [8, 8, 7, 1, 8], [3, 4, 8, 9, 6]], [[8, 6, 1, 6, 9], [1, 9, 6, 9, 4], [6, 6, 6, 9, 6], [2, 5, 3, 6, 5], [6, 6, 9, 5, 7]]], [[[2, 4, 3, 6, 1], [6, 8, 2, 8, 8], [5, 2, 9, 7, 7], [1, 3, 5, 6, 2], [5, 3, 5, 7, 9]], [[5, 3, 8, 8, 5], [2, 7, 5, 3, 7], [2, 5, 1, 6, 6], [5, 7, 1, 4, 2], [5, 1, 4, 5, 2]], [[1, 6, 2, 5, 3], [3, 8, 1, 9, 4], [3, 9, 6, 7, 1], [8, 5, 3, 7, 1], [3, 8, 8, 1, 4]], [[3, 1, 2, 1, 9], [5, 7, 1, 4, 2], [1, 8, 5, 7, 3], [2, 5, 8, 2, 1], [9, 9, 6, 9, 7]], [[4, 8, 3, 5, 6], [5, 6, 4, 2, 3], [2, 5, 3, 1, 6], [2, 9, 4, 9, 4], [4, 6, 8, 2, 2]]]]
[[[[9, 8, 7], [6, 1, 8], [9, 8, 8]], [[4, 4, 7], [7, 6, 1], [7, 1, 4]], [[8, 4, 1], [5, 7, 5], [9, 1, 9]]], [[[3, 7, 6], [6, 7, 4], [3, 2, 7]], [[3, 4, 7], [9, 9, 2], [7, 2, 8]], [[2, 7, 4], [7, 2, 2], [4, 2, 1]]], [[[5, 4, 8], [8, 3, 6], [2, 4, 7]], [[7, 2, 8], [2, 1, 9], [1, 1, 7]], [[4, 5, 1], [1, 6, 3], [8, 7, 1]]]]
[[[[9]]]]
\$\endgroup\$
2
  • \$\begingroup\$ "All dimensions are the same" should probably be worded more like; "All dimensions are the same length". \$\endgroup\$
    – ATaco
    Jan 20 at 6:33
  • \$\begingroup\$ @ATaco Done. (filler) \$\endgroup\$
    – emanresu A
    Jan 20 at 6:34
0
\$\begingroup\$

Euler Irregular Primes

Your challenge is to find all Euler Irregular Primes (A prime p is Euler-irregular if it divides an Euler number E(2n) with 0<2n<p−1) under n.

Scoring

Your goal is to use the least amount of bytes.

New contributor
Gabe is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
\$\endgroup\$
2
  • \$\begingroup\$ welcome to this website ! challenges should be self contained, so while the link is good, you should Also include a definition of euler irregular primes \$\endgroup\$ Jan 20 at 1:49
  • \$\begingroup\$ Could you provide some test cases and define "storage" clearly? \$\endgroup\$ Jan 21 at 10:45
0
\$\begingroup\$

Deterministic oozes

Related

This challenge is similar to the above linked challenge except the task is to output the next state of the input.

Input

Input can be taken as:

  • A list of characters of states of cells
  • A string
  • A list of code points of characters

Task

Output the next generation of the input.

These conversions happen if there is food . or : next to them:

"o" → "O"
"O" → "8"
"8" → "oo"

Scoring

Number of bytes, shortest code wins!

Test Cases

"o. o" → "O o"    # Look the food is consumed
"oooo.8" → "oooO8"  # Left eats first
"8:8" → "oooo"   # Both eat
":8" → "Oo"  # Notice, 2 generations happen, ":8" to ".oo" to "Oo"

Meta:

  • Tags?
  • Clear?
\$\endgroup\$
5
  • \$\begingroup\$ There's a lot still missing here. It seems like most the challenge has to be guessed from a handful of test cases. \$\endgroup\$
    – Wheat Wizard Mod
    13 hours ago
  • \$\begingroup\$ @WheatWizard ok ill add more test cases tomorrow. \$\endgroup\$
    – PyGamer0
    13 hours ago
  • \$\begingroup\$ No that is the opposite of what I am saying. You need to specify the challenge not just add more test cases. \$\endgroup\$
    – Wheat Wizard Mod
    13 hours ago
  • \$\begingroup\$ The challenge should be completely understandable with the test cases removed. \$\endgroup\$
    – Wheat Wizard Mod
    13 hours ago
  • \$\begingroup\$ @WheatWizard ok i see, will do that tomorrow \$\endgroup\$
    – PyGamer0
    13 hours ago
0
\$\begingroup\$

Approximate Euler's Number

Euler's number (e) is one of the most well-known mathematical constants, with a simple way to approximate it. All you have to do is repeatedly generate a random number between 0 and 1, and add it to an accumulator. Record how many times you have to do this for the accumulator to exceed 1. If you do this over and over again, the average of all the times it takes will approximate Euler's number.

Your task

Write a program that, given a number of iterations as input, approximates Euler's number using the above method and prints the result.

Scoring

This is code-golf, so shortest answer wins. However, if the language you are using does not include a random number builtin, you may exclude from your byte count the code required to import it. For example, if you're writing a Python program to do this, you may assume the random module is already imported.

Example implementation (ungolfed)

import random
acc = 0
res = []
for x in range(int(input())):
    while acc < 1:
        acc += random.random()
    res.append(acc)
    acc = 0
total = 0
for x in res:
    total += x
print(total / len(res))
\$\endgroup\$
5
  • \$\begingroup\$ This looks like it's probably unobservable. You also need to specify how "random" is defined: can programs use a biased RNG (which will inevitably produce an inaccurate approximation)? \$\endgroup\$
    – pxeger
    10 hours ago
  • \$\begingroup\$ @pxeger Good point. How should I go about fixing this? \$\endgroup\$ 10 hours ago
  • 1
    \$\begingroup\$ IMO the interesting part of this is never going to be the random number generation, but the calculation based on them. You could just have challenges accept an input of a list of numbers, presuming them to be random, and give the approximation calculated if that list were the source of random numbers. So an input of [random.random() for _ in range(10000)] will produce about 2.72, but an input of [0] * 10000 will produce some completely wrong output \$\endgroup\$
    – pxeger
    10 hours ago
  • \$\begingroup\$ Also, your code is missing a parenthesis on line 4, and outputs \$ e / 2 \$, not \$ e \$. \$\endgroup\$
    – pxeger
    10 hours ago
  • \$\begingroup\$ @pxeger I know the RNG is boring, whcih is why it's excluded from the byte count. Sorry about the bugs, I'm fixing them. \$\endgroup\$ 10 hours ago
-1
\$\begingroup\$

The only differences that matter

Cops' task

Write two programs (or functions) A and B in the same version of the same programming language. They also should be called in the same way, meaning you can't write one program and one function. Each should accept an integer n and output the term n of a different integer sequence on OEIS.

You should reveal a substring of each of A and B. Call them PA and PB. If one instance of PA is replaced by PB from A, it should become B. That means every byte except the reveal part in A and B should be exactly the same. You also reveal the lengths of A and B, and the two OEIS sequences. You don't reveal the programming language you use.

Your answer is cracked if a robber finds two programs A' and B' that also print the elements in the two integer sequences respectively, where A' is no longer than A, and A' with one instance of PA replaced by PB is also B'. They don't have to be the same with your original A and B. And they don't have to be in the same programming language as yours, as long as they are in the same programming language themselves.

If your answer isn't cracked 7 days after you post the answer, you can reveal your language and the original A and B and mark the answer safe, and it will be immune to future crack. Your answer can still be cracked if you don't do it.

Your score is max(len(A)+len(PA)*5, len(B)+len(PB)*5). The safe answer posted before a certain date with the minimum score wins.

For example, if your two programs are The first program and The second program, you can reveal first and second. Your score is 18 + 6*5 = 48. And a robber can crack your answer by <<first>> <<second>> if they work. But you can also reveal first pro and second pro to prevent this crack.

Please post your answer using this template:

# <length of PA> / <length of A> bytes, <length of PB> / <length of B> bytes, score <score>, <open / safe / cracked>

Part of program A (outputing [<OEIS number>](<OEIS link>)):

    <code of PA>

Part of program B (outputing [<OEIS number>](<OEIS link>)):

    <code of PB>

<any other explanations>

Robbers' task

(To do.)

\$\endgroup\$
9
  • \$\begingroup\$ Do robbers have to produce the same program, or any program? \$\endgroup\$ Oct 28 '16 at 14:47
  • \$\begingroup\$ There are two tricky edge cases around character encodings which the question needs to address. 1. It talks about substrings of A and B, saying that every byte except the revealed ones must be the same. If A and B differ in one Unicode codepoint, such that in UTF-8 they differ in only one byte but it's part of a three-byte sequence, can I post just that one byte as PA/PB or must I post the three-byte sequence? (I.e. are the substrings operating on the bytes or on the codepoints?) \$\endgroup\$ Oct 28 '16 at 20:57
  • \$\begingroup\$ 2. If my program is in APL using an 8-bit encoding, do robbers answering in a language other than APL have to have the same bytes in the part of their file corresponding to PA/PB or the same Unicode codepoints? \$\endgroup\$ Oct 28 '16 at 20:57
  • \$\begingroup\$ @NathanMerrill Any program. \$\endgroup\$
    – jimmy23013
    Oct 28 '16 at 21:05
  • \$\begingroup\$ @PeterTaylor I'm considering requiring every program to be in printable ASCII (and tabs and newlines), as some special characters effectively banned many languages. But I'm not sure about newlines, which have the \r problem. \$\endgroup\$
    – jimmy23013
    Oct 28 '16 at 21:09
  • \$\begingroup\$ Maybe I'll just say \r\n is counted one byte in this challenge, and is interchangeable with \n. But the programs in one submission must use only \n or only \r\n. \$\endgroup\$
    – jimmy23013
    Oct 28 '16 at 21:13
  • 1
    \$\begingroup\$ An example would make this easier to understand, \$\endgroup\$
    – xnor
    Oct 29 '16 at 6:08
  • 2
    \$\begingroup\$ I'm skeptical about having the programming language be a free variable. If a cop writes an answer using a verbose language, a robber can comment out all the visible parts and stuff a terse language answer into the cracks. \$\endgroup\$
    – feersum
    Oct 29 '16 at 11:24
  • \$\begingroup\$ @feersum But that's the whole point of all the requirements. If you comment out all the visible parts, both your programs usually should output the same thing. But I realized it's easy to have some workarounds in languages such as Befunge. I may try to find a way to ban them, or just abandon this post. \$\endgroup\$
    – jimmy23013
    Oct 31 '16 at 0:59
-1
\$\begingroup\$

Translation Polyglot

Your task is to write a program which runs in two distinct programming languages to translate text. Input should be translated between each language i.e. running your code in Code Language A translates from language 1 to 2, while running your code in Code Language B translates from language 2 to 1.

Rules:

  • Code Languages must be distinct, two versions of the same language are disallowed
  • Your code may be a full program or function
  • Your code must take one string (or nearest equivalent) as input. Input may be user input, function arguments, or other reasonable form
  • Output may be a function return, output to STDOUT, or other reasonable form. I do not care about trailing newlines or spaces
  • Your code may translate from/to any language on the official language list on Wikipedia. List the languages in your answer
  • To accomplish your goal, you may use prebuilt language tanslation dictionaries such as the ones found here.
  • If you read your dictionary as an external file, only the code to read in the file (f = open("dictionary.txt", 'r') in Python) counts towards your byte count. If your dictionary is hardcoded in, only count the bytes required to make it syntatically valid code (s="word1_in_english word1_in_french ..." would be 4 (s="")). Essentially, do not include the dictionary as part of your submissions byte count.
  • The dictionary you use must have been created before this post (including sandbox time). You may not modifiy the dictionary in any way.
  • Any built-in translation tools are disallowed. Built-in dictionaries are ok, but whatever code used to import them into your code must be included in the byte count

This is code golf, so shortest answer in bytes wins.

\$\endgroup\$
5
  • \$\begingroup\$ wait... Are you actually asking for machine translation? Seems very difficult. Haven't you ever seen bad translator? If it actually is machine translation, this won't work, because of the different resolution of the languages (like converting a jpg to a png and expecting the same quality back) \$\endgroup\$ Nov 1 '16 at 4:11
  • \$\begingroup\$ It's really just value lookup. I'm not asking people to to make their own dictionary, just use a pre-built and accept whatever it translates \$\endgroup\$
    – wnnmaw
    Nov 1 '16 at 13:45
  • 1
    \$\begingroup\$ But that doesn't really satisfy Language A produces output O from input I, while running in Language B produces output I from input O. \$\endgroup\$ Nov 1 '16 at 22:04
  • 1
    \$\begingroup\$ Ah, now I see the source of confusion. Updated text to require basic translation, not symmetric translation \$\endgroup\$
    – wnnmaw
    Nov 2 '16 at 11:53
  • \$\begingroup\$ Also I don't think translation is objective enough for code golf... \$\endgroup\$ Nov 3 '16 at 5:30
-1
\$\begingroup\$

What in the heck just happened?

I want you to write a program that will bleep out the H-word, regardless of where it occurs, whether it is inside of another word or a stand-alone word, whether capitalized or not.

Input and Output

The inputs and outputs of your program may be any of the following: an array of characters, a string, or any other standard data structure which does the job. However, the output must match the case of the input.

Samples:

In the format of Input: Output
A Shell gas station : A Sheck gas station
Hell is a very bad place to be. : Heck is a very bad place to be.
Ella fell and Nelly dug a well. : Ella fell and Nelly dug a well.
Chellsea Thell bought shells. : Checksea Theck bought shecks.

Standard loopholes apply, and the entry submitted by [insert date here] with the lowest number of bytes as defined by the Meta will win.

\$\endgroup\$
3
  • 1
    \$\begingroup\$ I can't say for sure, as I don't have an exact reference, but I'm pretty sure a simple find and replace challenge has been done before. \$\endgroup\$
    – ATaco
    Feb 13 '17 at 0:19
  • 2
    \$\begingroup\$ "Hell" and "heck" are both "H-words", so you need to be clearer. Also, I feel like this is a duplicate. Though these are milder swear words, I think someone did one with swear words in general and it got deleted. If you're going to make a find/replace challenge, it's simple enough to make it about something else. \$\endgroup\$
    – mbomb007
    Feb 13 '17 at 0:19
  • \$\begingroup\$ Ah, I see. So, are you saying I should change what's being replaced or what my idea is? \$\endgroup\$ Feb 14 '17 at 0:50
-1
\$\begingroup\$

Prove the Undecideability of the Halting Problem

More information on the halting problem.

Either:

Create a program that, when given an input, no single program (which receives your source and your input) can determine if your program terminates, or

Create a function that, when given an input, no single program (which receives your source and your input) can determine if your function returns.

Your score is the byte count of your program plus the byte count of your input (or of the shortest input in the set of input that solves this problem).

Lowest score wins.

//I would love some input on my wording.

\$\endgroup\$
12
  • \$\begingroup\$ Can I make a request to an external URL until I get a 404? \$\endgroup\$
    – user58826
    May 17 '17 at 18:21
  • \$\begingroup\$ @programmer5000 can an external program determine whether your program will halt? For example, by pinging that URL themselves? \$\endgroup\$
    – Stephen
    May 17 '17 at 18:24
  • \$\begingroup\$ Oh. Could I make a program that stops when it finds 5 points that prove the Happy Ending Problem wrong? \$\endgroup\$
    – user58826
    May 17 '17 at 18:29
  • \$\begingroup\$ @programmer5000 if your program stops with a given input, and another program can predict that it will stop with that input, your program does not match specs. No input is accepted input, but it is very unlikely that an undecidable program can come from no input AFAIK. \$\endgroup\$
    – Stephen
    May 17 '17 at 18:32
  • \$\begingroup\$ @programmer5000 from the Wikipedia page it seems like that problem is already solved, so that program will terminate, so another program could predict that. Could be wrong though. \$\endgroup\$
    – Stephen
    May 17 '17 at 18:33
  • \$\begingroup\$ Um. eval. It's one byte long in GolfScript. \$\endgroup\$ May 17 '17 at 21:35
  • \$\begingroup\$ @PeterTaylor you need to provide an input that is undecidable, and that counts towards your score. \$\endgroup\$
    – Stephen
    May 17 '17 at 21:38
  • 2
    \$\begingroup\$ I don't think this is how the halting problem works... \$\endgroup\$ May 17 '17 at 23:50
  • \$\begingroup\$ @DestructibleLemon You may be right; Wikipedia says a general algorithm to solve the halting problem for all possible program-input pairs cannot exist. Do I need to require two inputs? This answer seems to contradict Wikipedia though. \$\endgroup\$
    – Stephen
    May 18 '17 at 0:10
  • \$\begingroup\$ hmmm, you definitely could do this (make it an interpreter) but I'm not sure how much you have to do to make this work... as in what the simplest program would be \$\endgroup\$ May 18 '17 at 0:17
  • 1
    \$\begingroup\$ @StephenS It doesn't require 2 inputs, it requires a pair (program, input). \$\endgroup\$ May 18 '17 at 1:07
  • 1
    \$\begingroup\$ It's the problem which is undecidable, not the instances. If you want to ask for a program which cannot be proven to halt or not halt, you have to specify the axiom system which can be used for the proof. See e.g. codegolf.stackexchange.com/q/79470/194 , codegolf.stackexchange.com/q/79620/194 \$\endgroup\$ May 18 '17 at 6:19
-1
\$\begingroup\$

Bike saddle drawn through a fractal

Based on the Mandelbrot image in every language, and on the observation the 3rd layer (0 indexed) always looks like a bike saddle, I had a little bit different challenge:

  • Language must be capable of graphical output or drawing charts (saving files disallowed)
  • Render a window or control that is resizable by mouse action. As example, it can be a typical GUI Window with the typical frame that allows resizing
  • After resizing the GUI element, the fractal should be updated according to the new pixel space
  • The fractal coordinates range from approximately -2-2i to 2+2i
  • The pixels outside of the 3rd layer (0 indexed) of Mandelbrot set should have one color; the ones inside 3rd and inner layers should have another. The only two colors used should be clearly distinguishable
  • At least 99 iterations
  • ASCII art not allowed

Winning conditions:
Shortest version (size in bytes) for each language will get a mention in this post, ordered by size.
No answer will ever be 'accepted' with the button.

\$\endgroup\$
1
  • \$\begingroup\$ @Mark Jeronimus: credits to you. \$\endgroup\$
    – sergiol
    May 27 '17 at 8:48
-1
\$\begingroup\$

The 2017 Loader contest

Here's a thing: Let's do the bignum bakeoff again.

Because why not.

What to do

Write a program in less than 256 characters that outputs the biggest number you can.
Yep, that's it. Biggest return value wins.

We'll run the program on a VM with infinite memory. (How do we do this?)

Rules

  • 256 chars max, excluding whitespace
  • Different leagues for each language
  • Output however you want
    • No explicitly printing numbers until your loop runs out. Print the number you generate directly. {1}
  • Program must terminate
  • No implementation-dependent shenanigans.
  • Implementation-independent shenanigans is encouraged.
  • ints are infinite.
  • Program must return the same number every time
  • Submission must include the approximate return value in any suitable googological notation.
  • Whitespace is space, tab, newline, formfeed, and return
    • BrainF***: Whitespace is all non-[]+-<> characters

{1} Allowed ways to return: printf("%d", num); return num;, etc.
Banned ways to return: for(;num>0;num--)printf("99999");, etc.


This is not a dupe of...

This because you can put any characters you want, not just non-digits; because we're hard-limiting the characters.


Suggested rules

  • No floats: float double long double, etc
  • No strings or chars
  • No bitfeilds
  • No looking at Command-line args

Next year's contest will be named after this year's winner, for no particular reason.

http://djm.cc/bignum-rules-posted.txt


Sandbox

  • How do you even test these programs?
  • What other rules should we have?
\$\endgroup\$
9
  • \$\begingroup\$ You don't actually explain the rules of the challenge, we would have to go to that link to find out what we are supposed to do. Aside from that, I think this has a lot of problems with your typing restrictions if these are not limited to C, but limiting it to C wouldn't really fit the spirit of the site. I think you may want to rethink how you want to approach this question. \$\endgroup\$ May 29 '17 at 16:43
  • \$\begingroup\$ @FryAmTheEggman "Typing restrictions"? (Added proper instructions) \$\endgroup\$ May 29 '17 at 16:45
  • 1
    \$\begingroup\$ Your post doesn't describe how people win. Is it by the largest possible number? Anyway, the problems are things like not counting whitespace, which can easily result in degenerate answers, as well as things like I/O streams and whatnot. All of your extra rules seem entirely based around C with no regard for other languages, which will not go well. \$\endgroup\$ May 29 '17 at 16:48
  • 5
    \$\begingroup\$ In answer to "Because why not": because it will be closed as a dupe. \$\endgroup\$ May 29 '17 at 17:59
  • \$\begingroup\$ Here's a couple of rules I would consider. 1. Program must generate the same result every time (e.g. not based on timer, probability, or the like). 2. Submissions should include, if not the exact resulting number, at least a best estimate, in scientific notation if need be. \$\endgroup\$ May 30 '17 at 18:32
  • \$\begingroup\$ Scientific notation? People will post answers that far, far exceed that. In fact, Mathematica, 22: Fold[Power,2~Range~9999] It's 2^3^4^...^9999. That's not being represented anytime soon. \$\endgroup\$ May 31 '17 at 3:31
  • 1
    \$\begingroup\$ This is a duplicate, and is also going to come down a lot to whether or not you allow programs that exceed the computational capacity of any existing computer. (If you require programs to work on a physical computer, the best they can possibly do is to use the entirety of memory as a counter and print out 9s over and over again. If you don't, the answers can easily be large enough that you need to use notation invented specifically for describing the number, because all other notations are not enough.) \$\endgroup\$
    – user62131
    May 31 '17 at 22:40
  • \$\begingroup\$ If your code can simulate a Turing machine, it becomes hard to judge who the winner is, and whether an answer is valid at all. \$\endgroup\$
    – anatolyg
    Jun 1 '17 at 20:35
  • \$\begingroup\$ Re your latest edit: you're wrong. The question it's a dupe of also has a hard limit to the number of characters; in fact it's a harder one, but the best answers could be copied with slight tweaking to take advantage of the extra space. And the digit restriction turned out not to be a serious problem: the winning answer would gain extremely little from being able to use digits. \$\endgroup\$ Jun 2 '17 at 9:07
-1
\$\begingroup\$

Do nothing

Write a program which terminates normally (not in an error), producing no output on the standard output stream (or the language's closest equivalent), nor on the standard error stream, regardless of what content is present on the standard input stream. (Note that this is intentionally overriding the normal I/O defaults; this is a challenge entirely about input/output handling.)

Additionally, your program may not have any other side effects (e.g. writing files, changing persistent state), unless they're an unavoidable consequence of running a program on the operating system you're using (e.g. on Linux, it's OK to change the "next process ID number to be assigned" value inside the kernel, because that happens whenever you run a program).

Finally, to avoid numerous uninteresting 0-byte (or boilerplate-plus-0-byte) solutions, you may not use a language in which the shortest program that does nothing (i.e. complies with the above specification) is also the shortest (or tied for the shortest) program which runs without error (but possibly reacts to input or produces output). In other words, you can't use a language unless doing nothing is more verbose than doing something.

Clarifications

  • Intentionally exiting the program early is permitted. If you do exit the program manually, on a system that uses exit codes, you may do so with any exit code.
  • Crashing the program is not permitted, even if it (for some reason) exits with a "success" code after the crash.
  • "No output" means 0 bytes of output, not even a trailing newline.
  • Likewise, your program must be able to handle any finite sequence of bytes on the standard input stream, even if it isn't, say, made of characters in the current encoding (but rather of arbitrary octets). You do not need to handle infinite input, though (e.g. your program won't be connected to /dev/zero or the like).
  • You don't have to actually read input; it's your choice as to whether you want to read and discard it, or not read it at all.

Victory condition

As a challenge, shorter is better, measured in bytes. (Remember that if you need to run the program in an unusual way, that incurs a byte penalty, under standard PPCG rules.)

Because languages which are particularly suited for this task (such as Perl and Python) are excluded by the rules, there's not much point in talking about the best answer cross-language; rather, the aim is to find the best answer you can in the language which you submit in. (Historically, on this sort of challenge, answers that are more unusual, interesting, or better-explained have tended to get more votes.)

Sandbox questions

Is this too trivial? We were discussing it in chat as a joke, and realised that it's actually possibly more interesting than it sounds. I'm fairly sure the spec's correct (although would definitely appreciate knowing if something's wrong here!), but would appreciate feedback on how much people would hate me if I posted it to main.

\$\endgroup\$
2
  • \$\begingroup\$ you can't use a language unless doing nothing is more verbose than doing something.you can't use a program unless your program is more verbose than any other program which does something. You must provide a shorter program which does something to prove your solutions validity. \$\endgroup\$
    – Adám
    Jun 8 '17 at 1:03
  • \$\begingroup\$ @Adám: If you did that, people would just add a comment byte or two to create a program of the shortest possible length that was longer than a program that did something. That isn't particularly interesting. \$\endgroup\$
    – user62131
    Jun 8 '17 at 1:21
-1
\$\begingroup\$

Draw an XBox

Here's an X:

\  /
 \/
 /\
/  \

And here's a Box:

+----+
|    |
|    |
|    |
|    |
+----+

So, for an XBox, just draw an X in a Box:

+----+
|\  /|
| \/ |
| /\ |
|/  \|
+----+

Your input will be a number (in any standard way) that will represent the size of the box. To output the above box, this could be the number of -/|\s (4), or the number of lines/columns (6), or even the intercept of the second diagonal (5) would be acceptable. (Don't ask me to accept the base256 encoding of the output though, as that's one of the many banned standard loopholes.)

Your program or function should then output (in any standard way) the XBox of the given size. If the \/s cross in the same character, place an X (as per Draw a big slash X). For example, here's an XBox three sizes larger than the one above:

+-------+
|\     /|
| \   / |
|  \ /  |
|   X   |
|  / \  |
| /   \ |
|/     \|
+-------+

This is , so the shortest program wins!

\$\endgroup\$
12
  • \$\begingroup\$ in some obvious way unclear/subjective \$\endgroup\$
    – MD XF
    Jun 9 '17 at 16:35
  • \$\begingroup\$ @MDXF 4 examples weren't sufficient? \$\endgroup\$
    – Neil
    Jun 9 '17 at 17:04
  • \$\begingroup\$ I'm just warning you that it could get closed for being too broad due to that statement. \$\endgroup\$
    – MD XF
    Jun 9 '17 at 17:05
  • \$\begingroup\$ I agree with @MDXF \$\endgroup\$
    – Beta Decay
    Jun 9 '17 at 18:03
  • \$\begingroup\$ @BetaDecay That's all very well, but I'm unclear as to what you want. \$\endgroup\$
    – Neil
    Jun 9 '17 at 19:15
  • \$\begingroup\$ Just a basic explanation of how scaling works. Some examples would suffice \$\endgroup\$
    – Beta Decay
    Jun 9 '17 at 21:32
  • \$\begingroup\$ I've added an example. \$\endgroup\$
    – Neil
    Jun 10 '17 at 0:42
  • \$\begingroup\$ @MDXF Here's my problem. I just tried implementing this in Charcoal, and came up with Try it online!. As it turns out, to produce those example XBoxes I actually need sizes of 7 and 10, but I didn't want to penalise that choice of input just because I hadn't predicted that particular scaling. \$\endgroup\$
    – Neil
    Jun 10 '17 at 13:42
  • \$\begingroup\$ @BetaDecay If you still have any further input it would be appreciated. \$\endgroup\$
    – Neil
    Jun 12 '17 at 12:06
  • \$\begingroup\$ Related \$\endgroup\$ Jun 15 '17 at 11:57
  • \$\begingroup\$ @KevinCruijssen Ugh, I even have an answer on that question... I guess the use of specific characters doesn't really sufficiently distinguish this one. \$\endgroup\$
    – Neil
    Jun 15 '17 at 12:42
  • \$\begingroup\$ @Neil Well, using /+x\ instead of just * does make it a bit trickier, but it's indeed a bit too similar imho. \$\endgroup\$ Jun 15 '17 at 13:11
-1
\$\begingroup\$

Plan and Chain a route through OEIS

Your Task is to reach so many OEIS sequences you could make with chaining your last sequence with a operation to a new sequence.

You must avoid last sequence minus last sequence plus first sequence or something similar that your new sequence is based on the first sequence except to make the second sequence.

Your starting OEIS sequence is in every case https://oeis.org/A001477

Given as Input an positive Integer and a Letter that matches [A-Z] or [a-Z]

Example

PHP, 171 bytes

for($a=0;$a<=$argv[1];$a++)$r[]=[$a,$b=$a&1,$c=$a+!$b,$d=(($c-!$b)/2^0)+$b,$A[$b]=$e=$d*$c,$f=$e+$A[!$b],$g=$a?$g*sqrt($f):1,$h=$g%2];echo$r[$argv[1]][ord($argv[2])%32-1];

Try it online!

The example gives back the n value of a OEIS sequence for the following letters. A letter greater h is for this example a invalid input

  • a https://oeis.org/A001477 numbers
    $a Valid first sequence

  • b https://oeis.org/A000035 mod 2
    $b=$a&1 Valid use the variable in the sequence before

  • c https://oeis.org/A109613 odd numbers
    $c=$a+!$b Valid Can use sequences before

  • d https://oeis.org/A110654 a(n) = floor(n/2) + n mod 2
    $d=(($c-!$b)/2^0)+$b Valid an invalid example is $d=(($a/2)^0)+$b cause it not use the sequence before

  • e https://oeis.org/A000217 triangular
    $A[$b]=$e=$d*$c Valid you can create help variables

  • f https://oeis.org/A000290 square
    $f=$e+$A[!$b] Valid use a help variabale and the variable of the sequence before. $f=$A[!$b]+$A[!$b] Invalid causes it makes the same value but use indirectly the variable of the sequence before

  • g https://oeis.org/A000142 factorial $g=$a?$g*sqrt($f):1 Valid cause your condition is not always the case that it have no relationship to the sequence before.

  • h https://oeis.org/A019590 Fermat's Last Theorem $h=$g%2 Valid but now we have the problem to find the next sequence

Could You make a full alphabet? My alphabet ends with the letter h

\$\endgroup\$
9
  • \$\begingroup\$ I'm rather confused as to what is being asked here. It might be helpful to state how one can get from one sequence to another. \$\endgroup\$
    – Wheat Wizard Mod
    Jun 10 '17 at 20:47
  • \$\begingroup\$ @WheatWizard I could understand you. The problem is at the moment to make rules that avoid that a trivial solution exits. There are too many sequences in OEIS. The way from every sequence to the next should not end in a simple addition or multiplication. But evrything else should be allowed to get more creative solutions \$\endgroup\$ Jun 10 '17 at 20:56
  • \$\begingroup\$ (1) The first sentence says that the aim is to build the longest chain possible, but the scoring mechanism rewards average code length per element in the chain rather than number of chains. I would think it most likely as it stands that the winner would be a chain of length 1 or at most 2. (2) If you delete everything from the header Example to the end, do you think that the question still makes sense? If not (and I don't think it does), it needs a lot of work. (3) What do the two values in the input mean? Why is the second one a letter rather than a number? \$\endgroup\$ Jun 10 '17 at 21:10
  • \$\begingroup\$ (4) I'm not sure how feasible it is to write objective rules which forbid "trivial" expressions. (5) It is not clear how to interpret the rule about the 32nd term where either it is not known or the sequence is finite and shorter than 32 terms. \$\endgroup\$ Jun 10 '17 at 21:12
  • \$\begingroup\$ @PeterTaylor (1) Think you that popularity Contest is a better winning criteria? (2+3) to limit the chaining length to 26. The goal is to show relationsships between two or more sequences. (4+5) Yes it is not easy and I can drop it if I switch to popularity Contest \$\endgroup\$ Jun 10 '17 at 21:26
  • \$\begingroup\$ @WheatWizard I allow now trivial solutions \$\endgroup\$ Jun 10 '17 at 21:53
  • \$\begingroup\$ I'm not clear on the purpose of the inputs if we're just supposed to hard code our way from one sequence to the next​. Replacing your PHP example with more generic, more verbose pseudo-code might help. \$\endgroup\$
    – Shaggy
    Jun 11 '17 at 0:16
  • \$\begingroup\$ @programmer5000 exists a limit of correct tags? \$\endgroup\$ Jun 11 '17 at 11:39
  • \$\begingroup\$ @Shaggy See it as restriction for ways to code. You must have a chaining to the sequence before. So far I know any working code is a pseudocode \$\endgroup\$ Jun 11 '17 at 11:48
-1
\$\begingroup\$

Braid Badly Boundlessly


Your program or function must, given a string in any standard input format, output an infinite stream of delimiter-separated strings where each string is determined from the previous by a braiding algorithm. The program starts with printing the input string.

The algorithm is described as follows: Infinitely alternate between

(1) splitting the string into three substrings then swapping the first two substrings and flattening.

and

(2) splitting the string into three substrings then swapping the last two substrings and flattening.

starting with (1).

The three substrings should be of non-increasing length with the maximum length no more than 1 greater than the minimum length of the three substrings. (This means that when the length of the given string is a multiple of three, the three substrings should be the same length. When the length of the given string is one more than a multiple of three, the first substring should be one character longer than each of the last two substrings. When the length of the given string is two more than a multiple of three, the first and second substrings should each be one character longer than the last substring.)

Example

Let the input be "abcdefg". Let the delimiter be a newline.

Then the program would first print "abcdefg".

It applies (1) which splits the string into ["abc","de","fg"] and swaps the first two elements, reaching ["de","abc","fg"]. It flattens to get "deabcfg" which it prints and uses for the next step.

The program applies (2) to "deabcfg" to split into ["dea","bc","fg"] and swaps into ["dea","fg","bc"], flattening to reach "deafgbc".

The program applies (1) to "deafgbc" and the process repeats ad infinitum.

Then the output would be the newline-separated

abcdefg
deabcfg
deafgbc
fgdeabc
fgdbcea
bcfgdea
bcfeagd
eabcfgd
eabgdcf
gdeabcf
gdecfab
cfgdeab
cfgabde
abcfgde
abcdefg
deabcfg
deafgbc
fgdeabc
fgdbcea
bcfgdea
bcfeagd
eabcfgd
eabgdcf
gdeabcf
gdecfab
cfgdeab
cfgabde
abcfgde
abcdefg
[...]

Specifications

  • Note that the string should not be split at the beginning and then only swapped later. The string should be split on each and every iteration
  • The delimiter between lines could be whichever character is convenient. You may assume it does not appear in the input string.
  • The string input shall be at least three characters
  • The input consists solely of printable characters (0x20-0x7F)
  • Of course, standard loopholes are forbidden.

I/O

  • The input and output should be taken in standard I/O methods.
  • The input and output should be taken as string, list of characters, or equivalent.
  • The output should be output continuously, which means you may assume infinite memory.

Test cases

For the test cases, we will assume that the delimiter is a newline. Just the portion before the endless stream is repeats is shown.

input
--
output
-----
abcdefg
--
abcdefg
deabcfg
deafgbc
fgdeabc
fgdbcea
bcfgdea
bcfeagd
eabcfgd
eabgdcf
gdeabcf
gdecfab
cfgdeab
cfgabde
abcfgde
-----
abc
--
abc
bac
bca
cba
cab
acb
-----
abcdefgh
--
abcdefgh
defabcgh
defghabc
ghadefbc
ghabcdef
bcdghaef
bcdefgha
efgbcdha
efghabcd
habefgcd
habcdefg
cdehabfg
cdefghab
fghcdeab
fghabcde
abcfghde
abcdefgh
-----
Braid
--
Braid
aiBrd
aidBr
dBair
dBrai
radBi
raidB
idraB
idBra
Brida
-----
Cycle
--
Cycle
clCye
cleCy
eCcly
eCycl
yceCl
ycleC
leycC
leCyc
Cylec
-----
O Canada!
--
O Canada!
anaO Cda!
anada!O C
da!anaO C
da!O Cana
O Cda!ana
-----
A man, a plan, a canal - panama!
--
A man, a plan, a canal - panama!
an, a canalA man, a pl - panama!
an, a canal - panama!A man, a pl
 - panama!Aan, a canal man, a pl
 - panama!A man, a plan, a canal
 man, a pla - panama!An, a canal
 man, a plan, a canal - panama!A
n, a canal  man, a pla- panama!A
n, a canal - panama!A man, a pla
- panama!A n, a canal man, a pla
- panama!A man, a plan, a canal 
man, a plan- panama!A , a canal 
man, a plan, a canal - panama!A 
, a canal -man, a plan panama!A 
, a canal - panama!A man, a plan
 panama!A m, a canal -an, a plan
 panama!A man, a plan, a canal -
an, a plan, panama!A m a canal -
an, a plan, a canal - panama!A m
 a canal - an, a plan,panama!A m
 a canal - panama!A man, a plan,
panama!A ma a canal - n, a plan,
panama!A man, a plan, a canal - 
n, a plan, panama!A maa canal - 
n, a plan, a canal - panama!A ma
a canal - pn, a plan, anama!A ma
a canal - panama!A man, a plan, 
anama!A mana canal - p, a plan, 
anama!A man, a plan, a canal - p
, a plan, aanama!A man canal - p
, a plan, a canal - panama!A man
 canal - pa, a plan, anama!A man
 canal - panama!A man, a plan, a
nama!A man, canal - pa a plan, a
nama!A man, a plan, a canal - pa
 a plan, a nama!A man,canal - pa
 a plan, a canal - panama!A man,
canal - pan a plan, a ama!A man,
canal - panama!A man, a plan, a 
ama!A man, canal - pana plan, a 
ama!A man, a plan, a canal - pan
a plan, a cama!A man, anal - pan
a plan, a canal - panama!A man, 
anal - panaa plan, a cma!A man, 
anal - panama!A man, a plan, a c
ma!A man, aanal - pana plan, a c
ma!A man, a plan, a canal - pana
 plan, a cama!A man, anal - pana
 plan, a canal - panama!A man, a
nal - panam plan, a caa!A man, a
nal - panama!A man, a plan, a ca
a!A man, a nal - panamplan, a ca
a!A man, a plan, a canal - panam
plan, a cana!A man, a al - panam
plan, a canal - panama!A man, a 
al - panamaplan, a can!A man, a 
al - panama!A man, a plan, a can
!A man, a pal - panamalan, a can
!A man, a plan, a canal - panama
lan, a cana!A man, a pl - panama
lan, a canal - panama!A man, a p
l - panama!lan, a canaA man, a p
l - panama!A man, a plan, a cana
A man, a pll - panama!an, a cana
\$\endgroup\$
-1
\$\begingroup\$

Rock Paper Scissors, but it's a big, custom tournament

We all know "Rock, Paper, Scissors", and it's pretty variated.

A world tournament is held every year, and it's dang popular.

However, the contestants are able to bring their own ways of play to the plate, and they play with them.

The challenge:

Create a program that, by process of elimination through RPS, determines the winner of the tournament.

The tournament rules:

  • No slackers. (Let the amount of players be an integer equally divisible by 2. [In other words, an even number.])

  • You can bring 2 of either of the 4 variants:

    None: Play regular RPS.

    RPSLV: Play "Rock, Paper, Scissors, Lizard, Spock" (play diagram shown here).

    Best out of three: Play 3 rounds; if by round 2, a player wins the round and has two points, they auto win. Else, winner of the next round wins.

    Double RPS: Play with four hands (two hands used by each player).

  • You cannot bring two of the same variant.

  • In order to use a variant, the two players must have the same type of variant. If there are no matching variants, the gameplay is automatically None.

  • However, if there are more than one variant matches, a game of mode None will be played. The winner of the game mentioned decides what mode they play for the match they will play to see who goes to the next round.

  • In the case of a tie, replay until a win occurs (for all modes)

  • There can be only one winner.

The coding rules:

  • All choices must be randomized (no strategies, to make this simple.).

  • No standard loopholes.

  • Give an explanation as much as you can. (If possible, include a "Try it out online" sample.)

Sample Input/Output:

You must make a table variable with all the player numbers, from 1 to n, with two variants for each player.

n = the amount of players you intend to enter.

Example Input:

Player # | Var 1 | Var 2
1        | RSPLV | None
2        | None  | x2 RPS
3        | x2 RPS| Boo3
4        | Boo3  | x2 RPS
...      |...    | ...

Make a func() that:

1: Checks the variants of the next two availible players on the list, starting at player 1, then does the second to third last rules depending on what happens.

2: Makes the pair engage in battle, gameplay depending on the chosen variant.

3: Finally, boot the loser off the game and add the winner to the next list (round). (The "boot the loser" part isn't that required, but I recommend so as to not make the program add a player to the next table.)

Output (uses table from input):

 Round 1:
 1 vs. 2 // None, since the None variant matches both of them
 ["Rock"/*1*/,"Scissors"/*2*/]
 1 wins

 3 vs. 4 // They have more than one match, so they fight for who decides
 ["P"/*3*/,"S"/*4*/]
 4 wins, and chooses Best out of 3 
 Match 1:
 ["P"/*3*/,"R"/*4*/] // 1(3) - 0(4)

 Match 2:
 ["P"/*3*/,"S"/*4*/] // 1(3) - 1(4)

 Match 3:
 ["P"/*3*/,"R"/*4*/] // 2(3) - 1(4)
 3 wins

 Round 2:
 1 vs. 4 //No matches, defaults to None
 ["R"/*1*/,"R"/*4*/] // No-one wins
 ["R"/*1*/,"S"/*4*/]
 1 wins the tournament

Misc. requirements (some optional):

A {!} means it is required.

  • {!} Print each match, and who wins.

  • {!} Print the tournament winner.

  • {!} The number of players must be flexible.

  • Print the table for each round.

Scenarios:

None:

a vs. b //Either they have no matches, or they have both None matches
["R"/*a*/,"S"/*b*/]
a wins

RPSLV (will make this one quick):

a vs. b //RPSLV chosen
["V"/*a*/,"L"/*b*/]
b wins

Best out of Three:

Scenario 1: (a tie occurs at match 2)

a vs. b //Boo3 chosen
Match 1:
["P"/*a*/,"S"/*b*/] // 0(a) - 1(b)

Match 2:
["P"/*a*/,"P"/*b*/] // tie
["P"/*a*/,"S"/*b*/] // 1(a) - 1(b)

Match 3:
["R"/*a*/,"S"/*4*/] // 2(a) - 1(b)
a wins

Scenario 2: (a player has two points by the end of match 2)

a vs. b //Boo3 chosen
Match 1:
["P"/*a*/,"S"/*b*/] // 0(a) - 1(b)

Match 2:
["S"/*a*/,"P"/*b*/] // 0(a) - 2(b)
b automatically wins

Double RPS:

a vs. b //x2 RPS chosen
[("R", "P")/*a*/, ("S", "S")/*b*/] // lock
[("P", "P")/*a*/, ("S", "S")/*b*/]
b wins

Both the coding and tournament rules apply to your code.

For sandbox use only (won't be included in real question)

I don't know if this kind of problem is suitable for code golf, it could be a programming puzzle, I'm not sure. Go ahead in the comments and tell me what mode it should be, and if I should improve it. (Also, sorry for the mix of Python lists and C++ comments, if it confuses you.) A ** means the choice is random.

\$\endgroup\$
4
  • \$\begingroup\$ Hi and welcome to PPCG, and thanks for using the sandbox! I had a hard time following what you intended from this challenge. The rules are rather disorganised with many points early on not making sense until later. For example, you say: "No slackers. (Let p be a number equally divisible by 2.)" before it is clear that you intend for us to implement a single elimination tournament. I had no idea what "p" was supposed to mean, or why this should matter. I'd recommend trying to explain this to someone verbally, perhaps, to try to organise your thoughts better. Good luck! \$\endgroup\$ Jul 15 '17 at 21:50
  • \$\begingroup\$ Ah, thanks. I will edit the problem. \$\endgroup\$ Jul 15 '17 at 22:03
  • \$\begingroup\$ I'm not quite sure what we're supposed to implement. The controller for the tournament and what else? Do we also implement the players, so that we're simulating the entire thing? Or do we have to provide some kind of API for the players? In the first case, how does "The winner decides what mode they play" work? \$\endgroup\$ Jul 16 '17 at 7:14
  • \$\begingroup\$ Again, any multi-choice is random. \$\endgroup\$ Jul 16 '17 at 19:29
-1
\$\begingroup\$

Quick! Tell me all the numbers from 1 to 100,000!

Your task is to write a program or function that, when run, output all the numbers from 1 to 100 thousand as quickly as possible to STDOUT. It's that simple. All answers are tested on an HP Compaq nx9420 with an Intel Core Duo @ 1.83 GHz and 3 gigs of RAM using the time command.


Of course, standard loopholes are strictly forbidden.
This is , so may the fastest code win and the best programmer prosper...

\$\endgroup\$
9
  • 3
    \$\begingroup\$ Have you tried running an example to see if the times are variable enough to be meaningful? As-is, this is going to be strongly dependent upon how fast the code can do I/O, which makes the challenge pretty uninteresting, IMO. \$\endgroup\$ Jul 19 '17 at 18:16
  • \$\begingroup\$ @AdmBorkBork Might be interesting \$\endgroup\$
    – ckjbgames
    Jul 19 '17 at 21:12
  • 1
    \$\begingroup\$ As far as I can tell, this takes less than a tenth of a second, which means submissions will probably be differentiated solely by noise on your computer. \$\endgroup\$ Jul 20 '17 at 2:37
  • \$\begingroup\$ upvoted, though I think the differenciation is really difficult, unless you test it on a raspberry PI (for example) having ONLY the program and its compiler installed. \$\endgroup\$ Jul 20 '17 at 13:36
  • \$\begingroup\$ @FryAmTheEggman How could I improve on that? \$\endgroup\$
    – ckjbgames
    Jul 20 '17 at 23:38
  • 1
    \$\begingroup\$ @V.Courtois I do have a Pi, and I think I will use that (it has Raspbian installed). \$\endgroup\$
    – ckjbgames
    Jul 20 '17 at 23:39
  • \$\begingroup\$ The time is still so small even a basic operating system will have to much noise in process creation, etc, for this to work out. You need to make what we are computing substantially more complicated for this to be reasonable. \$\endgroup\$ Jul 21 '17 at 0:10
  • \$\begingroup\$ @FryAmTheEggman K \$\endgroup\$
    – ckjbgames
    Jul 21 '17 at 1:20
  • \$\begingroup\$ @ckjbgames good then :) \$\endgroup\$ Jul 21 '17 at 5:26
-1
\$\begingroup\$

Is it cat-urday?

Caturday is one of the oldest memes out there. For this challenge you need to write a program that outputs the input, but only on Saturday.

The catch:

You can acquire the date via UNIX timestamp, or as a formatted date string (local or UTC). However, you can not:

  • use day of the week information in a date string
  • directly acquire the day of the week of a date by some other means
  • use Date or Calendar functions, beyond one to simply give you the current date
  • use any external resources (files, Internet)

Don't forget leap years!


Does this question work as is? Should I make anything clearer?

\$\endgroup\$
1
  • 5
    \$\begingroup\$ This is a "do X without Y" challenges, and those have been done to death. \$\endgroup\$ Jul 22 '17 at 20:28
-1
\$\begingroup\$

What's that character? (Part 1)

Recently I ran a command on my laptop that returned a bunch of characters - some printable, some non-printable. I'm having trouble figuring out what those characters are, so I could use some help. Unfortunately, I'm running low on disk space, so you'll have to write me the shortest program you can that I can run.

Challenge

Given a list of ASCII characters, return their names as written on www.asciitable.com, my go-to site for looking up character points.

Input

You may take a string, a list of characters, or a list of ASCII code points (e.g. 'a' -> 97).

You may optionally take the length of the string/list as well. Note that for C, you must take this parameter, since the string could contain NUL bytes, so strlen won't work here.

Output

Output is flexible as usual; you may print or return from a function as you see fit. You should output a list of strings.

The Table

0 NUL
1 SOH
2 STX
3 ETX
4 EOT
5 ENQ
6 ACK
7 BEL
8 BS
9 TAB
10 LF
11 VT
12 FF
13 CR
14 SO
15 SI
16 DLE
17 DC1
18 DC2
19 DC3
20 DC4
21 NAK
22 SYN
23 ETB
24 CAN
25 EM
26 SUB
27 ESC
28 FS
29 GS
30 RS
31 US
32 Space
33 !
34 "
35 #
36 $
37 %
38 &
39 '
40 (
41 )
42 *
43 +
44 ,
45 -
46 .
47 /
48 0
49 1
50 2
51 3
52 4
53 5
54 6
55 7
56 8
57 9
58 :
59 ;
60 
63 ?
64 @
65 A
66 B
67 C
68 D
69 E
70 F
71 G
72 H
73 I
74 J
75 K
76 L
77 M
78 N
79 O
80 P
81 Q
82 R
83 S
84 T
85 U
86 V
87 W
88 X
89 Y
90 Z
91 [
92 \
93 ]
94 ^
95 _
96 `
97 a
98 b
99 c
100 d
101 e
102 f
103 g
104 h
105 i
106 j
107 k
108 l
109 m
110 n
111 o
112 p
113 q
114 r
115 s
116 t
117 u
118 v
119 w
120 x
121 y
122 z
123 {
124 |
125 }
126 ~
127 DEL

Test Cases

[0, 97, 7, 22] -> [NUL, a, BEL, SYN]

More to come...

Meta

  • Would it be more interesting to use the UTF-8 names for the printable characters (0x20 - 0x7E), and the ASCII names for the control characters?
\$\endgroup\$
4
  • \$\begingroup\$ hand copy the table from the website please dont. Try a Google search: theasciicode.com.ar/ascii-codes.txt \$\endgroup\$
    – Stephen
    Jul 23 '17 at 22:39
  • \$\begingroup\$ @StepHen good call, thanks \$\endgroup\$ Jul 23 '17 at 23:24
  • \$\begingroup\$ Downvoter: I would much like your feedback rather than just your vote \$\endgroup\$ Jul 24 '17 at 1:39
  • 1
    \$\begingroup\$ IMO just have take a letter and output the code. Since that part is boilerplate str.chars.map( real program ). Also for ASCII char names NUL is it ok is we output them in lower case? e.g. nul (obviously ascii letters would have fixed case) \$\endgroup\$
    – Downgoat
    Jul 24 '17 at 1:42
-1
\$\begingroup\$

Lennyface parser and selector

Your mission

Create, in the language of your choice, a program that outputs a randomly selected lennyface (artistic minifigures, see this) from an input - a string composed of numbers and lennyfaces. You will have to : first, parse this input; second, extract a probability mass function f from the parsed input; third, select and output a lennyface respecting f. Read the rules for more details.

Rules

  • Input : A string with lennyfaces and numbers (positive AND negative integers), separated by newlines. You may take input by STDIN or function parameter for example.
  • Output (STDOUT for example) : the randomly-selected lennyface, as a string.
  • The input creates a probability mass function f. If l is a lennyface, then f(l)=(sum of all numbers since the previous lennyface)/x where x is obtained afterwards by summing each of those numerators. @Sandbox : is it clear enough?
  • If (sum of all numbers since the previous lennyface) is equal to zero or negative, you must do as if the numerator is equal to 1 in f's definition.
  • A line with a number contains only this number ; same for a line with a lennyface. So you can assume there will never be a number in a lennyface.
  • If there is nothing on a line (two newlines in a row), you must consider it as a lennyface.
  • You must consider that the last line of the string is directly before its first line. See Test 1 for an example.
  • You can assume there will be at least 1 lennyface in the list; it cannot be composed just by numbers (don't forget that an empty line is a lennyface too).

Example

Given this input list :

( ͡° ͜ʖ ͡°)
2
¯\_ツ_/¯
34
-4
8
└[⸟‿⸟]┘

1

You must have 1/42 chances of outputting ( ͡° ͜ʖ ͡°), 2/42 chances of outputting ¯\_ツ_/¯, 38/42 chances of outputting └[⸟‿⸟]┘ and 1/42 chances of outputting nothing (line 7).

Test cases

Test 1

(⌐■_■)
3

Must output (⌐■_■) with 3/3 chances.

Test 2

ʢ◉ᴥ◉ʡ

Must output ʢ◉ᴥ◉ʡ with 1/1 chance.

Test 3

0
\(ᗝ)/

Must output \(ᗝ)/ with 1/1 chance.

Test 4

( ͡° ͜ʖ ͡°)
2
¯\_ツ_/¯
34
4
☞   ͜ʖ  ☞

0

Must output ( ͡° ͜ʖ ͡°) with 1/42 chance, ¯\_ツ_/¯ with 1/21 chance, ☞  ͜ʖ  ☞ with 19/21 chances and nothing with 1/42 chance.

Test 5

1



( ͡° ͜ʖ ͡°)

Must output ( ͡° ͜ʖ ͡°) with 1/4 chance and nothing with 3/4 chance, since there are 3 empty lines.

Test 6

42

-1
( ͡° ͜ʖ ͡°)

Must output nothing with 43/44 chance and ( ͡° ͜ʖ ͡°) with 1/44 chance.

@Sandbox : should I add test cases?

This is , so shortest code in bytes wins. Standard loopholes apply.

Note : Please do not be discouraged if the parsing is difficult to handle in your language, or if testing is hard because of randomness. Your solution might be very interesting algorithmically, not obviously in terms of golfing. Just please explain in your answer why it works.

Moreover, this is the first code-golf I create, so please let me know if something is not appropriate or if I should give more details on a point. And overall, if you downvote, explain me why so I can improve it.

\$\endgroup\$
16
  • \$\begingroup\$ Yours tests seems a bit contraditory. The number is the chance of the next face (line), so what's the point of the empty line in the example / test 4? By the same logic, the test1 should have a 3/4 of outputting nothing? What is the point of the 0 in the test 4? \$\endgroup\$
    – Rod
    Jul 3 '17 at 14:03
  • \$\begingroup\$ Why is the chance of outputting ( ͡° ͜ʖ ͡°) 1/42 and not 0 ? (since there are no numbers above it) \$\endgroup\$
    – Dada
    Jul 3 '17 at 14:04
  • \$\begingroup\$ Sorry ! I forgot to copy paste the fact that the minimal chance is 1! \$\endgroup\$ Jul 3 '17 at 14:05
  • \$\begingroup\$ Also, a common thing to do on challenges involving randomness, and therefore, hard to test, is to ask people to provide a mandatory explanation, or at least ask them to show why it works. \$\endgroup\$
    – Dada
    Jul 3 '17 at 14:05
  • \$\begingroup\$ @Dada thanks. I note this. \$\endgroup\$ Jul 3 '17 at 14:06
  • \$\begingroup\$ @Rod the empty line is a lennyface, as said here : If there is nothing on a line, you must consider it as a lennyface. \$\endgroup\$ Jul 3 '17 at 14:08
  • \$\begingroup\$ @V.Courtois I meant and empty line without a preceding number \$\endgroup\$
    – Rod
    Jul 3 '17 at 14:09
  • \$\begingroup\$ As I said, the minimum is one (sorry again for forgetting it). \$\endgroup\$ Jul 3 '17 at 14:10
  • 1
    \$\begingroup\$ If only positive integers are to be expected, you should write it. Otherwise, give some details and examples about what you consider "numbers". \$\endgroup\$
    – Dada
    Jul 3 '17 at 14:12
  • \$\begingroup\$ @Dada editing. In fact I said the minimum is 1, but you can have things like 2,-1,-3,17 and then your lennyface ; that means the probability is 15/ total. \$\endgroup\$ Jul 3 '17 at 14:14
  • \$\begingroup\$ @V.Courtois just a small suggestion, to make the "list as circle" more explicit you could change the value to something else than 0 or 1, this way it would not overlap the "missing number" rule \$\endgroup\$
    – Rod
    Jul 3 '17 at 14:15
  • \$\begingroup\$ @Rod does it? Sorry if I'm not getting what you are saying, but the list is always a circle, meaning if your list is 2,3,( ͡° ͜ʖ ͡°),4,5,☞  ͜ʖ  ☞,6, you have 6+2+3 chance of getting ( ͡° ͜ʖ ͡°) and 4+5 chance of getting ☞  ͜ʖ  ☞. \$\endgroup\$ Jul 3 '17 at 14:18
  • \$\begingroup\$ thanks for editing @musicman523 \$\endgroup\$ Jul 4 '17 at 7:21
  • 5
    \$\begingroup\$ KISS. This is far more complicated than common sense would require. Deliberately overcomplicating things to make it "more difficult" is a guaranteed method to make a bad question. \$\endgroup\$ Jul 4 '17 at 7:32
  • 1
    \$\begingroup\$ The challenge has two parts as far as I can tell. a) Create a probability mass function from an input by parsing b) sample from the probability mass function. Part a) needs to be rewritten as it is at best ambiguous and at worst just incorrect. \$\endgroup\$
    – user9206
    Jul 5 '17 at 7:50
-1
\$\begingroup\$

Golf Cubically code

Your task is to optimize Cubically source code using one or more optimizations in this post.

How this challenge works:

  • You will choose one or more optimizations below and write a program (in the language of your choice) that performs those optimizations on a Cubically program.
  • Your program will take a Cubically program as input using any allowed input methods, and output a Cubically program using any allowed output methods.
  • The first answer to successfully perform all optimizations wins!

Optimizations

1. Face turn arguments

Before a face turn is performed, the interpreter calculates turns = turns mod 4. So R5 would be equivalent to R1 which is equivalent to R, R7 is equivalent to R3 which is equivalent to R', etc. Also note that R11111 is equivalent to R5, and R22 is equivalent to nothing at all.

Performing this optimization will mean evaluating all arguments to an R, L, U, D, M, E, or S command and shortening them as much as possible.

Test cases:

Relevant code -> Optimization
R11           -> R2
R1            -> R
L33           -> L2
U22           ->
D222          -> D2
M11111        -> M
E00001        -> E
S9            -> S

2. Repeated face turn

When multiple calls to the same face turn command are present right next to each other, they can clearly be golfed. For example, R2R1 is equivalent to R3. UUU is equivalent to U3. F2F2F2F2 is equivalent F8.

Test cases:

Relevant code -> optimization
R2R2R2        -> R6            (R2 if you also choose optimization 1)
LLL           -> L3
UU            -> UU or U2
D3D2D1        -> D6            (D2 if you also choose optimization 1)

3. "Set notepad to" commands

There are some commands that, instead of adding to/subtracting from/multiplying by/dividing by the notepad, just assign to it. Here are all such commands:

_^=<>⊕«»·|:

When called with multiple arguments, since each argument calls the command separately, only the final argument is relevant. So =123 is equivalent to =3, _00000 is equivalent to _0, and :12345678987654321 is equivalent to 1.

Test cases:

Relevant code -> Optimization
_333          -> _3
=12321        -> =1
+54321        -> +54321
:55           -> :5
/55           -> /55

4. Repeated non-face-turn commands

When multiple face turn commands are present right by each other, their arguments can simply be added together. Commands do not act this way. While R2 calls R with 2, =2 calls = with the face sum of the front face (face index 2).

To perform this optimization, when multiple commands outside of RLUDFBMES appear next to each other, simply remove the duplicated commands without removing the arguments.

Relevant code -> Optimization
_1_1_1_1      -> _1111         (_1 if you also choose optimization 3)
%11%22%33     -> %112233       (%3 if you also choose optimization 3)
+12345+67+8   -> +12345678

5. Nonexistent commands

Go check out the Cubically commands page and you'll see that there are plenty of characters that are not commands. For example, there are no commands that are lowercase letters.

To perform this optimization, remove all nonexistent commands and their arguments from the Cubically source. If the commands also have arguments, you must remove the arguments so that they are not passed to the previous command.

Test cases:

Relevant code -> Optimization
moo cow moo   -> 
moo2cow2moo   -> 
misteR2 FOO   -> R2F
FEAR ME.      -> ERME
u1U2u3U4u5U6  -> U2U4U6   (nothing if you also choose optimization 1, U12 if you also choose optimization 2)

6. Non-implicit commands

There are lots of implicit commands in Cubically (RLUDFBMES()$~&E!), but there are plenty that need to be called with arguments. So %%%% is equivalent to nothing at all while %%2%% is equivalent to %2.

Test cases:

Relevant code -> Optimization
%%%%          -> 
$$$$          -> $$$$
++2++2++2     -> +2+2+2                 (+222 if you also choose optimization 4)
+++>--<-      -> Not Brainf**k, sorry!  (:P)

Sandbox

I'll add more optimizations later.

\$\endgroup\$
2
  • \$\begingroup\$ Clarification on R123: That's the same as R6 and R2, not R3, right? Digits are summed, there are multidigit numbers? That would be better to specify \$\endgroup\$
    – isaacg
    Aug 17 '17 at 20:13
  • \$\begingroup\$ A few things: first, I can't find the tag "fgitw", is there a typo? Second, does optimization 1 require handling F and B as well, or just the currently listed ones? Third, in optimization 3 most of the listed commands seem invalid because the notepad is used in calculation and then overwritten with the output; for example =11 is not the same as =1 in most circumstances. In fact, I think only _: are valid. Fourth, is the winning answer one which performs all optimizations in a single program, or one which contains a separate program for each optimization? \$\endgroup\$ Aug 18 '17 at 18:03
-1
\$\begingroup\$

Hungry for Apples?

enter image description here

This challenge is simple, given an integer 0 <= n or 0 < n, output an ASCII-apple with that many bites taken out of it.


No bites (0):

         //
     .-.:|.-.
   .'   ''   '.
   ;          ;
  :            :
  :            :
  :            :
   :          ;
   '.        :
     '-_.._-'

Bite 1:

         //
     .-.:|.-.
   .'   ''   '.
   ;          ;
   '-.         :
     }         :
   .-'         :
   :          ;
   '.        :
     '-_.._-'

Bite 2:

         //
     .-.:|.-.
   .'   ''   '.
   '-.        ;
     }         :
     }         :
     }         :
   .-'        ;
   '.        :
     '-_.._-'

Bite 3:

         //
     .-.:|.-.
   .'   ''   '.
   '-.        ;
     }      .-'
     }      {
     }      '-.
   .-'        ;
   '.        :
     '-_.._-'

Bite 4:

         //
     .-.:|.-.
   .'   ''   '.
   '-.      .-'
     }      {
     }      {
     }      {
   .-'      '.
   '.        :
     '-_.._-'

Bite 5:

         //
     .-.:|.-.
   .'   ''   '.
   '-.      .-'
     }".    {
     } }    {
     } }    {
   .-'"     '.
   '.        :
     '-_.._-'

Bite 6:

         //
     .-.:|.-.
   .'   ''   '.
   '-.      .-'
     }"~".  {
     } } }  {
     } } }  {
   .-'"~"   '.
   '.        :
     '-_.._-'

Bite 7:

         //
     .-.:|.-.
   .'   ''   '.
   '-.      .-'
     }"~"~".{
     } } } }{
     } } } }{
   .-'"~"~" '.
   '.        :
     '-_.._-'

Bite >7:

[empty output]

Rules

  • You may have trailing spaces, make it consistent though.
  • You may have exactly 1 trailing newline.
  • You are NOT doing an animation here, you are taking in n and outputting an apple.
  • You may error on integers less than 0, as the spec provides n > 0.
  • You must have empty output (no error) on n > 7/8.
    • You threw out the core; you didn't error the core into non-existence.

This is

\$\endgroup\$
3
  • 3
    \$\begingroup\$ I feel this would be better if there was some more symmetry in the 5, 6, and 7 bytes so that people could possibly make better compression. \$\endgroup\$ Aug 4 '17 at 18:26
  • \$\begingroup\$ @AdmBorkBork better? \$\endgroup\$ Aug 22 '17 at 21:26
  • 1
    \$\begingroup\$ Yes, much better. \$\endgroup\$ Aug 23 '17 at 12:33
-1
\$\begingroup\$

Proper Kerning

Kerning is the adjustment of spacing between pairs of letters in order to obtain an aesthetic result. When kerning is applied automatically by a program (typically whatever editor you're using), it is said to be automatic. There are two types of automatic kerning. The one used in this challenge is metric kerning. With metric kerning, the amount of space between pairs of letters is dictated by the kerning tables found in the font file.

Given a TrueType font file, output the kerning values for each mapping in the kerning table for ASCII characters 48 - 122 inclusive.

Example

calibri.ttf

l="A" r="C" v="-15"
l="A" r="G" v="-15"
l="A" r="J" v="23"
l="A" r="O" v="-23"
l="A" r="Q" v="-23"
l="A" r="T" v="-160"
l="A" r="U" v="-32"
l="A" r="V" v="-89"
l="A" r="W" v="-80"
l="A" r="Y" v="-150"
l="A" r="t" v="-52"
l="A" r="v" v="-38"
l="A" r="y" v="-41"
l="A" r="?" v="-68"
l="B" r="A" v="-20"
l="B" r="T" v="-48"
l="B" r="V" v="-25"
l="B" r="W" v="-24"
l="B" r="X" v="-44"
l="B" r="Y" v="-57"
l="B" r="Z" v="-20"
l="B" r="f" v="-20"
l="B" r="t" v="-20"
l="B" r="v" v="-20"
l="B" r="x" v="-15"
l="B" r="y" v="-20"
l="C" r="G" v="-18"
l="C" r="J" v="12"
l="C" r="O" v="-18"
l="C" r="Q" v="-18"
l="C" r="T" v="10"
l="D" r="A" v="-30"
l="D" r="J" v="-22"
l="D" r="T" v="-23"
l="D" r="V" v="-24"
l="D" r="W" v="-14"
l="D" r="X" v="-31"
l="D" r="Y" v="-39"
l="D" r="Z" v="-22"
l="E" r="A" v="-22"
l="E" r="C" v="-24"
l="E" r="G" v="-24"
l="E" r="O" v="-32"
l="E" r="Q" v="-32"
l="E" r="S" v="-20"
l="E" r="Z" v="-10"
l="E" r="a" v="-34"
l="E" r="c" v="-28"
l="E" r="d" v="-30"
l="E" r="e" v="-37"
l="E" r="f" v="-64"
l="E" r="o" v="-37"
l="E" r="q" v="-30"
l="E" r="t" v="-24"
l="E" r="v" v="-48"
l="E" r="w" v="-34"
l="E" r="y" v="-48"
l="F" r="A" v="-115"
l="F" r="C" v="-18"
l="F" r="G" v="-18"
l="F" r="J" v="-109"
l="F" r="O" v="-18"
l="F" r="Q" v="-18"
l="F" r="S" v="-29"
l="F" r="X" v="-22"
l="F" r="Z" v="-11"
l="F" r="a" v="-55"
l="F" r="c" v="-28"
l="F" r="d" v="-20"
l="F" r="e" v="-30"
l="F" r="o" v="-28"
l="F" r="q" v="-20"
l="F" r="s" v="-35"
l="G" r="T" v="-10"
l="G" r="V" v="-10"
l="G" r="W" v="-9"
l="G" r="Y" v="-30"
l="G" r="v" v="-29"
l="G" r="w" v="-22"
l="G" r="x" v="-14"
l="G" r="y" v="-30"
l="J" r="A" v="-35"
l="J" r="X" v="-20"
l="K" r="C" v="-78"
l="K" r="G" v="-80"
l="K" r="O" v="-97"
l="K" r="Q" v="-97"
l="K" r="S" v="-18"
l="K" r="U" v="-29"
l="K" r="W" v="-34"
l="K" r="a" v="-34"
l="K" r="c" v="-40"
l="K" r="d" v="-33"
l="K" r="e" v="-37"
l="K" r="f" v="-25"
l="K" r="m" v="-32"
l="K" r="n" v="-32"
l="K" r="o" v="-37"
l="K" r="p" v="-32"
l="K" r="q" v="-33"
l="K" r="r" v="-32"
l="K" r="s" v="-18"
l="K" r="t" v="-38"
l="K" r="u" v="-32"
l="K" r="v" v="-101"
l="K" r="w" v="-95"
l="K" r="y" v="-85"
l="L" r="C" v="-22"
l="L" r="G" v="-47"
l="L" r="J" v="25"
l="L" r="O" v="-45"
l="L" r="Q" v="-45"
l="L" r="T" v="-150"
l="L" r="U" v="-44"
l="L" r="V" v="-147"
l="L" r="W" v="-118"
l="L" r="Y" v="-167"
l="L" r="f" v="-23"
l="L" r="t" v="-38"
l="L" r="v" v="-78"
l="L" r="w" v="-72"
l="L" r="y" v="-79"
l="O" r="A" v="-23"
l="O" r="J" v="-27"
l="O" r="T" v="-55"
l="O" r="V" v="-25"
l="O" r="W" v="-22"
l="O" r="X" v="-64"
l="O" r="Y" v="-55"
l="O" r="Z" v="-38"
l="O" r="x" v="-12"
l="O" r="z" v="-10"
l="P" r="A" v="-151"
l="P" r="J" v="-140"
l="P" r="T" v="-9"
l="P" r="V" v="-10"
l="P" r="X" v="-35"
l="P" r="Y" v="-11"
l="P" r="Z" v="-29"
l="P" r="a" v="-44"
l="P" r="c" v="-43"
l="P" r="d" v="-34"
l="P" r="e" v="-41"
l="P" r="f" v="12"
l="P" r="o" v="-41"
l="P" r="q" v="-34"
l="P" r="s" v="-32"
l="P" r="t" v="12"
l="P" r="y" v="12"
l="Q" r="J" v="41"
l="Q" r="T" v="-47"
l="Q" r="V" v="-25"
l="Q" r="W" v="-12"
l="Q" r="X" v="12"
l="Q" r="Y" v="-46"
l="Q" r="g" v="59"
l="Q" r="j" v="79"
l="Q" r="x" v="31"
l="Q" r=";" v="60"
l="Q" r="]" v="32"
l="R" r="C" v="-18"
l="R" r="G" v="-19"
l="R" r="O" v="-20"
l="R" r="Q" v="-20"
l="R" r="S" v="-27"
l="R" r="T" v="-20"
l="R" r="V" v="-28"
l="R" r="W" v="-18"
l="R" r="Y" v="-30"
l="R" r="e" v="-36"
l="R" r="o" v="-42"
l="R" r="v" v="-26"
l="R" r="w" v="-33"
l="R" r="y" v="-33"
l="S" r="A" v="-15"
l="S" r="J" v="-9"
l="S" r="T" v="-14"
l="S" r="V" v="-14"
l="S" r="W" v="-15"
l="S" r="X" v="-13"
l="S" r="Y" v="-20"
l="S" r="v" v="-23"
l="S" r="w" v="-17"
l="S" r="y" v="-25"
l="T" r="A" v="-160"
l="T" r="C" v="-42"
l="T" r="G" v="-59"
l="T" r="J" v="-65"
l="T" r="O" v="-58"
l="T" r="Q" v="-58"
l="T" r="S" v="-10"
l="T" r="T" v="28"
l="T" r="a" v="-160"
l="T" r="c" v="-177"
l="T" r="d" v="-147"
l="T" r="e" v="-182"
l="T" r="g" v="-151"
l="T" r="m" v="-127"
l="T" r="n" v="-127"
l="T" r="o" v="-182"
l="T" r="p" v="-127"
l="T" r="q" v="-147"
l="T" r="r" v="-127"
l="T" r="s" v="-153"
l="T" r="u" v="-127"
l="T" r="v" v="-92"
l="T" r="w" v="-86"
l="T" r="x" v="-90"
l="T" r="y" v="-93"
l="T" r="z" v="-142"
l="T" r=";" v="-114"
l="T" r=":" v="-134"
l="U" r="A" v="-45"
l="U" r="J" v="-40"
l="V" r="A" v="-96"
l="V" r="C" v="-18"
l="V" r="G" v="-25"
l="V" r="J" v="-80"
l="V" r="O" v="-27"
l="V" r="Q" v="-27"
l="V" r="S" v="-12"
l="V" r="V" v="9"
l="V" r="a" v="-114"
l="V" r="c" v="-103"
l="V" r="d" v="-87"
l="V" r="e" v="-102"
l="V" r="g" v="-100"
l="V" r="m" v="-50"
l="V" r="n" v="-50"
l="V" r="o" v="-86"
l="V" r="p" v="-50"
l="V" r="q" v="-87"
l="V" r="r" v="-50"
l="V" r="s" v="-90"
l="V" r="u" v="-50"
l="V" r="y" v="-35"
l="V" r="z" v="-82"
l="V" r=";" v="-108"
l="V" r=":" v="-73"
l="W" r="A" v="-93"
l="W" r="C" v="-22"
l="W" r="G" v="-22"
l="W" r="J" v="-88"
l="W" r="O" v="-22"
l="W" r="Q" v="-22"
l="W" r="S" v="-10"
l="W" r="X" v="-13"
l="W" r="a" v="-71"
l="W" r="c" v="-78"
l="W" r="d" v="-72"
l="W" r="e" v="-75"
l="W" r="g" v="-54"
l="W" r="m" v="-60"
l="W" r="n" v="-60"
l="W" r="o" v="-86"
l="W" r="p" v="-60"
l="W" r="q" v="-72"
l="W" r="r" v="-60"
l="W" r="s" v="-73"
l="W" r="u" v="-60"
l="W" r="v" v="-34"
l="W" r="y" v="-53"
l="W" r=";" v="-156"
l="X" r="C" v="-57"
l="X" r="G" v="-65"
l="X" r="O" v="-57"
l="X" r="Q" v="-57"
l="X" r="S" v="-20"
l="X" r="d" v="-44"
l="X" r="e" v="-39"
l="X" r="g" v="-9"
l="X" r="o" v="-38"
l="X" r="q" v="-44"
l="X" r="t" v="-31"
l="X" r="u" v="-38"
l="X" r="v" v="-55"
l="X" r="w" v="-49"
l="X" r="y" v="-43"
l="Y" r="A" v="-152"
l="Y" r="C" v="-67"
l="Y" r="G" v="-67"
l="Y" r="J" v="-112"
l="Y" r="O" v="-66"
l="Y" r="Q" v="-66"
l="Y" r="S" v="-17"
l="Y" r="Z" v="-10"
l="Y" r="a" v="-134"
l="Y" r="c" v="-159"
l="Y" r="d" v="-131"
l="Y" r="e" v="-147"
l="Y" r="f" v="-62"
l="Y" r="g" v="-142"
l="Y" r="i" v="-32"
l="Y" r="j" v="-49"
l="Y" r="m" v="-94"
l="Y" r="n" v="-94"
l="Y" r="o" v="-153"
l="Y" r="p" v="-94"
l="Y" r="q" v="-131"
l="Y" r="r" v="-94"
l="Y" r="s" v="-115"
l="Y" r="t" v="-44"
l="Y" r="u" v="-94"
l="Y" r="v" v="-69"
l="Y" r="w" v="-62"
l="Y" r="x" v="-70"
l="Y" r="y" v="-65"
l="Y" r="z" v="-100"
l="Y" r=";" v="-138"
l="Y" r=":" v="-154"
l="Z" r="A" v="-11"
l="Z" r="C" v="-25"
l="Z" r="G" v="-24"
l="Z" r="O" v="-24"
l="Z" r="Q" v="-24"
l="Z" r="W" v="-7"
l="Z" r="Y" v="-7"
l="Z" r="a" v="-10"
l="Z" r="c" v="-12"
l="Z" r="d" v="-18"
l="Z" r="e" v="-31"
l="Z" r="o" v="-29"
l="Z" r="q" v="-18"
l="Z" r="v" v="-45"
l="Z" r="w" v="-38"
l="Z" r="y" v="-37"
l="a" r="f" v="-12"
l="a" r="t" v="-19"
l="a" r="v" v="-34"
l="a" r="w" v="-14"
l="a" r="x" v="-19"
l="a" r="y" v="-38"
l="b" r="f" v="-17"
l="b" r="s" v="-10"
l="b" r="t" v="-9"
l="b" r="v" v="-10"
l="b" r="w" v="-10"
l="b" r="x" v="-41"
l="b" r="y" v="-10"
l="b" r="z" v="-28"
l="c" r="a" v="-17"
l="c" r="o" v="-17"
l="e" r="f" v="-18"
l="e" r="t" v="-11"
l="e" r="v" v="-10"
l="e" r="w" v="-10"
l="e" r="x" v="-31"
l="e" r="y" v="-13"
l="e" r="z" v="-20"
l="f" r="a" v="-40"
l="f" r="c" v="-45"
l="f" r="d" v="-53"
l="f" r="e" v="-51"
l="f" r="f" v="-20"
l="f" r="g" v="-60"
l="f" r="o" v="-43"
l="f" r="q" v="-53"
l="f" r="s" v="-27"
l="f" r="v" v="13"
l="f" r="w" v="6"
l="f" r="y" v="10"
l="f" r="z" v="-20"
l="g" r="a" v="-38"
l="g" r="c" v="-12"
l="g" r="d" v="-19"
l="g" r="e" v="-17"
l="g" r="g" v="19"
l="g" r="o" v="-14"
l="g" r="q" v="-19"
l="g" r="t" v="-31"
l="h" r="f" v="-12"
l="h" r="t" v="-19"
l="h" r="v" v="-34"
l="h" r="w" v="-14"
l="h" r="x" v="-19"
l="h" r="y" v="-38"
l="k" r="a" v="-35"
l="k" r="c" v="-48"
l="k" r="d" v="-56"
l="k" r="e" v="-66"
l="k" r="o" v="-69"
l="k" r="q" v="-56"
l="k" r="s" v="-19"
l="k" r="t" v="-10"
l="k" r="u" v="-26"
l="m" r="f" v="-12"
l="m" r="t" v="-19"
l="m" r="v" v="-34"
l="m" r="w" v="-14"
l="m" r="x" v="-19"
l="m" r="y" v="-38"
l="n" r="f" v="-12"
l="n" r="t" v="-19"
l="n" r="v" v="-34"
l="n" r="w" v="-14"
l="n" r="x" v="-19"
l="n" r="y" v="-38"
l="o" r="v" v="-9"
l="o" r="w" v="-8"
l="o" r="x" v="-40"
l="o" r="y" v="-11"
l="o" r="z" v="-27"
l="p" r="f" v="-17"
l="p" r="s" v="-10"
l="p" r="t" v="-9"
l="p" r="v" v="-10"
l="p" r="w" v="-10"
l="p" r="x" v="-41"
l="p" r="y" v="-10"
l="p" r="z" v="-28"
l="q" r="g" v="10"
l="r" r="a" v="-42"
l="r" r="c" v="-30"
l="r" r="d" v="-28"
l="r" r="e" v="-27"
l="r" r="g" v="-28"
l="r" r="o" v="-33"
l="r" r="q" v="-28"
l="r" r="s" v="-35"
l="r" r="v" v="19"
l="r" r="w" v="11"
l="r" r="y" v="10"
l="s" r="f" v="-19"
l="s" r="t" v="-23"
l="s" r="v" v="-31"
l="s" r="w" v="-10"
l="s" r="x" v="-22"
l="s" r="y" v="-37"
l="s" r="z" v="-18"
l="t" r="a" v="-25"
l="t" r="c" v="-25"
l="t" r="d" v="-23"
l="t" r="e" v="-22"
l="t" r="o" v="-20"
l="t" r="q" v="-23"
l="t" r="t" v="-29"
l="v" r="a" v="-30"
l="v" r="c" v="-25"
l="v" r="d" v="-20"
l="v" r="e" v="-20"
l="v" r="f" v="11"
l="v" r="g" v="-28"
l="v" r="o" v="-19"
l="v" r="q" v="-20"
l="v" r="s" v="-9"
l="v" r="t" v="10"
l="v" r="v" v="12"
l="v" r="w" v="12"
l="v" r="y" v="12"
l="v" r="z" v="-26"
l="w" r="a" v="-23"
l="w" r="c" v="-20"
l="w" r="d" v="-18"
l="w" r="e" v="-18"
l="w" r="f" v="6"
l="w" r="g" v="-18"
l="w" r="o" v="-19"
l="w" r="q" v="-18"
l="w" r="s" v="-18"
l="w" r="t" v="4"
l="w" r="v" v="12"
l="w" r="w" v="8"
l="w" r="y" v="12"
l="w" r="z" v="-17"
l="x" r="a" v="-37"
l="x" r="c" v="-46"
l="x" r="d" v="-44"
l="x" r="e" v="-54"
l="x" r="o" v="-55"
l="x" r="q" v="-44"
l="x" r="s" v="-12"
l="x" r="t" v="6"
l="x" r="u" v="-20"
l="y" r="a" v="-31"
l="y" r="c" v="-26"
l="y" r="d" v="-24"
l="y" r="e" v="-25"
l="y" r="f" v="10"
l="y" r="g" v="-26"
l="y" r="o" v="-24"
l="y" r="q" v="-24"
l="y" r="s" v="-19"
l="y" r="t" v="10"
l="y" r="v" v="12"
l="y" r="w" v="8"
l="y" r="y" v="10"
l="y" r="z" v="-17"
l="z" r="a" v="-34"
l="z" r="c" v="-45"
l="z" r="d" v="-46"
l="z" r="e" v="-46"
l="z" r="f" v="-10"
l="z" r="g" v="-17"
l="z" r="o" v="-45"
l="z" r="q" v="-46"
l="z" r="s" v="-22"
l="z" r="u" v="-10"
l="z" r="v" v="-18"
l="z" r="w" v="-22"
l="z" r="y" v="-18"

Scoring

This is , so the shortest answer (in bytes) wins.

Meta

I know this challenge is going to need a lot of work before it's ready for main. Please hold criticisms for now. Helpful ideas and thoughts are welcome.

\$\endgroup\$
7
  • \$\begingroup\$ I'm not sure that the problem is well defined. There's a reason it's called font hinting: the rendering application is free to take it into account or not, or even to apply more complex logic. E.g. some fonts have multiple sets of font hints for different contexts. There are other complex issues. A font can have Latin and Cyrillic letters and define hints for kerning between pairs of Latin and pairs of Cyrillic but not between Latin and Cyrillic; however, some letters may have identical glyphs, so a judgement on whether the kerning is "correct" might be ambiguous. Then there's antialiasing. \$\endgroup\$ May 24 '17 at 6:15
  • \$\begingroup\$ @PeterTaylor Good notes. I will likely restrict the character set. I just wanted to start getting ideas down in the sandbox. \$\endgroup\$
    – Poke
    May 24 '17 at 6:51
  • \$\begingroup\$ Very ambiguous. \$\endgroup\$
    – anna328p
    May 25 '17 at 17:48
  • \$\begingroup\$ @Mendeleev It's not done yet. I'm aware it's ambiguous. \$\endgroup\$
    – Poke
    May 26 '17 at 16:10
  • \$\begingroup\$ Looking at developer.apple.com/fonts/TrueType-Reference-Manual/RM06/… I can see a number of issues to address. 16- vs 32-bit entries? Should multiple tables be combined or printed separately? All tables or only tables with certain coverage values? Which of the four defined formats need to be supported? Do you have a test case which covers glyph index differing from codepoint? \$\endgroup\$ Sep 16 '17 at 17:28
  • \$\begingroup\$ @PeterTaylor I have a proof of concept that I wrote (it's the reason I have taken so long to update this) and I'm planning to address all of your questions. Thanks for doing a bit of research to help me out, though :] \$\endgroup\$
    – Poke
    Sep 16 '17 at 18:57
  • \$\begingroup\$ Downvoter, why? \$\endgroup\$
    – Poke
    Oct 4 '17 at 21:03
-1
\$\begingroup\$

Six Flags over HTTP

Let's say you need to transmit six boolean flags in a URL string. Obviously you could do it with six ones or zeroes, but you want better compression. With a little math you can pack them into two characters using 0-7 octal.

How about mapping all six to a single ASCII character? Here we have a problem: you are not allowed to use , / ? : @ & = + $ # or space. Now the range of printable ASCII no longer has 64 valid characters in a row.

In Javascript (or another language that can run from a web page, if any), what is the shortest code for a pair of functions to encode and decode this data, between an array of six booleans and a single character?

\$\endgroup\$
2
  • \$\begingroup\$ -1 language restriction, most languages have HTTP libraries so I think any language should be allowed \$\endgroup\$
    – ASCII-only
    Sep 24 '17 at 13:11
  • \$\begingroup\$ This challenge could be improved by rephrasing it to: "Write a bijective function between an array of six booleans and a single printable character excluding the characters ,/?:@&=+$# ". Mentioning that the encoder and decoder should be separate programs/functions would be helpful. Also, may the encoder and decoder share code? \$\endgroup\$ Sep 24 '17 at 22:08
-1
\$\begingroup\$

Count letter frequency

Inspired by question Tweetable hash function challenge, you should take the English dictionary used there and produce a program or function that outputs the the absolute and relative frequency of each character. It is CASE SENSITIVE and the APOSTROPHE is also accountable as a real letter.

Example of a valid output format (but with stupid guessing values):

A      5566    20%
...
Z        60     0.2%
a     27000    30%
...
z       120     0.01%
'       450     3.5%

It is , but no answer will be accepted. Wanna know shortest script for each language.

\$\endgroup\$
1
  • 1
    \$\begingroup\$ -1 (01) Don't rely on another challenge to define yours; include all the information we need in your write-up. (02) Make an effort to come up with some actual test cases - do you honestly expect us to verify our solutions against "stupid guessing values"? \$\endgroup\$
    – Shaggy
    Sep 30 '17 at 0:55
-1
\$\begingroup\$

Is it a perfect loop?

Your task is to take a GIF or an animated image in any reasonable format as input (including taking the file name of a GIF in the current directory), and output whether it is a "perfect loop" - that is, the frames transition seamlessly from the end to the start, and a human cannot notice where it starts and ends at first glance. Return or print a truthy value if it is a perfect loop, otherwise print or return a falsy value.

Scoring

Winners will be determined from the percentage of test cases they get correct. In the event of a tie, highest votes wins. You can view test cases at https://ghostbin.com/paste/m3yaw. Show your score against the test cases when you post.

Input

If you are not taking input in a GIF, please provide a program that will convert a GIF to your desired format.

Images corresponding to a truthy value have been taken from /r/perfectloops and for falsy test cases, /r/almostperfectloops and /r/gifs.

Restrictions

  • Hard coding is not allowed (violates standard loophole 1 and 2).
  • You must provide consistent results for the same GIF (no randomness)
  • Remember, this is not , so byte count is not needed in your solution. Just post the language name and add the percentage correct when I comment.
\$\endgroup\$
2
  • \$\begingroup\$ I'm not sure it's as simple as comparing the first to the last frame, if it is we'd have duplicate frames. is this challenge allowing HTTP requests? \$\endgroup\$
    – tuskiomi
    Oct 17 '17 at 21:15
  • \$\begingroup\$ If hashing the inputs is not allowed, then you should clearly define what constitutes a “perfect loop”. It's not good to extrapolate from a handful of test cases where the pass/fail cases are very similar. \$\endgroup\$
    – japh
    Oct 18 '17 at 14:31
1
109 110
111
112 113
122

You must log in to answer this question.

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