text:
# Rotational friction on small globular proteins: Combined dielectric and hydrodynamic effect

Mukherjee, Arnab and Bagchi, Biman (2004) Rotational friction on small globular proteins: Combined dielectric and hydrodynamic effect. [Preprint]

 Preview
PDF
Rotational-sl.no.230-pdf.pdf

Rotational friction on proteins and macromolecules is known to derive contributions from at least two distinct sources –hydrodynamic (due to viscosity) and dielectric friction (due to polar interactions). In the existing theoretical approaches, the effect of the latter is taken into account in an ad hoc manner, by increasing the size of the protein with the addition of a hydration layer. Here we calculate the rotational dielectric friction on a protein ($\zeta_{DF}$) by using a generalized arbitrary charge distribution model (where the charges are obtained from quantum chemical calculation) and the hydrodynamic friction with stick boundary condition, ($\zeta_{hyd}^{stick}$) by using the sophisticated theoretical technique known as tri-axial ellipsoidal method, formulated by Harding [S. E. Harding, Comp. Biol. Med. 12, 75 (1982)]. The calculation of hydrodynamic friction is done with only the dry volume of the protein (no hydration layer). We find that the total friction obtained by summing up $\zeta_{DF}$ and $\zeta_{hyd}^{stick}$ gives reasonable agreement With the experimental results, i.e., $\zeta_{exp} \approx \zeta_{DF} + \zeta_{hyd}^{stick}$.

format: plain


text:
## 物理：狭义相对论中的质量增大是质量真的变大了吗？为什么不能超光速？

$m=\frac{m_0}{\sqrt{1-v^2/c^2}}$

$m=\frac{1}{\sqrt{1-v^2/c^2}}m_0=\gamma m_0$

## 物理学：Leidenfrost Phenomenon与Random Walk

Leidenfrost Phenomenon 翻译成 “莱顿弗罗斯特现象”，是指液体不会润湿炙热的表面，而仅仅在其上形成一个蒸气层的现象，由科学家莱顿弗罗斯特在1756年发现。

When Water Flows Uphill

The Inverse Leidenfrost Effect

The WALKING WATER Mystery (in SPACE and SLOW MOTION!) – Smarter Every Day 160

## Candidate theories

There are a number of proposed quantum gravity theories.[33] Currently, there is still no complete and consistent quantum theory of gravity, and the candidate models still need to overcome major formal and conceptual problems. They also face the common problem that, as yet, there is no way to put quantum gravity predictions to experimental tests, although there is hope for this to change as future data from cosmological observations and particle physics experiments becomes available.[34][35]

There are a number of other approaches to quantum gravity. The approaches differ depending on which features of general relativity and quantum theory are accepted unchanged, and which features are modified.[51][52] Examples include:


text:
# 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 your first try can be difficult, and there is a much better chance of your challenge being well received if you post it in the Sandbox first.

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

## print 1000 digits of $$\\pi\$$ base 3

The question was on hold for "unclear what you're asking". Really? What was the real reason?

No input. We need to compute and print the values of $$\\pi\$$ and Euler constant $$\\gamma\$$
to $$\1000\$$ digits after decimal point
in base $$\3\$$ with digits $$\-1,0,1\$$ represented as -,0,+ respectively.

For $$\\pi\$$ output is likely starts with +0.0++-+++-000-0++-++0+-++++++00--++.
$$\\pi\$$ can be computed as series of $$\\tan^{-1}\$$, $$\\gamma\$$ -- like here, or any other method will do if fast enough to provide needed accuracy for at most $$\60\$$ seconds for both numbers.

Storing or using entire pre-computed values are forbidden.
One may though use wolframalpha regular-base-3 values for checking their output -- for $$\\pi\$$ and $$\\gamma\$$ (hit "More digits" some times to get $$\1000\$$).

Scoring method is code-golf, but TIO should run at most $$\60\$$ seconds.
Good luck. Please fell free to improve this post.

• "Storing or using entire pre-computed values are forbidden" is definitely one source of unclarity. What amount of pre-computation could be done? All but the last digit? All but two? Further there doesn't seem to be any reason to ask for two numbers, nor is there a on-site way to check the results. You shouldn't make your answerers have to go to an external site to verify their submission. – FryAmTheEggman Nov 21 '19 at 19:43

# Introduction

As programming languages reproduce are created, documentation is even more important for programmers. Your task is simple: output the esolangs.org documentation for your programming language.

With wikis being wikis, languages are heavily penalized in this challenge for being used often and for being interesting to write about, the goal here is to draw attention to languages that may not get utilized otherwise.

# Challenge

For this task, you will need to output the source for the article on esolangs.org for your language, with greater than or equal to 95% accuracy. Your score is your program length in bytes, as in other challenges.

Languages not on this multi-page list of languages as of the time of this posting are ineligible.

Standard loopholes are forbidden.

None

## Output

The source (as of this challenge being posted), for the esolangs wiki page for your language, with at least 95% accuracy.

# Example

Language: ///

Output:

{{featured language}}
'''///''' (pronounced "slashes") is a minimalist [[Turing-complete]] esoteric programming language, invented by Tanner Swett ([[User:Ihope127]]) in 2006 based on [[wikipedia:sed|the "s/foo/bar/" notation that everybody seemed to be using in IRC]]. The only operation is repeated string substitution, using the syntax <code>/''pattern''/''replacement''/</code>. Despite its extreme simplicity – there isn't even an obvious way to create a loop – it was proved [[Turing-complete]] by [[Ørjan Johansen]] in 2009, who created [[#Bitwise Cyclic Tag interpreter|an interpreter]] for the Turing-complete language [[Bitwise Cyclic Tag]].
...

• -1: Interesting idea, but I don't think it can work as a challenge. I'm not convinced that kolmogorov-complexity-ing a volatile data source is a good idea. What happens if the page is edited two weeks from now? – Beefster Dec 13 '19 at 22:39
• Loophole. I blanked the esolangs.org documentation of my language. Therefore I can output nothing to achieve my goal. – user85052 Dec 18 '19 at 4:07
• @A̲̲ nope, you have to output what it was at the time of posting – iPhoenix Dec 18 '19 at 11:53
• Obviously, you blank the page and then post before it gets fixed. – the default. Dec 19 '19 at 13:55

# Background

"The finite element method (FEM), is a numerical method for solving problems of engineering and mathematical physics." -Wikipedia

One of the elementary formulations of fem in structural engineering is the truss. They are very basic, but have a lot of utility.

When one designs a truss, especially in the preliminary stages some assumptions are usually made to simplify the procedure. For instance, members are assumed to carry only tension or compression load. This means that we can only load the truss at the nodals points. Depending on how the connection is designed and detailed, these assumptions can be quite close to how the structure actually will behave in the real world.

So, what's so special about having a member with only axial loading? Well, there's a property of the material itself we can take advantage of. Most materials have a property of 'linear elasticity' when the material is stretched or compressed a very small amount. A material like steel is quite ductile, and so this range of linear elasticiticy is quite large, as compared to something like ceramics. This means if we push or pull on some steel with a small force, it will displace a proportional amount. If we double our applied force, its displacement will double as well. Also if we release our force, the material will go back to its original configuration. So as long as we deform the material elastically, we won't waste any energy deforming it plastically.

If you have ever taken a physics class, you may know that a spring has these exact same properties. Therefore, we can idealize all the members in our truss as just simple springs.

## Building up to direct stiffness method

A zero dimensional spring equation looks like this. $$K \cdot u = F$$ This relates the force required to any deformation of the spring. The force and deformation are linearly proportional by $$\K\$$, the spring constant. The constant $$\K\$$ has units of [force/distance] e.g. [pounds/in] or [kilograms/meter]. For example, if $$\K = 50 lb/in\$$, it would take $$\50lb\$$ of force to displace the spring $$\1\$$ inch, and $$\100lb\$$ to displace the spring $$\2\$$ inches. The stiffness in our truss members is similar:

$$K = \frac{EA}{L}$$

$$\E\$$ is Young's Modulus, $$\A\$$ is the cross sectional area, and $$\L\$$ is the length of the bar. The only scary thing here is probably $$\E\$$, but it's not too crazy. It's kind of like stiffness, but it's normalized. Instead of [force/distance] we have [stress/strain]. Stress is like the normalized force, it's the amount of force over the area of the element. Strain is like the normalized displacement, it's calculated by (change in length/original length) or percent elongation.

Let's develop this a bit more and put it in matrix form. This will allow us to relate the force on one side of the bar to force on the other.

$$\frac{EA}{L} \left[\begin{array}{cc} 1 & -1\\ -1 & 1 \\ \end{array}\right] \cdot \left[\begin{array}{c} u_1 \\ u_2 \\ \end{array}\right] = \left[\begin{array}{c} f_1 \\ f_2 \\ \end{array}\right]$$

Now we have our one dimensional spring equation. Instead of a single displacement, we have a displacement vector. We can displace both sides of the spring independently and find what the resultant forces on each side will be.

Examples:

Displace the right node 1 unit to the right $$\frac{EA}{L} \left[\begin{array}{cc} 1 & -1\\ -1 & 1 \\ \end{array}\right] \cdot \left[\begin{array}{c} 0 \\ 1 \\ \end{array}\right] = \left[\begin{array}{c} f_1 \\ f_2 \\ \end{array}\right]\\ f_1 = \frac{-E A}{L}, f_2 = \frac{E A}{L}$$

This makes sense, because if we displace the right side by a unit, we need a force in the equal and opposite direction on the left side to not drag that side along.

Displace both nodes $$\1\$$ unit to the right $$\frac{EA}{L} \left[\begin{array}{cc} 1 & -1\\ -1 & 1 \\ \end{array}\right] \cdot \left[\begin{array}{c} 1 \\ 1 \\ \end{array}\right] = \left[\begin{array}{c} f_1 \\ f_2 \\ \end{array}\right]\\ f_1 = 0, f_2 = 0$$

This makes sense, because if we displace both sides at the same time, the distance between them does not change. It would be as if we just translated the spring across the table and did not strech it. We don't need some force holding it in a deformed configuration.

That's cool, but one dimensional structures are lame. I want a two dimensional structure to build a bridge! Well, it's not that much more difficult. We just need to add a $$\y\$$ degree of freedom (dof) on each side of the spring. We can also couple our $$\x\$$ and $$\y\$$ dofs into one angle from the $$\+x\$$ direction to simplify our matrix. And so with some magic (rotational matrix) we can get the following:

## Step 1 - Local Stiffnes Matrix

