Skip to main content
added 57 characters in body
Source Link
Kirill L.
  • 14.3k
  • 2
  • 17
  • 54

R, 111111 108 bytes

f=\(n,e,`+`=el)`if`(length(e),f(n,x<-e[-1])-f(n-1,unique(Map(\(i)sort(ifelse(i+e+1-el(e)[1]i,i,el(e)[2]+e+2)),e[-1]x))),c(!1:n*0n,1))

Attempt This Online!Attempt This Online!

Takes input as the number of vertices n and list of edges e. Outputs a vector of coefficients in ascending order.

Thanks to pajonk for -3 bytes.

R, 111 bytes

f=\(n,e)`if`(length(e),f(n,e[-1])-f(n-1,unique(Map(\(i)sort(ifelse(i-el(e)[1],i,el(e)[2])),e[-1]))),c(1:n*0,1))

Attempt This Online!

Takes input as the number of vertices n and list of edges e. Outputs a vector of coefficients in ascending order.

R, 111 108 bytes

f=\(n,e,`+`=el)`if`(length(e),f(n,x<-e[-1])-f(n-1,unique(Map(\(i)sort(ifelse(+e+1-i,i,+e+2)),x))),c(!1:n,1))

Attempt This Online!

Takes input as the number of vertices n and list of edges e. Outputs a vector of coefficients in ascending order.

Thanks to pajonk for -3 bytes.

Source Link
Kirill L.
  • 14.3k
  • 2
  • 17
  • 54

R, 111 bytes

f=\(n,e)`if`(length(e),f(n,e[-1])-f(n-1,unique(Map(\(i)sort(ifelse(i-el(e)[1],i,el(e)[2])),e[-1]))),c(1:n*0,1))

Attempt This Online!

Takes input as the number of vertices n and list of edges e. Outputs a vector of coefficients in ascending order.