3 deleted 4 characters in body
source | link

Haskell - 579-25 = 554 603603-25-30 576-25-30 = 548521 Bytes

Strategy:

  • Make a list of (d,x,y) triples for all pixels (d is distance to center)
  • sort the list by distance
  • beginning with the greatest distance: if the pixel the only green pixel in a small neighborhood, keep it's distance in a list L, else blacken it
  • calculate score from the distance list L

Output ist a triple (score,misses,Xs), e.g. (52,1,1) for the test image.

The program may fail if the pixel of a circle closest to the center is within 3 pixels of another circle.

import Data.List
import Codec.Picture
import Codec.Picture.RGBA8
import Codec.Picture.Canvas
z=fromIntegral
f(e,x,y)(v,h)|all id$j|and$j x y:[not$j a b|a<-[x-3..x+3],b<-[y-3..y+3],not(a==x&&b==y)]=(v,e:h)|1<2=(setColor x y(PixelRGBA8 0 0 0 0)v,h)
 where j n m=case(getColor n m v)of(PixelRGBA8m|PixelRGBA8 0 255 0 _)->True;__<->FalsegetColor n m v=0<1|0<1=0>1
d k r(h,i,j)|r>10*k=(h,i+1,j)|r<k*3/5=(h+10,i,j+1)|1<2=(10-(floor$r/k)+h,i,j)
main=do
 i<-readImageRGBA8 "p.png";letpng"
 let(Right c)=imageToCanvas i
 let s=canvasWidth c
 leti;s=canvasWidth c;q=[3..s-4];(_,g)=foldr f(c,[])$sort[(sqrt$(z x-z s/2)^2+(z y-z s/2)^2,x,y)|x<-[3..s-4]q,y<-[3..s-4]]q]
 print$foldr(d$z s/20)(0,0,0)g

Haskell - 579-25 = 554 603-25-30 = 548 Bytes

Strategy:

  • Make a list of (d,x,y) triples for all pixels (d is distance to center)
  • sort the list by distance
  • beginning with the greatest distance: if the pixel the only green pixel in a small neighborhood, keep it's distance in a list L, else blacken it
  • calculate score from the distance list L

Output ist a triple (score,misses,Xs), e.g. (52,1,1) for the test image.

The program may fail if the pixel of a circle closest to the center is within 3 pixels of another circle.

import Data.List
import Codec.Picture
import Codec.Picture.RGBA8
import Codec.Picture.Canvas
z=fromIntegral
f(e,x,y)(v,h)|all id$j x y:[not$j a b|a<-[x-3..x+3],b<-[y-3..y+3],not(a==x&&b==y)]=(v,e:h)|1<2=(setColor x y(PixelRGBA8 0 0 0 0)v,h)
 where j n m=case(getColor n m v)of(PixelRGBA8 0 255 0 _)->True;_->False
d k r(h,i,j)|r>10*k=(h,i+1,j)|r<k*3/5=(h+10,i,j+1)|1<2=(10-(floor$r/k)+h,i,j)
main=do
 i<-readImageRGBA8 "p.png";let(Right c)=imageToCanvas i
 let s=canvasWidth c
 let (_,g)=foldr f(c,[])$sort[(sqrt$(z x-z s/2)^2+(z y-z s/2)^2,x,y)|x<-[3..s-4],y<-[3..s-4]]
 print$foldr(d$z s/20)(0,0,0)g

Haskell - 579-25 = 554 603-25-30 576-25-30 = 521 Bytes

Strategy:

  • Make a list of (d,x,y) triples for all pixels (d is distance to center)
  • sort the list by distance
  • beginning with the greatest distance: if the pixel the only green pixel in a small neighborhood, keep it's distance in a list L, else blacken it
  • calculate score from the distance list L

Output ist a triple (score,misses,Xs), e.g. (52,1,1) for the test image.

The program may fail if the pixel of a circle closest to the center is within 3 pixels of another circle.

import Data.List
import Codec.Picture
import Codec.Picture.RGBA8
import Codec.Picture.Canvas
z=fromIntegral
f(e,x,y)(v,h)|and$j x y:[not$j a b|a<-[x-3..x+3],b<-[y-3..y+3],not(a==x&&b==y)]=(v,e:h)|1<2=(setColor x y(PixelRGBA8 0 0 0 0)v,h)
 where j n m|PixelRGBA8 0 255 0 _<-getColor n m v=0<1|0<1=0>1
d k r(h,i,j)|r>10*k=(h,i+1,j)|r<k*3/5=(h+10,i,j+1)|1<2=(10-(floor$r/k)+h,i,j)
main=do
 i<-readImageRGBA8 "p.png"
 let(Right c)=imageToCanvas i;s=canvasWidth c;q=[3..s-4];(_,g)=foldr f(c,[])$sort[(sqrt$(z x-z s/2)^2+(z y-z s/2)^2,x,y)|x<-q,y<-q]
 print$foldr(d$z s/20)(0,0,0)g
2 added 73 characters in body
source | link

Haskell - 579579-25 = 554 603-25-30 = 554548 Bytes

Strategy:

  • Make a list of (d,x,y) triples for all pixels (d is distance to center)
  • sort the list by distance
  • beginning with the greatest distance: if the pixel the only green pixel in a small neighborhood, keep it's distance in a list L, else blacken it
  • calculate score from the distance list L

Output ist a pairtriple (score,misses,Xs), e.g. (52,1,1) for the test image.

The program may fail if the pixel of a circle closest to the center is within 3 pixels of another circle.