This is our local stiffness matrix, also known as $$\K^e\$$. It has all the same properties as our one dimensional stiffness matrix, but it takes into account $$\(x,y)\$$ displacements at each side of the spring. This gives us a total of four degrees of freedom.

You may begin to see how powerfull this method can be. We can now iterate through all of our elements and just calculate the angle and length from its nodes. This will give us $$\i\$$ local stiffness matrices, where $$\i\$$ is the number of elements. For example if we have $$\3\$$ elements in our truss, we can calculate our $$\3\$$ local matrices for each element.

Let's go through an example.

If we calcualted the local stiffness matrices for the figure above ($$\EA = 1\$$, $$\L(1,2)=1\$$), you would find: $$\hspace{50pt}\begin{array}{cccc}1 & 2 & 3 & 4\\\end{array} \\ K(1) = \begin{array}{c} 1 \\ 2 \\ 3 \\ 4 \\ \end{array} \left[\begin{array}{cccc} 1 & 0 & -1 & 0\\ 0 & 0 & 0 & 0\\ -1 & 0 & 1 & 0\\ 0 & 0 & 0 & 0\\ \end{array}\right]$$ $$\hspace{50pt}\begin{array}{cccc}3 & 4 & 5 & 6\\\end{array} \\ K(2) = \begin{array}{c} 3 \\ 4 \\ 5 \\ 6 \\ \end{array} \left[\begin{array}{cccc} 0 & 0 & 0 & 0\\ 0 & 1 & 0 & -1\\ 0 & 0 & 0 & 0\\ 0 & -1 & 0 & 1\\ \end{array}\right]$$ $$\hspace{50pt}\begin{array}{cccc}1 & 2 & 5 & 6\\\end{array} \\ K(3) = \begin{array}{c} 1 \\ 2 \\ 5 \\ 6 \\ \end{array} \left[\begin{array}{cccc} 0.64 & 0.48 & -0.64 & -0.48\\ 0.48 & 0.36 & -0.48 & -0.36\\ -0.64 & -0.48 & 0.64 & 0.48\\ -0.48 & -0.36 & 0.48 & 0.36\\ \end{array}\right]$$

Where the numbers outside the array correspond to the global matrix indicies.

## Step 2 - Assemble local matrices into the global matrix

These local matricies are uncoupled, and so they don't really tell us much about the global system of the truss, or how to solve for the displacements with given forces. However, we can do something called matrix assembly to put them all into one big global stiffness matrix. This will couple all of our local element equations so we can solve our system of equations.

We do this by matching the local degrees of freedom to our global degrees of freedom, then add our local to our global matrix.

Since our global truss has 3 nodes and each node has $$\2\$$ dofs $$\(x,y)\$$, our global matricies are of size 6. $$\K \in \mathbb R^{6 \times 6}, F \in \mathbb R^{6 \times 1}, u \in \mathbb R^{6 \times 1}\$$. If we layed out the dof number for each row/column of our stiffness matrix we would get the following:

$$\hspace{35pt}\begin{array}{cccccc}1 & 2 & 3 & 4 & 5 & 6\\\end{array} \\ K = \begin{array}{c} 1 \\ 2 \\ 3 \\ 4 \\ 5 \\ 6 \\ \end{array} \left[\begin{array}{cccccc} 0 & 0 & 0 & 0 & 0 & 0\\ 0 & 0 & 0 & 0 & 0 & 0\\ 0 & 0 & 0 & 0 & 0 & 0\\ 0 & 0 & 0 & 0 & 0 & 0\\ 0 & 0 & 0 & 0 & 0 & 0\\ 0 & 0 & 0 & 0 & 0 & 0\\ \end{array}\right]$$

From step 1, the global dofs of $$\k(1)\$$ were $$\1,2,3,4\$$. This means we just add them index by index into our global stiffness matrix.

$$\hspace{35pt}\begin{array}{cccc}1 & 2 & 3 & 4\\\end{array} \\ k(1) = \begin{array}{c} 1 \\ 2 \\ 3 \\ 4 \\ \end{array} \left[\begin{array}{cccc} k_{11} & k_{12} & k_{13} & k_{14}\\ k_{21} & k_{22} & k_{23} & k_{24}\\ k_{31} & k_{32} & k_{33} & k_{34}\\ k_{41} & k_{42} & k_{43} & k_{44}\\ \end{array}\right]$$

If we match up the indicies, we can just add: $$K_{11} += k_{11}\\ K_{12} += k_{12}\\ K_{13} += k_{13}\\ K_{14} += k_{14}\\ K_{21} += k_{21}\\ ...$$

We can see if we do this for all three elements, we can match up where they will go in the global matrix with colors. This is shown in the figure below.

## Step 3 - Add bounds on the stiffness matrix, and modify the force vector

We are almost done! But there is one final important step. If we were given an arbitrary force vector and tried to find the displacements, our truss would just fly away to infinity. This is because there are no boundary conditions! There is nothing yet holding on to it, resisting the forces. But guess what? There's another neat trick we can use. This will keep everything in matrix form and give us the answers we want when we solve our system of equations.

All we do is remove the influence of the node on the force vector. For this example, we will assume the constraint on dof1 is set to $$\g\$$.

For the general case, we just set $$\dof1 = g\$$ in the force vector, and subtract g* the column of $$\K\$$ with dof1 = 0. If $$\g=0\$$, we just need to set $$\dof1 = 0\$$ in the force vector.

$$F = \left[\begin{array}{c} F_1\\ F_2\\ F_3\\ \vdots\\ F_n\\ \end{array}\right] \Rightarrow \left[\begin{array}{c} g\\ F_2\\ F_3\\ \vdots\\ F_n\\ \end{array}\right] - g \left[\begin{array}{c} 0\\ K_{21}\\ K_{31}\\ \vdots\\ K_{n1}\\ \end{array}\right]$$

Then we just restrain our stiffness matrix. This can be done by zeroing out the row and column of $$\dof1\$$, then setting $$\(dof1,dof1)=1\$$ as shown below.

$$K = \left[\begin{array}{cccc} K_{11} & K_{12} & \cdots & K_{1n}\\ K_{21} & K_{22} & \cdots & K_{2n}\\ \vdots & \vdots & \ddots & \vdots\\ K_{n1} & K_{n2} & \cdots & K_{nn}\\ \end{array}\right] \Rightarrow \left[\begin{array}{cccc} 1 & 0 & \cdots & 0\\ 0 & K_{22} & \cdots & K_{2n}\\ \vdots & \vdots & \ddots & \vdots\\ 0 & K_{n2} & \cdots & K_{nn}\\ \end{array}\right]$$

## Step 4 - Solve with linear algebra

Now we are finally back to our equation of a spring. However, in this case each variable below is an array or vector of size $$\n\$$, where $$\n\$$ is the number of $$\nodes \times 2\$$.

$$\mathbf{K} \cdot \mathbf{u} = \mathbf{F}$$

We can simply solve this system of equations by taking the inverse of the stiffness matrix. This gives us:

$$\mathbf{u} = \mathbf{K}^{-1} \cdot \mathbf{F}$$

This can be easily solved by a computer. For example Python:

    u = np.linalg.solve(K, F)

# Rules

• Input data type can for the most part be changed for your needs. However, it should be human-readable, or at least reasonable to be able to change the input for a new structure easily.

Example input

E = .
A = .
nodes = [., ., ...]
elements = [., ., ...]
forces = [., ., ...]
bounds = [., ., ...]

Example output

[., ., ...]

• Output can be in any form, as long as it's in order of dof.
• Inbuilt FEM functions not allowed. You must construct and assemble your matrices yourself. Inbuilt linear algebra is fine.

# Test Cases

From UNM example in references:

E = 29500
A = 1
nodes = [[0,0],[40,0],[40,30],[0,30]]
elements = [[1,2],[2,3],[1,3],[3,4]]
forces = [[0,0],[20,0],[0,-25],[0,0]]
bounds = [[0,0],[None,0],[None,None],[0,0]]

Output:

[0.0 0.0 0.027 0.0 0.006 -0.022 0.0 0.0]

Large Truss Input:

E = 29000
A = 25
nodes = [[0,0],[100,0],[200,0],[300,0],[0,100],[100,100],[200,100],[300,100],[400,100]]
elements = [[1,2],[1,5],[1,6],[2,3],[2,6],[2,7],[3,4],[3,7],[3,8],[4,8],[4,9],[5,6],[6,7],[7,8],[8,9]]
forces = [[0,-10],[0,-10],[0,-10],[0,-10],[0,0],[0,0],[0,0],[0,0],[0,-10]]
bounds = [[0,0],[None,None],[None,None],[None,None],[-0.01,0],[None,None],[None,None],[None,None],[None,None]]

Output:

[ 0.     0.    -0.008 -0.025 -0.012 -0.061 -0.014 -0.1   -0.01   0.     0.004 -0.019  0.012 -0.057  0.016 -0.098  0.018 -0.136]

Here is what the geometry and displacement looks like for the test cases so you can visualize it.

# References

Here are some references that may be useful if you are looking for some more in-depth information.

http://www.unm.edu/~bgreen/ME360/Finite%20Element%20Truss.pdf

https://engineering.purdue.edu/~aprakas/CE474/CE474-Ch5-StiffnessMethod.pdf

http://people.duke.edu/~hpgavin/cee421/truss-method.pdf

http://ocw.ump.edu.my/pluginfile.php/9806/mod_resource/content/2/7_Plane_Truss_Example.pdf

https://nptel.ac.in/content/storage2/courses/105105109/pdf/m4l24.pdf

And lastly, here is some working python 3 code that I wrote. It should lay out all the steps cleanly.

import numpy as np
from math import sqrt,sin,cos,acos

def ex_unm():
"""Example - Verification from UNM"""
print("Example UNM")
# Material Properties
E = 29500 # (units = ksi)
A = 1 # (units = in^2)
# Node locations (units = in)
nodes = {1:(0,0), 2:(40,0), 3:(40,30), 4:(0,30)}
# Element connections
elements = {1:(1,2), 2:(3,2), 3:(1,3), 4:(4,3)}
# Nodal forces (units = kips)
forces = {2:(20,0), 3:(0,-25)}
# Nodal Boundaries (units = in)
bounds = {1:{'x':0,'y':0},2:{'y':0},4:{'x':0,'y':0}}
# Run Analysis
displacements = analyze(E,A,nodes,elements,forces,bounds)
for i,disp in enumerate(displacements):
print("Node {},{}: {}".format(int(i/2)+1,['x','y'][i%2],round(disp,5)))

