461
\$\begingroup\$

What is the Sandbox?

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

To post to the Sandbox, scroll to the bottom of this page or click on the "Add Proposal" link below, 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. 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, replace the post here with a link to the challenge and delete it.

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

The Sandbox works best if you sort posts by "active".

Add Proposal

Search the Sandbox

Browse your pending proposals

Get the Sandbox Viewer to view the sandbox more easily

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

\$\endgroup\$
  • \$\begingroup\$ How are tags added to questions? \$\endgroup\$ – guest271314 Jan 9 at 7:51
  • \$\begingroup\$ @guest271314 You can use this markup to create a tag in a draft: [tag:code-golf] \$\endgroup\$ – DJMcMayhem Aug 29 at 15:19
  • \$\begingroup\$ Why no featured anymore? Can't we have it auto-added or something? \$\endgroup\$ – JL2210 Sep 26 at 15:57
  • 1
    \$\begingroup\$ @JL2210 We now have a permanent info box that links to the Sandbox, so the featured tag isn't necessary \$\endgroup\$ – caird coinheringaahing Sep 29 at 13:43

2621 Answers 2621

0
\$\begingroup\$

I'm sort of brainstorming a challenge. I'm not really paying attention to question format at the moment.

The challenge would be to generate and populate a Golf Scorecard.

The output would look something like this:

Hole    Par     Strokes Score
1       3       3       0
2       5       4       -1
3       4       5       1
4       3       4       1
5       4       4       0
6       5       3       -2
7       4       3       -1
8       3       5       2
9       5       5       0
Totals  36      36      0

A Par value would be generated by choosing a random number in [3, 4, 5].

A Stroke value would be generated by choosing a random number within some range (say -2/+2 or -3/+3) of Par. A Stroke can be no lower than 1.

Score = Stroke - Par

Total is adding up all the values in that column (not including Hole).

I'm wondering if it would be too much to ask to have the generated values be somewhat realistic (unlike my example output), in that Par values tend to be mostly 4, with about the same number between 3 and 5, and Stroke values tend to be close to or above Par, with it being very unlikely to be 1.

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

Proposed Question

Triskaidekaphobic Primes

It is known that a certain number, which lies between 12 and 14, brings bad luck. The Church of Triskaidekaphobia (CoTDP) asserts that the key to salvation is avoiding this number in all situations, such as numbering floors, license plates, space shuttle missions and more.

The IT department of CoTDP is looking for talented developers. Candidates must prove their ability to program in accordance with Triskaidekaphobic dogma. Can you get this prestigious job?

Your Mission

Write a program that prints all prime numbers below 1000, excluding the unlucky one. the program must obey the CoTDP programming rules.

Rules

  1. Numbers whose absolute value is greater than 12 and smaller than 14 are considered unlucky and must be avoided.
  2. Unlucky numbers must not be used in the program:
    • Must not appear in the program, in any representation/base.
    • Must not be the value of an expression or calculation (e.g. 5 + 8).
    • Must not be an intermediate value in an expression (e.g. 5 + 8 + 3, 35 % 22 == 0).
    • Must not be stored in a variable, register, memory etc (e.g. for i in xrange(20):).
    • Must not be passed to a function or returned from one.
    • The above applies to any complex type which contains an unlucky number (e.g. range(20) in Python 2).
    • The above applies to all expressions, not just constant expressions (e.g. x+1 is invalid if x happens to be 12).
  3. No calculation, or intermediate value of a calculation, may yield an unlucky number. For example, and for i in xrange(20): are forbidden.
  4. Output lines bust be separated by line-feed only (no carriage return).
  5. You must find primes using basic mathematical operations. If your language provides tools to find primes or test primality, you must not use them.
  6. Standard Loopholes apply.

Scoring

This is code-golf, the shortest solution (in bytes) wins.

Questions for Meta

  • Do the limitations make sense for all sorts of languages? I think they cover languages such as C/Python/Java that use expressions, and also languages such as BrainFuck that manipulate memory (I think it's obvious that you must not write 13 in a memory cell).
  • Is there a trivial solution that makes it uninteresting?
  • Would it be better as a popularity contest?
  • Or maybe, accept the shortest, but give a bounty for the most interesting/creative answer?
  • Can the expression "Church of Triskaidekaphobia" be considered offensive to followers of some churches?
\$\endgroup\$
  • \$\begingroup\$ Should we treat numbers such as 39 (13 * 3) as prime, or not prime for the sake of this calculation? If 13 is not a prime, then 39 is, but it's up to you. (I did something kind of similar to this here) \$\endgroup\$ – Stephen Jul 29 '17 at 19:15
  • \$\begingroup\$ @StepHen, IMO, an unlucky divisor is still a divisor. I think asking for "primes below 1000, excluding the unlucky one" makes it clear. Your interpretation might make it more challenging, but I'm not sure how it would work - 39 is a multiple of 3 (though you shouldn't actually do this division), so how can it be prime? Maybe 169. \$\endgroup\$ – ugoren Jul 29 '17 at 19:23
  • \$\begingroup\$ Related: we are not allowed to store 13, right? \$\endgroup\$ – Stephen Jul 29 '17 at 19:37
  • \$\begingroup\$ @StepHen, I'm not sure what you mean by "store". My intention is that 13 won't be used in any way. I write that it can't be used in the program and can't be derived by calculation, so how can it be stored? \$\endgroup\$ – ugoren Jul 29 '17 at 20:12
  • \$\begingroup\$ Well you could store it with x = ord("\r"), although if you can't use it there's not much point. \$\endgroup\$ – Stephen Jul 29 '17 at 20:25
  • \$\begingroup\$ ord("\r") is an expression that yields 13, and is therefore invalid. But it's worth clarifying. \$\endgroup\$ – ugoren Jul 29 '17 at 20:27
  • \$\begingroup\$ Your post (as it stands) says no calculation, not no expression. \$\endgroup\$ – Stephen Jul 29 '17 at 20:28
  • 1
    \$\begingroup\$ Numbers whose absolute value is greater than 12 and smaller than 14 are considered unlucky and must be avoided. is 12.5 allowed? \$\endgroup\$ – l4m2 Apr 2 '18 at 19:09
0
\$\begingroup\$

Fill to the line!

Given input consisting of the characters _, , and newline, fill the empty space up to the line!

Example:

I will use # as the filler character in the example.

1. Input


________



2. Fill up to the line, but not above.


________
########
########
########
  • You may assume that the input either is rectangular (is padded), or consists only of the line and newlines.
  • You may assume that there is only one straight, unbroken line.
  • The whitespace above the line is part of the input. Do not fill above the line.

Test cases:

"
Input
"
"
Output
"
**********

"



----




"
"



----
####
####
####
####
"

**********

"


________



"
"


________
########
########
########
"
\$\endgroup\$
  • \$\begingroup\$ is the input guaranteed to be rectangular? will the _ be on one line \$\endgroup\$ – Destructible Lemon May 24 '17 at 4:45
  • \$\begingroup\$ @DestructibleLemon I will edit to clarify. \$\endgroup\$ – Comrade SparklePony May 24 '17 at 12:11
  • \$\begingroup\$ If its padded its very trivial to just replace all the spaces with # \$\endgroup\$ – Notts90 May 25 '17 at 8:30
  • \$\begingroup\$ @Notts90 Not all the spaces, only the ones below the line. \$\endgroup\$ – Comrade SparklePony May 25 '17 at 12:08
  • \$\begingroup\$ Ah ok, might want to make it clearer the bit above the line are included in the input. \$\endgroup\$ – Notts90 May 25 '17 at 12:23
0
\$\begingroup\$

Comparing Strings

You will be given two non-empty strings containing printable ASCII. If their contents are exactly the same, output their contents. If their contents are different, output a third string. This third string cannot be a substring of either string, and neither string can be a substring of it.

Test Cases

Test cases are quoted to show they are strings. Outputs marked with * indicate they are one of infinitely many possible outputs.

input, input -> output

"test", "test" -> "test"
"do", "don't" -> "dnut"*
"ye s", "yes" -> "false"*
"yes", "yes" -> "yes"
"maybe", "mayue" -> "false"*
"false", "false" -> "false"
"false", "true" -> "fatr"*

Rules

  • The inputs will be composed of only printable ASCII - that is, space to tilde. Your output should also be composed of only printable ASCII, but a trailing newline is allowed.
  • Your algorithm may not make any assumption about the length of the inputs, except that they will not be empty.
  • The output must be valid with probability 1; that is, you may generate random strings until one is valid, but you can't just output a random string and hope it's valid. Source
  • Trailing newlines in output allowed (otherwise there will be no newlines - newlines are not in printable ASCII).

This is , so shortest answer in bytes wins.

