rosetta-stone

Code Golf: Musical Notes

前提是你 提交于 2019-11-27 09:50:52
问题 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 output musical notation based on user input. Input will be composed of a series of letters and numbers - letters will represent the name of the note and the number will represent the length of the note. A note is made of 4 vertical columns. The note's head

Code Golf: Collatz Conjecture

 ̄綄美尐妖づ 提交于 2019-11-27 09:42: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. Inspired by http://xkcd.com/710/ here is a code golf for it. The Challenge Given a positive integer greater than 0, print out the hailstone sequence for that number. The Hailstone Sequence See Wikipedia for more detail.. If the number is even, divide it by two. If the number is odd, triple it and add one. Repeat this

Code Golf: The wave

陌路散爱 提交于 2019-11-27 09:36:42
问题 The challenge The shortest code by character count to generate a wave from the input string. A wave is generated by elevating (line-1) a higher character, and degrading (line+1) a lower character. Equal characters are kept on the same line (no elevating or degrading done). Input is made of lower case characters and numbers only, letters are considered higher than numbers. Test cases: Input: 1234567890qwertyuiopasdfghjklzxcvbnm Output: z l x v n k c b m j h g y p s f t u o a d w r i 9 q e 8 0

Code Golf: Decision Tree

久未见 提交于 2019-11-27 09:35:44
问题 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. In Google Code Jam 2009, Round 1B, there is a problem called Decision Tree that lent itself to rather creative solutions. Post your shortest solution; I'll update the Accepted Answer to the current shortest entry on a semi-frequent basis, assuming you didn't just create a new language just to solve this problem. :-P

Code Golf New Year Edition - Integer to Roman Numeral

為{幸葍}努か 提交于 2019-11-27 02:38:45
问题 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. Write a program that take a single command line argument N and prints out the corresponding Roman Numeral. Eg N = 2009 should print MMIX. Let's say this should work for 0 < N < 3000. (Had fun playing my first ever round of code golf with the Christmas edition, and thought this could fit for New Year. Googled to see if

Code Golf: Lasers

妖精的绣舞 提交于 2019-11-26 23:45:52
问题 The challenge The shortest code by character count to input a 2D representation of a board, and output 'true' or 'false' according to the input . The board is made out of 4 types of tiles: # - A solid wall x - The target the laser has to hit / or \ - Mirrors pointing to a direction (depends on laser direction) v, ^, > or < - The laser pointing to a direction (down, up, right and left respectively) There is only one laser and only one target . Walls must form a solid rectangle of any size,

Code Golf: Tic Tac Toe

回眸只為那壹抹淺笑 提交于 2019-11-26 17:58:50
问题 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. Post your shortest code, by character count, to check if a player has won, and if so, which. Assume you have an integer array in a variable b (board), which holds the Tic Tac Toe board, and the moves of the players where: 0 = nothing set 1 = player 1 (X) 2 = player 2 (O) So, given the array b = [ 1, 2, 1, 0, 1, 2, 1, 0,

Code Golf: Conway's Game of Life

主宰稳场 提交于 2019-11-26 17:55: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: Write the shortest program that implements John H. Conway's Game of Life cellular automaton. [link] EDIT: After about a week of competition, I have selected a victor: pdehaan , for managing to beat the Matlab solution by one character with perl. For those who haven't heard of Game of Life, you take a grid

Code Golf: Number to Words

二次信任 提交于 2019-11-26 10:14:28
The code golf series seem to be fairly popular. I ran across some code that converts a number to its word representation. Some examples would be (powers of 2 for programming fun): 2 -> Two 1024 -> One Thousand Twenty Four 1048576 -> One Million Forty Eight Thousand Five Hundred Seventy Six The algorithm my co-worker came up was almost two hundred lines long. Seems like there would be a more concise way to do it. Current guidelines: Submissions in any programming language welcome (I apologize to PhiLho for the initial lack of clarity on this one) Max input of 2^64 (see following link for words,

Code Golf: Mathematical expression evaluator (that respects PEMDAS)

岁酱吖の 提交于 2019-11-26 07:24:39
问题 I challenge you to write a mathematical expression evaluator that respects PEMDAS (order of operations: parentheses, exponentiation, multiplication, division, addition, subtraction) without using regular expressions, a pre-existing \"Eval()\"-like function, a parsing library, etc. I saw one pre-existing evaluator challenge on SO (here), but that one specifically required left-to-right evaluation. Sample inputs and outputs: \"-1^(-3*4/-6)\" -> \"1\" \"-2^(2^(4-1))\" -> \"256\" \"2*6/4^2*4/3\"