plot_truss(nodes, elements, displacements, 200)

def ex_big_boi():
"""Example - Large Truss"""
print("Example BIG BOI")
# Material Properties
E = 29000 # (units = ksi)
A = 25 # (units = in^2)
# Node locations (units = in)
nodes = {1:(0,0), 2:(100,0), 3:(200,0), 4:(300,0),
5:(0,100), 6:(100,100), 7:(200,100), 8:(300,100), 9:(400,100)}
# Element connections
elements = {1:(1,2), 2:(1,5), 3:(1,6),
4:(2,3), 5:(2,6), 6:(2,7),
7:(3,4), 8:(3,7), 9:(3,8),
10:(4,8), 11:(4,9),
12:(5,6), 13:(6,7), 14:(7,8), 15:(8,9)}
# Nodal forces (units = kips)
forces = {1:(0,-10), 2:(0,-10), 3:(0,-10), 4:(0,-10), 9:(0,-10)}
# Nodal Boundaries (units = in)
bounds = {1:{'x':0,'y':0}, 5:{'x':-0.01,'y':0}}
#bounds = {1:{'x':0,'y':0}, 5:{'x':0,'y':0}}
# Run Analysis
displacements = analyze(E,A,nodes,elements,forces,bounds)
for i,disp in enumerate(displacements):
print("Node {},{}: {}".format(int(i/2)+1,['x','y'][i%2],round(disp,5)))

plot_truss(nodes, elements, displacements, 500)

"""Visualization, not really needed but may be good to see"""
import matplotlib.pyplot as plt

def plot_truss(nodes, elements, u, scale):
"""A very simple plot to show geometry and displacements of nodes"""
x = [coords[0] for node,coords in nodes.items()]
y = [coords[1] for node,coords in nodes.items()]
ux = x + u[::2] * scale
uy = y + u[1::2]* scale

fig,ax = plt.subplots()
# Plot original Points
ax.plot(x,y,'o',color=(0.5,0.5,0.5))
# Plot original Elements (Theres probably a better way to do this)
for element,eleNodes in elements.items():
ex = [x[i-1] for i in eleNodes]
ey = [y[i-1] for i in eleNodes]
ax.plot(ex,ey,color=(0.5,0.5,0.5))

# Plot displaced Points
ax.plot(ux,uy,'o',color=(0,0,1))
# Plot displaced Elements (Theres probably a better way to do this)
for element,eleNodes in elements.items():
ex = [ux[i-1] for i in eleNodes]
ey = [uy[i-1] for i in eleNodes]
ax.plot(ex,ey,color=(0,0,1))

# Make plot have same xy scale
ax.axis('equal')
#fig.tight_layout()
ax.set_title("Truss Geometry and Displacement, Scale = {}".format(scale))

def analyze(E, A, nodes, elements, forces, bounds):
"""Analyze a given system and return the nodal displacements"""
# Assemble global matricies
K = gen_global_K(E,A,nodes,elements)
F = gen_global_F(nodes,forces)
#F = restrain_stiffness(K, F, bounds)
restrain_stiffness(K, F, bounds)
# Solve K*u=F -> u=K^-1*F
u = np.linalg.solve(K, F)
# return the nodal displacements
return u

def gen_global_K(E, A, nodes, elements):
"""Generate the Global stiffness Matrix"""
# Initialize Global Stiffness Matrix
size = len(nodes)*2
K = np.zeros([size,size])

# Itterate through each element and add its local stiffness to global stiffness
for element,(node_1,node_2) in elements.items():
node_1_xy = nodes[node_1]
node_2_xy = nodes[node_2]
# Element length
L = sqrt((node_2_xy[0]-node_1_xy[0])**2 + (node_2_xy[1]-node_1_xy[1])**2)
# Get this element's local stiffness roated into global plane
K_local = (E*A/L) * gen_local_K(node_1_xy, node_2_xy)
# Assemble local matrix into global
assemble(K, K_local, node_1, node_2)
return K

def gen_local_K(n1, n2):
"""Create a local stiffness matrix from two nodes' angle"""
angle = gen_angle(n1,n2)
c  = cos(angle)**2
s  = sin(angle)**2
cs = cos(angle) * sin(angle)
# Create the local K matrix
K_local = np.array([[ c , cs,-c ,-cs],
[ cs, s ,-cs,-s ],
[-c ,-cs, c , cs],
[-cs,-s , cs, s ]])
return K_local

def gen_angle(n1, n2):
"""Find angle between two nodes and +x axis"""
v1 = np.array([n2[0]-n1[0],n2[1]-n1[1]])
v2 = np.array([1,0])
return acos(np.dot(v1,v2) / (np.linalg.norm(v1) * np.linalg.norm(v2)))

def assemble(K, K_local, n1, n2):
"""Assemble a local element stiffness matrix into the global stiffness"""
# Degrees of freedom of our local element
dofs = [2*(n1-1), 2*(n1-1)+1, 2*(n2-1), 2*(n2-1)+1]
# Go element by element to add matrix
for i_local,i_global in enumerate(dofs):
for j_local,j_global in enumerate(dofs):
K[i_global,j_global] += K_local[i_local,j_local]

def gen_global_F(nodes, forces):
"""Generate the global force vector"""
F = np.zeros(2*len(nodes))
for node,(f_x,f_y) in forces.items():
dof = 2*(node-1)
F[dof] = f_x
F[dof+1] = f_y
return F

def restrain_stiffness(K, F, bounds):
"""Use a given displacement bound to modify matricies"""
dir = {'x':0, 'y':1}
for node,this_bound in bounds.items():
for coord,disp in this_bound.items():
# Get what dof the bound is
dof = (node-1)*2 + dir[coord]

"""Move the fixed displacement over to F (since it's constant)"""
# Get displaced F by reducing by given displacement * stiffness column
# Must use -= to ensure python evaluates in-place
#   We don't need to return the array if it's passed by reference
F -= disp * K[:,n]
# Set the Force value at that dof to the given displacment
F[n] = disp
# Clear stiffness matrix dof row & col

"""Zero out row and col of dof, then make [n,n] = 1"""
for i in range(np.size(K,0)):
K[n,i] = 0
K[i,n] = 0
K[n,n] = 1

if __name__ == "__main__":
# Set print options if you want to print an array nicely (easier for debug)
np.set_printoptions(precision=2, suppress=True, linewidth=np.inf)
ex_unm()
ex_big_boi()

plt.show()

Good Luck!

• Really cool introduction to FEM! I allowed myself to make some corrections and convert some more equations to mathjax, I hope you are ok with that. Some points I noticed that I would suggest improving: If you introduce a new variable, always describe what it is: It doesn't seem clear from the start what $u$ is (displacement?) or how $\beta$ is defined. Then I'd also try to make the indexing consistent: I'd always use the indices like $K_i$ insetad of $K(i)$. – flawr Dec 28 '19 at 14:32
• Similarly I'd avoid reusing the same symbol: For example for $k(1)$ you reuse the symbol $k$ for its entries, so I'd recommend rewriting it as maybe $\vec k_1$. – flawr Dec 28 '19 at 14:35
• You talk about the degrees of freedom "dofs", aren't these just the entries of $u$? – flawr Dec 28 '19 at 14:37
• And what type of challenge is it anyway? code-golf or something else? – flawr Dec 28 '19 at 14:37
• Thanks! Yea, the u vector is the displacement of each node. It is common to have it in the form {node1 x, node1 y, node2 x, node2 y.,,,}. Each element of the vector would be a degree of freedom, and together they would be the degrees of freedom of the entire structure. However, the u vector is not the actual degrees of freedom, it is just the displacements at each degree of freedom. For instance, the force vector would have a force at each degree of freedom. I think it wold be standard code-colf, least bytes wins, however I'm not sure if there's a better challenge it should go into. – WretchedLout Dec 29 '19 at 4:21

# 101 Hello Worlds

I have a project where I'm trying to collect 101 versions of "Hello, World" using obscure and over-engineered approaches in JavaScript/Node.js:

https://github.com/georgemandis/101-hello-worlds

We're up to 38 so far and I've really enjoyed the community contributions.

I recognize the way this is phrased at the moment isn't compatible with the way Code Golf is setup, but I feel like there could be a large overlap with people who might be interested and this community.

Does this seem like something that would be welcome here? Would others have suggestions for how I might re-word this to create a suitable entry for Code Golf?

If it's not suitable or welcome here I respect being downvoted into oblivion and can remove the answer.

Thanks!

• Thanks for using the Sandbox. The answer is that no, this isn't really suited to the Code Golf site. The closest winning criterion to use would be popularity-contest, but that was retired a while ago, since it wasn't really objective. If you want inspiration though, you can look at the hello-world tag, which has a lot of interesting restrictions on hello world programs. For example, there's no repetition, radiation-hardened, polyglots, palindromes etc. – Jo King Feb 11 '20 at 4:52
• Thanks @JoKing. I'll take a look at that tag. I think I'll add a tag to it in my project's README as well to give other people inspiration. – George Mandis Feb 11 '20 at 14:28

# Hello, World, but looong

I couldn't find out that this challenge exists

If this challenge exists, let me know

Write a simple Hello, World! program.

The winner is the person who has the longest code.

However, any subsequence except itself cannot be the answer.

## Input

You can have input in which way.

## Output

Hello, World!

• – Adám Feb 13 '20 at 13:07

## Check if There is a Valid Path in a Grid

Given a m x n grid. Each cell of the grid represents a street. The street of $$\grid[i][j]\$$ can be:

• 1 which means a street connecting the left cell and the right cell.
• 2 which means a street connecting the upper cell and the lower cell.
• 3 which means a street connecting the left cell and the lower cell.
• 4 which means a street connecting the right cell and the lower cell.
• 5 which means a street connecting the left cell and the upper cell.
• 6 which means a street connecting the right cell and the upper cell.

You will initially start at the street of the upper-left cell $$\(0,0)\$$. A valid path in the grid is a path that starts from the upper left cell $$\(0,0)\$$ and ends at the bottom-right cell $$\(m - 1, n - 1)\$$. The path should only follow the streets.

Notice that you are not allowed to change any street.

Return true if there is a valid path in the grid or false otherwise

Test Case 1:

Input: grid = [[2,4,3],[6,5,2]]
Output: true
Explanation: As shown you can start at cell (0, 0) and visit all the cells of the
grid to reach (m - 1, n - 1).

Test Case 2:

