code-golf

Code Golf: Ulam Spiral

谁说我不能喝 提交于 2019-12-03 04:50:38
问题 Locked . This question and its answers are locked because the question is off-topic but has historical significance. It is not currently accepting new answers or interactions. The Challenge The shortest code by character count to output Ulam's spiral with a spiral size given by user input. Ulam's spiral is one method to map prime numbers. The spiral starts from the number 1 being in the center (1 is not a prime) and generating a spiral around it, marking all prime numbers as the character ' *

Code Golf: Lights out

你离开我真会死。 提交于 2019-12-03 04:35:17
Locked . This question and its answers are locked because the question is off-topic but has historical significance. It is not currently accepting new answers or interactions. Learn more . The challenge The shortest code by character count to solve the input lights out board. The lights out board is a 2d square grid of varying size composed of two characters - . for a light that is off and * for a light that is on. To solve the board, all "lights" have to be turned off. Toggling a light (i.e. turning off when it is on, turning on when it is off) is made 5 lights at a time - the light selected

Code Golf: Connecting the dots

烈酒焚心 提交于 2019-12-03 02:59:09
问题 Locked . This question and its answers are locked because the question is off-topic but has historical significance. It is not currently accepting new answers or interactions. You may remember these drawings from when you were a child, but now it's time to let the computer draw them (in full ascii splendour). Have fun! Description: The input are multiple lines (terminated by a newline) which describe a 'field'. There are 'numbers' scattered across this field (seperated by whitespace). All

Code Golf: Beehive

风流意气都作罢 提交于 2019-12-03 02:54:13
问题 Locked . This question and its answers are locked because the question is off-topic but has historical significance. It is not currently accepting new answers or interactions. The challenge The shortest code by character count that will generate a beehive from user input. A beehive is defined a a grid of hexagons in a size inputted by the user as two positive numbers greater than zero (no need to validate input). The first number ( W ) represents the width of the beehive - or - how many

Code golf: the Mandelbrot set

百般思念 提交于 2019-12-03 01:53:49
问题 Locked . This question and its answers are locked because the question is off-topic but has historical significance. It is not currently accepting new answers or interactions. Usual rules for the code golf. Here is an implementation in python as an example from PIL import Image im = Image.new("RGB", (300,300)) for i in xrange(300): print "i = ",i for j in xrange(300): x0 = float( 4.0*float(i-150)/300.0 -1.0) y0 = float( 4.0*float(j-150)/300.0 +0.0) x=0.0 y=0.0 iteration = 0 max_iteration =

Code Golf: Finite-state machine!

大憨熊 提交于 2019-12-03 01:10:34
问题 Locked . This question and its answers are locked because the question is off-topic but has historical significance. It is not currently accepting new answers or interactions. Finite state machine A deterministic finite state machine is a simple computation model, widely used as an introduction to automata theory in basic CS courses. It is a simple model, equivalent to regular expression, which determines of a certain input string is Accepted or Rejected . Leaving some formalities aside, A

Code golf: find all anagrams

旧巷老猫 提交于 2019-12-02 22:54:51
A word is an anagram if the letters in that word can be re-arranged to form a different word. Task: The shortest source code by character count to find all sets of anagrams given a word list. Spaces and new lines should be counted as characters Use the code ruler ---------10--------20--------30--------40--------50--------60--------70--------80--------90--------100-------110-------120 Input: a list of words from stdin with each word separated by a new line. e.g. A A's AOL AOL's Aachen Aachen's Aaliyah Aaliyah's Aaron Aaron's Abbas Abbasid Abbasid's Output: All sets of anagrams, with each set

Code Golf: 1x1 black pixel

限于喜欢 提交于 2019-12-02 21:08:43
Recently, I used my favorite image editor to make a 1x1 black pixel (which can come in handy when you want to draw solid boxes in HTML cheaply). Even though I made it a monochrome PNG, it came out to be 120 bytes! I mean, that's kind of steep. 120 bytes. For one pixel . I then converted it to a GIF, which dropped the size down to 43 bytes. Much better, but still... Challenge The shortest image file or program that is or generates a 1x1 black pixel. A submission may be: An image file that represents a 1x1 black pixel. The format chosen must be able to represent larger images than 1x1, and

How to generate a Mandelbrot with T-SQL?

旧巷老猫 提交于 2019-12-02 19:40:48
Learning a little about T-SQL, and thought an interesting exercise would be to generate a Mandelbrot set with it. Turns out someone already has (and recently, it appears). I'll let someone else post it as an answer, but I'm curious what optimizations can be made. Alternately, what would you do to make the code more readable? I'll select the most readable (yet reasonably compact) version as the accepted answer (too bad we don't have rep bounties yet!) unless someone really comes along with a great optimization. Bonus points to those answers that teach me a little something about T-SQL. -Adam

garble function contest

五迷三道 提交于 2019-12-02 19:23:37
Remember that away message on aim that said how: Aoccdrnig to a rscheearch at Cmabrigde Uinervtisy, it deosn't mttaer in waht oredr the ltteers in a wrod are, the olny iprmoetnt tihng is taht the frist and lsat ltteer be at the rghit pclae. The rset can be a toatl mses and you can sitll raed it wouthit porbelm. Tihs is bcuseae the huamn mnid deos not raed ervey lteter by istlef, but the wrod as a wlohe. Anyway I'm trying to make a function that would do that to an entire page. There are a few rules for this function. less then 4 characters leave alone. non-alphanumeric characters don't count