134 questions
- Bountied 0
- Unanswered
- Frequent
- Score
- Trending
- Week
- Month
- Unanswered (my tags)
8
votes
1
answer
3k
views
PowerShell shortest syntax to create a new PSObject using Property?
I use the following very often:
New-Object psobject -Property @{a=1; b=2; c=3; d=4}
I would like to make this as short as possible, perhaps even 1 character?
What's the shortest way to create a new ...
0
votes
7
answers
4k
views
Convert true and false in Coffeescript to 1 and -1 respectively
if x < change.pageX # pageX is cross-browser normalized by jQuery
val = Number(elem.text())
return elem.text(o.max) if val + o.step > o.max
return elem.text(o....
2
votes
2
answers
570
views
How do I turn on function name completion?
In golfing, one tries to complete a puzzle in as few characters as possible, generally using the base language only. One trick for golfing in R is to use partial completion so that e.g. rle(...)$...
20
votes
4
answers
19k
views
Ruby read/write to file in 1 line of code
I am kind of a newbie to Ruby, I am working out some katas and I stuck on this silly problem. I need to copy the content of 1 file to a new file in 1 line of code
First try:
File.open(out, 'w')....
10
votes
2
answers
3k
views
Can this Linux / 32bit x86 assembly "Hello, World" be made smaller still?
The following 32bit x86 Linux program prints a string of arbitrary length (as long as a program can be, anyway) and does exit(0) afterwards:
.global _start ; notice on entry here, all ...
4
votes
2
answers
4k
views
Convert DateTime to shortest possible version number (for url)
Challenge: convert a 'modified date' DateTime of an image file to a version number / string suitable for maintaining uniqueness in a url, so each modification of the image generates a unique url, the ...
2
votes
2
answers
263
views
Detect IsAlive on an IObservable
I'm writing a function IsAlive to take an IObservable<T>, and a timespan, and return an IObservable<bool> The canonical use case is to detect if a streaming server is still sending data.
...
6
votes
4
answers
3k
views
Python Code Shortening
I was trying to solve this problem here :- https://www.spoj.pl/problems/PHIVAL/
The questions asks you to output as many decimal digits of the golden ratio (1+sqrt(5))/2 as possible and also try to ...
1
vote
5
answers
742
views
How to Rewrite of One Line Code (or Less Line Code in command line) of this code in Perl?
I have a code like that:
#!/usr/bin/perl
use strict;
use warnings;
my %proteins = qw/
UUU F UUC F UUA L UUG L UCU S UCC S UCA S UCG S UAU Y UAC Y UGU C UGC C UGG W
CUU L CUC L CUA L CUG ...
18
votes
4
answers
2k
views
garble function contest
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 ...
Community wiki
35
votes
20
answers
11k
views
Code Golf: Finite-state machine!
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 ...
Community wiki
17
votes
8
answers
2k
views
Code Golf: Numeric Ranges
Challenge
Compactify a long list of numbers by replacing consecutive runs with ranges.
Example
Input
1, 2, 3, 4, 7, 8, 10, 12, 13, 14, 15
The input is guaranteed to be in ascending order and will not ...
Community wiki
36
votes
4
answers
7k
views
Code Golf: Countdown Number Game
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 ...
Community wiki
19
votes
9
answers
2k
views
CodeGolf: Find the Unique Paths
Here's a pretty simple idea, in this pastebin I've posted some pair of numbers. These represent Nodes of a directed graph. The input to stdin will be of the form, (they'll be numbers, i'll be using an ...
Community wiki
0
votes
3
answers
787
views
Perl - CodeGolf - Nested loops & SQL inserts
I had to make a really small and simple script that would fill a table with string values according to these criteria:
2 characters long
1st character is always numeric (0-9)
2nd character is (0-9) ...