Input: grid = [[1,2,1],[1,2,1]]
Output: false
Explanation: As shown you the street at cell (0, 0) is not connected with any street of
any other cell and you will get stuck at cell (0, 0)

Testcase 3:

Input: grid = [[1,1,2]]
Output: false
Explanation: You will get stuck at cell (0, 1) and you cannot reach cell (0, 2).

Testcase 4:

Input: grid = [[1,1,1,1,1,1,3]]
Output: true

Test Case 5:

Input: grid = [[2],[2],[2],[2],[2],[2],[6]]
Output: true

This is code-golf so shortest submission in bytes wins! If you liked this challenge, consider upvoting it... And happy golfing!

• May I use a different numbering/encoding to encode the six tiles? One example could be using 3, 5, 6, 9, 10, 12 to utilize bitwise ops, or a 4-element array per tile e.g. [0, 0, 1, 1], [0, 1, 0, 1], etc. – Bubbler Mar 24 '20 at 8:13
• You might want to clarify that the path is not required to cover every single cell (or the opposite). Also, are the top left and bottom right corners guaranteed to have a single side connected to the outside, e.g. 4 or 5 will never appear at the top left? – Bubbler Mar 24 '20 at 8:19
• Nothing to add to Bubbler's comments other than maybe make the images smaller and/or replace them with ASCII or Unicode diagrams. (imgur is blocked by some networks). – Adám Mar 24 '20 at 15:40
• This also has the issue of being a LeetCode problem, which you presumably don't have permission to post here. – xnor Mar 25 '20 at 0:56

## Longest happy prefix

A prefix of a string is a happy prefix if it's also a suffix of that string, but not if it's the entire string. This means that the string both begins and ends with it.

Given a non-empty string s, return the longest happy prefix of s. Note that this can be the empty string.

Test Cases:

Case 1:

Input: s = "level"
Output: "l"

Explanation: s contains 4 prefix excluding itself ("l", "le", "lev", "leve"), and suffix
("l", "el", "vel", "evel"). The largest prefix which is also suffix is given by "l".

Case 2

Input: s = "ababab"
Output: "abab"

Explanation: "abab" is the largest prefix which is also suffix.
They can overlap in the original string.

Case 3:

Input: s = "a"
Output: ""

This is code-golf so shortest submission in bytes wins! If you liked this challenge, consider upvoting it... And happy golfing!

• Would answering with the length not be reasonable? – Adám Mar 24 '20 at 9:19
• What else Should I ask to return?? – Pluviophile Mar 24 '20 at 15:31
• "Given a string s. Return the longest happy prefix of s ." → "Given a string s. Return the longest happy prefix of s or its length." – Adám Mar 24 '20 at 15:32
• If you remove "non-empty" you can also remove "Return an empty string if no such prefix exists." – Adám Mar 24 '20 at 15:35
• I tried to clear up the wording a bit. – xnor Mar 25 '20 at 0:52
• Wait, this is also a LeetCode problem! Are all of your challenges really copy-pasted from LeetCode and similar sites? That's not OK to do, unless you've been somehow given explicit permission to post them here. – xnor Mar 25 '20 at 1:07

# Write an if/else statement from scratch code-golfrestricted-source

I am new to this community, so please do not hesitate to point out edits and clarifications in this post. Also note that this is just a loose draft for the question. There are several improvements to be made..

We all use if/else statements in our daily programming life (except the oldies who write Machine code). However, put your feet in a young programmer's shoes. If you wanted to write the if/else statement, what would you do?

So basically you have to re-design or recreate the if/else statement in any language of your choice.

The if/else statement should obviously not use if/else from any other language. This does not mean that we can use a statement that has some other name in other languages, no function/statement that produces if/else statement behavior can be used.

So this means that functions like case etc. which can be used in substitution with if-else cannot be used. Neither can you use while loops to simulate an if/else....

### Ideas:-

On posting this as a question there were a lot of people saying that the challenge was not clear. Can anyone edit or point the mistakes in the lines or think that they can make the question a bit more clear?

In the simplest words, it is a challenge to write the if/else statement without using any of its counterparts (like in other languages it has other names) which can be used with a syntax for general cases. For example, it should be able to compare:-

arrays
lists
dicts
other data types (heap, stack,tree)
strings

Everything a normal if/else can do.

• – S.S. Anne Apr 26 '20 at 13:49
• 1+ have the command #, which pops a stack and jump to the nth # in the program. Is using # allowed? – null Apr 26 '20 at 13:57
• Some languages do not have conditional statements, and some have only a while loop. Some languages may not have any of your listed data types. You don't know, so it's suggested that you don't write a challenge based on that assumption. – S.S. Anne Apr 26 '20 at 13:57
• @HighlyRadioactive # is a kind of goto, so it's definitely allowed. – user92069 Apr 26 '20 at 14:15
• @petStorm Okay then, but I guess we are still waiting for the OP to clarify. Is it allowed to assume there are no #s before the snippet? – null Apr 26 '20 at 14:19
• I think that # can be allowed as long as it works for most of the data types. Atleast commmon types like string, integers, array should work with it.... – neel g Apr 26 '20 at 14:51
• @S.S.Anne I think that languages that have only a have a while loop are automatically disqualified. So any answerer should not use them. What about making esoteric languages compulsory? I am sure it will be very tough and feel like a real challenge! – neel g Apr 26 '20 at 14:54
• From the same page, this is also discouraged: Explicitly disallowing or disadvantaging arbitrary (classes of) languages. Going against the things to avoid guidelines will generally mean that your question will be downvoted and/or closed. Try to write a challenge that doesn't do anything that's listed there and it will be more likely that your question will get upvotes and will stay open. – S.S. Anne Apr 26 '20 at 14:56
• How can you tell what's an if/else/switch/loop and what's not? This fulfills your requirements, for example: ,[.[-]]+[-[.]]. I could argue that this contains none of these but you'd never know if it did or not. – S.S. Anne Apr 26 '20 at 15:03
• @S.S.Anne So what do you think is the best course of action to take? I don't want to scrap this question because it is really good at its core (but not the best in a practical scenario) Could anyone suggest a very innovative fix so that this question remains a good one? – neel g Apr 26 '20 at 15:16
• You should also look at this. I think you should define more clearly what do you want the if-else statement to allow doing. should it allow executing code that can be substituted, given as input based on an input falsy/truthy value? – Command Master Apr 26 '20 at 16:10
• I agree that this is far from clear. One additional question I have, is what must we be able to do within our if/else replacement. Do we have to be able to run arbitrary sequences of lines of code? Or is just producing a value enough? Note that some languages make a distinction between statements and expressions, and may have if/else constructs for one or both situations. – xnor Apr 26 '20 at 20:15
• @neelg As far as I know most Esolangs does not have string and array (as an object). For example, there is only one type in 1+, that is, unsigned integer. – null Apr 26 '20 at 23:58

# Produce the next Italy number code-golfintegersequence

This is the third post for the second RGS's Golfing Showdown.

Italy is a Southern European country that was greatly devastated by the impact of the coronavirus crisis in its fairly aged population. As of the 27th of April, Italy was roughly 600 cases short of hitting 200.000 total confirmed cases.

Your task is to produce the total number of confirmed cases on day n+1 given the total number of confirmed cases on day n, with n going from the 21st of February 2020 to the 10th of April 2020, as per Wikipedia's data, obtained at 19:38 27/04/2020 UTC.

For your convenience, these are the 20 numbers involved; the first 19 are inputs and the last 19 are outputs.

[20, 79, 150, 229, 322, 445, 650, 888, 1128, 1694, 2036, 2502, 3089, 3858, 4636, 5883, 7375, 9172, 10149, 12462]

# I/O

I/O should be integers or reasonable representations of those, with the restriction that your code must accept as input its own output.

# Test cases:

20 -> 79
79 -> 150
150 -> 229
229 -> 322
322 -> 445
445 -> 650
650 -> 888
888 -> 1128
1128 -> 1694
1694 -> 2036
2036 -> 2502
2502 -> 3089
3089 -> 3858
3858 -> 4636
4636 -> 5883
5883 -> 7375
7375 -> 9172
9172 -> 10149
10149 -> 12462

Python reference implementation

• Can we use ResourceObject["Epidemic Data for Novel Coronavirus COVID-19"] for Mathematica? (it involves fetching the data from a server, but 1) it's still built-in 2) so do many SomethingData functions for the first time). – the default. Apr 28 '20 at 1:47
• @mypronounismonicareinstate if that is not against some loophole, sure. Just make sure the numbers coincide with the numbers I posted – RGS Apr 28 '20 at 6:00
• How is this not a hard-code the data challenge? Is there any possible relation? Because otherwise, it seems really boring. – S.S. Anne Apr 29 '20 at 0:54
• @S.S.Anne thank you for your feedback; I changed the task and reduced the total amount of days we are dealing with. Please let me know if this looks more sensible. – RGS Apr 29 '20 at 18:40
• It's better, but I still don't see how this couldn't be solved without just a big array. – S.S. Anne Apr 29 '20 at 19:06
• @S.S.Anne someone will think of something! Hopefully :) – RGS Apr 29 '20 at 19:15
• You can't just hope that someone will find some interesting way to solve your challenge to make a boring challenge interesting. The shortest way I see to solve this right now is to hard-code the data, which is probably what everybody will do. – S.S. Anne Apr 29 '20 at 19:22
• Just graph your data, see how much it deviates from only a simple parabola? – S.S. Anne Apr 29 '20 at 19:29
• Maybe you could allow some small error bound on the output (say 10%)? Then the challenge would become about finding a model that approximates the data well, rather than hardcoding values – math junkie Apr 29 '20 at 20:16

# Make an Anti-compressor (WIP)

Create an algorithm that reversibly and losslessly makes files bigger. You must create the anti-compressor. The de-anti-compressor can be your own creation or something that already exists. The two programs do not need to be written in the same language.

### Objective Validity Criteria

• Inputs into the anti-compressor can be binary files using any or all byte values.
• All inputs into your anti-compressor must produce outputs that are at least one byte longer.
• The anti-compressor is losslessly reversible by either an existing program or your own.
• The de-anti-compressor must work on (at least) all possible outputs of the anti-compressor.
• Both the anti-compressor and de-anti-compressor can be executed on an actual computer. Keep execution time within reason (e.g. no $$\O(n!)\$$ programs, please)

This will be a unless I get a good suggestion for an objective scoring system.

My only idea so far is that the score could be based on the decompression ratio, cancelled out by how well gzip compresses the output. Unfortunately, this could be abused easily by inserting arbitrarily large amounts of random padding between significant bits of information, leading to an unbounded score that can always be beaten with trivial modification.

