rosetta-stone

Code Golf: Beehive

随声附和 提交于 2019-12-02 16:45:49
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 hexagons are on each row. The second number ( H ) represents the height of the beehive - or - how many hexagons are on each column. A Single hexagon is made from three ASCII characters: _ , / and \ , and three lines: __ / \ \__/ Hexagons complete each other: the first column of the

Code Golf: Connecting the dots

老子叫甜甜 提交于 2019-12-02 16:07:29
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 lines can be considered to be the same length (you can pad spaces to the end). the numbers always start at 1 they follow the ordering of the natural numbers: every 'next number' is incremented with 1 every number is surrounded by (at least) one whitespace on its left and right Task

Code Golf: Playing Cubes

限于喜欢 提交于 2019-12-02 14:21:30
The challenge The shortest code by character count, that will output playing bricks tower series according to user input. The input will be a series of numbers (positive, negative and zero) that represents the height of the current cube tower following their index. A height of 0 means no tower and is spaced. A cube tower is composed of stacked cubes. If the input number on the current index is positive, the cubes go up, if the input number is negative, the cubes go down. A single cube is drawn using the 4 following lines: __ /__ /| | | | |___|/ Cubes are 3D - this means they hide each other

Code golf: the Mandelbrot set

孤街醉人 提交于 2019-12-02 14:04:39
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 = 1000 while (x*x + y*y <= 4.0 and iteration < max_iteration): xtemp = x*x - y*y + x0 y = 2.0*x*y+y0 x = xtemp iteration += 1 if iteration == max_iteration: value = 255 else: value = iteration*10 % 255 print value im.putpixel( (i,j), (value, value, value)) im.save("image.png", "PNG"

Code Golf: Rotating Maze

血红的双手。 提交于 2019-11-30 11:58:58
问题 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. Code Golf: Rotating Maze Make a program that takes in a file consisting of a maze. The maze has walls given by # . The maze must include a single ball, given by a o and any number of holes given by a @ . The maze file can either be entered via command line or read in as a line through standard input. Please specify

Code Golf: Build Me an Arc

我怕爱的太早我们不能终老 提交于 2019-11-30 07:59:21
问题 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. Challenge The shortest program by character count that accepts standard input of the form X-Y R , with the following guarantees: R is a non-negative decimal number less than or equal to 8 X and Y are non-negative angles given in decimal as multiples of 45° ( 0 , 45 , 90 , 135 , etc.) X is less than Y Y is not 360 if X

Code Golf: Quickly Build List of Keywords from Text, Including # of Instances

ぃ、小莉子 提交于 2019-11-30 03:49:04
I've already worked out this solution for myself with PHP, but I'm curious how it could be done differently - better even. The two languages I'm primarily interested in are PHP and Javascript, but I'd be interested in seeing how quickly this could be done in any other major language today as well (mostly C#, Java, etc). Return only words with an occurrence greater than X Return only words with a length greater than Y Ignore common terms like "and, is, the, etc" Feel free to strip punctuation prior to processing (ie. "John's" becomes "John") Return results in a collection/array Extra Credit

Fibonacci Code Golf

孤街浪徒 提交于 2019-11-29 21:25:36
Generate the Fibonacci sequence in the fewest amount of characters possible. Any language is OK, except for one that you define with one operator, f , which prints the Fibonacci numbers. Starting point: 25 14 characters in Haskell : f=0:1:zipWith(+)f(tail f) f=0:scanl(+)1f Callum Rogers RePeNt, 9 , 8 chars 1↓[2?+1] Or 10 chars with printing: 1↓[2?+↓£1] Run using: RePeNt "1↓[2?+1]" RePeNt is a stack based toy language I wrote (and am still improving) in which all operators/functions/blocks/loops use Reverse Polish Notation (RPN). Command Explanation Stack ------- ----------- ----- 1 Push a 1

Code Golf - Banner Generation

风格不统一 提交于 2019-11-29 20:54:08
When thanking someone, you don't want to just send them an e-mail saying "Thanks!", you want to have something FLASHY: Input: THANKS!! Output: TTT H H AAA N N K K SSS !!! !!! T H H A A NNN K K S !!! !!! T HHH AAA NNN KK SSS !!! !!! T H H A A N N K K S T H H A A N N K K SSS !!! !!! Write a program to generate a banner. You only have to generate upper-case A-Z along with spaces and exclamation points (what is a banner without an exclamation point?). All characters are made up of a 3x5 grid of the same character (so the S is a 3x5 grid made of S). All output should be on one row (so no newlines).

Palindrome Golf

为君一笑 提交于 2019-11-29 19:45:13
The goal: Any language. The smallest function which will return whether a string is a palindrome. Here is mine in Python : R=lambda s:all(a==b for a,b in zip(s,reversed(s))) 50 characters. The accepted answer will be the current smallest one - this will change as smaller ones are found. Please specify the language your code is in. 7 characters in J: Not sure if this is the best way, I'm somewhat new to J :) p=:-:|. explanation: |. reverses the input. -: compares. the operands are implicit. p 'radar' 1 p 'moose' 0 Menkboy Here's mine; it's written in a domain-specific language I invented,