CMC: Given a list of strings, find the longest common prefix among them. There will always be at least 1 string in the list. The longest common prefix is the empty string if there's no shared prefixes.
General approach for a quine is: Have some way to represent arbitrary text, then write a piece of code that decodes that and prepends the encoded text formatted somehow
Then compress the decoder and pass that into the decoder
The Hexagony quine I remember seeing starts by pushing a big number and then feeding it into a decoder. No, I can't, for a number of reasons:
1. Single-digit numbers take two characters to push if you can't get them by manipulating what's already there ('0). 11 and up also take 2, but you use push-char rather than push-int. 10 is fun because the interpreter ignores newlines.
2. There is no "numbers are automatically concatenated as in decimal" functionality that Hexagony has
So then the general structure of the program would look like this:
A pair of very deliberate decisions makes everything slightly more difficult: 1. There is no "stack depth" instruction 2. Indexing past the bottom of the stack is UB
I might not be able to figure this out tonight but I have direction at least
I could even split the "bunch of data" section into two rows if I need to, and print the top half of the stack before the bottom half. This works because the last row can omit trailing NOPs; more than two rows will be difficult.
Introduction
As of today, June 5th, 2023, a large number of moderators, curators, contributors, and users from around Stack Overflow and the Stack Exchange network are initiating a general moderation strike. This strike is in protest of recent and upcoming changes to policy and the platform that...
Background
Imagine that I'm creating a really long necklace, consisting of only two characters, A and B. You must count the number of occurrences of the substring AB in the string.
However, since it's a necklace, you must also consider if the last character and the first character join to make AB...
This challenge is about computing the chromatic number of special types of graphs.
Input
The input will consist of two integers.
A positive integer \$n > 1\$.
A distance \$d < n\$.
Task
The two inputs values will define a graph with \$2^n\$ nodes. Each node corresponds to a different binary arr...
@PlaceReporter99 I don't really know either but you already treat odd and even numbers differently and primes being important for chromatic numbers seems plausible. I really don't know though except I'm curious what's going on
I see code-golf2631352023-07-21 16:11:172023-07-22 06:13:58code-golf2631352023-07-21 16:11:172023-07-22 04:20:28code-golf2631352023-07-21 16:11:172023-07-22 02:57:42
@PlaceReporter99 yes but I only provided them for people to test their code. It would be like if the question asked you to implement addition and gave 10 examples and your code only every outputted those ten answers
and didn't actually do any addition
as a concrete example, it doesn't give the right answer for 9,2
Optimising for the given test cases
This applies to code-challenges and things like fastest-code, where you write some code that is measured by a criterion like runtime or size of your output (e.g. in compression challenges). These often employ an obviously finite set of test cases, because you ...
It's not really valid but the challenge was more intended to figure out an efficient method than as an actual challenge so for that purpose a hint towards the solution is helpful. It was really asked on the wrong site for that purpose though so IDK
I doubt PlaceReporter, while smart, has enough formal math education to effectively prove the validity of algorithms without help
for node_from in tqdm(range(2**num_bits)):
for node_to in range(2**num_bits):
if (node_from ^ node_to).bit_count() == dist:
edges.append([node_from, node_to])
@mousetail the point is that the goal isn't to reproduce the numbers in the test set.It is to do the task as set out in the challenge
btw for a string n if there are 2 different strings x,y which have the same hamming distance to n they can't possibly have that hamming distance to each other.
@PlaceReporter99 would you mind deleting your comments from the question please? They don't make sense any more
thx
@PlaceReporter99 "For odd d the chromatic number will always be 2: The arrays for any two connected nodes differ in an odd number of positions, meaning the number of ones in the arrays will have a different parity. This means that coloring the nodes depending on the parity of the number of ones will always give a 2-coloring."
for even numbers d, if the hamming distance between (n and x) and (n and y) is d, x and y will also have the same hamming distance iff, when mapping n to all 0s, mapped x & mapped y have exactly d/2 bits with a value of 1.
let me define what I mean by mapping n to all 0's.
actually let me reexplain
for even numbers d, if the hamming distance between (n and x) and (n and y) is d, x and y will also have the same hamming distance iff ((x xor n) and (y xor n)) have exactly d/2 bits with a value of 1.
WumpusWars King of the Hill
This is probably going to stay in the sandbox for a few weeks, until I get the time to write the actual scoring code up... Yep, I'm both lazy and busy :P I'm not very good at coding challenges but I'm good at thinking up creative ideas, so this time my idea is to try ...
@ShiranYuan They would have to know a collision in the SHA256 hash system for the answer to be valid, so the US government would be very interested. — I am kind of a language dev2 hours ago
@Iamkindofalanguagedev Ok so maybe sending the challenge out would help CGCC get government attention and thus more publicity :P — Shiran Yuan1 hour ago