• Besides the usual issues with pop-cons, I'd really have no idea how to vote because the task is so broad and I don't know what's meant to be interesting in an answer. – xnor May 11 '20 at 20:00
• @xnor that's fair. I'm not entirely sure if this challenge is a good idea in the first place, but I got an upvote earlier, so I thought it might be worth it to refine it and see where it goes. I could see the subjective criteria being along the lines of the funniest or most clever way of anti-compressing a file. Injecting filler data, random or not, is not very clever, but having it output an overly verbose java program that outputs the original file when executed is both humorous and clever- but perhaps not as much as other ideas I haven't even thought of. – Beefster May 11 '20 at 23:09
• @Λ̸̸ The issue with that scoring system is that you can always make a file more bloated. Someone doubles every byte? I can just triple every byte. That kind of oneupmanship is not interesting. I can try to put limits on exactly what kind of bloating is allowed so that there is some sort of soft upper bound, but then the challenge becomes one of abusing the rules and finding clever interpretations and loopholes- also not very interesting. – Beefster May 12 '20 at 15:08
• I have an idea: make the answerer choose an existing compression algorithm, and then create an anti-compression program given an input string.The anti-compressed string, when compressed with the chosen algorithm, must produce the exact same output as the input. That way, the anti-compressing method of randomly inserting characters in the input string can be avoided, since there isn't a way to un-double speak a given input character, and for a string with randomly inserted characters, the compressor will not know which characters to leave out during the compression. – user92069 May 13 '20 at 2:36
• Given that, the scoring criterion can now be simply code-golf, since there isn't a way to create boring answers, and the only possible way to score answers left is just code-golf. – user92069 May 13 '20 at 2:38
• @Λ̸̸ At that point, it would make more sense to make a jillion different code-golf challenges since this essentially defines an entire class of golfing challenges. – Beefster May 13 '20 at 16:32

# Print all sequenced variants of the SARS-CoV-2 (COVID-19) genome in FASTA format

https://www.ncbi.nlm.nih.gov/genbank/sars-cov-2-seqs/

The FASTA format has the name of the sequence data following a >, a newline, 60 characters of As, Ts, Cs, and Gs, a newline, 60 characters of As, Ts, Cs, and Gs, and so on.

You need only print the name of the, not the location it came from. For example:

>XX-NNNNNN.N
GENOMIC DATA GOES HERE
>XX-NNNNNN.N
MORE GENOMIC DATA GOES HERE

• I can't imagine what good does requiring newlines every 60 characters do to the challenge. That site also has very many files linked, and you have not specified which ones we need to use, nor you provided us with the expected output (a plain link to a random website where we have to scrape and parse several thousands of files you haven't told us about is not enough). Since there are thousands of them, I strongly suspect suspect that zpaq will win this time. – the default. Jun 14 '20 at 8:13

# Wuhan Xi Estimates

Challenge
Create a program that takes two base-ten integer number inputs (w,x). The program should output the closest integer number that is x order of magnitude smaller than w, rounded downwards. The output should be zero if the result is less than 1.

Test cases

f(10,1) = 1
f(10,2) = 0
f(1000000, 3) = 1000
f(888, 2) = 8
f(99999, 4) = 9
f(7777777, 8) = 0
f(123455, 5) = 1
f(123455, 4) = 12345
f(123455, 0) = 123455

Example Code
Here's an ungolfed example in Lua:

a,b=b:match("([^,]+),([^,]+)")

if (b+0 > #a) then
print(0)
else
d = (a+0)/(10^b)
print (math.floor(d))
end

Try it online!

General rules

• This is , so shortest code in bytes in its respective language wins.

• Standard rules apply for your answer with default I/O rules, so you are allowed to use STDIN (with the specification above)/STDOUT, functions/method with the proper parameters and return-type, full programs.

• Default Loopholes are forbidden.

• Can we take input as string where the two numbers are separated by "E-" ? – Adám Jun 22 '20 at 21:52
• @Adám, Is "E-" executable code? If so, I guess that's fine, but it has to be part of the byte count. If it is just a glorified separator, or a switch of some kind, then yes and doesn't have to be included in the byte count. – ouflak Jun 23 '20 at 5:55
• My idea what that one could do something like floor(input) where input is e.g. 888E-2 thus trivialising the challenge. – Adám Jun 23 '20 at 5:57
• @Adám, That would be fine, and the challenge will have many 'trivial' answers in several languages. I'd be surprised if there isn't atleast a few 2/3 byte solutions. – ouflak Jun 23 '20 at 6:00
• Maybe mention in the challenge text that this amounts to computing $⌊w×10^{-x}⌋$? – Adám Jun 23 '20 at 6:10
• @Adám, There are other ways to look at it. My Turing Machine Code solution certainly won't be computing any powers. – ouflak Jun 23 '20 at 6:34
• Is that integers or positive integers? ;) – Trebor Jun 23 '20 at 16:07
• The wording 'closest integer number that is $x$ order of magnitude smaller than $w$' is ambiguous. I initially interpreted it to mean, e.g., f(1000000, 3) = 9999 (closest integer to 1000000 that is 3 orders of magnitude smaller). As Adám said above, it seems that you're just asking for $\lfloor w\times 10^{-x}\rfloor$. – Dingus Jun 25 '20 at 0:22

# Meta-golfing Numbers

The Esolangs Wiki has a page here cataloging the shortest known programs in Brainf*** to generate a given number. A similar catalog could exist for any language: it would simply be a list of the shortest known programs in that language outputting a given constant. By extension, we can assume that for any given language, a catalog like this could be generated programmatically, by creating a program that given a constant outputs another program outputting that constant.

## The Challenge

Your challenge is to create a program in any language $$\A\$$, such that when that program is given an input $$\N\$$, it outputs a program in language $$\B\$$ that will ouput $$\N\$$.

• Languages $$\A\$$ and $$\B\$$ need not be different; you can output a program in the same language as your source code.
• All outputted programs must be in the same language $$\B\$$.
• $$\N\$$ is guaranteed to be a positive integer. It may be $$\0\$$.

# I/O

• Input and output can be done with any of the default I/O methods.
• $$\N\$$ should be inputted as an integer, the string representation of an integer, or an array of digits. Programs should be outputted as a string or a list of characters.

## Restrictions

• Your program must handle values of $$\N\$$ at least up to $$\255\$$.
• Trailing whitespace and newlines are allowed, as long as they do not make any program invalid; ie., I can have trailing newlines and whitespace as long as the implementation of $$\B\$$ allows them in programs.

## Scoring

This question is a , so the answer with the most votes wins!

• A critique of the scoring system (and possibly the challenge as a whole): In some languages, the empty program outputs its input, and in some languages, a numeric literal outputs itself. So the optimal submission will be program A, 0 bytes, for a score of 0. But even if the scoring system is changed to prevent the multiplying-by-zero exploit, I don't see how any other approach will be better than the empty-identity-program approach. So as it stands, this challenge will gather multiple trivial answers--and probably some interesting ones, but with worse scores. – DLosc Aug 21 '20 at 1:52
• I don't think lowest score wins is a good idea for a contest where you have the flexibility to choose how difficult the task it. Might be better as a popularity contest, or maybe it would be better with a list of difficult languages to print constants in. – Razetime Aug 21 '20 at 2:09
• @Razetime yeah, I actually hadn't realized the multiplying by zero exploit, so this seems like the best course of action - I've updated the answer. – sugarfi Aug 21 '20 at 12:09
• Righ now, this is not metagolf, this is just... meta? – the default. Aug 22 '20 at 3:10
• I guess so, yeah... But metagolf is a bit catchier, isn't it? – sugarfi Aug 22 '20 at 13:23
• Program: any implementation of cat in any language A. Language B: cat. – user253751 Aug 24 '20 at 17:46

# Feedback Wanted

• Is this too vague? should I change it to something like "create a quine with the fewest unique bytes", or perhaps adapt another existing challenge that might otherwise use lots of repeated bytes?
• Maybe the idea is just too boring on its own and I should create a new proper challenge based around it?
• Should I change the scoring system (votes - unique_bytes) - should it be divided instead, or use a more complex formula?

# Introduction

This is , but not as you know it. Instead of every byte, This is sort-of also a question.

# Challenge

Write an interesting program that uses the fewest unique bytes. This is not really about what the program does, but what you can do with a limited set of characters.

### Rules

• Your program must run on Try It Online
• Programming languages with only a few permissible bytes anyway like Brainfuck's +-.,[]<>, are allowed, but officially considered boring

Apart from this, you can write anything.

### Scoring

• Hybrid of and "fewest-unique-bytes". Score is calculated as votes - unique_bytes
• Unique bytes is based on bytes, not characters or whatever. You can calculate unique bytes using this Python snippet: len(set(b"your code here"))
• It's definitely too vague. "Interesting" could mean anything, and you'd have to argue with several people over whether their ignore-input-and-print-0 program counts as interesting before the challenge is closed as too broad or unclear. [popularity-contest] is also a dangerous tag, in that it's very hard to do well and has fallen out of favor long ago. This extends to all scoring systems that involve votes. – Zgarb Aug 21 '20 at 19:33
• I think this idea has been largely covered by Fewest (distinct) characters for Turing Completeness. Many languages require surprisingly few characters to run arbitrary code, so I expect there's not much interesting room for specific programs that use fewer characters than needed for that. – xnor Aug 21 '20 at 22:39
• As far as I remember, there exists a Lenguage quine (that uses only 1 unique byte). I think combining popularity-contest with something else is even worse than simply using popularity-contest. – the default. Aug 22 '20 at 3:00
• For future reference, start your sandbox entries with the title of your challenge rather than a generic "feedback wanted". It's the prevailing convention and doing something different is a little confusing to scroll past. – Beefster Aug 24 '20 at 16:18

# Solving P=NP!

Today, we are going to solve P=NP, kinda...

## Input

A guaranteed prime positive integer, P.

## Output

The smallest composite number (NonPrime,NP) which sum of digits equals P.

## Examples

Input (P)    Output (NP)      Why? (for reference)
2              20          2+0=2 and 11 is prime
3              12                 1+2=3
5              14                 1+4=5
7              16                 1+6=7
11             38          3+8=11 and 29 is prime
13             49                 4+9=13
17             98          9+8=17 and 89 is prime

Check OEIS A073868 for more results.

## Challenge

Write a function or program that, given a positive prime number P as input, calculates NP, the smallest composite number which sum of digits equals P.

