Skip to main content
deleted 47 characters in body
Source Link
Martin Ender
  • 197.2k
  • 67
  • 447
  • 975

Ruby, 13561356 1268 * 3 = 40683804 bytes

if File.file?(?b)
s='P3
50 50
255
'
d=e=0
[153,44,6,1,42,1,6,1,42,1,6,1,42,1,6,1,42,1,6,1,42,1,6,1,42,1,4,40,5,1,4,1,1,1,36,1,5,1,4,1,1,1,36,1,5,1,4,1,1,1,36,1,5,1,4,1,1,1,36,1,5,1,4,1,1,34,3,1,5,1,4,1,34,1,3,1,5,1,4,1,34,1,3,1,5,1,4,1,34,1,3,1,5,1,4,1,34,1,3,1,5,1,4,1,34,1,3,1,5,1,4,1,34,1,3,1,5,1,4,1,34,1,3,1,5,1,4,1,34,1,3,1,5,1,4,1,34,1,3,1,5,1,4,1,34,1,3,1,5,1,4,1,34,1,3,1,5,1,4,1,34,1,3,1,5,1,4,1,8,31,5,1,4,1,8,1,25,1,9,1,4,1,8,1,25,1,9,1,4,1,8,1,25,1,9,1,4,1,8,1,25,1,9,1,4,1,8,1,25,1,9,1,4,1,8,1,25,1,9,1,4,1,8,1,25,1,9,1,4,1,8,37,4,1,34,1,14,1,34,1,14,1,34,1,14,1,34,1,14,1,34,1,14,1,34,1,14,1,34,1,14,1,34,1,14,1,34,1,14,1,34,1,14,1,34,1,14,36,63].map{|n|n.times{s+=[" 255 255 255"," 0 0 255"][d];s+=$/if (e+=1)%50==0};d=1-d}
File.write 'blue.ppm',s
elsif File.file?(?a)
puts [["","Mary had a little lamb",
Little"little lamblamb", little lamb?,
Mary had a little lamb,
Its?,,"Its fleece was white as snow

Andsnow"],["And everywhere","everywhere that Mary went",
Mary"Mary wentwent", Mary went?,
Everywhere that Mary went
The,'',"The lamb was sure to go

It followed her to school one day
School one daygo"], school one day
It["","It followed her to school","school one day
Whichday",'','',"Which was against the rules.

It"],["","It made the children laugh and play",
Laugh"laugh and playplay", laugh and play?,
It made the children laugh and play
To,'',"To see a lamb at school"school"]].map{|a,b,c,d,e,f|[a+b+c+d,c.capitalize+', '+c+d,b.capitalize+c+e,f]*$/}*"

"
`touch b`
else
1971.times{|i|$><<"#{i} "if i.to_s.chars.map(&:to_i).reduce(:+)%17<1}
`touch a`
end

I haven't golfed the second program yet. To keep track of the invocation, I'm creating an empty file a on the first run and an empty file b on the second run.

The first program uses a certain property of the numbers, and the third program currently uses just a naive run-length encoding. I'll look into actually encoding the path of the line later.

  • The first program uses a certain property of the numbers.
  • The second program uses a bunch of reusable parts of the verses, but that currently only saves 100 bytes over naively printing the entire thing.
  • The third program currently uses just a simple run-length encoding. I'll look into actually encoding the path of the line later.

Ruby, 1356 * 3 = 4068 bytes

if File.file?(?b)
s='P3
50 50
255
'
d=e=0
[153,44,6,1,42,1,6,1,42,1,6,1,42,1,6,1,42,1,6,1,42,1,6,1,42,1,4,40,5,1,4,1,1,1,36,1,5,1,4,1,1,1,36,1,5,1,4,1,1,1,36,1,5,1,4,1,1,1,36,1,5,1,4,1,1,34,3,1,5,1,4,1,34,1,3,1,5,1,4,1,34,1,3,1,5,1,4,1,34,1,3,1,5,1,4,1,34,1,3,1,5,1,4,1,34,1,3,1,5,1,4,1,34,1,3,1,5,1,4,1,34,1,3,1,5,1,4,1,34,1,3,1,5,1,4,1,34,1,3,1,5,1,4,1,34,1,3,1,5,1,4,1,34,1,3,1,5,1,4,1,34,1,3,1,5,1,4,1,8,31,5,1,4,1,8,1,25,1,9,1,4,1,8,1,25,1,9,1,4,1,8,1,25,1,9,1,4,1,8,1,25,1,9,1,4,1,8,1,25,1,9,1,4,1,8,1,25,1,9,1,4,1,8,1,25,1,9,1,4,1,8,37,4,1,34,1,14,1,34,1,14,1,34,1,14,1,34,1,14,1,34,1,14,1,34,1,14,1,34,1,14,1,34,1,14,1,34,1,14,1,34,1,14,1,34,1,14,36,63].map{|n|n.times{s+=[" 255 255 255"," 0 0 255"][d];s+=$/if (e+=1)%50==0};d=1-d}
File.write 'blue.ppm',s
elsif File.file?(?a)
puts "Mary had a little lamb,
Little lamb, little lamb,
Mary had a little lamb,
Its fleece was white as snow

And everywhere that Mary went,
Mary went, Mary went,
Everywhere that Mary went
The lamb was sure to go

It followed her to school one day
School one day, school one day
It followed her to school one day
Which was against the rules.

It made the children laugh and play,
Laugh and play, laugh and play,
It made the children laugh and play
To see a lamb at school"
`touch b`
else
1971.times{|i|$><<"#{i} "if i.to_s.chars.map(&:to_i).reduce(:+)%17<1}
`touch a`
end

I haven't golfed the second program yet. To keep track of the invocation, I'm creating an empty file a on the first run and an empty file b on the second run.

The first program uses a certain property of the numbers, and the third program currently uses just a naive run-length encoding. I'll look into actually encoding the path of the line later.

Ruby, 1356 1268 * 3 = 3804 bytes

if File.file?(?b)
s='P3
50 50
255
'
d=e=0
[153,44,6,1,42,1,6,1,42,1,6,1,42,1,6,1,42,1,6,1,42,1,6,1,42,1,4,40,5,1,4,1,1,1,36,1,5,1,4,1,1,1,36,1,5,1,4,1,1,1,36,1,5,1,4,1,1,1,36,1,5,1,4,1,1,34,3,1,5,1,4,1,34,1,3,1,5,1,4,1,34,1,3,1,5,1,4,1,34,1,3,1,5,1,4,1,34,1,3,1,5,1,4,1,34,1,3,1,5,1,4,1,34,1,3,1,5,1,4,1,34,1,3,1,5,1,4,1,34,1,3,1,5,1,4,1,34,1,3,1,5,1,4,1,34,1,3,1,5,1,4,1,34,1,3,1,5,1,4,1,34,1,3,1,5,1,4,1,8,31,5,1,4,1,8,1,25,1,9,1,4,1,8,1,25,1,9,1,4,1,8,1,25,1,9,1,4,1,8,1,25,1,9,1,4,1,8,1,25,1,9,1,4,1,8,1,25,1,9,1,4,1,8,1,25,1,9,1,4,1,8,37,4,1,34,1,14,1,34,1,14,1,34,1,14,1,34,1,14,1,34,1,14,1,34,1,14,1,34,1,14,1,34,1,14,1,34,1,14,1,34,1,14,1,34,1,14,36,63].map{|n|n.times{s+=[" 255 255 255"," 0 0 255"][d];s+=$/if (e+=1)%50==0};d=1-d}
File.write 'blue.ppm',s
elsif File.file?(?a)
puts [["","Mary had a ","little lamb",?,,?,,"Its fleece was white as snow"],["And ","everywhere that ","Mary went",?,,'',"The lamb was sure to go"],["","It followed her to ","school one day",'','',"Which was against the rules."],["","It made the children ","laugh and play",?,,'',"To see a lamb at school"]].map{|a,b,c,d,e,f|[a+b+c+d,c.capitalize+', '+c+d,b.capitalize+c+e,f]*$/}*"

"
`touch b`
else
1971.times{|i|$><<"#{i} "if i.to_s.chars.map(&:to_i).reduce(:+)%17<1}
`touch a`
end

To keep track of the invocation, I'm creating an empty file a on the first run and an empty file b on the second run.

  • The first program uses a certain property of the numbers.
  • The second program uses a bunch of reusable parts of the verses, but that currently only saves 100 bytes over naively printing the entire thing.
  • The third program currently uses just a simple run-length encoding. I'll look into actually encoding the path of the line later.
added 193 characters in body
Source Link
Martin Ender
  • 197.2k
  • 67
  • 447
  • 975

The first program uses a certain property of the numbers, and the third program currently uses just a naive run-length encoding. I'll look into actually encoding the path of the line later.

The first program uses a certain property of the numbers, and the third program currently uses just a naive run-length encoding. I'll look into actually encoding the path of the line later.

Source Link
Martin Ender
  • 197.2k
  • 67
  • 447
  • 975

Ruby, 1356 * 3 = 4068 bytes

if File.file?(?b)
s='P3
50 50
255
'
d=e=0
[153,44,6,1,42,1,6,1,42,1,6,1,42,1,6,1,42,1,6,1,42,1,6,1,42,1,4,40,5,1,4,1,1,1,36,1,5,1,4,1,1,1,36,1,5,1,4,1,1,1,36,1,5,1,4,1,1,1,36,1,5,1,4,1,1,34,3,1,5,1,4,1,34,1,3,1,5,1,4,1,34,1,3,1,5,1,4,1,34,1,3,1,5,1,4,1,34,1,3,1,5,1,4,1,34,1,3,1,5,1,4,1,34,1,3,1,5,1,4,1,34,1,3,1,5,1,4,1,34,1,3,1,5,1,4,1,34,1,3,1,5,1,4,1,34,1,3,1,5,1,4,1,34,1,3,1,5,1,4,1,34,1,3,1,5,1,4,1,8,31,5,1,4,1,8,1,25,1,9,1,4,1,8,1,25,1,9,1,4,1,8,1,25,1,9,1,4,1,8,1,25,1,9,1,4,1,8,1,25,1,9,1,4,1,8,1,25,1,9,1,4,1,8,1,25,1,9,1,4,1,8,37,4,1,34,1,14,1,34,1,14,1,34,1,14,1,34,1,14,1,34,1,14,1,34,1,14,1,34,1,14,1,34,1,14,1,34,1,14,1,34,1,14,1,34,1,14,36,63].map{|n|n.times{s+=[" 255 255 255"," 0 0 255"][d];s+=$/if (e+=1)%50==0};d=1-d}
File.write 'blue.ppm',s
elsif File.file?(?a)
puts "Mary had a little lamb,
Little lamb, little lamb,
Mary had a little lamb,
Its fleece was white as snow

And everywhere that Mary went,
Mary went, Mary went,
Everywhere that Mary went
The lamb was sure to go

It followed her to school one day
School one day, school one day
It followed her to school one day
Which was against the rules.

It made the children laugh and play,
Laugh and play, laugh and play,
It made the children laugh and play
To see a lamb at school"
`touch b`
else
1971.times{|i|$><<"#{i} "if i.to_s.chars.map(&:to_i).reduce(:+)%17<1}
`touch a`
end

I haven't golfed the second program yet. To keep track of the invocation, I'm creating an empty file a on the first run and an empty file b on the second run.