Skip to main content
deleted 137 characters in body
Source Link
Flonk
  • 7.8k
  • 3
  • 23
  • 25

Haskell, 495 442442 402

Who needs formatting anyway?

I might be able to shave off a few more bytes, but I'll do that later since I'm a lazy bastard.

import Data.List
d=1:1:1%2;f=filter;p1%2
f=filter
p 0="0";p0="0"
p 1="1";p1="1"
p n=p(n`div`2div n 2)++show++p(mod n 2)
u[al=length
u z[a,b]=headb]=sort.head.dropWhile((<b).lengthl)$map$m(nub.foldl1 intersect.y"1"y(reversetail.p$a+16p$31-a).(`map`[y"0"(z>>=p)z,z#1`m`[d,f(v.group.sort.p)[1..],d]z#1,y(z>>=p)z]).take)z
v[a]=1>2;vw=(=='0')
v[a]=1>2
v x=all(tall w.lengthtail.p.l)x;t 1=1<2;t n|n`mod`2==1=1>2|1<2=t$n`div`2x
y[c]w=mapy fstx=m snd.f((==c).snd)w.(`zip`wfst);z=[0..];x#n=n`take`x++dropzip x
x#n=n`take`x++drop(n+n+1)x#(n+2)
n%m=d!!(m-d!!n)+d!!(m-d!!(n-1)):m%(m+1);main=interact$show
main=interact$show.uu[0.map.].m read.words
m=map

It even performs faster than I thought it wouldreasonably well. Here are a couple of OP's examples:

Flonk@home:~>echo 15 10 | codegolf
[10,23,40,57,58,139,147,149,212,228]
Flonk@home:~>echo 9 12 | codegolf
[3,8,10,14,19,20,21,23,24,31,37,40]
Flonk@home:~>echo 2 10 | codegolf
[0,3,4,5,10,11,12,13,14,21]
Flonk@home:~>echo 12 6 | codegolf
[2,4,5,6,9,10]

Haskell, 495 442

Who needs formatting anyway?

I might be able to shave off a few more bytes, but I'll do that later since I'm a lazy bastard.

import Data.List
d=1:1:1%2;f=filter;p 0="0";p 1="1";p n=p(n`div`2)++show(mod n 2)
u[a,b]=head.dropWhile((<b).length)$map(nub.foldl1 intersect.y"1"(reverse.p$a+16).(`map`[y"0"(z>>=p)z,z#1,f(v.group.sort.p)[1..],d]).take)z
v[a]=1>2;v x=all(t.length)x;t 1=1<2;t n|n`mod`2==1=1>2|1<2=t$n`div`2
y[c]w=map fst.f((==c).snd).(`zip`w);z=[0..];x#n=n`take`x++drop(n+n+1)x#(n+2)
n%m=d!!(m-d!!n)+d!!(m-d!!(n-1)):m%(m+1);main=interact$show.u.map read.words

It even performs faster than I thought it would. Here are a couple of OP's examples:

Flonk@home:~>echo 15 10 | codegolf
[10,23,40,57,58,139,147,149,212,228]
Flonk@home:~>echo 9 12 | codegolf
[3,8,10,14,19,20,21,23,24,31,37,40]
Flonk@home:~>echo 2 10 | codegolf
[0,3,4,5,10,11,12,13,14,21]
Flonk@home:~>echo 12 6 | codegolf
[2,4,5,6,9,10]

Haskell, 495 442 402

import Data.List
d=1:1:1%2
f=filter
p 0="0"
p 1="1"
p n=p(div n 2)++p(mod n 2)
l=length
u z[a,b]=sort.head.dropWhile((<b).l)$m(nub.foldl1 intersect.y(tail.p$31-a).(`m`[d,f(v.group.sort.p)[1..],z#1,y(z>>=p)z]).take)z
w=(=='0')
v[a]=1>2
v x=all(all w.tail.p.l)x
y x=m snd.f(w.fst).zip x
x#n=n`take`x++drop(n+n+1)x#(n+2)
n%m=d!!(m-d!!n)+d!!(m-d!!(n-1)):m%(m+1)
main=interact$show.u[0..].m read.words
m=map

It performs reasonably well. Here are a couple of OP's examples:

Flonk@home:~>echo 15 10 | codegolf
[10,23,40,57,58,139,147,149,212,228]
Flonk@home:~>echo 9 12 | codegolf
[3,8,10,14,19,20,21,23,24,31,37,40]
Flonk@home:~>echo 2 10 | codegolf
[0,3,4,5,10,11,12,13,14,21]
Flonk@home:~>echo 12 6 | codegolf
[2,4,5,6,9,10]
Rollback to Revision 2
Source Link
Flonk
  • 7.8k
  • 3
  • 23
  • 25

Haskell, 495 442 401442

Who needs formatting anyway?

I might be able to shave off a few more bytes, but I'll do that later since I'm a lazy bastard.

import Data.List
d=1:1:1%2
f=filter
p1%2;f=filter;p 0="0"
p0="0";p 1="1"
p1="1";p n=p(div n 2n`div`2)++p++show(mod n 2)
l=length
u z[au[a,b]=sort.headb]=head.dropWhile((<b).llength)$m$map(nub.foldl1 intersect.yy"1"(tailreverse.p$31-ap$a+16).(`m`[d`map`[y"0"(z>>=p)z,z#1,f(v.group.sort.p)[1..],z#1,y(z>>=p)z]d]).take)z
w=(=='0')
v x=lv[a]=1>2;v x==1||allx=all(all w.tail.pt.llength)x
yx;t x=m1=1<2;t sndn|n`mod`2==1=1>2|1<2=t$n`div`2
y[c]w=map fst.f(w(==c).fstsnd).zip x
x#n=n`take`x++drop(`zip`w);z=[0..];x#n=n`take`x++drop(n+n+1)x#(n+2)
n%m=d!!(m-d!!n)+d!!(m-d!!(n-1)):m%(m+1)
main=interact$show.u[0.;main=interact$show.]u.mmap read.words
m=map

It even performs reasonably wellfaster than I thought it would. Here are a couple of OP's examples:

Flonk@home:~>echo 15 10 | codegolf
[10,23,40,57,58,139,147,149,212,228]
Flonk@home:~>echo 9 12 | codegolf
[3,8,10,14,19,20,21,23,24,31,37,40]
Flonk@home:~>echo 2 10 | codegolf
[0,3,4,5,10,11,12,13,14,21]
Flonk@home:~>echo 12 6 | codegolf
[2,4,5,6,9,10]

Haskell, 495 442 401

import Data.List
d=1:1:1%2
f=filter
p 0="0"
p 1="1"
p n=p(div n 2)++p(mod n 2)
l=length
u z[a,b]=sort.head.dropWhile((<b).l)$m(nub.foldl1 intersect.y(tail.p$31-a).(`m`[d,f(v.group.sort.p)[1..],z#1,y(z>>=p)z]).take)z
w=(=='0')
v x=l x==1||all(all w.tail.p.l)x
y x=m snd.f(w.fst).zip x
x#n=n`take`x++drop(n+n+1)x#(n+2)
n%m=d!!(m-d!!n)+d!!(m-d!!(n-1)):m%(m+1)
main=interact$show.u[0..].m read.words
m=map

It performs reasonably well. Here are a couple of OP's examples:

Flonk@home:~>echo 15 10 | codegolf
[10,23,40,57,58,139,147,149,212,228]
Flonk@home:~>echo 9 12 | codegolf
[3,8,10,14,19,20,21,23,24,31,37,40]
Flonk@home:~>echo 2 10 | codegolf
[0,3,4,5,10,11,12,13,14,21]
Flonk@home:~>echo 12 6 | codegolf
[2,4,5,6,9,10]

Haskell, 495 442

Who needs formatting anyway?

I might be able to shave off a few more bytes, but I'll do that later since I'm a lazy bastard.

import Data.List
d=1:1:1%2;f=filter;p 0="0";p 1="1";p n=p(n`div`2)++show(mod n 2)
u[a,b]=head.dropWhile((<b).length)$map(nub.foldl1 intersect.y"1"(reverse.p$a+16).(`map`[y"0"(z>>=p)z,z#1,f(v.group.sort.p)[1..],d]).take)z
v[a]=1>2;v x=all(t.length)x;t 1=1<2;t n|n`mod`2==1=1>2|1<2=t$n`div`2
y[c]w=map fst.f((==c).snd).(`zip`w);z=[0..];x#n=n`take`x++drop(n+n+1)x#(n+2)
n%m=d!!(m-d!!n)+d!!(m-d!!(n-1)):m%(m+1);main=interact$show.u.map read.words

It even performs faster than I thought it would. Here are a couple of OP's examples:

Flonk@home:~>echo 15 10 | codegolf
[10,23,40,57,58,139,147,149,212,228]
Flonk@home:~>echo 9 12 | codegolf
[3,8,10,14,19,20,21,23,24,31,37,40]
Flonk@home:~>echo 2 10 | codegolf
[0,3,4,5,10,11,12,13,14,21]
Flonk@home:~>echo 12 6 | codegolf
[2,4,5,6,9,10]
deleted 143 characters in body
Source Link
Flonk
  • 7.8k
  • 3
  • 23
  • 25

Haskell, 495 442442 401

Who needs formatting anyway?

I might be able to shave off a few more bytes, but I'll do that later since I'm a lazy bastard.

import Data.List
d=1:1:1%2;f=filter;p1%2
f=filter
p 0="0";p0="0"
p 1="1";p1="1"
p n=p(n`div`2div n 2)++show++p(mod n 2)
u[al=length
u z[a,b]=headb]=sort.head.dropWhile((<b).lengthl)$map$m(nub.foldl1 intersect.y"1"y(reversetail.p$a+16p$31-a).(`map`[y"0"(z>>=p)z,z#1`m`[d,f(v.group.sort.p)[1..],d]z#1,y(z>>=p)z]).take)z
v[a]=1>2;v x=allw=(t.length=='0')x;t
v 1=1<2;tx=l n|n`mod`2==1=1>2|1<2=t$n`div`2
y[c]w=mapx==1||all(all fstw.f((==c)tail.sndp.l)x
y x=m snd.f(`zip`w);z=[0w.fst).];x#n=n`take`x++dropzip x
x#n=n`take`x++drop(n+n+1)x#(n+2)
n%m=d!!(m-d!!n)+d!!(m-d!!(n-1)):m%(m+1);main=interact$show
main=interact$show.uu[0.map.].m read.words
m=map

It even performs faster than I thought it wouldreasonably well. Here are a couple of OP's examples:

Flonk@home:~>echo 15 10 | codegolf
[10,23,40,57,58,139,147,149,212,228]
Flonk@home:~>echo 9 12 | codegolf
[3,8,10,14,19,20,21,23,24,31,37,40]
Flonk@home:~>echo 2 10 | codegolf
[0,3,4,5,10,11,12,13,14,21]
Flonk@home:~>echo 12 6 | codegolf
[2,4,5,6,9,10]

Haskell, 495 442

Who needs formatting anyway?

I might be able to shave off a few more bytes, but I'll do that later since I'm a lazy bastard.

import Data.List
d=1:1:1%2;f=filter;p 0="0";p 1="1";p n=p(n`div`2)++show(mod n 2)
u[a,b]=head.dropWhile((<b).length)$map(nub.foldl1 intersect.y"1"(reverse.p$a+16).(`map`[y"0"(z>>=p)z,z#1,f(v.group.sort.p)[1..],d]).take)z
v[a]=1>2;v x=all(t.length)x;t 1=1<2;t n|n`mod`2==1=1>2|1<2=t$n`div`2
y[c]w=map fst.f((==c).snd).(`zip`w);z=[0..];x#n=n`take`x++drop(n+n+1)x#(n+2)
n%m=d!!(m-d!!n)+d!!(m-d!!(n-1)):m%(m+1);main=interact$show.u.map read.words

It even performs faster than I thought it would. Here are a couple of OP's examples:

Flonk@home:~>echo 15 10 | codegolf
[10,23,40,57,58,139,147,149,212,228]
Flonk@home:~>echo 9 12 | codegolf
[3,8,10,14,19,20,21,23,24,31,37,40]
Flonk@home:~>echo 2 10 | codegolf
[0,3,4,5,10,11,12,13,14,21]
Flonk@home:~>echo 12 6 | codegolf
[2,4,5,6,9,10]

Haskell, 495 442 401

import Data.List
d=1:1:1%2
f=filter
p 0="0"
p 1="1"
p n=p(div n 2)++p(mod n 2)
l=length
u z[a,b]=sort.head.dropWhile((<b).l)$m(nub.foldl1 intersect.y(tail.p$31-a).(`m`[d,f(v.group.sort.p)[1..],z#1,y(z>>=p)z]).take)z
w=(=='0')
v x=l x==1||all(all w.tail.p.l)x
y x=m snd.f(w.fst).zip x
x#n=n`take`x++drop(n+n+1)x#(n+2)
n%m=d!!(m-d!!n)+d!!(m-d!!(n-1)):m%(m+1)
main=interact$show.u[0..].m read.words
m=map

It performs reasonably well. Here are a couple of OP's examples:

Flonk@home:~>echo 15 10 | codegolf
[10,23,40,57,58,139,147,149,212,228]
Flonk@home:~>echo 9 12 | codegolf
[3,8,10,14,19,20,21,23,24,31,37,40]
Flonk@home:~>echo 2 10 | codegolf
[0,3,4,5,10,11,12,13,14,21]
Flonk@home:~>echo 12 6 | codegolf
[2,4,5,6,9,10]
deleted 21 characters in body
Source Link
Flonk
  • 7.8k
  • 3
  • 23
  • 25
Loading
Source Link
Flonk
  • 7.8k
  • 3
  • 23
  • 25
Loading