• Range of input: any integer prime number greater than 1, up to the limit of the chosen language.
• Range of output: also according to the limits of the chosen language.
• Means of input/output: free to choose.

## Winning condition

This is a challenge. The shortest code wins!

## Meta

I have searched if this was already posted, but with no success.

• To me, this isn't all that interesting of a challenge because it's a mash-up of "find a number whose digit sum is X" and "check if a number is prime." If a language has a built-in for primality, it's done. If not, it's still been done over and over again. The fact that the input is prime doesn't really add anything here for me. And skipping over primes as possible answers doesn't either. Why not do "find the smallest number whose digits add to X?" or "Find the Yth number whose digits add to X" where both x and y are inputs? – Xcali Dec 23 '20 at 20:37
• The challenge itself looks to be well specified but I dislike the title. I'm all for using clever/controversial titles to attract attention, but not at the expense of accurately conveying what the challenge is about. – Dingus Jan 1 at 1:38

# Enumerate all possible IPv4 addresses

Title might make the challenge hard, but it's easy.

You have to print all the possible IPv4 addresses from 0.0.0.0 to 255.255.255.255

Standard loopholes apply, no internet usage for this

# English Grammar Checker

Being tired of checking English grammar, I decided to write an English grammar regular expression.

## Notations

1. All capital letters denote an expression.
2. Quoted strings (like "a") and lower-case letters denotes literals.
3. AB means concatenating expressions / literals A and B together.
4. (...) groups the expression inside the parentheses, as a whole expression.
5. A* means repeating the expression A zero or more times.
6. A? means the expression A is optional here.
7. A|B means either A or B can be placed here.
8. A=B means all expression A should be replaced by B.

## Grammatical Rules

### Parts of Speech

For simplicity, all parts of speech are substituted using symbols.

Symbol Part of Speech
a article
b verb
m numeral
n noun
r pronoun

### Rules

There's a whole bunch of rules in English grammar. For simplicity, I only chose a tip of the iceberg. Your RegEx should only match all valid S's.

1. S=N+V
2. N=((a|m)?j*n(pN)?)|r
3. V=b((pN)*|N)?v?

## Examples

These should be matched Real-life example
anb The man runs
rbpajjnv He dives into the deep blue sea quickly
anpanbpr The wave on the sea came towards me
mnpambv Two friends of the man walks slowly
anpmjjnbajjnv The robot of two tall thin girls greets the young handsome man repeatedly
These shouldn't be matched Real-life "wrong" sentences example
nn Man child
nabr Student a told me
arbv The you laughed happily
anbvv The woman sang slowly beautifully
rbvj He is very funny

Notice that the last example is a valid English sentence, but it doesn't match our simplified rules. You shouldn't match them.

## Tips

You can assume that there's no whitespaces and line feeds in the input.

You can assume that you only need to match 1 input per time.

You can use any RegEx dialects no newer than this challenge.

## Scoring

Your score is the bytes in your RegEx. Flags are not counted.

The least score wins!