\$\endgroup\$
  • \$\begingroup\$ This is the canonical string equal question, but it does not allow you to use string comparison. \$\endgroup\$ – Stephen Aug 1 '17 at 21:37
  • 4
    \$\begingroup\$ Bro... Come on, at least 3 sentences. \$\endgroup\$ – Magic Octopus Urn Aug 1 '17 at 21:39
  • \$\begingroup\$ Do you need to handle strings with new lines or spaces in them? \$\endgroup\$ – geokavel Aug 2 '17 at 0:08
  • \$\begingroup\$ @MagicOctopusUrn added a bit more clarification :P what else is there to say? \$\endgroup\$ – Stephen Aug 2 '17 at 1:21
  • \$\begingroup\$ @geokavel clarified \$\endgroup\$ – Stephen Aug 2 '17 at 1:21
  • \$\begingroup\$ This needs more information, test cases and to actually be made into a challenge. \$\endgroup\$ – TheLethalCoder Aug 2 '17 at 8:59
  • \$\begingroup\$ @TheLethalCoder I forgot testcases - thank you. However, what else would I add to make it a challenge? \$\endgroup\$ – Stephen Aug 2 '17 at 11:03
  • \$\begingroup\$ Usual boilerplate stuff, I'm sure something like this has been posted before too but I'm having trouble finding it. \$\endgroup\$ – TheLethalCoder Aug 2 '17 at 11:05
  • \$\begingroup\$ @TheLethalCoder OK, how's that? and thanks for the feedback. \$\endgroup\$ – Stephen Aug 2 '17 at 11:15
  • \$\begingroup\$ Better. I still don't like the challenge though it'll just lead to solutions like s=>t=>s==t?s:s+t Block ways of doing that and it'll be better \$\endgroup\$ – TheLethalCoder Aug 2 '17 at 11:18
  • \$\begingroup\$ @TheLethalCoder hm, that was my idea for the harder challenge - that was why this says easy in the title. Do you think this is too trivial? I can just skip the easy one and go straight to the harder one. \$\endgroup\$ – Stephen Aug 2 '17 at 11:20
  • \$\begingroup\$ I personally would. The easy one just leads to lots of FGITW answers. Yeah it'll probably be popular but boring. \$\endgroup\$ – TheLethalCoder Aug 2 '17 at 11:21
  • \$\begingroup\$ @TheLethalCoder ok how's that? \$\endgroup\$ – Stephen Aug 2 '17 at 11:26
  • \$\begingroup\$ Better but again I think you need to defend against the trivial cases i.e. ab, cd -> bc seems to be allowed and so does ab, cd -> bb yet they're both trivial changes to the inputs. \$\endgroup\$ – TheLethalCoder Aug 2 '17 at 11:30
  • \$\begingroup\$ @TheLethalCoder I think I can only go so far in blocking those, and with what you have, for the your first case, entering aa, ab, and for your second case, entering aa, bc would result in invalid output. Half the fun here will be "cracking" them. \$\endgroup\$ – Stephen Aug 2 '17 at 11:37
0
\$\begingroup\$

Can you generate this random sequence for me?

Inspired by this question on Retrocomputing

I want to create a random generator that always returns a desired word. I desperately need this so I can hide some easter eggs. For science easter!

Input

A word, either in string format or an array or vector of characters. You can assume all lowercase and only the regular characters a-z.

Task

Write a full program or function that finds a seed such that when taking a random sample of letters, the desired word is output. The function then should return or save another full program or function that does the generating of this desired word.

Rules

  • The returned function of program should use random sampling to create the output, so it is not allowed to hardcode (obligatory XKCD)
  • The output can be written to file in the case of a full program or returned.
  • Hiding an easter eggs is easiest when there is little code, so the shortest code wins.
  • If there is no seed that generates the required output, your program is allowed to run forever.
  • Standard codegolf rules and loopholes apply.

Example implementation:

> f <- function(string){
+     seed <- 1
+     set.seed(seed)
+     repeat{
+         seed <- seed + 1
+         set.seed(seed)
+         if(all(sample(letters, length(string), replace = TRUE) == string)){
+             break
+         }
+     }
+     generator <- function(){
+         set.seed(seed)
+         sample(letters, length(string), replace = TRUE)
+     }
+     return(generator)
+ }
> f("a")
function(){
        set.seed(seed)
        sample(letters, length(string), replace = TRUE)
    }
<bytecode: 0x000000001c83f2d8>
<environment: 0x000000001f906c20>
> g=f("a")
> g()
[1] "a"
> g()
[1] "a"
> g()
[1] "a"
\$\endgroup\$
  • \$\begingroup\$ So we're finding the seed to a pRNG that produces the correct output from a scrambled input? Have you actually managed to do this with any two none-trivial inputs? i.e. not just a few letters long? \$\endgroup\$ – TheLethalCoder Aug 3 '17 at 7:58
  • \$\begingroup\$ @TheLethalCoder I was initially thinking of doing dicerolls instead of words, since those should be easier, but I liked words better because they fit the related question better. The sample code did work for 5 letter words. \$\endgroup\$ – JAD Aug 3 '17 at 8:22
0
\$\begingroup\$

Complicating Simple Maths

We do know what 1 + 1 is, or 2 - 1. How about we turn those and other really simple operations into complex numbers?

Goal:

As stated in the intro, taking an operation that can be done within the range of the following operators ( +, -, /, *, ^ and () ), print out a complex number operation that is pretty much a transformed version, and when done using the order of operations, results in the same answer as the inputted operation.

Examples:

Input: 5 - 1
Output: 5 + 2i

Input: 4 * (7 ^ 2)
Output: (4 * 4i) * (7 ^ 2) 

