code-golf

Code-golf: generate pascal's triangle

你说的曾经没有我的故事 提交于 2019-11-27 05:21:41
问题 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. Generate a list of lists (or print, I don't mind) a Pascal's Triangle of size N with the least lines of code possible! Here goes my attempt (118 characters in python 2.6 using a trick): c,z,k=locals,[0],'_[1]' p=lambda n:[len(c()[k])and map(sum,zip(z+c()[k][-1],c()[k][-1]+z))or[1]for _ in range(n)] Explanation: the

Code Golf: Countdown Number Game

自作多情 提交于 2019-11-27 05:05: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. Challenge Here is the task, inspired by the well-known British TV game show Countdown . The challenge should be pretty clear even without any knowledge of the game, but feel free to ask for clarifications. And if you fancy seeing a clip of this game in action, check out this YouTube clip. It features the wonderful late

Simple PHP form: Attachment to email (code golf)

淺唱寂寞╮ 提交于 2019-11-27 02:46:31
Imagine a user that would like to put a form on their website that would allow a website visitor to upload a file and a simple message, which will immediately be emailed (ie, the file is not stored on the server, or if it is then only temporarily) as a file attachment with the note in the message body. See more details at http://a2zsollution.com/php-secure-e-mail/ What is the simplest way to accomplish this? Simplest in terms of: Size (code golf) Ease of implementation (ideally all in one file, needs few to no external resources) Not obfuscated for the sake of obfuscation (tradeoffs for size

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 - hex to (raw) binary conversion

删除回忆录丶 提交于 2019-11-27 01:24: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. In response to this question asking about hex to (raw) binary conversion, a comment suggested that it could be solved in "5-10 lines of C, or any other language." I'm sure that for (some) scripting languages that could be achieved, and would like to see how. Can we prove that comment true, for C, too? NB: this doesn't

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,

Evaluating a string of simple mathematical expressions [closed]

帅比萌擦擦* 提交于 2019-11-26 21:17:51
Challenge Here is the challenge (of my own invention, though I wouldn't be surprised if it has previously appeared elsewhere on the web). Write a function that takes a single argument that is a string representation of a simple mathematical expression and evaluates it as a floating point value. A "simple expression" may include any of the following: positive or negative decimal numbers, + , - , * , / , ( , ) . Expressions use (normal) infix notation . Operators should be evaluated in the order they appear, i.e. not as in BODMAS , though brackets should be correctly observed, of course. The

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

Simple PHP form: Attachment to email (code golf)

纵然是瞬间 提交于 2019-11-26 17:29:51
问题 Imagine a user that would like to put a form on their website that would allow a website visitor to upload a file and a simple message, which will immediately be emailed (ie, the file is not stored on the server, or if it is then only temporarily) as a file attachment with the note in the message body. See more details at http://a2zsollution.com/php-secure-e-mail/ What is the simplest way to accomplish this? Simplest in terms of: Size (code golf) Ease of implementation (ideally all in one