• Are you sure that this grammar is really decidable with a regex? – user202729 Feb 19 at 9:12
• YES @user202729 and I've already made one; but not decided to make it public yet. – SketchySketch Feb 19 at 9:14
• It's better if you explain what format the rules are specified in. (while I can understand it, it isn't obvious) The standard is Backus-Naur form I guess? – user202729 Feb 19 at 9:20
• Any dialect restriction? – user202729 Feb 19 at 9:21
• I wrote the format for rules in Notation section; is it unclear? – SketchySketch Feb 19 at 9:22
• Originally I overlook that = can be recursive and I can't find capital N in the table. – user202729 Feb 19 at 9:24
• Err, yes, but I don't have good ideas about how to explain ='s. It's just kind of, substitution? But it can be recursive? Anyone have ideas? – SketchySketch Feb 19 at 9:26
• Perhaps you can show an example of a simple (recursive) pattern matching a simple string. – user202729 Feb 19 at 9:30
• Not sure if you're asking an example regex matching a recursive rule. For A=(yA)|x using the same notation, regex: y*x. – SketchySketch Feb 19 at 9:37
• Does "without flags" mean ", flags are not counted"? That sentence can be interpreted as "regex flags are not allowed" too. – user202729 Feb 20 at 8:44
• English grammar is not regular and cannot be matched with a regular expression. At best, you can tease out some subset that is context-free, but realistically, this is not a good challenge as it is written. Natural languages tend to be riddled with all sorts of crazy complexity that makes them highly context-sensitive and possibly undecidable. – Beefster Feb 22 at 16:55
• @Beefster As I wrote in the challenge you should only match the simplified "rules", as in section Rules. There're only 3 rules. As I commented before I already wrote a regex that can match these rules, so the challenge is absolutely solvable. – SketchySketch Feb 23 at 2:54
• @Beefster And op did do that. (op claim that the chosen subset is context-free, but I didn't verify it) – user202729 Feb 24 at 3:52
• @user202729 if you want to verify, <S> ::= <N><V>, <J> ::= "j"<J> | "", <N> ::= "r" | "a"<J>"np"N | "a"<J>"n" | "m"<J>"np"N | "m"<J>"n" | <J>"np"N | <J>"n", <P> ::= "p"N<P> | "", <V> ::= "b" | "bv" | "b"<N> | "b"<N>"v" | "b"<P> | "b"<P>"v". Really verbose. – SketchySketch Feb 24 at 4:08
• Even with this limited subset, reducing it to a regex really only has one optimal approach and isn't particularly interesting in lending itself to many different approaches. – Beefster Feb 24 at 16:31

## Code-challenge: Guess my number

### The challenge

You have a number from 1 to 10 in mind, and your program should ask questions to find out which number. These questions can be any questions, the program only has to find out the number as fast as possible.

Your program should ask a question, such as "Is the number a prime?", and the user must answer either y or n (yes or no). Ask questions until you know the number.

### The scoring

To calculate the score, you need to take the sum of the question count for each number. For example, if you need 1 question to find the number 1, 2 questions to find the number 2, and so on, the score is 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10, so the score is 55.

Important note: the question count for a specific number must always be the same. For example, if you need 4 questions to find out the number 10, then you have to ask always 4 questions to find out the number 10, otherwise it is impossible to calculate the score.

• boooring. The Huffman tree for a uniform set is any perfectly balanced tree. The question asks us to perform a binary search on the usr device. Is the number greater than 5? Is the number greater than 2? Is the number greater than 1? Hey' I think it's 1. – John Dvorak Jan 2 '14 at 11:49
• Maybe if this were a pop-contest and the goal was to make the most original set of questions while still keeping the score at its theoretical minimum. – John Dvorak Jan 3 '14 at 5:28

Bovine Ignorance

I'm curious about code which still works after being mangled by figlet, toilet, cowsay et al, but I'm not sure whether this in any way sane.

What I'm toying with is a challenge in which a participant may submit any program in any language. It should be possible to use this program's source code as input to cowsay or whatever, and the result should be another valid program in any language, which still does a similar thing. For instance, the following bf program prints Hello world! with no newline:

+++++ +++++
[
> +++++ ++
> +++++ +++++
> +++
> +
<<<< -
]
> ++ .
> + .
+++++ ++ .
.
+++ .
> ++ .
<< +++++ +++++ +++++ .
> .
+++ .
----- - .
----- --- .
> + .
+++++++++++++++++++++++++++++++++++++++++

Running cat ./prog.bf | cowsay -e .. -T $'>.' yields the following output:  _________________________________________ / +++++ +++++ [ > +++++ ++ > +++++ +++++ \ | > +++ > + <<<< - ] > ++ . > + . +++++ | | ++ . . +++ . > ++ . << +++++ +++++ | | +++++ . > . +++ . ----- - . ----- --- . | | > + . | | +++++++++++++++++++++++++++++++++++++++ | \ ++ / ----------------------------------------- \ ^__^ \ (..)\_______ (__)\ )\/\ >. ||----w | || ||  Which is itself a valid bf program which prints Hello world!!!, followed by a newline. The problem with using bf here is that it ignores most of the cow, making this a bit too easy. The problem with using any other language is that it doesn't ignore most of the cow, making this far too difficult. Is there a sensible middle ground I could pick for this? I don't think it's impossible, I'm fairly sure you can exploit cowsay's behavior on one-liners to produce valid svgs, but I'm not sure how best to pose this challenge. Any ideas? • I could not think of any language that falls in the middle ground. Even brainfuck is affected by the -----------------------------------------..>.---- inserted by cowsay. Most languages have strong parsing rules that would not cope with being post-processed by cowsay. The few exceptions for this will be either completely unaffected or badly affected, making the challenge uninteresting. – Victor Stafusa Feb 19 '14 at 12:32 • Actually, you can't transform just any brainfuck program to cowsay-brainfuck. Namely those that can output fewer than three characters cannot be transformed at all. – John Dvorak Feb 19 '14 at 14:52 • @JanDvorak, I was intending to allow competitors to choose the parameters of their calls to cowsay. For the uninitiated, -e controls the string used for eyes and defaults to oo, and -T controls the string used for the tongue, defaulting to  U. This is all yak-shaving, though, and having written this up and read the comments, I suspect that this idea has neither legs, horns nor udders. – ymbirtt Feb 19 '14 at 23:19 • If I could propose a variant that is more feasible, you could do a challenge like "Write a program in your language of choice that draws ASCII art of a cow saying something (does not have to be identical or even similar to the cowsay art). The entire drawing must itself be valid source code that does something other than no-op. Post results of both programs." That gives people more leeway to work around the specific restrictions of their compiler. – Jonathan Van Matre Feb 21 '14 at 23:22 • Ok, I found a language that falls within the middle ground: whitespace. Anyway, this question has a too narrow scope to develop an interesting challenge. – Victor Stafusa Feb 22 '14 at 18:31 • @JonathanVanMatre That would be a subjective validity criterion, and would probably be closed as too broad. – wastl Jul 2 '18 at 13:55 # 99 Bottles of Errors While there are already many versions of "print 99 Bottles of Beer," I thought another one wouldn't hurt. The challenge is fairly simple: print the lyrics to 99 bottles of Beer to STDERR. I don't care how you do it, so long as the entire lyrics show up. An entire program is required, so the following Java program would be invalid (even if it did do the correct thing): System.out.println("99 Bottles of Beer on the Wall, take one down and pass it around...");  ## The scoring: • This challenge is , so shortest code by byte count wins. • If necessary, assume UTF-8 is the character encoding used. ## The rules • All the code must be in one file. • Any language is allowed. • Reading input, whether it is from STDIN, a file, or the web, is not allowed. • This is trivial in some languages (Java), where it reduces to a simple kolmogorov challenge, and impossible in others (those that have no distinct STDERR) – John Dvorak Mar 27 '14 at 7:42 # Create an Identicon Generator The challenge is to create an identicon generator. The identicons must be randomly generated, so we get a new identicon for each key the program receives. You can input a key using std-in or you can use your language's random number generator for the key. In order to make your identicon look reasonably nice, it must generate a picture, then rotate that picture around the bottom right corner, the way this mockup shows: The output must be to a PNG file. Shortest code wins. • Far too broad. As this stands I can create a 1-pixel image whose colour is just the key. I don't think this question will be ready to go until you've found a way to prevent me from making the images differ only in their palette (and to pre-empt, I think that adding a rule "Images may not differ only in their palette" isn't a real fix). – Peter Taylor Mar 28 '14 at 14:50 • If you just ask for "random" images, you'll get images that are either hardly random at all (a solitary pixel in a random location), or completely random (noise). To get something "reasonably nice", you'll have to provide very clear instructions on how to produce these images. I suggest you try creating a few of these yourself, and find a minimal set of rules that produces results that look OK. Include requirements on dimensions (100x100px?), selection of colours (at least 2, not too similar), and drawing method (e.g., "five triangles with random vertices and a minimum area of 20 px²"). – r3mainer Mar 28 '14 at 15:25 • How important is the PNG file output? This will be a challenge in itself for many languages. Would you accept an uncompressed non-interlaced format like PPM? – trichoplax Apr 16 '14 at 9:45 ## Underhand Bejewled Help me to write a game of bejewled, which cannot be lost! ## Bejewled game rules If you ever played bejewled, you can skip this, but for those who did not see it ever: • Playing field of 8*8 grid is filled in with gems of 7 different types randomly • By swapping two adjective stones, your goal is to create a line of at least three same type of stones in the either vertical or horizontal line • If did so, the gems will dissappear, points are added (say 20 points for a matching) and new gems are provided randomly from the top • image related: ## Your challenge Provide me a game which cannot be lost. In other words, the gems falling from the top are not random at all, but are falling in order that there is always at least one possibility to match three gems But, from looking at the code at level of newbie programmer, it should look like that game acts as if it was random ## Output Playable game. As long as it is the grid of 8*8 filled in with 7 different types of "gems" the game is ok. It does not to have killer graphics, neither it does not need to be playable by mouse. (But in that case please make sure you show which "gem" is hovered and then selected) ## Winning criteria This is popularity contest. So highest rated game wins • I think this is too big a task to work well for an underhanded contest. The programs will be way too large for anyone to actually read the source and try to find what's underhanded about it. – Martin Ender Nov 11 '14 at 8:32 • Thats what I was also afraid of. I will either take it as lesson to progress on my programming skill, or abandon the idea completly – Pavel Janicek Nov 11 '14 at 8:38 # Shortest Program that May or May not Terminate: Write a program such that whether or not it terminates depends on the answer to an unsolved question in Computer Science or Mathematics. For example, your program might test the Goldbach conjecture for every N and quit if a counterexample is found, or hunt for odd perfect numbers. Please include an explanation of why your program may or may not terminate! Note: assume infinite memory and stack size, because otherwise they all terminate. Your program must be self contained, take no input, and only use standard libraries. This is Codegolf, so shortest code wins! • What about "unsolvable" problems, e.g. halting problem? Can I take another code as input and terminate if that terminates? Because that other program may or may not terminate, and there's no way to tell. – Martin Ender Nov 20 '14 at 18:03 • The intention was that the program isn't allowed to take input. I'll be more specific. – QuadmasterXLII Nov 20 '14 at 18:50 • Does this differ from this previous question in the sandbox? – trichoplax Nov 20 '14 at 19:34 • (even if not the comments explaining why that one wouldn't work as a question may help Taylor this one) – trichoplax Nov 20 '14 at 19:35 • The intent of this doesn't differ significantly from the question you linked, I searched posted questions but forgot to search the sandbox. – QuadmasterXLII Nov 20 '14 at 19:41 • Infinite memory isn't required. – feersum Nov 20 '14 at 21:46 # Something Else - ASCII Art maker: A text to ASCII art generator maker, the program must input a string and return ASCII art from it. Something like patorjk.com/software/taag/. It has to use the Graffiti font. The winning criteria is the whoever gets the most likes. • Hello! Just a few things to point out: 1) The current spec is very broad. For example, what fonts, how does spacing look, what characters need to be supported... there's a lot more details that need to be included than just "return ASCII art of this text" – Sp3000 Feb 24 '15 at 4:07 • 2) What's the winning criterion? Popularity contest? Code golf? – Sp3000 Feb 24 '15 at 4:08 # Identifying a Sonnet This challenge is about determining if a given file (read-in from stdin) meets the criteria to be a sonnet. You may use any language for this challenge. If your language supports an API to use an online dictionary you may use that API, if your language doesn't then too bad. Additionally, it is preferred if your language is one that can be ran directly from the command line and is a language that has a compiler or interpreter available directly from my distro's repos(Fedora), as I would rather just use a bash script to test the various programs, then test each program manually. # Definition of a Sonnet • Has 14 Lines (lines are denoted as the standard newline on your operating system). • Has a definite rhyme scheme, it will have one of the following rhyme schemes • ABBA ABBA CD CD CD • ABBA ABBA CDE CDE • ABAB ABBA EFEF GG • Iambic Pentameter - consists of alternating stressed, unstressed syllables. This doesn't have to be perfect 100% of the time, just at least 50% of the time. In order for your program to declare a given string a sonnet, it must meet all of the above criteria. ## Additional Notes You do not have to identify the following: • Thought Structure - too intense for a code golf challenge, and too subjective. • Topic - computer lacks context to determine this # Input Input will be read from stdin. This is the string that you will be declaring to be or not to be a sonnet. # Output Your program will output either yes or no for the question: Does this string meet the given requirements to be a sonnet? As this is code golf yes or no can be abbreviated to Y/N. # Winner The solution with fewest number of bytes win that has the highest accuracy ratio for the correct identification of a sonnet. The preference is for higher accuracy rather than brevity of the program. # Test Data and Resources ## What is not a sonnet The following are examples that you program should return false on: • Beowulf • Haiku • Input that doesn't have exactly 14 Lines in it • The text of this question. • The text of just about any other question on StackExchange. • Things that don't have a rhyme scheme. See Below # Not A Sonnet A man got on a boat The boat was leaky and had poor construction For it was made by a one-eyed blind man and his dumb intern As soon as he got out of port at the fort it started to sink eventually, it tanked. And it capsized If only that shipwright wasn't so blind deaf and dumb as microsoft tech support That's not much support at all.  • I think without dictionaries for rhymes and stresses this is probably not a good idea. Of course you can use some sort of accuracy ratio, but then you also need false positives, and you need a lot more examples than the few on the pages you've linked. But if you do this there's no requirement to actually recognise the sonnets by their rhymes and stresses - instead, I'm pretty sure, people will just regex golf the test sets. – Martin Ender Mar 24 '15 at 19:36 • @MartinBüttner I updated the requirements with an accuracy percentage, and added the option to use an API to look up terms from a dictionary. – HSchmale Mar 24 '15 at 19:57 • 1. Test data which only covers one possible output isn't test data. I can write a program which always outputs Y in as little as one byte and it will pass all of the linked "test data", but it comes nowhere near to meeting spec. 2. Unless you specify which rhyme/stress dictionary to use, you can't guarantee that the test data is "correct". – Peter Taylor Mar 24 '15 at 20:20 • @PeterTaylor I added examples of what is not a Sonnet. – HSchmale Mar 24 '15 at 20:32 • I'm not sure how to say this, but it feels as though this task has a lot of individual parts, each of which could be quite tricky. Especiallly detecting rhymes/syllables/stresses, since words can be pronounced/stressed differently based on context. Also if you're using Shakespeare's sonnets I have no idea where to get rhyming and stress dictionaries for Elizabethan English... – Sp3000 Mar 25 '15 at 14:18 • To make this interesting, you'll need some interesting near-misses: non-sonnets that can't be detected by something simple like counting lines or words per line. – xnor Mar 25 '15 at 20:59 • @xnor You mean a file with a that looks like a sonnet but has no rhyme. – HSchmale Mar 25 '15 at 21:04 • Yes, for example. Or, one with rhyme by wrong rhythm. Or, one with nonsense characters that seem to "rhyme". – xnor Mar 25 '15 at 21:06 • @Sp3000 You can just use modern english, or just base it on words that have similar endings. – HSchmale Mar 25 '15 at 21:11 This and this gave me an idea, but I'm not quite sure if this can be done at all, or if it is trivial. If it is, maybe point out how it could be changed to be interesting. # Anti golfing - Write the longest program not repeating any character Well, it's just what the title says. Finally you're allowed to use as much bytes as possible. ## Conditions • The code of the program or function should not use any character that is used in the code before. • Your program should print some sort of result to stdout, or into a file or return a value. You're not allowed to output or return the empty string or only a newline. • Other than that your program might do anything. Read input, print lots of output, or what you can think of, but you have to explain what it does, of course. • Only characters in the ASCII range [32 .. 126] and newlines are allowed, which limits the maximal code length to 96 bytes. • Variable names are only allowed to consist of a single character • String literals or the like are forbidden. They could be used to hold the unused characters (though they would need two " in most languages anyway). • The same rule applies for similar literal constructs like blocks or what else is there in some languages. • Even if the length of a string literal would be used to generate a number, it is forbidden. • Variables can not just be declared and never be used. They have to be reflected in the output somehow. • If you've read and understood the above rules and still found a loophole and used it, you should go and stand in the corner for a while, thinking about what you've done. So all in all, only use characters for actual code that does something generating the output, might it be calculating a value or formatting. And don't put unused characters somewhere in your code as a literal. Numbers are an exception, but I guess it's no problem to use them anyway. I guess you should have a pretty good idea of what would be considered cheating here. Example in awk BEGIN{gsub(a,9);print$j-13+d^c/4*5678%20}

It prints 15.5, score is 42.

It replaces the empty string a with 9 in $0, which is the empty string in the beginning. So $0 becomes 9.

Then it prints the result of 9-13+1/4*5678%20.

($j is $0 (==9), because j is not defined

d^c ist 1, because c and d are not defined)

Please don't invent languages for this ;)

The longest code in bytes wins.