Rules:

  • It is recommended you print out the sector(s) that holds your complex number(s) as a + bi, e.g. (a + bi) - (ci * (di ^ f)). (NOTE: If you are doing non-communicative operations, such as ^, /, or -, the recommendation doesn't apply to the sub-operation).

  • No standard loopholes.

  • If you want to, feel free to use operations/functions other than the set mentioned in the Goal, but your input operation must have at least one of them.

  • You can format your operators in any way, e.g. x or • instead of *, ÷ instead of /, etc.

  • Input and output is allowed in any format as long as it fits within the standard I/O rules.

  • Input must also be flexible (as in to return any input from a simple operation to a complex number operation.

  • This is , so shortest answer wins.

Sandbox use only:

Is there any way I can improve this challenge? Are there any other loopholes to be covered in the rules?

\$\endgroup\$
  • \$\begingroup\$ Can you relax output to standard IO too? At the moment it seems you can only print the result. Also isn't this essentially calculate the result of the inputted expression then work out a complex expression that gives the same answer seeing as you don't need to keep anything in the input the same. \$\endgroup\$ – TheLethalCoder Aug 7 '17 at 10:32
  • 3
    \$\begingroup\$ And if that is the case isn't this challenge just return input + (1 + i^2)? \$\endgroup\$ – TheLethalCoder Aug 7 '17 at 10:33
  • \$\begingroup\$ No, the challenge is to transform parts of the input into complex numbers and output that. \$\endgroup\$ – S.G. Harmonia Aug 7 '17 at 13:13
  • 1
    \$\begingroup\$ But 5 - 1 becomes 5 + 2i You are removing two stages - and 1 and adding 2 + and 2i. It's not entirely clear how much you can remove and how much you can add. \$\endgroup\$ – TheLethalCoder Aug 7 '17 at 13:15
  • \$\begingroup\$ At least one sub-operation should be transformed from simple to complex (which could take two steps). \$\endgroup\$ – S.G. Harmonia Aug 7 '17 at 13:16
0
\$\begingroup\$

Make it night!

You just went on vacation to see some scenery in the beautiful night. Unfortunately, your alarm clock malfunctions and when you wake up, it's daytime.

Your mother would like to see some photos, but you can only take pictures in the day. You would like to be able to convert these daytime pictures to pictures in the nighttime.

Challenge

Given an image taken in the daytime, process it and turn it into night time as best as you can.

Sometimes it might be hard to do, like images that have a sun, but you can write your algorithm to remove the sun or do something else.

Example

(I did this by hand, so it might not be that good)

Original

Result

Voting

Please vote accordingly to how well the algorithms perform.

  • Is the sky dark like a night sky?
  • Does the picture look photoshopped/edited?
  • Are there vivid colors that shouldn't appear in the night?
  • If you were showed both images, would you believe that there was no processing?

(If you have a suggestion, please comment.)

Test Cases

Test case 1

Test case 2

Test case 3

Winning

Since this is a , the answer with the highest score (upvotes minus downvotes) wins.

\$\endgroup\$
  • \$\begingroup\$ how to deal with the sun... \$\endgroup\$ – Destructible Lemon Aug 10 '17 at 4:30
  • \$\begingroup\$ @HelkaHomba This URL is invalid or has expired. \$\endgroup\$ – Oliver Ni Aug 10 '17 at 5:50
  • \$\begingroup\$ @DestructibleLemon Not sure, I'll think about it. \$\endgroup\$ – Oliver Ni Aug 10 '17 at 5:51
  • \$\begingroup\$ What would i.stack.imgur.com/nkx4V.jpg become? \$\endgroup\$ – Calvin's Hobbies Aug 10 '17 at 6:39
  • \$\begingroup\$ @HelkaHomba This is a popularity-contest, so that depends on how your algorithm handles it. The better it does, the more votes you will probably get.. \$\endgroup\$ – Oliver Ni Aug 10 '17 at 6:41
  • \$\begingroup\$ Won't this fall under the usual "No objective winning criteria" that pop cons have been falling under lately? \$\endgroup\$ – TheLethalCoder Aug 10 '17 at 7:58
  • \$\begingroup\$ @TheLethalCoder Fixed. \$\endgroup\$ – Oliver Ni Aug 10 '17 at 9:14
  • \$\begingroup\$ @OliverNi How? The voting criteria is still subjective and that's why recent ones have been closed. \$\endgroup\$ – TheLethalCoder Aug 10 '17 at 9:17
  • \$\begingroup\$ @TheLethalCoder as I know, "highest score (upvotes minus downvotes)" is exactly the defaults for popularity-contest, at least it is written in the tag description: "A popularity contest is a competition where the answer with the highest vote tally (upvotes minus downvotes) wins." \$\endgroup\$ – Oliver Ni Aug 10 '17 at 9:25
  • \$\begingroup\$ @OliverNi Yeah you're winning criteria is fine. It's the subjective voting criteria I'm questioning. \$\endgroup\$ – TheLethalCoder Aug 10 '17 at 9:34
  • \$\begingroup\$ @TheLethalCoder Voting is subjective. You can't just tell someone to 'downvote if the answer has x pixels that are y units apart from all the four neighboring pixels' or something like that. \$\endgroup\$ – Oliver Ni Aug 10 '17 at 9:37
  • \$\begingroup\$ @OliverNi I know and isn't that the whole reason recent pop cons have been closed? Because the criteria people should vote on is subjective. \$\endgroup\$ – TheLethalCoder Aug 10 '17 at 9:39
  • \$\begingroup\$ Let us continue this discussion in chat. \$\endgroup\$ – Oliver Ni Aug 10 '17 at 9:39
  • 1
    \$\begingroup\$ Provided you explicitly say what to do with the "dangerous" cases like the 'images with sun', this imo is a nice pop-contest but... you surely know well enough that pop-contests, almost always, don't garner much love here. \$\endgroup\$ – officialaimm Aug 10 '17 at 12:28
  • \$\begingroup\$ So... if you vertically flip any of those images your algorithm would fail? \$\endgroup\$ – Magic Octopus Urn Aug 11 '17 at 20:38
0
\$\begingroup\$

Multiplicity of a Curve

Given an polynomial p in two variables x and y as well as a point (u,v), determine the multiplicity m of the curve C = { (x,y) | p(x,y) = 0} at the point (u,v).

Details

  • The degree of a monomial a * x^i * y^j in two variables is d = i+j.
  • A polynomial is homogeneous if all its monomials have the same degree d.
  • Any polynomial p (where d is the degree of p, i.e. the maximum of the degree of all its monomials) can uniquely be decomposed into a sum of polynomials p = p0 + p1 + ... + pd where each pk is homogeneous of degree k OR possibly zero.
  • The multiplicity of a curve C given by the polynomial p at (u,v) can be determined using the following computation:

    • First decompose the polynomial p(x-u,y-v) (this is p with x,y replaced with x-u,y-v) into a sum of homogeneous polynomials as described above:

      p(x-u,y-v) = q0 + q1 + ... + qd
      
    • Then determine the minimal k such that qk is nonzero. Then the multiplicity is defined as m := k.

Example

Let us consider the polynomial p(x,y) = -x^2 - 4x + y^2 - 2y -3 and the point (u,v) = (-2,1).

p(x-u,y-v) = y^2 - x^3

So the decomposition is

p(x-u,y-v) = [0] + [0] + [y^2] + [-x^3]

Here the brackets are just used to highlight the homogeneous polynomials of each degree.

We see that y^2 is the nonzero polynomial of least degree, so m = 2

TODO

  • add more testcases
\$\endgroup\$
  • \$\begingroup\$ 1. My interpretation is that the multiplicity is just the minimum degree of all nonzero terms in the polynomial p(x-u, y-v). If this is true, stating so would simplify reading. 2. What input formats are permitted? Few languages have Polynomial as a type, so an input such as [[0,1],[2,3]] could be taken to represent 0x⁰y⁰ + 1x¹y⁰ + 2x⁰y¹ + 3x¹y¹. \$\endgroup\$ – fireflame241 Aug 20 '17 at 18:43
  • \$\begingroup\$ I did not add the formats yet, but these are the two I had in mind, as we did it in previous challenges. \$\endgroup\$ – flawr Aug 20 '17 at 19:51
  • \$\begingroup\$ Regarding the degree: Yes that is essentially what I wrote down, just a little bit more detailed for people who are not familiar with the topic. \$\endgroup\$ – flawr Aug 20 '17 at 21:39
0
\$\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\$
  • \$\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\$ – Kamil Drakari Aug 18 '17 at 18:03
0
\$\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
    \$\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\$ – AdmBorkBork Aug 4 '17 at 18:26
  • \$\begingroup\$ @AdmBorkBork better? \$\endgroup\$ – Magic Octopus Urn Aug 22 '17 at 21:26
  • 1
    \$\begingroup\$ Yes, much better. \$\endgroup\$ – AdmBorkBork Aug 23 '17 at 12:33
0
\$\begingroup\$

Code the beach on the beach (heavily WIP)

The Gods of the Sea have seen your coding ability and asked you to rewrite their beach-generating program.

Code the beach

This program will take no input and, in this order:

  • Print sand (.)
  • Print ocean waves (~)
  • Print crabs (>.<)
  • Print seagulls (-v-)

This program will be run by the Gods of the Sea. They will run it once a day and will want a different beach every time they run it, so the beach items should be generated (pseudo)randomly.

To avoid this beach becoming overloaded, there should be:

  • Between five and eight crabs
  • Between three and seven seagulls
  • Between eighty and one hundred grains of sand
  • Eighty ocean waves

Your program should create the beach just as the Gods' existing program does. It will first draw the sand at the bottom of the screen, in the last three lines. Example sand:

. .. .. . . ... . ... ..  . ..  .... .. . ... . .. . .. . . .. . .. . . .... ...
  .. . .. .. .. .. ... .   ..  .. ... ...  .   .   ....... .... ...... ... .
. . . .. .. ...... ... .. ......... .  .... .. . . . . ... .. .. . . . ...

Then the waves will be printed, starting from the leftmost character in the fourth-to-last line. The point where the waves meet the sand should vary by at most one character, and waves should never go off the screen. All water that is not curling in a wave will cover the sand, so there can be no sand under the water. Example waves:

TODO: Add example waves

Crabs should be spawned in the last four lines and cannot be spawned on waves, because if they were, they would be quickly sucked under and disappear.

Seagulls may be spawned anywhere, and should be evenly distributed to the best of your pRNG's ability.

On the beach

The Gods were born in ancient times, so they're still using VGA; their terminal has 80x25 characters for output, as does their text editor - which is so old it does not support scrolling. Your program will have to fit in this text editor, so it will need to be small.

The Gods do not yet have the internet, so you'll have to write your program on the beach in a location they can see it. Unfortunately, the only convenient place at the moment is a very small sandbar on the Oregon coast. Waves occasionally reach this spot. To make sure you have enough time write the entire program before it's washed away, it will need to be as small as possible.

Furthermore, since the Gods are so far away, some characters written in the sand are indistinguishable. Gods are good at guessing, so if they see a character that looks like another they'll get it right, but another character that looks similar to the character they guessed will be assumed to be said previous character. So if a l is present in the source before an I, the Gods will see two ls.

Here are the lookalikes:

  • o and O
  • l and I and |
  • : and ;
  • " and '

The Gods don't have the technology to easily use Unicode characters, so you'll have to give them a lot of help. Each non-ASCII character you use will cost 5 bytes to describe it to them.

\$\endgroup\$
  • 1
    \$\begingroup\$ I'm not sure if the lookalike characters and penalty for non-ASCII characters is necessary. Drawing the beach, random placement and number of objects, and constrained placement of objects sounds like enough to me. The 80x25 hard constraint also seems superfluous. A line width limit of 80 keeps the idea, but would still allow for golfing in more verbose languages. \$\endgroup\$ – Andrew says Reinstate Monica Aug 23 '17 at 18:53
0
\$\begingroup\$

Help Me Catch Up With xkcd!

I definitely enjoy xkcd, and you, as a code golfer, most likely enjoy it as well. However, I often find that I won't check the website for a while and there will be a lot to read! So, I want to make a solution for that. In proper code golf fashion.


The Challenge

Your task is to write a program which, when run, will check for a new xkcd and, if there is a new comic (in other words, it is different from the one when the program last ran), output the text "There's a new xkcd out!". Use this method to check:

  1. When the program is run, check if there is a file named .xkcd in the user's home directory. If not, create the file, which will contain the title of the current xkcd comic, then exit.
  2. If the file .xkcd does exist in the user's home directory, the program will check if the title of the xkcd comic on the front page of xkcd.com is the same as the one in .xkcd. If it is, the program will exit and do nothing else. However, if the titles aren't the same, the program will output the specified text, change the contents of .xkcd to the new title, then exit.

If you have any other methods, tell me about them.


This is , so may the shortest code win and the best programmer prosper...

\$\endgroup\$
  • 2
    \$\begingroup\$ This seems rather close to codegolf.stackexchange.com/q/91847/194 \$\endgroup\$ – Peter Taylor Aug 27 '17 at 15:51
  • \$\begingroup\$ @PeterTaylor Dupe? \$\endgroup\$ – ckjbgames Aug 27 '17 at 22:06
  • \$\begingroup\$ @PeterTaylor Also, how could I distinguish it and add something unique so that it isn't marked as a dupe? \$\endgroup\$ – ckjbgames Aug 27 '17 at 22:10
  • \$\begingroup\$ My opinion in general is that when a question is a borderline dupe it's more productive to ditch it and try to think of a radically different question than to try to bisect to find the minimal sufficient difference. I don't see anything about this particular topic which would make it an exception to that general rule. \$\endgroup\$ – Peter Taylor Aug 28 '17 at 14:09
0
\$\begingroup\$

? ?

JS, 44 bytes

Here's a list of languages & byte counts from PPCG:

Jelly, 27 bytes
Mathematica, 174 bytes
Scala, 91 bytes
05AB1E, 12 bytes
dc, 13 bytes
Python 2, 115 bytes
V, 25 bytes
Charcoal, 48 bytes
Jelly, 10 bytes
Haskell, 25 bytes
MATL, 14 bytes
x86-16, 43 bytes
Emoji, 50 bytes
Pyth, 9 bytes
C, 38 bytes
JavaScript, 69 bytes
R, 73 bytes
Node.js, 70 bytes
Ly, 7 bytes
Japt, 7 bytes
Java, 2777 bytes
Husk, 18 bytes
Beatnik, 148 bytes
APL, 10 bytes
Powershell, 127 bytes
Python 3, 111 bytes
Ruby, 38 bytes
Cubically, 1231 bytes
C++, 292 bytes
Common, 98 bytes
Swift 4, 63 bytes
Axiom, 91 bytes
Groovy, 7 bytes
Bitmap, 160 bytes
Batch, 86 bytes
Perl 5, 34 bytes
Pyke, 7 bytes
Java, 182 bytes
PHP, 1 bytes
C#, 163 bytes
Processing, 85 bytes
Tcl, 66 bytes
PowerShell, 11 bytes
LOGO, 33 bytes
axo, 22 bytes
Excel, 37 bytes
TXR Lisp, 76 bytes
Alice, 17 bytes
Moorhens, 716 bytes
PHP, 2943 bytes
Python, 79 bytes
QBIC, 25 bytes
D, 65 bytes
Emojicode, 50 bytes
REXX, 46 bytes
BBC, 70 bytes
Retina, 24 bytes
Bash, 74 bytes
Cubix, 28 bytes
cQuents, 7 bytes
J, 90 bytes
AHK, 110 bytes
Mathics, 46 bytes
RProgN 2, 8 bytes
SOGL, 36 bytes
Röda, 36 bytes
><>, 238 bytes
QuadR, 32 bytes
C#, 289 bytes
Bash, 385 bytes
JS, 2823 bytes
C, 14 bytes
HTML, 132 bytes
Ruby, 40 bytes
JS, 130 bytes
Gaia, 17 bytes
TI-BASIC, 17 bytes
Befunge, 10 bytes
Ruby 2.4, 53 bytes
Pari/GP, 21 bytes
Actually, 10 bytes
APL, 4 bytes
TXR, 74 bytes
Sage, 102 bytes
Grime, 28 bytes
Ruby, 101 bytes
C++17, 71 bytes
Perl, 41 bytes
CPython, 25984 bytes
SmileBASIC, 43 bytes
WendyScript, 50 bytes
Python, 2969 bytes
Clojure, 156 bytes
Lost, 57 bytes
C++, 19 bytes
Brachylog, 4 bytes
Octave, 25 bytes
C#, 123 bytes
Magneson, 102 bytes
Brain-Flak, 36 bytes

This list will change before this challenge is posted.

Your challenge

Look at the program before you. It will print something like JS, 23 bytes. That means that you must use JS as your language.

Then pick a line from the list. Let's say you pick LOGO, 33 bytes. That means that you must print LOGO, 33 bytes in JS.

Because LOGO, 33 bytes is the 44th line, your byte count modulo the number of languages in the list (there are 100) must equal 44.

The three restrictions:

  • You must use JS
  • You must print LOGO, 33 bytes
  • Your byte count modulo 100 must be 44

So a valid submission might be:

x=>"LOGO, 33 bytes"//just wasting some bytes

Then, after your submission, you add the list from the last answer to your answer. Then, you remove Logo, 33 bytes from the list: (in your answer, not the question)

That's the language you used, and the byte count you used. Add it to the bottom. Dupes are OK.

Your answer will look like this:

JS, 44 bytes

x=>"LOGO, 33 bytes"//just wasting some bytes

Here's the new list:

(Insert the list here, and remove `Logo, 33 bytes`)

The next submission must use Logo.

Note that the list will continually get smaller, making the challenge harder.


Meta

  • Winning criterion? Last answer? Second-to-last?
  • Unclear?
  • Dupe?
\$\endgroup\$
  • \$\begingroup\$ @BusinessCat Ok, I think I'll restrict to TIO-only langs when I update the list. Thanks for the feedback! \$\endgroup\$ – programmer5000 Aug 23 '17 at 14:00
  • 3
    \$\begingroup\$ 1. In the interests of clarity, when picking arbitrary numbers make them different. 44 seems to occur in two different contexts in the example. 2. The bit about adding to the list is unclear. Are you saying that after submitting an answer, you must edit the question? That will (a) cause conflicts; (b) (I think) cause the question to become community wiki quite quickly; (c) break the example. And to accomplish what? 3. Expanding on that previous question: what is the motivation? Even answer-chaining questions benefit from a clear motivation for the core task. \$\endgroup\$ – Peter Taylor Aug 23 '17 at 21:29
  • \$\begingroup\$ @PeterTaylor I hope the recent edit clarified 2., and I will use a different list when I post this (1.) \$\endgroup\$ – programmer5000 Aug 24 '17 at 11:38
  • \$\begingroup\$ @AdmBorkBork it is. Do you know what the correct spelling is? \$\endgroup\$ – programmer5000 Aug 24 '17 at 21:41
  • \$\begingroup\$ @AdmBorkBork sorry, I meant to reply to Erik the Outgolfer. \$\endgroup\$ – programmer5000 Aug 25 '17 at 13:04
  • \$\begingroup\$ @BusinessCat status-completed \$\endgroup\$ – programmer5000 Aug 25 '17 at 14:12
  • \$\begingroup\$ @EriktheOutgolfer I think so. What's the correct spelling? \$\endgroup\$ – programmer5000 Aug 25 '17 at 14:12
  • \$\begingroup\$ @programmer5000 Röda \$\endgroup\$ – Erik the Outgolfer Aug 25 '17 at 14:15
  • \$\begingroup\$ @EriktheOutgolfer status-completed \$\endgroup\$ – programmer5000 Aug 25 '17 at 14:17
  • \$\begingroup\$ @AdmBorkBork You don't duplicate list items in most cases. See edits \$\endgroup\$ – programmer5000 Aug 25 '17 at 14:18
  • \$\begingroup\$ @programmer5000 Thanks, that clears up adding to the list. \$\endgroup\$ – AdmBorkBork Aug 25 '17 at 14:25
  • \$\begingroup\$ You probably want to remove from the list either what language was previously printed or what language you're currently printing, that way the list remains modulo 100. \$\endgroup\$ – AdmBorkBork Aug 25 '17 at 14:28
  • \$\begingroup\$ I think that every answer-chaining question so far has some mechanism to make it increasingly harder to extend the chain. With this one it seems to get easier to extend the chain rather than harder. Is this not a fundamental flaw? \$\endgroup\$ – Peter Taylor Aug 27 '17 at 17:34
  • \$\begingroup\$ @AdmBorkBork now the list gets shorter. See edits \$\endgroup\$ – programmer5000 Aug 28 '17 at 11:25
  • 1
    \$\begingroup\$ The way I read it, every answerer removes one item from the list and adds one item to the list, so it doesn't get shorter. \$\endgroup\$ – Peter Taylor Aug 28 '17 at 13:56
0
\$\begingroup\$

Paint with Pride!

Task: Output a 6 banded version of the pride flag

Details:

The flag consists of 6 bands of colour, each band is rectangular, and all are the same size which is 9x1 units (WxH) . These bands are stacked one on top of each other in the order shown to form a flag that is 9x6 units in size.

The output scale can be chosen by the participant, but all components must be in those ratios, that is, an output must have an aspect ratio which is a multiple of 3:2.

The hexadecimal values and relative positions of the colours are as below:

Full size

Or from top to bottom RGB (255,0,0), (255,153,0), (255,255,0), (0,153,0), (0,0,255), (204,0,153)

A minimal version would look like this:

Min size

Acceptable output:

Output to screen or as a file in a commonly accepted image format is allowed, ascii art is however not.

Sandbox notes:

related, related

I chose this flag because I think the rainbow provides potential for an additional mathematical element

I'm not sure whether to include a minimum size limit, such as the one for drawing the french flag, as perhaps the small output size allows hardcoded answers to succeed (which I don't really want) - any advice?

\$\endgroup\$
  • 1
    \$\begingroup\$ This is a duplicate of this unfortunately \$\endgroup\$ – caird coinheringaahing Aug 29 '17 at 19:05
  • \$\begingroup\$ @cairdcoinheringaahing Shoot, all that time searching for "Pride" and "Flags", forgot to search for rainbow! Perhaps this is significant-enough a variant (rectangle vs bow) that it will allow for different approaches though. I'm not sure what the etiquette is, but I guess I'll leave this up for a while longer and let votes tell me whether it is too much of a duplicate to post. \$\endgroup\$ – Greedo Aug 29 '17 at 19:25
  • \$\begingroup\$ personally, I would close as a duplicate, but if you want to keep it here and see otherwise, go ahead. \$\endgroup\$ – caird coinheringaahing Aug 29 '17 at 19:26
0
\$\begingroup\$

The source of pi

Inspired by an International Obfuscated C Code Contest entry.

Task

As you all know, pi is a constant that represents the ratio of a circle's circumference to its diameter.

Using the dimensions of your own source code, approximate pi to at least two decimal places.

That is, your source code should read itself to obtain both circumference and diameter, then output the ratio.

For example, if your code is:

 AB
CDEF
 GH

Your circumference is 14 and your diameter is 4.

For the purposes of this challenge, let diameter equal the larger of the height or width of your code.

Rules

  • Take no input
  • Hardcoded values for pi are not allowed
  • Output pi to at least two decimal places (e.g., 3.14 and 3.1415 are both acceptable outputs)
  • Answers can be either whole programs or functions

Notes

Answers with higher precision values are acceptable.

Standard rules apply.


Meta

Looking for suggestions of a better title.

\$\endgroup\$
  • 1
    \$\begingroup\$ Well, I'm not sure what "Using the area of your own source code" means. I could do some pretty "standard" approximation algorithm to fullfill your rules. \$\endgroup\$ – Felix Palmen Aug 29 '17 at 16:58
  • \$\begingroup\$ Wouldn't print(3.14) work? It isn't hardcoding pi, as pi isn't 3.14. \$\endgroup\$ – caird coinheringaahing Aug 29 '17 at 19:22
  • \$\begingroup\$ @FelixPalmen - I've updated the specification. Hopefully it is more clear. \$\endgroup\$ – CzarMatt Aug 29 '17 at 20:14
  • \$\begingroup\$ @cairdcoinheringaahing - I've updated the specification. Hopefully it is more clear. \$\endgroup\$ – CzarMatt Aug 29 '17 at 20:16
0
\$\begingroup\$

"Square Root of Pi(e)"

A pie (r=3) is drawn as such:

  @@
 @@@@
@@@@@@
 @@@@
  @@

Pretending that it's a perfect circle, the square root of such a pie would be sqrt(PI*32) = 3sqrt(PI) ~ 5.317. Now take a square out of the pie, whose area is closest to the square root of the pie. In this case it would be a square of area 4. Therefore, you can output:

  @@
 @@@@
@@  @@
 @  @
  @@

Yep, I took a square out of the pie, how do you like that?


r=7

      @@
     @@@@
    @@@@@@
   @@@@@@@@
  @@@@@@@@@@ 
 @@@@@@@@@@@@
@@@@@@@@@@@@@@
 @@@@@@@@@@@@
  @@@@@@@@@@
   @@@@@@@@
    @@@@@@
     @@@@
      @@ 

7*sqrt(PI) ~ 12.407. Closer to 3x3 than 4x4 square.

      @@
     @@@@
    @@@@@@
   @@@@@@@@
  @@@@@@@@@@ 
 @@@@@@@@@@@@
@@@@@@@@@@@@@@
 @@@@@@   @@@
  @@@@@   @@
   @@@@   @
    @@@@@@
     @@@@
      @@ 

Specifications:

  1. Input will be only a "pie" with integer radius of at least two. As you can see, the longest row has 2r @s, and the smallest rows have 2 @s.
  2. You can use a symbol other than "@".
  3. You can take a square out of the inside or the edge.
  4. Approximate PI to at least 3.14.

Bonus: Valid answers that are in a language with food-related name get a free upvote!

\$\endgroup\$
  • \$\begingroup\$ You don't ever define How one forms the pie shape, and in general you seem to be lacking specification. \$\endgroup\$ – Wheat Wizard Sep 3 '17 at 3:37
0
\$\begingroup\$

The Best Question

This site gets a variety of questions: the good, the bad, the ugly. However, I've noticed some patterns that I think will help us find The Best Question (of a given week).

Procedure

You are given a date in a human-readable format of your choice as input. You need to find the best question from that week. The week starts on Sunday and ends on Saturday. Click on the link for a valid query to use if the input is Aug 31, 2017. Note that when using the API without a key you can use UNIX epoch time or YYYY-MM-DD to specify the dates (info here). Since this site gets only about 45 questions a week, you can assume that no more than 100 questions will be asked in a given week in order to avoid pagination.

Scoring

First of all, closed questions are disqualified. Next, here is the formula for Question Rating (QR)1, given Question Score (S) and Number of Answers (A):

The thinking is that there are two kinds of questions that undeservedly get a very high question score: 1) the ones that are easy and get a lot of answers, and 2) the ones that are so difficult that they get few or no answers. I've determined that the best questions have a QuestionScore:Answer ratio of about 3:2.

