A popular method for solving Rubik's cube consists of:
solving its first two layers, by convention starting with the white side
orienting the last layer's pieces so they face the same direction with their common colour - usually yellow, which is opposite white
permuting the last layer's pieces...
Connect Four is a two-player game. You may read rules here if unfamiliar.
A winning line is a line of 4 pieces of 1 color. A winnable line is a potential winning line of one color that is is not obstructed by opposite color pieces.
A winnable line for red may look like one of these:
For example,...
Your task is to write two programs/functions, in the same language.
Program 1: Verify that two inputs are anagrams of each other.
Program 2: Verify that two inputs differ from each other at every character position.
"Verify" means, return a value you define as true for this case, and a different ...
Mulenère cipher is a version of Vigenère ciphers, which uses multipling instead of adding.
Algorithm
It's simple. First, the password will repeated as much as reach a size bigger than length of the text input.
For encoding, ASCII code of each character of text will multiplied by the character in ...
Your challenge is to print any 100 consecutive digits of square root of 1000 (1000^0.5 or √1000). You must give the index at which that subsequence appears. The 31 is not included. For example, you could print any of the following:
Index 1..100: 622776601683793319988935444327185337195551393252168...
from Latexmk:
If you use cross-references, you often have to run LaTeX more than once ...
Sometimes cross-referenced location changed and you need to run LaTeX again to create the correct reference. Then something else changed again and you need to run another time. This repeats until the outpu...
Given a list of words (letters only) in no particular order, output the shortest string containing every word. Output must be lowercase, except the first letter of each word is uppercase. Input can be in any case you like. When there are multiple minimal solutions, output one.
Code golf.
Sample d...
Task:
Write a code golf program that, given two positive integers n and m, returns a list of the distances between consecutive prime numbers in the range [n, m] inclusive.
Note: My question if different from this one
Assumptions:
1 is considered the first prime number
n<m
Both n and m are inclus...
Speaking of underhanded questions, I wnoder how this one managed to evade the closed/locks that all others had faced:
Pathological Sorting
We thought underhanded stuff was off-topic and closed or locked as historical, but this one wasn't. Why?
I'm always amazed by some of the techniques used in normal languages, as well as the density and conciseness of the manipulation done in golfing languages.
Are there any recommended entertaining talks or videos which relate to golfing? I'm not necessary looking for a technical documentation or tu...
Rig The Lottery, but Don't Get Caught
I have read a news story about a programmer who worked for the state lottery and various friends and family of his won the lottery on key dates where had programmed it to use specific numbers. He ultimately got caught.
Assume you work for a sort of powerball ...
Objective
Compute \$\pi\$ using nothing but \$i\$ (\$\sqrt{-1}\$).
Guidelines
ONLY exponentiation and multiplication may be used (i.e. \$i^i\$ or \$ii\$)
No additional symbols may be used (so no addition, subtraction, parentheses)
The result must be real and cannot be complex.
If the solution is...
Your goal is to find out the order of the drivers in a race (1st, 2nd, 3rd, etc) for each time the start / finish line is crossed. This would allow someone to see the progression of a driver throughout the race, for example if they started in 3rd, then fell backwards to 5th halfway through the ra...
Challenge Brief
In “classic” Tetris you drop one tetromino after another, optionally rotating / sliding it left or right before it locks in place.
Your task is to take a finite piece sequence and report the final height of the stack (rows that contain at least one filled cell) after optimal place...
Find an NP-complete problem that covers all finite ASCII strings, and present a solver for the problem in the programming language of your choice.
By the definition, if there is a finite ASCII string input that yields an output that is neither truthy nor falsy, your submission is invalid. This pr...
We have a few questions related to pokemon types, but the only one that has you print the type chart requires you to take a parameter for dual typings which adds a ton of complexity, switches the axes around from a standard type chart, and shuffled the type order. Thus, we should standardize it u...
The Gather Operation
You may take in input and output in any reasonable format. Output should be result after the gather operation. You may write a function or full program. You can use any other syntax you like for the gather operation if it supports full gather's parameters.
This is code-golf, ...
Since the C and JS have a very similar syntax, I wondered if it would possible to do a Polyglot with the 2.
The JS should run in the console of a browser, and the C should compile with GCC.
Is challenges which are generally1 hard to solve like this challenge not good and will downvoted? I assume the question is well and no problem on itself, just hard to solve.
1: A hard challenge is not a challenge which hard to solve in some languages, it's hard to solve in any language, after al...
Stack Overflow have started a beta "challenges" page - see https://stackoverflow.com/beta/challenges
Have there been discussions about how that overlaps with this community, or if we want it to?
Welcome VIPs to the 33rd Squid Games. Players from the following numbers sequentially 21, 62, 67, 87, 96, 101, 151, 202, 218, 244, 308, 322, 360, 407, 453, 456 were given shirts to choose from numbers 1-16. Here is what they chose:
#1
#2
#3
#4
#5
#6
#7
#8
096
308
062
021
453
244
151
407
...
Generate four 2D arrays that follows a glider in Conway's life of game.
Each cell is 3x3 plus 1-width border.
Each frame, it advances 1 cycle and shift the image by 1/4 cell, aka. 1 pixel.
After 4 cycle it returns to original state.
Use three values in output to mean white, black and grey(cell ...
There is this game Genshin Impact, when an element is applied to an enemy i.e. Electro it remains for some time causing decay to the enemy health. For this challenge, we'll simplify this to a single integer representing the "aura strength" and a fixed "decay amount" per "tick." When the aura stre...
Local allocators can be beneficial in situations where tracking memory usage or releasing all allocated memory without running destructors at the end of an activity is possible. From that perspective, a memory arena, a custom thread-local allocator and a work-package-local allocator (e.g. Runnabl...
I'm overloaded with lots of stuff to implement for a language, and I'd find it easier to use natural language to implement it, perhaps prompting an existing AI with a huge specification and some existing resources it can reuse (like my parser) for building a type checker and maybe a build system....
In a specific language's build system (or package manager), checking third party sources (whether local or from a package registry) can be done in different ways.
NPM forces libraries to transpile TS/TSX to JS before being relied on due to the tsconfig.json configuration (which is ignored in thi...
Phi nodes join data flow based on incoming control flow edges.
Determination of incoming control flow can be encoded either by directly listing predecessors or by listing blocks dominating predecessors.
Since predecessors dominate themselves, that encoding is trivially convertible to dominator en...
What metric, what objective, do language developers of golfing languages like Vyxal, Jelly, etc. focus on optimizing when developing their languages to be as "golfy" as possible? "Reducing bytecount" is not the answer I'm looking for - that's the overall point of these languages. What measures do...
What's the history and reasoning behind the differences in the typeclass hierarchies in various functional programming language standard libraries? For instance, why does Applicative in Haskell extend Functor and require function definitions for pure and (<*>), whereas Applicative in PureScript e...
I've previously asked Compile-time reference resolution across Java-like packages. One of the answers unfortunately give a long paper, but it mentions about lazy caching, which I suppose I've done in my previous type checker (e.g. to avoid duplucate diagnostics; to skip certain type checking step...
I am interested in the concept of stackful coroutines, as how it is used by the developer in a language.
I have learned that Erlang and Go (perhaps some other languages) does have preemptive coroutines. As how I understand it, those "tasks" have "safe points", injected by the compiler where they ...
In most C-like languages, a call such as printf("%d", x) is followed by two parentheses; and I see that return(x); would be ugly compared to return x;, but why is the inconsistency?
In my language, for its official implementation, I'm planning to support an approach like React.js's one, which, I admit, looks more cryptic than approaches like (.NET XAML)/(Adobe MXML) if code comments aren't added, but well, other than that it looks okay.
I'd like to know if there is a better ...
In my language, for its official implementation, I'm planning to support an approach like React.js's one, which, I admit, looks more cryptic than approaches like (.NET XAML)/(Adobe MXML) if code comments aren't added, but well, other than that it looks okay.
I'd like to know if there is a better ...
In Adobe Flex (now Apache Flex and Apache Royale) there is support for ActionScript 3 and MXML files in MXMLC. MXML is used for describing UI components, where the root element tag is equivalent to defining a class that extends the type indicated by the tag, something like:
<!-- src/HelloWorld.mx...
I'm prototyping a language that is memory safe by managing all pointers (details irrelevant here).
I want to have a null-coalescing operator with high precedence, it should bind more closely than almost all other operators, so that individual variables can be "substituted" as needed without redun...
I actually drafted most of this question before the relavent stack overflow question but it's still relevant
C has a famously confusing operator precedence order. . It is divided into 15 levels and within the levels there is a clearly defined associativity. Post programmers don't fully remember t...
As a follow-up to How should I read type system notation? (since it doesn't give depth on that)
Type variables
An algorithm I'm trying to understand uses the $\alpha$ and $\beta$ symbols to denote type variables, and at the same time the paper also uses $A, B, C$ symbols to denote types. What are...
An algorithm I'm trying to understand uses the $\alpha$ and $\beta$ symbols to denote type variables, and at the same time the paper also uses $A, B, C$ symbols to denote types. What are exactly "type variables" versus "types"?
E.g.:
Are they locations holding a type at compile-time so that they...
Continuing from the question How does bidirectional typechecking for higher-ranked polymorphism work?
I'm very used to build type systems in an immediate way, where types are usually nominal and structural ones just interned (although I won't intern at all anymore due to factors like doc. comment...
In my language everything except $\text{undefined}$ and $\text{null}$ are auto managed objects extending a very broad class, where primitives like numerics and booleans are auto-boxed as needed. Of course union types are not necessarily $\in \text{the broad class}$.
In type theory they often call...
What are some options for integrating subtyping with Damas-Hindley-Milner inference? gets into this tangentially at the end of Jon Purdy's post ("Placing various restrictions on recursion (acyclicity)"). If not specific algorithms, general approaches would be appreciated. I am guessing having onl...
I've done some noob work in JavaScript before and it took around 1 minute to type-check, but there are the following to take:
I wasn't following V8's inline cache optimization guidelines. And for a dumb reason I was doing prototype work manually instead of using classes directly.
I decided not t...
Interpret Custom Language
First Line of Input: An ASCII character, which this character in the language will increase counter by 1
Second Line of Input: An ASCII character, which this character in the language will print a character to output with ASCII code of counter mod 127, and sets counter t...
C has a famously confusing operator precedence order. . It is divided into 15 levels and within the levels there is a clearly defined associativity. Post programmers don't fully remember the exact precedence rules when writing code citation needed, so to aid understandably, style guides usually r...
Continuing from the question How does bidirectional typechecking for higher-ranked polymorphism work?
I'm very used to build type systems in an immediate way, where types are usually nominal and structural ones just interned (although I won't intern at all anymore due to factors like doc. comment...
What are some options for integrating subtyping with Damas-Hindley-Milner inference? gets into this tangentially at the end of Jon Purdy's post ("Placing various restrictions on recursion (acyclicity)"). If not specific algorithms, general approaches would be appreciated. I am guessing having onl...