Skip to main content
deleted 16 characters in body
Source Link
Sacchan
  • 701
  • 5
  • 8

Haskell, 228 227 225225 224 bytes

import Data.List
z=zipWith
a!b=div(max(a*a)(a*b))a
l x=z(!)(z(!)x(0:x))$tail x++[0]
s=(\x->>length.(sum[1|b<-x,b>0],sum[1|b<-x$x).filter<$>[(>0),b<0](<0)]).nub.(>>=id).(until=<<((==)=<<))((.)>>=id$transpose.map l).z(\i->z(\j x->2^i*j*(2*x-1))[1,3..])[1..]

Try it online!Try it online!

s=(\x->>length.(sum[1|b<-x,b>0],sum[1|b<-x$x).filter<$>[(>0),b<0](<0)]).nub.(>>=id).(until=<<((==)=<<))((.)>>=id$transpose.map l).z(\i->z(\j x->2^i*j*(2*x-1))[1,3..])[1..]
(\x->>length.(sum[1|b<-x,b>0],sum[1|b<-x$x).filter<$>[(>0),b<0](<0)]).nub.(>>=id)

(>>=id) squashes the list of lists into a single list, nub gets rid of doubles, (\x->>length.(sum[1|b<-x,b>0],sum[1|b<-x$x).filter<$>[(>0),b<0](<0)]) partitions the list into a pair of lists, one for positive and one for negative numbers, and calculates their lengths via replacing all entries with 1 and summing.

Haskell, 228 227 225 bytes

import Data.List
z=zipWith
a!b=div(max(a*a)(a*b))a
l x=z(!)(z(!)x(0:x))$tail x++[0]
s=(\x->(sum[1|b<-x,b>0],sum[1|b<-x,b<0])).nub.(>>=id).(until=<<((==)=<<))((.)>>=id$transpose.map l).z(\i->z(\j x->2^i*j*(2*x-1))[1,3..])[1..]

Try it online!

s=(\x->(sum[1|b<-x,b>0],sum[1|b<-x,b<0])).nub.(>>=id).(until=<<((==)=<<))((.)>>=id$transpose.map l).z(\i->z(\j x->2^i*j*(2*x-1))[1,3..])[1..]
(\x->(sum[1|b<-x,b>0],sum[1|b<-x,b<0])).nub.(>>=id)

(>>=id) squashes the list of lists into a single list, nub gets rid of doubles, (\x->(sum[1|b<-x,b>0],sum[1|b<-x,b<0])) partitions the list into a pair of lists, one for positive and one for negative numbers, and calculates their lengths via replacing all entries with 1 and summing.

Haskell, 228 227 225 224 bytes

import Data.List
z=zipWith
a!b=div(max(a*a)(a*b))a
l x=z(!)(z(!)x(0:x))$tail x++[0]
s=(\x->length.($x).filter<$>[(>0),(<0)]).nub.(>>=id).(until=<<((==)=<<))((.)>>=id$transpose.map l).z(\i->z(\j x->2^i*j*(2*x-1))[1,3..])[1..]

Try it online!

s=(\x->length.($x).filter<$>[(>0),(<0)]).nub.(>>=id).(until=<<((==)=<<))((.)>>=id$transpose.map l).z(\i->z(\j x->2^i*j*(2*x-1))[1,3..])[1..]
(\x->length.($x).filter<$>[(>0),(<0)]).nub.(>>=id)

(>>=id) squashes the list of lists into a single list, nub gets rid of doubles, (\x->length.($x).filter<$>[(>0),(<0)]) partitions the list into a pair of lists, one for positive and one for negative numbers, and calculates their lengths.

added 52 characters in body
Source Link
Sacchan
  • 701
  • 5
  • 8

Haskell, 228 227227 225 bytes

import Data.List
z=zipWith
a!b=div(max(a*a)(a*b))a
l x=z(!)(z(!)x(0:x))$tail x++[0]
f p=length.filter p;s=s=(\x->(f(>0)sum[1|b<-x,f(<0)b>0],sum[1|b<-x,b<0])).nub.(>>=id).(until=<<((==)=<<))((.)>>=id$transpose.map l).z(\i->z(\j x->2^i*j*(2*x-1))[1,3..])[1..]

Try it online!Try it online!

s=(\x->(f(>0)sum[1|b<-x,f(<0)b>0],sum[1|b<-x,b<0])).nub.(>>=id).(until=<<((==)=<<))((.)>>=id$transpose.map l).z(\i->z(\j x->2^i*j*(2*x-1))[1,3..])[1..]
(\x->(f(>0)sum[1|b<-x,f(<0)b>0],sum[1|b<-x,b<0])).nub.(>>=id)

(>>=id) squashes the list of lists into a single list, nub gets rid of doubles, (\x->(f(>0)sum[1|b<-x,f(<0)b>0],sum[1|b<-x,b<0])) partitions the list into a pair of lists, one for positive and one for negative numbers, and calculates their lengths, using the via replacing all entries with f p=length.filter p1 convenience functionand summing.

Haskell, 228 227 bytes

import Data.List
z=zipWith
a!b=div(max(a*a)(a*b))a
l x=z(!)(z(!)x(0:x))$tail x++[0]
f p=length.filter p;s=(\x->(f(>0)x,f(<0)x)).nub.(>>=id).(until=<<((==)=<<))((.)>>=id$transpose.map l).z(\i->z(\j x->2^i*j*(2*x-1))[1,3..])[1..]