Output

All you have to do is output the full URL of the question that got the best question score. If multiple tie, you can output them all or just one.

Example

Here's a list of 8 imaginary questions, with their question score followed by the number of answers they received, and their resulting QR:

1. +6, 23A -> -0.333
2. +10, 0A -> 7.78
3. +8, 4A -> 7.56
4. -2, 6A -> -4.44
5. +5, 3A [closed] -> DQ
6. +20 2A -> 16.22
7. +24, 40A -> 16
8. +15, 14A -> 13.67

So the winner is question 6. Output its URL.

Note

You don't need to handle the rare edge case when there are no valid questions in a given week.

1Disclaimer: This scoring system is just a joke.


Suggestions on formula and other stuff welcome.

\$\endgroup\$
  • \$\begingroup\$ Is that abs((QuestionScore/2)-Answers)/2 or abs(QuestionScore/(2-Answers))/2? \$\endgroup\$ – Shaggy Sep 1 '17 at 12:05
  • \$\begingroup\$ Hopefully this looks a bit better. \$\endgroup\$ – geokavel Sep 1 '17 at 15:29
0
\$\begingroup\$

Extend the Pattern

Given a raster image with a lattice pattern, extend it to twice the size of the input image in both directions.

Details

The input image is a section of an infinite repeating pattern defined by two vectors u=(ux,uy),v=(vx,vy) with integer entries, that are linearly independent. This means that both vectors are nonzero and do not point in the same direction. The pattern is defined such that the pixel at a point p = (x,y) has the exact same colour as the pixel at

