You are not logged in.

#26 2010-02-13 18:35:11

tlvb
Member
From: Sweden
Registered: 2008-10-06
Posts: 297
Website

Re: The Golf Tournament!

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

#27 2010-02-13 22:38:44

linkmaster03
Member
Registered: 2008-12-27
Posts: 269

Re: The Golf Tournament!

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

Last edited by linkmaster03 (2010-02-13 22:41:09)

Offline

#28 2010-02-14 00:04:24

Procyon
Member
Registered: 2008-05-07
Posts: 1,819

Re: The Golf Tournament!

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

#29 2010-02-14 00:15:39

Hide
Member
From: Castalia
Registered: 2007-02-02
Posts: 368

Re: The Golf Tournament!

some-guy94 wrote:

No one using bash's printf?

printf "%d I love archlinux\n" {1..5}

I never believed bash could be this simple smile

Offline

#30 2010-02-14 08:00:22

juster
Forum Fellow
Registered: 2008-10-07
Posts: 195

Re: The Golf Tournament!

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

#31 2010-02-14 10:21:27

Ramses de Norre
Member
From: Leuven - Belgium
Registered: 2007-03-27
Posts: 1,289

Re: The Golf Tournament!

This is the shortest I get it in Haskell

putStr.unlines$[show x++" I love archlinux"|x<-[1..5]]

Offline

#32 2010-02-14 10:48:50

Ashren
Member
From: Denmark
Registered: 2007-06-13
Posts: 1,229
Website

Re: The Golf Tournament!

Dmz: Please choose the winner, so we can get the next challenge.

Offline

#33 2010-02-15 06:32:13

dmz
Member
From: Sweden
Registered: 2008-08-27
Posts: 881
Website

Re: The Golf Tournament!

Ashren wrote:

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

#34 2010-02-15 06:45:16

hatten
Arch Linux f@h Team Member
From: Sweden, Borlange
Registered: 2009-02-23
Posts: 736

Re: The Golf Tournament!

Why not Juster? What I could see of the rules it didn't state what version one have to use.

Offline

#35 2010-02-15 06:56:40

dmz
Member
From: Sweden
Registered: 2008-08-27
Posts: 881
Website

Re: The Golf Tournament!

Yes, I'm sorry, missed that. Go ahead Juster.

Offline

#36 2010-02-15 14:29:08

hatten
Arch Linux f@h Team Member
From: Sweden, Borlange
Registered: 2009-02-23
Posts: 736

Re: The Golf Tournament!

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

#37 2010-02-16 08:45:45

dptkby
Member
Registered: 2009-07-02
Posts: 64

Re: The Golf Tournament!

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

Offline

#38 2010-02-16 08:49:17

Peasantoid
Member
Registered: 2009-04-26
Posts: 928
Website

Re: The Golf Tournament!

bash. 8 chars.

codegolf

This calls a script called 'codegolf'.

Okay, so I cheated. tongue

Offline

#39 2010-02-16 13:49:54

n0dix
Member
Registered: 2009-09-22
Posts: 956

Re: The Golf Tournament!

Peasantoid wrote:

bash. 8 chars.

codegolf

This calls a script called 'codegolf'.

Okay, so I cheated. tongue

lol lol

Last edited by n0dix (2010-02-16 13:50:13)

Offline

#40 2010-02-16 14:25:27

zowki
Member
From: Trapped in The Matrix
Registered: 2008-11-27
Posts: 582
Website

Re: The Golf Tournament!

Peasantoid wrote:

bash. 8 chars.

codegolf

This calls a script called 'codegolf'.

Okay, so I cheated. tongue

bash. 1 character

c

This calls a script called 'c'. I win.


How's my programming? Call 1-800-DEV-NULL

Offline

#41 2010-02-16 14:57:08

Procyon
Member
Registered: 2008-05-07
Posts: 1,819

Re: The Golf Tournament!

zowki wrote:
Peasantoid wrote:

bash. 8 chars.

codegolf

This calls a script called 'codegolf'.

Okay, so I cheated. tongue

bash. 1 character

c

This calls a script called 'c'. I win.

Bash:

Displaying PS1. 0 characters.

Offline

#42 2010-02-16 19:23:00

awkwood
Member
From: .au <=> .ca
Registered: 2009-04-23
Posts: 91

Re: The Golf Tournament!

Ruby, 41 chars

5.times{|x|puts"#{x+1} I love archlinux"}

Last edited by awkwood (2010-02-16 19:50:39)

Offline

#43 2010-02-16 19:44:53

tomd123
Developer
Registered: 2008-08-12
Posts: 565

Re: The Golf Tournament!

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

#44 2010-02-16 20:11:08

PJ
Member
From: Sweden
Registered: 2005-10-11
Posts: 602

Re: The Golf Tournament!

PJ wrote:

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

Offline

#45 2010-02-16 21:57:12

awkwood
Member
From: .au <=> .ca
Registered: 2009-04-23
Posts: 91

Re: The Golf Tournament!

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 smile

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

#46 2010-02-16 22:03:34

juster
Forum Fellow
Registered: 2008-10-07
Posts: 195

Re: The Golf Tournament!

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

#47 2010-02-16 22:27:54

raf_kig
Member
Registered: 2008-11-28
Posts: 143

Re: The Golf Tournament!

my python entry, 55 characters

for i in range(9):print("ArchLinux"*81)[78*i:78*(i+1)]

Offline

#48 2010-02-16 22:38:00

awkwood
Member
From: .au <=> .ca
Registered: 2009-04-23
Posts: 91

Re: The Golf Tournament!

Ruby, 35 chars

puts ("ArchLinux"*78).scan(/.{78}/)

Offline

#49 2010-02-16 23:13:01

Bralkein
Member
Registered: 2004-10-26
Posts: 354

Re: The Golf Tournament!

puts ("ArchLinux"*78).scan /.{78}/

wink

Offline

#50 2010-02-17 00:19:16

PJ
Member
From: Sweden
Registered: 2005-10-11
Posts: 602

Re: The Golf Tournament!

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

Board footer

Powered by FluxBB