• Are you sure you want to allow ASCII 127? That's the unprintable<DEL> character. The main problem with this challenge is "only use characters for actual code that does something". This is essentially unenforceable, because there may be arbitrarily complicated no-ops in the code. It's also why most code-bowling challenges fail to be popular/interesting. – Martin Ender Sep 14 '15 at 7:32
• Well, I thought about making it a "most votes win" challenge, but I guess that would be unfair for less known users. I don't know what could be done with what you are pointing out. – Cabbie407 Sep 14 '15 at 7:51
• I don't think this is a good candidate for a popularity contest. Popularity contests shouldn't be used as a cop out if the actual spec is a bit vague. They work best for challenges where the actual scoring criterion can be well specified but is more easily judged by humans than machines (e.g. "visually approximate a given image with these constraints..."). – Martin Ender Sep 14 '15 at 7:54
• Yeah, it's hard to formulate the rules for this. But I think it's not always about finding a winner anyway. Thought this might be fun. Resolved the character 127 situation btw.. – Cabbie407 Sep 14 '15 at 7:57
• How could I change that rule? I'm thinking about "only use code that contributes to the generation of the output" – Cabbie407 Sep 14 '15 at 8:02
• How do you define "contribute"? E.g. this GolfScript program prints the length of the block in {...} which is a convenient way to stuff all characters except in '"# in there. Do all those random characters actually contribute? In Slashes everything which isn't an unescaped slash is printed to STDOUT, so as long as I put \/ together, I can put any characters I want there and they'll all contribute. – Martin Ender Sep 14 '15 at 8:07
• Hmm, I thought this would be covered by forbidding string literals.. might think about extending that rule to blocks. Well, I'm not that fluent at esolangs. – Cabbie407 Sep 14 '15 at 8:10
• It's trivial to use all possible 96 bytes. Trust me. If you really want to see the program I'm thinking of, I suppose I could write it, but I'm pretty sure it can be done. – mbomb007 Sep 16 '15 at 18:34
• Yeah, I guess you're right. i have no idea how it would be done, but alright. – Cabbie407 Sep 16 '15 at 20:10
• Not to mention this is pretty much a duplicate of codegolf.stackexchange.com/questions/30159/… – pppery Aug 6 '17 at 12:52

# Stop the dance!

Your sister was at the hospital, but now she's fine, awfully, you lost a day of work, one of your most important days.

You work at your local television, and they have a contest, called "Stop the dance!", what is it about?: People is dancing, they have a big screen in the wall, while it says "Dance!", they have to dance, if it says "Stop!", they must stop, if you move, you lose.

You don't have internet at the studio, so you use some strange offline data sharing method. The day you weren't there, another programmer came, such a silly programmer! He made a "Reciever" program, basically, gets data, processes data and prints data in the Big Screen Wall.

The programmer was bored, so he made a way to get data, well, you don't know what way he choose! (Author comment: Let's assume he made all the possible ways. Cya.) Now you have to make a sender program, in any language, that sends data to that program using the protocol specified under this section.

You are an expert code golfer, so you decide that you must make the shortest code possible. (Another author comment: Any lang is allowed. Cya.)

# How did I came out with this idea?

Having a shower, my friend...

You must make the shortest (and winner) code possible, that sends data to the reciever, using this protocol:

The reciever must recieve:

$displaytext:"<text here>";$instnm:<integer here>;

$displaytext corresponds to what it is going to be displayed on the Big Screen Wall.$instnm corresponds to the number of the instruction, the count of things displayed, starts from 1.

Your program may take an input, and send the data, in any way (except the ones in Rules) to the Reciever. Remember there's no internet.

The winner will be the user with shortest bytes of code.

# Rules

## As a good code golfer, you may not:

• You can't use program arguments to send the data.
• It must be an application.
• If you apply for the bonus, mind you have to make both programs, if not, just the sender.
• The string you have to send it has to be STRICT, no different ones, if not, unvalid answer. (I decided to call that "Strict JASON Protocol", get the joke?)

# Bonus

You can make the reciever program, and you get -1 byte. Not much, but k. (In bytes, you must not decrement your byte result, you must do: "n Bytes + Bonus")

# Example Input and Output

## Input:

From Sender program:

Dance! or Stop!

## Protocol:

Inbetween both commands

$displaytext:"Dance!";$instnm:5

## Output:

In Reciever program:

Dance! (9) or Stop! (187)

# Overall objective:

Send data between two programs, without internet connection.

Edit: i can't post an example answer, because then i can give ideas of how to do this codegolf/puzzle, while the ideas are limited, i'm finding for the creativity of the user.

• I have no idea what you're asking me to do. – Peter Taylor Feb 3 '16 at 21:26
• It is pretty clear what is asking you to, is defined in Task (You must make the shortest (and winner) code possible, that sends data to the reciever, using this protocol), all the story and background is defined on Introduction. I dont see any hole on the post. – TheCrimulo Feb 3 '16 at 22:11
• @TheCrimulo Example answer? – Xwtek Feb 7 '16 at 7:06
• There is no Example, because you are just sending the same info you wrote in. If you type ´Dance!´, the output will be Dance! (n), n being the number of the sequence. The idea isn't to read input, and append (n) to it. You have to make it, in anyway (except command args/internet), dropping out the enoded data (input in the protocol), and, if necessary, make a reciever program, the reciever program its a bonus that discounts 1 byte, also, it can help you making your sender smaller. I can, i.e., make a file with the info on it. As explained, the reciever will read it. – TheCrimulo Feb 7 '16 at 15:54

# Biggest single character

This challenge is simple, its like the challenges we've had before where the goal is to produce the biggest output one can. But in this one, you can only use one character in your code.

You get no input, your code has to be a single character (not byte), and the person with the largest output in byte wins, ties broken by posting time.

• Doesn't this boil down to which language has the biggest output stored in a predefined variable? – Denker Apr 3 '16 at 20:50
• @DenkerAffe true. maybe i should make it 2 byte src code. that might allow some interesting stuff – Maltysen Apr 3 '16 at 20:52
• I think I would raise the char amount a bit more to allow for some competition between the same language. Also you should keep in mind that this rules out every non-golfing language. While this should be allowed per meta consensus, I am not sure how much the community likes this. – Denker Apr 3 '16 at 20:58
• G for pyth wins :D :D – Leaky Nun Apr 4 '16 at 4:45
• Befunge & co. would probably win via infinite output. If output has to be finite though, I wouldn't consider this a very interesting challenge since it would just be one big language hunt. – Sp3000 Apr 4 '16 at 10:27
• Actually, N in Seriously wins. 11752 bytes output. – user45941 Apr 6 '16 at 4:06
• @Mego Vitsy wins. 0 bytes, 11752 bytes of output. – Addison Crump Apr 7 '16 at 17:07

# Alphabetization 101 (popularity contest)

Your task is to use all 52 letters of both the uppercase and lowercase alphabet, ONCE and ONCE only, and make a program.

You are free to use any other ASCII character more than once, or use a letter of the alphabet more than once if it's required for the language to function.

## Meta:

• Not sure if this has been done before.
• Any questions regarding the task?
• Not really meta: Is there any place I can go to (like a chat or something) to post a question about BF? StackOverflow probably isn't suitable. – clismique Apr 17 '16 at 6:48
• Come to our chatroom! :) – Leaky Nun Apr 17 '16 at 6:50
• I would vote to close this as too broad. It's not a particularly interesting restriction per se, and it certainly doesn't make a good question without some restriction on the task to be performed. – Peter Taylor Apr 17 '16 at 14:07
• @PeterTaylor That's why it's a popularity contest, though - it lets the people decide whether the program made is good or not. What WOULD be a good restriction on the task? – clismique Apr 18 '16 at 1:40
• The popularity-contest tag is not an excuse for a broad challenge. "Write a program that does anything..." is pretty much the definition of "too broad", regardless of any source code restriction put on the program. So at least you should choose a specific task. Could be anything really, but if it relates to the restriction it might be more interesting (e.g. a pangram checker). Even so, I agree with Peter that the restriction isn't particularly interesting. There are tons of languages where it's trivial to avoid unwanted letters and then include the remaining ones in a string or comment. – Martin Ender Apr 21 '16 at 7:04

# Why did I come to Sandbox?

I have a very specific challenge, and I wanted to see if it was too specific.

The challenge is to output "Valdosta ACM" using the shortest number of characters with the BrainF**k programming language.

I've noticed it isn't the norm to specify a programming language on this domain, so I've come here to get feedback on whether or not this is acceptable.

# Introduction

As a challenge to the members of my local Association for Computing Machinery(ACM) chapter, I asked them to produce the shortest Brainf**k code that would output "Valdosta ACM".

This was a very fun challenge for all of our members, and we got very competitive! I was impressed with the solutions turned in, but I wondered if it was possible to beat our best solution. Surely it's possible, but who could do it?

# Challenge

Output the string "Valdosta ACM".

Stipulations:

• Use only the Brainf**k programming language (you can test your code here)

• No input can be accepted by your program

• The space in the string must be ASCII character #032.

These are the ASCII values of each character, as they appear in the string, for convenience:

 086 097 108 100 111 115 116 097 032 065 067 077

The winner is determined by the shortest code, by character count.

# Example Input and Output

### Input:

NO input is allowed

### Output:

Valdosta ACM

• Welcome to Programming Puzzles & Code Golf! Thanks for using the Sandbox. :) A few things to note: 1.) Generally we discourage language-specific challenges, 2.) typically code golf is scored by bytes rather than characters, and 3.) printing a fixed string like this would be insufficiently different from the Hello, World! challenge to avoid it being closed as a duplicate. – Alex A. Apr 25 '16 at 3:38
• Thanks Alex! Since I want to compare the results of my local competition with the results of the challenge here, is there anything I could change about the challenge to make it acceptable? I don't see a way to do this, but I was so excited about seeing if anyone here could do better than our coders. And thanks for the warm welcome! :) – Matt C Apr 25 '16 at 3:48
• You could look at Brainf**k solutions to other challenges (like this one), and see if the techniques used there can help you improve your solution. – ugoren Apr 25 '16 at 7:09
• We also have a tips question that may be of interest. – trichoplax Apr 26 '16 at 6:30
• Although this particular challenge is probably too similar to "Hello, World!" (as Alex pointed out), if you had a different challenge that you wanted to see solutions for in a specific language, you can still post it but just allow all languages to compete. If you don't see solutions in your specific language you can post a bounty for that language to encourage it. – trichoplax Apr 26 '16 at 6:33