You are not logged in.
forth:
6 1 do i . ." I love archlinux" cr loop
edit0: meh language restriction -_- pfft
edit1: shorter than the zsh version though ^_^
edit2: just because:
echo I love archlinux | sed "s/^/1 /;:x;p;y/1234/2345/;s/[1-4]/&/;tx"
(started with a pure sed one, but that one would require an <cr> press to run.)
Last edited by tlvb (2010-02-13 18:46:19)
I need a sorted list of all random numbers, so that I can retrieve a suitable one later with a binary search instead of having to iterate through the generation process every time.
Offline
This is longer than the other Python ones, but oh well. This list comprehension works in Python 2.x.
print '\n'.join(['%i I love archlinux'%i for i in range(1,6)])
The following is shorter than the first Python entry in this thread, but it requires i to equal 1 prior to being run:
while i<6:print i,'I love archlinux';i+=1
The following throws an exception:
i=1;while i<6:print i,'I love archlinux';i+=1
I'm not surprised though. Python isn't designed for mind-boggling one-liners.
Last edited by linkmaster03 (2010-02-13 22:41:09)
Offline
One very bad way to get rid of the newlines by `sed =`
yes [A[C I love archlinux|sed =\;5q
Still 37 characters
On the other hand sed 5q is shorter than head -n5. So
yes I love archlinux|sed 5q|cat -n
34 characters
edit: one more:
seq 5|sed 's/$/ I love archlinux/'
Last edited by Procyon (2010-02-14 00:27:12)
Offline
No one using bash's printf?
printf "%d I love archlinux\n" {1..5}
I never believed bash could be this simple
Offline
Perl version, modifying Trent's:
You can remove the parenthesis from the range, requiring 1 less char for 37 chars:
warn"$_ I love archlinux\n"for 1..5
If we are allowed to use perl 5.10, we can use say for 33 chars:
say"$_ I love archlinux"for 1..5
Offline
This is the shortest I get it in Haskell
putStr.unlines$[show x++" I love archlinux"|x<-[1..5]]
Offline
Dmz: Please choose the winner, so we can get the next challenge.
Offline
Dmz: Please choose the winner, so we can get the next challenge.
I think you're the only one that actually followed the rules and presented the desired output. Go ahead.
Offline
Why not Juster? What I could see of the rules it didn't state what version one have to use.
Offline
Yes, I'm sorry, missed that. Go ahead Juster.
Offline
1. When posting your reply, clearly say the amount of characters used.
2. When posting, and not using one of the desired languages, clearly announce that in the beginning. (Note: php is allowed, the link says it, but not the first post)
3. If you post a reply that you know ain't shorter than one of the earlier post, clearly announce that too.
4. Note if your code does not put out exactly the same outcome.
5. The code should not depend on anything else except for built in, default, functions.
Right now it's a hell to go through the post and check all of this. I'm a newbie when it comes to programming, and I'm not the first poster, so please change what's deemed necessary and put it in the first post. And I think we should allow more languages, if not all 'common' languages.
Offline
Not an entry (just wanted to add an alternative Python 3 approach):
list(map(print,range(1,6),["I love Arch Linux"]*5))
This is actually a bit irritating; if I use Python 2 I can get rid of the list() function call, but then I have to add more code because print isn't a function in Python 2.
So, the best way I could come up with, which was this:
map(print,range(1,6),["I love Arch Linux"]*5)
... works partly in Python 2 and the rest of it works in Python 3 but it doesn't work completely in any of them .
Offline
bash. 8 chars.
codegolf
This calls a script called 'codegolf'.
Okay, so I cheated.
Offline
bash. 8 chars.
codegolf
This calls a script called 'codegolf'.
Okay, so I cheated.
lol
Last edited by n0dix (2010-02-16 13:50:13)
Offline
bash. 8 chars.
codegolf
This calls a script called 'codegolf'.
Okay, so I cheated.
bash. 1 character
c
This calls a script called 'c'. I win.
How's my programming? Call 1-800-DEV-NULL
Offline
Peasantoid wrote:bash. 8 chars.
codegolf
This calls a script called 'codegolf'.
Okay, so I cheated.
bash. 1 character
c
This calls a script called 'c'. I win.
Bash:
Displaying PS1. 0 characters.
Offline
Ruby, 41 chars
5.times{|x|puts"#{x+1} I love archlinux"}
Last edited by awkwood (2010-02-16 19:50:39)
Offline
I'm surprised no one had OCAML yet!
for i = 1 to 5 do print_string ( (string_of_int i) ^ " I love archlinux\n" ) done;;
81 characters
Last edited by tomd123 (2010-02-16 19:49:58)
Offline
Makefile:
%: @echo $@" I love Archlinux" all:1 2 3 4 5
</edit>
I just reallized that it could be simplified to somthing like this:
%:
@echo $@" I love archlinux"
5:1 2 3 4
42 characters. I guess it is the answer to life, the universe and everything...
Offline
Congratulations Juster!
Out of curiosity, does anyone have an unposted ruby version smaller than 41 chars?
Raf_kig's is 41, and all of the one's I've come up with are 41 too
Ruby 1.9.1
printf("%s I love archlinux\n"*5,*(1..5))
$><<"%s I love archlinux\n"*5%[1,2,3,4,5]
print (1..5).zip(" I love archlinux\n"*5)
Offline
How about this for the next challenge. A little harder, not much. You will want to fill up 9 lines with "ArchLinux". Each line is wrapped at 78 columns (chars). The block of text should fit perfectly on 9 lines:
mclapdawg:~ juster$ ruby golf.rb
ArchLinuxArchLinuxArchLinuxArchLinuxArchLinuxArchLinuxArchLinuxArchLinuxArchLi
nuxArchLinuxArchLinuxArchLinuxArchLinuxArchLinuxArchLinuxArchLinuxArchLinuxArc
hLinuxArchLinuxArchLinuxArchLinuxArchLinuxArchLinuxArchLinuxArchLinuxArchLinux
ArchLinuxArchLinuxArchLinuxArchLinuxArchLinuxArchLinuxArchLinuxArchLinuxArchLi
nuxArchLinuxArchLinuxArchLinuxArchLinuxArchLinuxArchLinuxArchLinuxArchLinuxArc
hLinuxArchLinuxArchLinuxArchLinuxArchLinuxArchLinuxArchLinuxArchLinuxArchLinux
ArchLinuxArchLinuxArchLinuxArchLinuxArchLinuxArchLinuxArchLinuxArchLinuxArchLi
nuxArchLinuxArchLinuxArchLinuxArchLinuxArchLinuxArchLinuxArchLinuxArchLinuxArc
hLinuxArchLinuxArchLinuxArchLinuxArchLinuxArchLinuxArchLinuxArchLinuxArchLinux
mclapdawg:~ juster$ cat golf.rb
A="ArchLinux"
txt = A*(78*9/A.length)
txt.scan(/.{78}/).each{|x| puts x}
mclapdawg:~ juster$ wc -c golf.rb
73 golf.rb
mclapdawg:~ juster$
I was going to use terminal color codes too but thought better of it at the last minute. Hope this isn't too hard/easy!
edit: oops I had said 10 lines, but its 9
Last edited by juster (2010-02-16 22:08:33)
Offline
my python entry, 55 characters
for i in range(9):print("ArchLinux"*81)[78*i:78*(i+1)]
Offline
Ruby, 35 chars
puts ("ArchLinux"*78).scan(/.{78}/)
Offline
puts ("ArchLinux"*78).scan /.{78}/
Offline
Not the smallest so far. 44 characters and written in bash:
seq -sArchlinux 79|sed s/[0-9]//g|fold -w78
Last edited by PJ (2010-02-17 00:33:08)
Offline