Try it online!

s=(\x->(f(>0)x,f(<0)x)).nub.(>>=id).(until=<<((==)=<<))((.)>>=id$transpose.map l).z(\i->z(\j x->2^i*j*(2*x-1))[1,3..])[1..]
(\x->(f(>0)x,f(<0)x)).nub.(>>=id)

(>>=id) squashes the list of lists into a single list, nub gets rid of doubles, (\x->(f(>0)x,f(<0)x)) partitions the list into a pair of lists, one for positive and one for negative numbers, and calculates their lengths, using the f p=length.filter p convenience function

Haskell, 228 227 225 bytes

import Data.List
z=zipWith
a!b=div(max(a*a)(a*b))a
l x=z(!)(z(!)x(0:x))$tail x++[0]
s=(\x->(sum[1|b<-x,b>0],sum[1|b<-x,b<0])).nub.(>>=id).(until=<<((==)=<<))((.)>>=id$transpose.map l).z(\i->z(\j x->2^i*j*(2*x-1))[1,3..])[1..]

Try it online!

s=(\x->(sum[1|b<-x,b>0],sum[1|b<-x,b<0])).nub.(>>=id).(until=<<((==)=<<))((.)>>=id$transpose.map l).z(\i->z(\j x->2^i*j*(2*x-1))[1,3..])[1..]
(\x->(sum[1|b<-x,b>0],sum[1|b<-x,b<0])).nub.(>>=id)

(>>=id) squashes the list of lists into a single list, nub gets rid of doubles, (\x->(sum[1|b<-x,b>0],sum[1|b<-x,b<0])) partitions the list into a pair of lists, one for positive and one for negative numbers, and calculates their lengths via replacing all entries with 1 and summing.

deleted 86 characters in body
Source Link
Sacchan
  • 701
  • 5
  • 8

Haskell, 228228 227 bytes

import Data.List
n=length;z=zipWithz=zipWith
a!b=div(max(a*a)(a*b))a
l x=z(!)(z(!)x(0:x))$tail x++[0]
s=(\f p=length.filter p;s=(a,b)\x->(n af(>0)x,n bf(<0)x).partition(>0).nub.(>>=id).(until=<<((==)=<<))((.)>>=id$transpose.map l).z(\i->z(\j x->2^i*j*(2*x-1))[1,3..])[1..]

Try it online!Try it online!

s=(\(a,b)\x->(n af(>0)x,n bf(<0)x).partition(>0).nub.(>>=id).(until=<<((==)=<<))((.)>>=id$transpose.map l).z(\i->z(\j x->2^i*j*(2*x-1))[1,3..])[1..]
(\(a,b)\x->(n af(>0)x,n bf(<0)x).partition(>0).nub.(>>=id)

(>>=id) squashes the list of lists into a single list, nub gets rid of doubles, partition(\x->(f(>0)x,f(<0)x)) partitions the list into a pair of lists, one for positive and one for negative numbers, (\(a,b)->(n a,n b)) gives the and calculates their lengths of both lists, rather than the lists themselves, withusing the nf p=length.filter p shorthand defined in line two to shave off a few bytes.convenience function

Haskell, 228 bytes

import Data.List
n=length;z=zipWith
a!b=div(max(a*a)(a*b))a
l x=z(!)(z(!)x(0:x))$tail x++[0]
s=(\(a,b)->(n a,n b)).partition(>0).nub.(>>=id).(until=<<((==)=<<))((.)>>=id$transpose.map l).z(\i->z(\j x->2^i*j*(2*x-1))[1,3..])[1..]

Try it online!

s=(\(a,b)->(n a,n b)).partition(>0).nub.(>>=id).(until=<<((==)=<<))((.)>>=id$transpose.map l).z(\i->z(\j x->2^i*j*(2*x-1))[1,3..])[1..]
(\(a,b)->(n a,n b)).partition(>0).nub.(>>=id)

(>>=id) squashes the list of lists into a single list, nub gets rid of doubles, partition(>0) partitions the list into a pair of lists, one for positive and one for negative numbers, (\(a,b)->(n a,n b)) gives the lengths of both lists, rather than the lists themselves, with the n shorthand defined in line two to shave off a few bytes.

Haskell, 228 227 bytes

import Data.List
z=zipWith
a!b=div(max(a*a)(a*b))a
l x=z(!)(z(!)x(0:x))$tail x++[0]
f p=length.filter p;s=(\x->(f(>0)x,f(<0)x)).nub.(>>=id).(until=<<((==)=<<))((.)>>=id$transpose.map l).z(\i->z(\j x->2^i*j*(2*x-1))[1,3..])[1..]

Try it online!

s=(\x->(f(>0)x,f(<0)x)).nub.(>>=id).(until=<<((==)=<<))((.)>>=id$transpose.map l).z(\i->z(\j x->2^i*j*(2*x-1))[1,3..])[1..]
(\x->(f(>0)x,f(<0)x)).nub.(>>=id)

(>>=id) squashes the list of lists into a single list, nub gets rid of doubles, (\x->(f(>0)x,f(<0)x)) partitions the list into a pair of lists, one for positive and one for negative numbers, and calculates their lengths, using the f p=length.filter p convenience function

added 87 characters in body
Source Link
Sacchan
  • 701
  • 5
  • 8
Loading
added 3 characters in body
Source Link
Sacchan
  • 701
  • 5
  • 8
Loading
Source Link
Sacchan
  • 701
  • 5
  • 8
Loading