Skip to main content
Commonmark migration
Source Link

#Oracle SQL 11.2, 218 216 201 bytes#

Oracle SQL 11.2, 218 216 201 bytes

WITH v(a,b,c,d,i)AS(SELECT 0,1,1,4,3 FROM DUAL UNION ALL SELECT b,c,d,3*c-a,i+1 FROM v WHERE i<:1)SELECT SIGN(LEVEL-1) FROM DUAL WHERE LEVEL-1<=:1 CONNECT BY LEVEL<4UNION ALL SELECT d FROM v WHERE:1>2;

Un-golfed

WITH v(a,b,c,d,i) AS 
(
  SELECT 0,1,1,4,3 FROM DUAL 
  UNION ALL 
  SELECT b,c,d,3*c-a,i+1 FROM v WHERE i<:1
)
SELECT SIGN(LEVEL-1) FROM DUAL WHERE LEVEL-1<=:1 CONNECT BY LEVEL<4
UNION ALL SELECT d FROM v WHERE:1>2;

I managed to gain a few bytes by using (abusing ?) the SIGN function to generate the first 3 elements of the sequence.

#Oracle SQL 11.2, 218 216 201 bytes#

WITH v(a,b,c,d,i)AS(SELECT 0,1,1,4,3 FROM DUAL UNION ALL SELECT b,c,d,3*c-a,i+1 FROM v WHERE i<:1)SELECT SIGN(LEVEL-1) FROM DUAL WHERE LEVEL-1<=:1 CONNECT BY LEVEL<4UNION ALL SELECT d FROM v WHERE:1>2;

Un-golfed

WITH v(a,b,c,d,i) AS 
(
  SELECT 0,1,1,4,3 FROM DUAL 
  UNION ALL 
  SELECT b,c,d,3*c-a,i+1 FROM v WHERE i<:1
)
SELECT SIGN(LEVEL-1) FROM DUAL WHERE LEVEL-1<=:1 CONNECT BY LEVEL<4
UNION ALL SELECT d FROM v WHERE:1>2;

I managed to gain a few bytes by using (abusing ?) the SIGN function to generate the first 3 elements of the sequence.

Oracle SQL 11.2, 218 216 201 bytes

WITH v(a,b,c,d,i)AS(SELECT 0,1,1,4,3 FROM DUAL UNION ALL SELECT b,c,d,3*c-a,i+1 FROM v WHERE i<:1)SELECT SIGN(LEVEL-1) FROM DUAL WHERE LEVEL-1<=:1 CONNECT BY LEVEL<4UNION ALL SELECT d FROM v WHERE:1>2;

Un-golfed

WITH v(a,b,c,d,i) AS 
(
  SELECT 0,1,1,4,3 FROM DUAL 
  UNION ALL 
  SELECT b,c,d,3*c-a,i+1 FROM v WHERE i<:1
)
SELECT SIGN(LEVEL-1) FROM DUAL WHERE LEVEL-1<=:1 CONNECT BY LEVEL<4
UNION ALL SELECT d FROM v WHERE:1>2;

I managed to gain a few bytes by using (abusing ?) the SIGN function to generate the first 3 elements of the sequence.

added 17 characters in body
Source Link
Jeto
  • 1.7k
  • 9
  • 10

#Oracle SQL 11.2, 218 216216 201 bytes#

WITH v(a,b,c,d,i)AS(SELECT 0,1,1,4,3 FROM DUAL UNION ALL SELECT b,c,d,3*c-a,i+1 FROM v WHERE i<:1)SELECT 0 FROM DUAL UNION ALL SELECT SIGN(LEVEL-1) FROM DUAL WHERE LEVEL<=LEVEL-1<=:1 CONNECT BY LEVEL<3UNIONLEVEL<4UNION ALL SELECT d FROM v WHERE:1>2;

Un-golfed

WITH v(a,b,c,d,i) AS 
(
  SELECT 0,1,1,4,3 FROM DUAL 
  UNION ALL 
  SELECT b,c,d,3*c-a,i+1 FROM v WHERE i<:1 
)
SELECT 0 FROM DUAL
UNION ALL SELECT SIGN(LEVEL-1) FROM DUAL WHERE LEVEL<=LEVEL-1<=:1 CONNECT BY LEVEL<3LEVEL<4
UNION ALlALL SELECT d FROM v WHERE :1>2;

Still looking for a wayI managed to cut thegain a few bytes by using SELECT 0... and(abusing SELECT 1... from?) the querySIGN function to generate the first 3 elements of the sequence.

#Oracle SQL 11.2, 218 216 bytes#

WITH v(a,b,c,d,i)AS(SELECT 0,1,1,4,3 FROM DUAL UNION ALL SELECT b,c,d,3*c-a,i+1 FROM v WHERE i<:1)SELECT 0 FROM DUAL UNION ALL SELECT 1 FROM DUAL WHERE LEVEL<=:1 CONNECT BY LEVEL<3UNION ALL SELECT d FROM v WHERE:1>2;