q := p + s*u + t*v 

for every integer s,t. This means if you know the colours of the pixels within the fundamental parallelogram Z = { s*u + t*v | s in [0,1),t in [0,1)} and corresponding vectors u,v you can extend the pattern to an arbitrary size. The goal of this challenge is finding the pattern and extend the image.

enter image description here

Specs

  • You can take the input image in any non-compressed image format that allows for at least 3 colours, this includes e.g. matrices, 2d arrays or strings.
  • The input method must match the output method. That means if you read a .png file as input, you must also write a .png file as output, or if you take the input via console, you must also print the output via console e.t.c.

Examples

(to be added...)

\$\endgroup\$
  • \$\begingroup\$ Is there freedom to choose which quadrant of the output image corresponds to the input image? \$\endgroup\$ – Peter Taylor Sep 3 '17 at 18:05
  • \$\begingroup\$ You need to add some harder test-cases - at present you can just check for overlaps, tile "infinitely" then crop. \$\endgroup\$ – wizzwizz4 Sep 4 '17 at 16:25
  • \$\begingroup\$ @PeterTaylor Good question, I think I will leave the direction arbitrary. \$\endgroup\$ – flawr Sep 4 '17 at 19:53
  • \$\begingroup\$ @wizzwizz4 I think this method works in any case, or do you have an example in mind where this does not work? \$\endgroup\$ – flawr Sep 4 '17 at 19:54
  • \$\begingroup\$ @flawr One where there's less than one copy of the parallelogram... wait, that wouldn't prevent the overlap technique from working. \$\endgroup\$ – wizzwizz4 Sep 4 '17 at 19:58
0
\$\begingroup\$

Golf a Brainfuck compresser.

The eso-lang Brainfuck only has 8 instructions that do something: +-><[],. so in theory you could represent them in 3 bits. You could store 8 instructions in 24 bits or 3 bytes.

BrnFck

This is compressed brainfuck an instruction will be represented by its bits.

  1. + : 000
  2. - : 001
  3. > : 010
  4. < : 011
  5. [ : 100
  6. ] : 101
  7. , : 110
  8. . : 111

This is a language counted in bits, 8 bits is 1 byte depending on the challenge you may round up or keep a decimal.

The goal

Write the shortest program that can compile any inputted brainfuck code to BrnFck code:

  • You can choose how you output it, byte,bit/boolean arrays and output streams are all acceptable. Just printing ASCII-letters is too.
  • You can do anything (including crash) if the input isn't valid code or contains a non-bf character.

And can compile the BrnFck code back to Brainfuck (or any other language (except BrnFck)). You may ask which way you want to compile or write 2 separate programs/functions and sum their scores.

If you post the code online (for example as an answer) this should automatically allow BrnFck as a language in all future challenges!

Scoring

If you use brainfuck you can divide your bytes by 2.

If you use BrnFck you can divide your bytes by 4 (let's get some recursion going here).

1 bit will be counted as 0.125 bytes (please put both in the title) so decimal byte scores are allowed.

Tags

brainfuck,code-golf,...

\$\endgroup\$
  • 1
    \$\begingroup\$ This encoding doesn't really work since no sensible architecture allows partial bits. Since each 3 bit word is already used, there is no way to distinguish say ,+. from ,+.. if you happen to fill the remaining bits in that way. That said, it isn't totally required for the question for this to work. Otherwise, the bonuses and scoring are needless and confusing, so I'd recommend removing them. \$\endgroup\$ – FryAmTheEggman Sep 3 '17 at 16:57
  • 3
    \$\begingroup\$ Nearly every byte score on PPCG is decimal (base 10): I think you mean that fractional byte scores are possible. To deal with the padding problem, I suggest that you specify that where one or two padding bits are required, 0 should be used; and where three to seven are required, the padding should be 101 followed by as many 0s as necessary. Since [] must be balanced, this allows unambiguous detection of the padding on decompression. Then make sure to include a test case which ends in ] and requires no padding... \$\endgroup\$ – Peter Taylor Sep 4 '17 at 8:02
0
\$\begingroup\$

Program that allows the user to edit it's own source code

Write a program that displays and allows the user to view, edit and save it's own source code.

  • If no edits are made, the output file should be the same as the program, and hence executing it should allow the user to edit the program's code again. (ie a quine)
  • If the code has been edited in a sensible way, running the program again should display the edited code. The definition of 'sensible' is left flexible to prevent this being impossible - as the source code can be edited, a user can obviously edit the program in such a way that it no longer displays it's source code.