import Data.List
import Codec.Picture
import Codec.Picture.RGBA8
import Codec.Picture.Canvas
z=fromIntegral
f(e,x,y)(v,h)|all id$j x y:[not$j a b|a<-[x-3..x+3],b<-[y-3..y+3],not(a==x&&b==y)]=(v,e:h)|1<2=(setColor x y(PixelRGBA8 0 0 0 0)v,h)
 where
  j n m=case(getColor n m v)of(PixelRGBA8 0 255 0 _)->True;_->False
d k r(h,i,j)|r>10*k=(h,i+1,j)|r<k*3/5=(h+10,i,j+1)|1<2=(10-(floor$r/k)+h,i,j)
main=do
 i<-readImageRGBA8 "p.png";let(Right c)=imageToCanvas i
 let s=canvasWidth c
 let (_,g)=foldr f(c,[])$sort[(sqrt$(z x-z s/2)^2+(z y-z s/2)^2,x,y)|x<-[3..s-4],y<-[3..s-4]]
 print$foldr(\r(h,i)->if r>10*zd$z s/20 then(h,i+1)else(10-(floor$r/z s*20)+h0,i))(0,0)g

Haskell - 579-25 = 554 Bytes

Strategy:

  • Make a list of (d,x,y) triples for all pixels (d is distance to center)
  • sort the list by distance
  • beginning with the greatest distance: if the pixel the only green pixel in a small neighborhood, keep it's distance in a list L, else blacken it
  • calculate score from the distance list L

Output ist a pair (score,misses), e.g. (52,1) for the test image.

The program may fail if the pixel of a circle closest to the center is within 3 pixels of another circle.

import Data.List
import Codec.Picture
import Codec.Picture.RGBA8
import Codec.Picture.Canvas
z=fromIntegral
f(e,x,y)(v,h)|all id$j x y:[not$j a b|a<-[x-3..x+3],b<-[y-3..y+3],not(a==x&&b==y)]=(v,e:h)|1<2=(setColor x y(PixelRGBA8 0 0 0 0)v,h)
 where
  j n m=case(getColor n m v)of(PixelRGBA8 0 255 0 _)->True;_->False
main=do
 i<-readImageRGBA8 "p.png";let(Right c)=imageToCanvas i
 let s=canvasWidth c
 let (_,g)=foldr f(c,[])$sort[(sqrt$(z x-z s/2)^2+(z y-z s/2)^2,x,y)|x<-[3..s-4],y<-[3..s-4]]
 print$foldr(\r(h,i)->if r>10*z s/20 then(h,i+1)else(10-(floor$r/z s*20)+h,i))(0,0)g

Haskell - 579-25 = 554 603-25-30 = 548 Bytes

Strategy:

  • Make a list of (d,x,y) triples for all pixels (d is distance to center)
  • sort the list by distance
  • beginning with the greatest distance: if the pixel the only green pixel in a small neighborhood, keep it's distance in a list L, else blacken it
  • calculate score from the distance list L

Output ist a triple (score,misses,Xs), e.g. (52,1,1) for the test image.

The program may fail if the pixel of a circle closest to the center is within 3 pixels of another circle.

import Data.List
import Codec.Picture
import Codec.Picture.RGBA8
import Codec.Picture.Canvas
z=fromIntegral
f(e,x,y)(v,h)|all id$j x y:[not$j a b|a<-[x-3..x+3],b<-[y-3..y+3],not(a==x&&b==y)]=(v,e:h)|1<2=(setColor x y(PixelRGBA8 0 0 0 0)v,h)
 where j n m=case(getColor n m v)of(PixelRGBA8 0 255 0 _)->True;_->False
d k r(h,i,j)|r>10*k=(h,i+1,j)|r<k*3/5=(h+10,i,j+1)|1<2=(10-(floor$r/k)+h,i,j)
main=do
 i<-readImageRGBA8 "p.png";let(Right c)=imageToCanvas i
 let s=canvasWidth c
 let (_,g)=foldr f(c,[])$sort[(sqrt$(z x-z s/2)^2+(z y-z s/2)^2,x,y)|x<-[3..s-4],y<-[3..s-4]]
 print$foldr(d$z s/20)(0,0,0)g
1
source | link

Haskell - 579-25 = 554 Bytes

Strategy:

  • Make a list of (d,x,y) triples for all pixels (d is distance to center)
  • sort the list by distance
  • beginning with the greatest distance: if the pixel the only green pixel in a small neighborhood, keep it's distance in a list L, else blacken it
  • calculate score from the distance list L

Output ist a pair (score,misses), e.g. (52,1) for the test image.

The program may fail if the pixel of a circle closest to the center is within 3 pixels of another circle.

import Data.List
import Codec.Picture
import Codec.Picture.RGBA8
import Codec.Picture.Canvas
z=fromIntegral
f(e,x,y)(v,h)|all id$j x y:[not$j a b|a<-[x-3..x+3],b<-[y-3..y+3],not(a==x&&b==y)]=(v,e:h)|1<2=(setColor x y(PixelRGBA8 0 0 0 0)v,h)
 where
 j n m=case(getColor n m v)of(PixelRGBA8 0 255 0 _)->True;_->False
main=do
 i<-readImageRGBA8 "p.png";let(Right c)=imageToCanvas i
 let s=canvasWidth c
 let (_,g)=foldr f(c,[])$sort[(sqrt$(z x-z s/2)^2+(z y-z s/2)^2,x,y)|x<-[3..s-4],y<-[3..s-4]]
 print$foldr(\r(h,i)->if r>10*z s/20 then(h,i+1)else(10-(floor$r/z s*20)+h,i))(0,0)g