code-golf

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: combining multiple sorted lists into a single sorted list

烂漫一生 提交于 2019-11-30 05:12:37
Implement an algorithm to merge an arbitrary number of sorted lists into one sorted list. The aim is to create the smallest working programme, in whatever language you like. For example: input: ((1, 4, 7), (2, 5, 8), (3, 6, 9)) output: (1, 2, 3, 4, 5, 6, 7, 8, 9) input: ((1, 10), (), (2, 5, 6, 7)) output: (1, 2, 5, 6, 7, 10) Note : solutions which concatenate the input lists then use a language-provided sort function are not in-keeping with the spirit of golf, and will not be accepted: sorted(sum(lists,[])) # cheating: out of bounds! Apart from anything else, your algorithm should be (but

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

Code Golf: Duplicate Character Removal in String

家住魔仙堡 提交于 2019-11-30 02:54:08
The challenge: The shortest code, by character count , that detects and removes duplicate characters in a String. Removal includes ALL instances of the duplicated character (so if you find 3 n's, all three have to go), and original character order needs to be preserved. Example Input 1: nbHHkRvrXbvkn Example Output 1: RrX Example Input 2: nbHHkRbvnrXbvkn Example Output 2: RrX (the second example removes letters that occur three times; some solutions have failed to account for this) (This is based on my other question where I needed the fastest way to do this in C#, but I think it makes good

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).

Convert a string into Morse code [closed]

本秂侑毒 提交于 2019-11-29 19:56:54
The challenge The shortest code by character count, that will input a string using only alphabetical characters (upper and lower case), numbers, commas, periods and question mark, and returns a representation of the string in Morse code. The Morse code output should consist of a dash ( - , ASCII 0x2D) for a long beep (AKA 'dah') and a dot ( . , ASCII 0x2E) for short beep (AKA 'dit'). Each letter should be separated by a space ( ' ' , ASCII 0x20), and each word should be separated by a forward slash ( / , ASCII 0x2F). Morse code table: alt text http://liranuna.com/junk/morse.gif Test cases:

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,

Code Golf: Running Water

≡放荡痞女 提交于 2019-11-29 19:25:36
The challenge The shortest code by character count to identify and mark water depressions in the ASCII representation of a land from input. Input will be an ASCII representation of a landscape, having hills, valleys and flat lands. The program should simulate what the landscape would look like if if was flooded - filling all valleys with water (character x ). The landscape will always start and stop with the character _ and will be at least 2 characters long, making the shortest input __ . A hill is defined as a raise, and should not be filled with water: __ _/ \_ A valley is defined as a