The standard quine rule applies: no reading the source file directly.


Additional Notes and things to consider:

  • How robust is your program? What percentage of your program can be edited (sensibly) before it stops displaying it's own source or saving the edits you made.
  • Both overwriting and saving with a different filename are valid ways for the program to save it's new code
  • If it is a compiled language, the program does not have to invoke the compiler or do the compiling itself after saving.
  • This is a code challenge not code golf. Robustness, interface and 'coolness' of the solution are favoured over brevity.

  • Extra, uh, points(?!) if your program can identify errors in the quine before saving.


Is this a feasible challenge? Does it need clarification?

\$\endgroup\$
  • 1
    \$\begingroup\$ If the only winning-criteria is "Percentage of the characters which can be changed without breaking it" then the answerer can arbitrarily pad their score with an irrelevant string if their language has very versatile quining capabilities. The other things "favored" only really count if it's a popularity-contest and challenges with that tag are discouraged. \$\endgroup\$ – Kamil Drakari Sep 7 '17 at 21:07
  • \$\begingroup\$ Do you have any suggestions on how to score it? I can't think of any cross-language methods. \$\endgroup\$ – sdfgeoff Sep 7 '17 at 21:21
  • \$\begingroup\$ Currently you are scoring it as (characters that can change / total), You could square or cube the total to incentivise golfing, that way padding can only hurt you. However you want to watch out for very short programs that make little effort to complete the task but by virtue of their shortness are highly scoring. \$\endgroup\$ – Wheat Wizard Sep 17 '17 at 0:35
0
\$\begingroup\$

Prime Number Locator

Given a prime number p > 1, determine at what index p appears in A000040.

  • You may 0 or 1 index, meaning 2 can return 0 or 1.
  • If you are given a non-prime number you must return -1.
    • If you are 1-indexing you may return 0 instead, or still return -1.
  • Your time complexity must be less than O(n): Please explain your calculations in the answer.

First 10 return values (0-indexed):

[2, 3, 5, 7, 11, 13, 17, 19, 23, 29]
[0, 1, 2, 3,  4,  5,  6,  7,  8,  9]

This is : Reduce your byte-count to win.

\$\endgroup\$
  • \$\begingroup\$ Related \$\endgroup\$ – H.PWiz Sep 8 '17 at 17:41
  • \$\begingroup\$ @H.PWiz, I'd call that a dupe; the count is the index. \$\endgroup\$ – Shaggy Sep 9 '17 at 11:48
  • \$\begingroup\$ @Shaggy This one is restricted-complexity though \$\endgroup\$ – H.PWiz Sep 9 '17 at 12:00
  • \$\begingroup\$ o(n) is impossible: this isn't a problem which can be solved without reading all of the input. If that were relaxed to O(n) I think this would fit the "Too broad" close criterion because a properly explained answer would be a (very good) doctoral thesis. The current state-of-the-art algorithms are O(2^(2n/3) + epsilon), so a polynomial algorithm would already be impressive, and a linear one would be astounding. \$\endgroup\$ – Peter Taylor Sep 11 '17 at 8:59
0
\$\begingroup\$

Do the line segments cross?

Description: Today, we're going to do some geometry: We have two line segments and want to find out where they cross! A point is a pair of two integers being the x and y coordiantes of said point. If your calculations result in non-integers, you continue with the integer closest to your result.

I/O: You are given the two segments in form of 8 integers representing the 4 end points. You may take them in the order that fits you best, but you have to state the ordering. The output consisting of the point where the lines intersect, or null, an empty string or something similar, but no undefined behavior. You may use STDOUT, a file etc. to write your output.

This is - the shortest answer in bytes wins!

\$\endgroup\$
  • \$\begingroup\$ Can I take 4 tuples (x,y) instead? \$\endgroup\$ – H.PWiz Sep 8 '17 at 17:46
  • \$\begingroup\$ Of course. Are you golfing in Haskell? \$\endgroup\$ – racer290 Sep 8 '17 at 18:03
  • \$\begingroup\$ I'm not golfing now. Many languages have tuples. \$\endgroup\$ – H.PWiz Sep 8 '17 at 18:05
  • \$\begingroup\$ This is just a subset of this challenge. \$\endgroup\$ – AdmBorkBork Sep 8 '17 at 19:48
  • \$\begingroup\$ Only up to a certain degree. The challenge you mentioned is ok with a truthy/falsey value. That makes a difference in chosing your "algorithm". \$\endgroup\$ – racer290 Sep 9 '17 at 5:17
0
\$\begingroup\$

...?

Fork for n times

-bash: fork: HE COMES

TL;DR: fork up to n times, than hang forever

Relevant chat discussion

Your challenge is to make a program / function that calls itself twice or uses some other method of creating copies of itself that create copies of itself, etc.

However, to avoid crashing the system, your program limits itself before it forks to death. Given an input n, your program should stop forking when it has n total copies of itself (including itself), and keep running forever with n total copies of itself.


Meta

  • Under-specified?
  • Is the min of 500 good?
  • Tags?
  • Better title?
\$\endgroup\$
  • 1
    \$\begingroup\$ It's not exactly a dupe of this one, but that one is the same spirit, and it's closed and locked, so I wouldn't expect this to be well received. Also see this and this \$\endgroup\$ – DJMcMayhem Aug 22 '17 at 21:41
  • \$\begingroup\$ @DJMcMayhem see edits \$\endgroup\$ – programmer5000 Aug 22 '17 at 22:05
0
\$\begingroup\$

Where do I live? *

Given a coordinate pair, supporting at least 2 decimal places (precision .01), determine the country containing that coordinate pair. The coordinate will be on land and will be at least ~0.5 degrees (~50 km Great Circle distance; thanks Peter Taylor!) from any border or coastline.

Input will be given as two decimal numbers in any reasonable format. Output should be the English name of the country according to this source; spaces, accents, non-alphanumeric characters, and capital letters are all optional. For countries like Iran, you can choose to output either "Iran" or "Islamic Republic of Iran". The same applies for all ...Republic... countries, like N/S Korea, Lao, Taiwan, etc. For Côte D'ivoire, you can choose to output either "Côte D'ivoire" or "Ivory Coast".

Exact built-ins are not allowed (ahem Mathematica). Online APIs are not allowed (ahem Google Maps).

Western and Southern coordinates can be given as a negative decimal or with W and S (you can also have N and E if wanted). Please specify your input format.

You will have to handle coordinates in Antarctica. Apparently it's a country now.

Test Cases

Input           -> Output

43.26N,  79.54W -> Canada
37.42N,  94.88W -> United States of America
25.96N, 103.51W -> Mexico
 9.39S,  59.39W -> Brazil
79.66S,  65.22E -> Antarctica
90.00S,  00.00E -> Antarctica # It's such a shame that 90N ?E/W is in the middle of the ocean
74.25N,  40.00W -> Greenland
63.08N,  15.34E -> Sweden
66.19N,  98.93E -> Russia
30.72N, 103.39E -> China
 2.89S, 119.55E -> Indonesia
26.96S, 132.91E -> Australia

* not a real tag but I propose to add it

\$\endgroup\$
  • \$\begingroup\$ Does "at least 0.5 degrees from any border or coastline" mean "at least 55.6km from any border or coastline" (i.e. great circle distance)? \$\endgroup\$ – Peter Taylor Sep 11 '17 at 8:34
  • \$\begingroup\$ @PeterTaylor Yes, thanks for the calculation. I'll just say ~50 km, thanks. \$\endgroup\$ – HyperNeutrino Sep 11 '17 at 12:12
0
\$\begingroup\$

[tag:H̸̡̪̯ͨ͊̽̅̾̎Ȩ̬̩̾͛ͪ̈́̀́͘ ̶̧̨̱̹̭̯ͧ̾ͬC̷̙̲̝͖ͭ̏ͥͮ͟Oͮ͏̮̪̝͍M̲̖͊̒ͪͩͬ̚̚͜Ȇ̴̟̟͙̞ͩ͌͝S̨̥̫͎̭ͯ̿̔̀ͅ]

Parse HTML with regex!

Alternate titles:

RegEx match open tags except XHTML self-contained tags

H̸̡̪̯ͨ͊̽̅̾̎Ȩ̬̩̾͛ͪ̈́̀́͘ ̶̧̨̱̹̭̯ͧ̾ͬC̷̙̲̝͖ͭ̏ͥͮ͟Oͮ͏̮̪̝͍M̲̖͊̒ͪͩͬ̚̚͜Ȇ̴̟̟͙̞ͩ͌͝S̨̥̫͎̭ͯ̿̔̀ͅ - Parse HTML with regex

Background

Don't parse HTML with regex. It always fails and sometimes summons Cthulhu.

But, because PPCG is different, we will parse HTML with regex.

And not easy, beginner HTML. HTML with comments, attributes with no quotes, HTML in script tags not commented out and much more. Can you write a regex to parse that?

The challenge

Your challenge is to make a regex that matches valid HTML tags. Don't match comments, don't match invalid HTML, don't match HTML in comments, just match valid HTML tags. Each full regex match is one HTML tag.

Your input HTML will never contain commas. You will try to get the most points possible by successfully matching the HTML tags and not the text in as many inputs as possible. Whoever gets the most points wins. Please say at least 1 regex flavor that your regex works with.

You are not allowed to use regex features to execute language code. (Sorry, Perl)

The length of your regex is irrelevant, this is not code golf.

Test cases

