Skip to main content
Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Code code:"if (foo != bar)"
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Saves in:saves
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with
Search options not deleted user 49820

A competition to solve a particular problem through the usage and manipulation of arrays.

3 votes

Find the largest and the smallest number in an array

SELECT REGEXP_SUBSTR(:1,'[^,]+',1,LEVEL)i FROM DUAL CONNECT BY LEVEL<REGEXP_COUNT(:1,',')+2 ) WHERE TRIM(TRANSLATE(i,' 0123456789',' '))IS NULL; The sub-query parse the array … I wish I could have found a way to do it with LEAST and GREATEST, but no luck with how to handle the array as a parameter. …
Jeto's user avatar
  • 1,701
2 votes

Falsify brief truths

Oracle SQL 12.1, 137 135 bytes SELECT REPLACE(REPLACE(REPLACE(:1,m,2),1,0),2,m)FROM(SELECT MAX(TRIM(COLUMN_VALUE))m FROM XMLTABLE(('"'||REPLACE(:1,0,'",0,"')||'"'))); Un-golfed -- Replace the m …
Jeto's user avatar
  • 1,701
2 votes

Reverse positive runs

Oracle SQL 11.2, 131 123 bytes Abusing XML functions. SELECT LISTAGG(REVERSE(COLUMN_VALUE||''))WITHIN GROUP(ORDER BY rownum)FROM XMLTABLE(('"'||REPLACE(:1,'0','","0","')||'"'));
Jeto's user avatar
  • 1,701
4 votes

Compute minimax of an array

Oracle SQL 11.2, 261 bytes SELECT MIN(m)FROM(SELECT MAX(a)OVER(ORDER BY i ROWS BETWEEN CURRENT ROW AND :2-1 FOLLOWING)m,SUM(1)OVER(ORDER BY i ROWS BETWEEN CURRENT ROW AND:2-1 FOLLOWING)c FROM(SELECT T …
Jeto's user avatar
  • 1,701
1 vote

Determine the depth of an array

Oracle SQL 11.2, 133 bytes SELECT MAX(d)FROM(SELECT SUM(DECODE(SUBSTR(:1,LEVEL,1),'[',1,']',-1,0))OVER(ORDER BY LEVEL)d FROM DUAL CONNECT BY LEVEL<=LENGTH(:1)); Un-golfed SELECT MAX(d) FROM ( …
Jeto's user avatar
  • 1,701