Un-golfed

WITH v(a,b,c,d,i) AS
(
  SELECT 0,1,1,4,3 FROM DUAL
  UNION ALL
  SELECT b,c,d,3*c-a,i+1 FROM v WHERE i<:1 
)
SELECT 0 FROM DUAL
UNION ALL SELECT 1 FROM DUAL WHERE LEVEL<=:1 CONNECT BY LEVEL<3
UNION ALl SELECT d FROM v WHERE :1>2;

Still looking for a way to cut the SELECT 0... and SELECT 1... from the query.

#Oracle SQL 11.2, 218 216 201 bytes#

WITH v(a,b,c,d,i)AS(SELECT 0,1,1,4,3 FROM DUAL UNION ALL SELECT b,c,d,3*c-a,i+1 FROM v WHERE i<:1)SELECT SIGN(LEVEL-1) FROM DUAL WHERE LEVEL-1<=:1 CONNECT BY LEVEL<4UNION ALL SELECT d FROM v WHERE:1>2;

Un-golfed

WITH v(a,b,c,d,i) AS 
(
  SELECT 0,1,1,4,3 FROM DUAL 
  UNION ALL 
  SELECT b,c,d,3*c-a,i+1 FROM v WHERE i<:1
)
SELECT SIGN(LEVEL-1) FROM DUAL WHERE LEVEL-1<=:1 CONNECT BY LEVEL<4
UNION ALL SELECT d FROM v WHERE:1>2;

I managed to gain a few bytes by using (abusing ?) the SIGN function to generate the first 3 elements of the sequence.

added 13 characters in body
Source Link
Jeto
  • 1.7k
  • 9
  • 10

#Oracle SQL 11.2, 218218 216 bytes#

WITH v(a,b,c,d,i) AS(SELECT 0,1,1,4,3 FROM DUAL UNION ALL SELECT b,c,d,3*c-a,i+1 FROM v WHERE i<:1)SELECT 0 FROM DUAL UNION ALL SELECT 1 FROM DUAL WHERE LEVEL<=:1 CONNECT BY LEVEL<3UNION ALL SELECT d FROM v WHERE :1>2;

Un-golfed

WITH v(a,b,c,d,i) AS
(
  SELECT 0,1,1,4,3 FROM DUAL
  UNION ALL
  SELECT b,c,d,3*c-a,i+1 FROM v WHERE i<:1 
)
SELECT 0 FROM DUAL
UNION ALL SELECT 1 FROM DUAL WHERE LEVEL<=:1 CONNECT BY LEVEL<3
UNION ALl SELECT d FROM v WHERE :1>2;

Still looking for a way to cut the SELECT 0... and SELECT 1... from the query.

#Oracle SQL 11.2, 218 bytes#

WITH v(a,b,c,d,i) AS(SELECT 0,1,1,4,3 FROM DUAL UNION ALL SELECT b,c,d,3*c-a,i+1 FROM v WHERE i<:1)SELECT 0 FROM DUAL UNION ALL SELECT 1 FROM DUAL WHERE LEVEL<=:1 CONNECT BY LEVEL<3UNION ALL SELECT d FROM v WHERE :1>2;

Un-golfed

WITH v(a,b,c,d,i) AS
(
  SELECT 0,1,1,4,3 FROM DUAL
  UNION ALL
  SELECT b,c,d,3*c-a,i+1 FROM v WHERE i<:1 
)
SELECT 0 FROM DUAL
UNION ALL SELECT 1 FROM DUAL WHERE LEVEL<=:1 CONNECT BY LEVEL<3
UNION ALl SELECT d FROM v WHERE :1>2;

Still looking for a way to cut the SELECT 0... and SELECT 1... from the query.

#Oracle SQL 11.2, 218 216 bytes#

WITH v(a,b,c,d,i)AS(SELECT 0,1,1,4,3 FROM DUAL UNION ALL SELECT b,c,d,3*c-a,i+1 FROM v WHERE i<:1)SELECT 0 FROM DUAL UNION ALL SELECT 1 FROM DUAL WHERE LEVEL<=:1 CONNECT BY LEVEL<3UNION ALL SELECT d FROM v WHERE:1>2;

Un-golfed

WITH v(a,b,c,d,i) AS
(
  SELECT 0,1,1,4,3 FROM DUAL
  UNION ALL
  SELECT b,c,d,3*c-a,i+1 FROM v WHERE i<:1 
)
SELECT 0 FROM DUAL
UNION ALL SELECT 1 FROM DUAL WHERE LEVEL<=:1 CONNECT BY LEVEL<3
UNION ALl SELECT d FROM v WHERE :1>2;

Still looking for a way to cut the SELECT 0... and SELECT 1... from the query.

Post Undeleted by Jeto
added 56 characters in body
Source Link
Jeto
  • 1.7k
  • 9
  • 10
Loading
Post Deleted by Jeto
Source Link
Jeto
  • 1.7k
  • 9
  • 10
Loading