Here are the test cases. You can also find them at https://hastebin.com/raw/mikaxakipe.txt.

1,1,<b>HTML!</b>,<b>,</b>
2,1,<i><b>HTML</b></i>,<i>,<b>,</b>,</i>
3,1,a < b implies b > a,
4,2,<img alt=text>Img,<img alt=text>
5,2,<a href = "http://example.com">Example Domain</a>,<a href = "http://example.com">,</a>
6,2,<hr><br/>,<hr>,<br/>
7,2,<div id ="hi" class="what">What</div>,<div id ="hi" class="what">,</div>
8,3,<a>fake</>,<a>
9,3,Self-closing <img src = "self-closing.jpeg" />?,<img src = "self-closing.jpeg" />
10,3,<self-closed/>O_O<unclosed>,<self-closed/>,<unclosed>
11,3,Do<yOU>like<LoTs>of<mIXeD><cAsE>?,<yOU>,<LoTs>,<mIXeD>,<cAsE>
12,3,Wh<a b='c'd="e">at?,<a b='c'd="e">
13,3,Hi<p data-hi=3>hihihi</p>,<p data-hi=3>,</p>
14,4,<a"oops">Oops,
15,5,<!-- <b><!--hi--><i>,<i>
16,5,<0>NOT VALID</0><h0>fine</h0>,<h0>,<h0>
17,5,<a a=b<>what</a>,<a a=b<>,</a>
18,6,<!-- <b><!--hi--><i>-->,<i>
19,7,<how><deep can><your nesting nesting><level></level></go>?<how>Deep</how><can><your>nesting <go x=? j><how><deep can><your nesting nesting><level></level></go>?<how>Deep</how><can><your>nesting <go x=? j><how><deep can><your nesting nesting><level></level></go>?<how>Deep</how><can><your>nesting <go x=? j></your></can></your></deep></how></your></can></your></deep></how></your></can></your></deep></how>,<how>,<deep can>,<your nesting nesting>,<level>,</level>,</go>,<how>,</how>,<can>,<your>,<go x=? j>,<how>,<deep can>,<your nesting nesting>,<level>,</level>,</go>,<how>,</how>,<can>,<your>,<go x=? j>,<how>,<deep can>,<your nesting nesting>,<level>,</level>,</go>,<how>,</how>,<can>,<your>,<go x=? j>,</your>,</can>,</your>,</deep>,</how>,</your>,</can>,</your>,</deep>,</how>,</your>,</can>,</your>,</deep>,</how>
20,7,<plaintext><b></plaintext>,<plaintext>,</plaintext>
21,7,What<img src="imgs/>lolz.png" alt = "<heh"/>,<img src="imgs/>lolz.png" alt = "<heh"/>
22,7,<b><a href = "#" title = "4 > 3">hi</a></b>,<b>,<a href = "#" title = "4 > 3">,</a>,</b>
23,10,<StYle><b title = "not in html"></style><B>HTML!</b><style></style>,<StYle>,</style>,<B>,</b>,<style></style>
24,10,<script>//<script>< /script></script><script></script><p>,<script>,</script>,<script>,</script>,<p>
25,10,<i></i this="will be removed by a browser">,<i>,</i this="will be removed by a browser">
26,10,<div id="hi" class=class="what" data-the="heck='is'this" get-good>Attributes are weird<div>,<div id="hi" class=class="what" data-the="heck='is'this">,<div>
27,10,<!--<b>Do you like comments??</b>--><p>,<p>
28,13,<textarea><script>/* *////*///*<!--</script><b>WHAT</b></textarea><i>Hi-->,<textarea>,</textarea>,<i>
29,15,<!--<b>Do you like comments??</b><script>--><script>//<!--hello</script><b>hi</b><!--What--><script>//<!-- <script> <!-- <script> --> </script><i>hello--><script></script>,<b>,</b>,<script>,</script>,<i>,<script>,</script>
30,15,<hi>hi</hi><0>hi</0><h0>hi</h0><h&>hi</h&><&>hi</&><??>hi</??><?php>hi</?php><php?>hi</php?><->hi</-><_-_>hi</_-_><h->hi</h-><_>hi</_><h-_>hi</h-_><?>hi</?><{>hi</{><h{>hi</h{></>hi<//><h~!@#$%^&*()>hi</h~!@#$%^&*()><h>hi</h><h~>hi</h~><h!>hi</h!><@>hi</@><h@>hi</h@><h!@#$%^&*()>hi</h!@#$%^&*()><@f>hi</@f><%>hi</%><;>hi</;><h>>hi</h>><h&>hi</h&><h~>hi</h~>,<hi>,</hi>,<h0>,</h0>,<H&>,</H&>,<PHP?>,</PHP?>,<h->,</h->,<H-_>,</H-_>,<H{>,</H{>,<H~!@#$%^&*()>,</H~!@#$%^&*()>,<H>,</H>,<H~>,</H~>,<H!>,</H!>,<h@>,</h@>,<h!@#$%^&*()>,</h!@#$%^&*()>,<H>,</H>,<H&>,</H&>,<h~>,</h~>
31,30,<hi>hi</hi><0 WHAT_is=HtMl>hi&<i attrubute="oops'></0><h0 attRiBu350Te="<b>oops</b><style>/*">hi</h0>*/<h&>hi</h&><&>hi</&><??>hi</??><?php>hi</?php><php?>hi</php?><->hi</-><_-_>hi</_-_><h->hi</h-><_>hi</_><h-_>hi</h-_><?>hi</?><{>hi</{><h{>hi</h{></>hi&<//><script>     &/*<h~!@#$%^&*()>*/</ script></StyLe>/*</ScrIPT>/*<b>oops</b>hi</h~!@#$%^&*()><h>hi</h><h~>hi</h~><h!>hi</h!><@>hi</@><h@>hi</h@><h!@#$%^&*()>hi</h!@#$%^&*()><@f>hi</@f><%>hi</%><;>hi</;><h>>hi</h>><h&>hi&</h&><h~>hi/*/</h~><b>oops</b>hi</h~!@#$%^&*()><h>hi</h><h~>hi</h~><h!>hi</h!><@>hi</@><h@>hi</h@><h!@#$%^&*()>hi</h!@#$%^&*()><@f>hi</@f><%>hi</%><;>hi</;><h>>hi</h>><h&>hi&</h&><h~>hi/<script></StyLe></ScrIPT><textarea><b>HE COMES</b></textarea><h!>hi</h!><@>hi</@><h@>hi</h@><h!@#$%^&*()>hi</h!@#$%^&*()><@f>hi</@f><%>hi</%><;>hi</;><h>>hi</h>><h&>hi&</h&><h~>hi</h~>,<hi>,</hi>,<i attrubute="oops'></0><h0 attRiBu350Te="<b>,<style>,</style>,<textarea>,</textarea>,<h!>,</h!>,<h@>,</h@>,<h!@#$%^&*()>,</h!@#$%^&*()>,<h&>,</h&>,<h~></h~>

Each line is a separate test case. They are in this format:

1,1,<b>HTML!</b>,<b>,</b>
| | |            |   |
| | |            +---+- The correct output: all HTML tags in the string separated by commas
| | +- The HTML for you to parse
| +- The number of points you get if you parse this HTML correctly
+- The test case number

Example

Let's say we have the regex /<.*?>/g (all flavors). For test case #1, it matches 2 times: <b>, and </b>. The correct output in the test case says that it should match <b> and </b>, so it is correct. Our regex gets 1 point.

Then for test case #2. Our regex matches <i>, <b>, </b>, and </i>, which is consistent with the test case so we get 1 point.

Now for test case #3. Our regex matches < b implies b >, when it should have not matched anything. We get 0 points for that.

Continuing for each test case gets us a score of 50 (out of 207, or 24.15%). Not great. Can you do better?

Try It Online

If your regex will work with the ECMAScipt / JS flavor than you can try it here and get automatic scoring!

Tie breaker

Here are the scoring systems. Whoever has the best score on the first wins. In the event of a tie, whoever out of the ties scores the best wins, etc.

  1. Most points
  2. Shortest length
  3. First posted

Answer format

[insert score here] / 207 points

[insert regex here]

Explanation (optional but encouraged)

Proof of score (matched output vs. test cases, link to TIO to try it, etc.)


Meta

\$\endgroup\$
  • \$\begingroup\$ Any tie breaking for regexes with the same score, e.g. length? \$\endgroup\$ – Laikoni Sep 11 '17 at 5:28
  • 1
    \$\begingroup\$ 1. This is a meta-regex question, and scoring it just on test cases means that there are already programs out there which will generate a regex that gets a perfect score. As it stands it's a pretty pointless contest. 2. I don't see a specification for an HTML tag, or even a link to one. Why, for example, is < b implies b > invalid? Without a spec it's even more a meta-regex question rather than an HTML question. 3. This isn't parsing HTML with regex. It's closer to lexing HTML with regex, and no-one said that that was impossible or would summon the Elder Ones. \$\endgroup\$ – Peter Taylor Sep 11 '17 at 7:50
  • \$\begingroup\$ @Laikoni status-completed \$\endgroup\$ – programmer5000 Sep 11 '17 at 21:10
0
\$\begingroup\$

Matrix Decomposition

Meta

  • Duplicate?
  • What rules should I add?
  • Are my explanations sufficient?
  • Any room for improvement?

It's possible to "factor" any invertible (a.k.a. non-singular) square matrix A into a combination of a permutation matrix1 (P), a unit3 lower triangular matrix2 (L), a diagonal matrix4 (D), and a unit upper triangular matrix2 (U).

That is, A = PLDU

For instance, the matrix [[4, 5], [2, 3]] can be expressed as the multiplication of the following matrices:

P = [[0, 1],
     [1, 0]]
L = [[1, 0],
     [2, 1]]
D = [[2, 0 ],
     [0, -1]]
U = [[1, 3/2],
     [0, 1  ]]

Task

Given an invertible square matrix A, output P, L, D, and U.

Test Cases

TBD

Rules

  • Any reasonable output format is acceptable, but P, L, D, and U must be separate outputs.

1. A permutation matrix is a permutation of the identity matrix.

2. An upper triangular matrix is a square matrix whose nonzero values occur only on or above the main diagonal, and a lower triangular matrix is a matrix whose nonzero values occur only on or below the main diagonal.

3. A unit triangular matrix is a triangular matrix whose main diagonal is all 1s.

4. A diagonal matrix is a matrix whose nonzero values occur only on the main diagonal.

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

Become a Word-Pontif

The french used to define the word pontif as one who builds bridges stemming from the conjunction of pons, facere which literally translates to a bridge, to create one. Your task will be, given a list of 1 or more lower-case words l (String Array), output the MAXIMUM length of a bridge that can be built from these words.


Bridge Rules

  • Bridges can be made by connecting two or more words together:
    • Words must be connected prefix-to-suffix or suffix-to-prefix.
      • To join two words into one:
        • The suffix of the first must match the prefix of the second (abc+cba=abcba).
        • The prefix of the first must match the suffix of the second (earl+toe=toearl).
    • If a word's prefix/suffix contains more than one common character:
      • You can only connect them with the maximal common substring.
      • In other words,abc and bcdefg can be connected using a[bc]defg.
  • The length of a bridge is simply the length of the conjoined words in characters.

Building Material Rules

  • The list will contain at fewest 1 word.
  • The list may hold 0 links between words, in this case the maximal size is the longest word in the list.
  • The list will not contain the empty string and will only use the lowercase alphabet (a-z).
  • The list MAY NOT contain duplicates.

Examples

Example 1:

[abcdefgh,holographic,graphical,quine,loitering]

abcdefholo[graphic]al = 19

19

Example 2:

[noon,moon,loon,noon,groom]

groo[m]oon

8

Example 3:

[spoon,whatifgodwereoneofus,oneofusisatraitor,aaaaaaaaaaaaaa,aaaaaaaaaa]

whatifgodwere[oneofus]isatraitor (because the two aaaaa's overlap too much).

30

Example 4:

[abc,def,ghi,jkl,mnop,qrst,uvwxyz]

uvwxyz (No matches)

6

Example 5:

[xox,xxox,lol,lolol,lololol,xoxx]

xo[xx]o[x]ox    < 8  (Maximal of the xox path)
[lol]o[l]ololol < 10 (Maximal of the lol path)

10

Example 6 (Base):

[hi]

hi

2

Example 7:

# Note, when a link has been used it cannot be used twice.
# In other words, the brackets used cannot overlap in these examples.
[aa,aaa,aaaa] 

aa[aa][a]a (Chose to use aaaa,aaa,aa)

7

General Rules

\$\endgroup\$
  • \$\begingroup\$ 1. This is extremely close to codegolf.stackexchange.com/q/132561/194 . 2. Examples 5 and 7 look wrong. \$\endgroup\$ – Peter Taylor Sep 12 '17 at 8:52
  • \$\begingroup\$ In example 1, isn't it abcdefgholographicaloitering = 28? \$\endgroup\$ – KSmarts Sep 18 '17 at 14:22
0
\$\begingroup\$

Validating Words in Word Grids

A follow on from Generating Word Grids

Given a grid of letters and a set of co-ordinates, validate that the co-ordinates follow only cardinal direction changes, at least one of the co-ordinates touch an empty space in the centre of the grid, the resulting word is valid given the dictionary (taking into consideration any blank tiles) and return either the grid, with the letters at the co-ordinate removed along with the score of the word, or, if one of the conditions fails, the original grid and a score of -1.

Details

Please use the dictionary provided which is a /usr/bin/dict clone with all words converted to lowercase, non-alphabetic characters removed, and then de-duplicated.

0,0 will be the uppermost, leftmost character on the grid, working right and down.

Scoring

Letters are worth their values as per Scrabble:

0 points: blank tiles
1 point: E, A, I, O, N, R, T, L, S, U
2 points: D, G
3 points: B, C, M, P
4 points: F, H, V, W, Y
5 points: K
8 points: J, X
10 points: Q, Z

Bonus tiles (indicated by a lowercase letter, or ! for a blank tile) provide a *2 multiplier and stack (eg. if my co-ordinates spell gOLf I would earn (((2+1+1+4)*2)*2), 32 points).

Examples:

Input:

6,4 6,5 5,5 4,5 3,5 3,6 2,6 1,6
UWDESTKP?
ItDBaDEdI
TERMDYTSR
ROANJLEFT
EkCI OOsT
IPAJPGMNY
MZLORITVI
GwEGgPUeI
MNROYOEER

Output:

9
UWDESTKP?
ItDBaD dI
TERMDY SR
ROANJ  FT
EkCI  OsT
IPAJP MNY
MZLO  TVI
GwEGgPUeI
MNROYOEER

(spells RIGOLETE, (1+1+2+1+1+1+1))

Input:

0,3 0,4 0,5 0,6
UWDESTKP?
ItDBaD dI
TERMDY SR
ROANJ  FT
EkCI  OsT
IP  P MNY
MZL   TVI
GwE gPUeI
MNROYOEER

Output:

-1
UWDESTKP?
ItDBaD dI
TERMDY SR
ROANJ  FT
EkCI  OsT
IP  P MNY
MZL   TVI
GwE gPUeI
MNROYOEER

(spells DEST which doesn't appear in the dictionary)

Input:

5,6 4,6 4,7 4,8
UWDESTKP?
ItDBaD dI
TERMDY SR
ROANJ  FT
EkCI  OsT
IP  P MNY
MZL   TVI
GwE gPUeI
MNROYOEER

Output:

12
UWDESTKP?
ItDBaD dI
TERMDY SR
ROANJ  FT
EkCI     
IP  P  NY
MZL   TVI
GwE gPUeI
MNROYOEER

(spells MOsT, (3+1+1+1)*2)

Rules

This is so the shortest code in bytes wins.

  • The order is not important, it can be score then grid, or vice versa.
  • Any reasonable format can be used for I/O assuming it is consistent.
  • All standard loopholes are forbidden.

\$\endgroup\$
  • \$\begingroup\$ This looks pretty good to me. \$\endgroup\$ – Rɪᴋᴇʀ Sep 15 '17 at 18:20
  • \$\begingroup\$ Thanks @Pavel, I'll bear that in mind, i'm not sure how much interest there is based off of part 1, but I might still post this in the next week or so :) \$\endgroup\$ – Dom Hastings Sep 16 '17 at 9:21
0
\$\begingroup\$

Word Grid Pathfinding

A follow up to Generating Word Grids and Validating Words in Word Grids.


Meta

My original idea for this was to have entries compete, but I'd like to have different winning conditions. Given grid x, pit all scripts against each other for the following win criteria:

  • Highest Score
  • Shortest Path
  • Fewest remaining tiles
  • Longest Words

but I think perhaps just making it code golf and offering a bounty to each of the criteria above after some time. I'd like some feedback on this. I like @LegionMammal978's idea, but feel like perhaps that could be a separate challenge (again, only if these are interesting to anyone!)


Given a grid of letters, complete a path of words that reaches from the centre of the board, to the edges. You must return lists of your moves as co-ordinates and your score will be tallied. As soon as there is a clear path from the centre to the edge, the game is over, and no further words will be scored.

Details

Grids will always have an equal, odd, number of rows and columns, such that no direction contains fewer tiles.

Restrictions

In the event that the grid is unsolvable (or becomes unasolvable because of your chosen path, you may return something falsy instead of a list of co-ordinates.

Your script must be able to handle grids of varying sizes and solve them in a reasonable time, such that a service like TIO can be used, without causing problems in most cases, for extremely large inputs (> 500). You are free to take input in any reasonable format, but please include a link to your script with a wrapper such that it can take input in via STDIN/script arguments via an online service.

#TODO: copy details of the adjacency rules from above.

For example, in the grid provided below, the J, I, P or O letters (north, east, south and west of the blank square) must be included, once this word has been removed, you have more available words.

There are bonus letters that provide a double point score, denoted by a lowercase letter or ! (instead of ? for a blank tile). Blank tiles are used exactly as they are in Scrabble and can count as any letter, the validating program will search for words replacing the ? (or !) with a wildcard. Letters are scored as per Scrabble:

0 points: blank tiles
1 point: E, A, I, O, N, R, T, L, S, U
2 points: D, G
3 points: B, C, M, P
4 points: F, H, V, W, Y
5 points: K
8 points: J, X
10 points: Q, Z

Your score will be calculated by the validator.

Examples

Input:

UWDESTKP?
ItDBaDEdI
TERMDYTSR
ROANJLEFT
EkCI OOsT
IPAJPGMNY
MZLORITVI
GwEGgPUeI
MNROYOEER

Output:

6,4 6,5 5,5 4,5 3,5 3,6 2,6 1,6
5,6 4,6 4,7 4,8

Total moves: 2
Points: 21

#TODO: more examples.

\$\endgroup\$
0
\$\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\$
  • \$\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\$ – Peter Taylor 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\$ – dkudriavtsev 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\$ – Peter Taylor 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

You must log in to answer this question.

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