title: Universal Unicode Clock

text:
# Question
Title: Universal Unicode Clock
## Plot contrivance

You wake up to find that something has gone horribly wrong! Your time machine has malfunctioned and you are lost sometime between June 2022 and October 1991.

You check the computer that you keep on the desk to see what time it is, but alas the positron interference from your quantum undetangler has fried the system clock, the internet, and several other sensible ways to use a computer to check the time!

You wrack your brain, for some way to figure out the time. It's too dangerous to go outside... you haven't changed your decor in decades .. *Aha!* You've got it! You know for sure that over the last 31 years you've always kept a perfectly updated version of your favorite programming language on this very computer! You're still a bit loopy from the decompactification so you can't remember some things, but you do retain your perfect knowledge of the history of the Unicode standard.

## Task

Your task is to write a computer program which when run will output the approximate date or date range based on the implementation of Unicode available.

### Example

For example, since  (`Ogham Letter Eadhadh`) was added to Unicode in version 3.0 the following Haskell program determines if we are before the release of 3.0 in September 1999 or after.

```
import Data.Char
main =
  putStrLn $
    if
      generalCategory 'ᚓ' == OtherLetter
    then
      "September 1999-present"
    else
      "October 1991-August 1999"

```

Try it online!

## Rules

You may assume either

1. Your programming language has an *idealized* version of its Unicode handling library that has always implemented the current standard. (Even for dates before the invention of your language)
2. Your programming language has the *actual* up-to-date version of its Unicode library that would be available at the particular date, bugs, and all.

To keep things neat and tidy do not mix and match. If you exploit a bug you're on track two, if you use anachronistic language features you're on track one.

You should not use any language features other than the library to determine the date. For example, you can't just pull the language version string or check if a certain function exists. You must use calls to the Unicode handling library.

## Scoring

This is a so answers will be scored by their vote counts.

I encourage voters to consider the following criteria when judging programs:

1. Granularity. Vote-up programs that can distinguish the date to high levels of detail.
2. Conciseness. Not exactly code-golf, but I encourage you to vote up programs that determine the date in fewer checks.
3. Cleverness. No matter what I say people are going to vote up cleverer answers, but it's worth mentioning. I encourage you to vote up answers that use obscure Unicode trivia, exploit strange edge cases, etc.

# Answer
> 13 votes
# Java 4+, 20 date-ranges

```
/*
Language limitations: https://en.wikipedia.org/wiki/Java_(programming_language)#Versions
- String#replaceAll / java.util.regex.Pattern were added in Java 1.4 (February 6th, 2002)
- Alternatives Character.isDefined(int) / Character.getType(int) were added in Java 5 (September 30th, 2004)

Sources:
- Version changelogs with links: https://en.wikipedia.org/wiki/Unicode#Versions
- More accurate release dates: https://unicode.org/history/publicationdates.html
*/
class Main{
  public static void main(String[]a){
    String test = "A\u4E00\u1100\uBB5E\u20AC\u13A0\u10400\u1740\u10800\u1A00\u1B00\u102A0\u10B00\u1BC0\u11100\u20BA\u061C\u16AD0\u11700\u1E900\u11A00\u11800\u10FE0\u32FF\u10FB0\u1E290";
    int length = test.replaceAll("\\p{Cn}","").length();
    switch(length){
      // 'A': Added as default
      case 1: // no-op
        System.out.print("v1.0.0:\tOctober 1991 (up to and including May 1992)");
        break;
      // '\u4E00': https://en.wikipedia.org/wiki/CJK_Unified_Ideographs_(Unicode_block)
      case 2: // no-op
        System.out.print("v1.0.1:\tJune 1992 (up to and including May 1993)");
        break;
      // '\u1100': https://en.wikipedia.org/wiki/Hangul#Unicode
      case 3: // no-op
        System.out.print("v1.1:\tJune 1993 (up to and including June 1995)");
        break;
      // '\uBB5E': https://unicode.org/Public/MAPPINGS/OBSOLETE/EASTASIA/KSC/HANGUL.TXT
      case 4: // no-op
        System.out.print("v2.0:\tJuly 1996 (up to and including April 1998)");
        break;
      // '\u20AC': https://www.unicode.org/versions/Unicode2.1.0/ & https://www.unicode.org/Public/2.1-Update4/ReadMe-2.1.9.txt (search for "version 2.1.2")
      case 5: // no-op
        System.out.print("v2.1.2:\tMay 1998 (up to and including August 1999)");
        break;
      // '\u13A0': https://en.wikipedia.org/wiki/Cherokee_(Unicode_block)
      case 6: // no-op
        System.out.print("v3.0:\tSeptember 1999 (up to and including February 2001)");
        break;
      // '\u10400': https://en.wikipedia.org/wiki/Deseret_(Unicode_block)
      case 8: // first case
        //System.out.print("v3.1:\tMarch 2001 (up to and including February 2002)");
        System.out.print("v3.1:\tMarch 2001 (February 6th, 2002 up to and including February 28th, 2002)");
        break;
      // '\u1740': https://en.wikipedia.org/wiki/Buhid_(Unicode_block)
      case 9:
        System.out.print("v3.2:\tMarch 2002 (up to and including March 2003)");
        break;
      // '\u10800': https://en.wikipedia.org/wiki/Cypriot_Syllabary_(Unicode_block)
      case 11:
        System.out.print("v4.0:\tApril 2003 (up to and including March 30th, 2005)");
        break;
      // '\u1A00': https://en.wikipedia.org/wiki/Buginese_(Unicode_block)
      case 12:
        System.out.print("v4.1:\tMarch 31st, 2005 (up to and including July 13th, 2006)");
        break;
      // '\u1B00': https://en.wikipedia.org/wiki/Balinese_(Unicode_block)
      case 13:
        System.out.print("v5.0:\tJuly 14th, 2006 (up to and including April 3rd, 2008)");
        break;
      // '\u102A0': https://en.wikipedia.org/wiki/Carian_(Unicode_block)
      case 15:
        System.out.print("v5.1:\tApril 4th, 2008 (up to and including September 30th, 2009)");
        break;
      // '\u10B00': https://en.wikipedia.org/wiki/Avestan_(Unicode_block)
      case 17:
        System.out.print("v5.2:\tOctober 1st, 2009 (up to and including October 10th, 2010)");
        break;
      // '\u1BC0': https://en.wikipedia.org/wiki/Batak_(Unicode_block)
      case 18:
        System.out.print("v6.0:\tOctober 11th, 2010 (up to and including January 30th, 2012)");
        break;
      // '\u11100': https://en.wikipedia.org/wiki/Chakma_(Unicode_block)
      case 20:
        System.out.print("v6.1:\tJanuary 31st, 2012 (up to and including September 25th, 2012)");
        break;
      // '\u20BA': https://en.wikipedia.org/wiki/Turkish_lira#Currency_sign
      case 21:
        System.out.print("v6.2:\tSeptember 26th, 2012 (up to and including September 29th, 2012)");
        break;
      // '\u061C': Diff https://www.unicode.org/Public/6.2.0/ucd/UnicodeData.txt and https://www.unicode.org/Public/6.3.0/ucd/UnicodeData.txt
      case 22:
        System.out.print("v6.3:\tSeptember 30th, 2012 (up to and including June 15th, 2014)");
      // '\u16AD0': https://en.wikipedia.org/wiki/Bassa_Vah_(Unicode_block)
      case 24:
        System.out.print("v7.0:\tJune 16th, 2014 (up to and including June 16th, 2015)");
        break;
      // '\u11700': https://en.wikipedia.org/wiki/Ahom_(Unicode_block)
      case 26:
        System.out.print("v8.0:\tJune 17th, 2015 (up to and including June 20th, 2016)");
        break;
      // '\u1E900': https://en.wikipedia.org/wiki/Adlam_(Unicode_block)
      case 28:
        System.out.print("v9.0:\tJune 21st, 2016 (up to and including June 19th, 2017)");
        break;
      // '\u11A00': https://en.wikipedia.org/wiki/Zanabazar_Square_(Unicode_block)
      case 30:
        System.out.print("v10.0:\tJune 20th, 2017 (up to and including June 4th, 2018)");
        break;
      // '\u11800': https://en.wikipedia.org/wiki/Dogra_(Unicode_block)
      case 32:
        System.out.print("v11.0:\tJune 5th, 2018 (up to and including March 4th, 2019)");
        break;
      // '\u10FE0': https://en.wikipedia.org/wiki/Elymaic_(Unicode_block)
      case 34:
        System.out.print("v12.0:\tMarch 5th, 2019 (up to and including May 6th, 2019)");
        break;
      // '\u32FF': https://en.wikipedia.org/wiki/Reiwa#Technology
      case 35:
        System.out.print("v12.1:\tMay 7th, 2019 (up to and including March 9th, 2020)");
        break;
      // '\u10FB0': https://en.wikipedia.org/wiki/Chorasmian_(Unicode_block)
      case 37:
        System.out.print("v13,9:\tMarch 10th, 2020 (up to and including September 13th, 2021)");
        break;
      // '\u1E290': https://en.wikipedia.org/wiki/Toto_(Unicode_block)
      case 39:
        System.out.print("v14.0:\tSeptember 14th, 2021 (up to and including June 15th, 2022)");
        break;
      default:
        System.err.printf("Unknown unicode version and date! (%d)%n", length);
        break;
    }
  }
}

```

(Don't) try it online.

**Explanation:**

Uses `\p{Cn}` regex-replacement to remove unassigned unicode characters from a string, before evaluating its length.

This uses rule option #2. Since `String#replaceAll` and `java.util.regex.Pattern` were added in Java 4, released on February 6th, 2002 (and alternatives `Character#isDefined(int)` and `Character#getType(int)` with `Character.UNASSIGNED` since Java 5 of September 30th, 2004), it only works for beyond that date. I've added the previous Unicode versions and date-ranges to the code for completeness, but since Java 4 wasn't released yet at the time, they can be seen as no-ops.

This is just an initial version which looks at added characters in the Unicode versions, mentioned on Wikipedia. I'll see if I can further define inner Unicode versions later on, since there are versions where the Unicode standard has been updated, but no characters were added/removed (e.g. added casing support for lower-/uppercase letters and things like that). But this already was quite time-consuming, so this will do for now.

# Answer
> 5 votes
# Erlang, 4 date ranges

```
#!/usr/bin/env escript
-module(norm).

main(_) ->
    Versions = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                "v9.0:\tJune 21st, 2016 (up to and including May 6th, 2019)",
                "v14.0:\tSeptember 14th, 2021 (up to and including June 15th, 2022)",
                0,
                "v13.0:\tMarch 10th, 2020 (up to and including September 13th, 2021)",
                "v12.1:\tMay 7th, 2019 (up to and including March 9th, 2020)"},
    Index =
        %% Unicode 14.0.0
        tryit(16#a7f2) +
        %% Unicode 13.0.0
        tryit(16#ab69) +
        %% Unicode 12.1.0
        tryit(16#32ff),
    io:format("~s~n", [element(Index, Versions)]).

tryit(C) ->
    NFKD = unicode:characters_to_nfkd_list([C]),
    Hex = [io_lib:format("~.16B", [X]) || X <- NFKD],
    io:format("~6.16B -> ~s~n", [C, lists:join(", ", Hex)]),
    iolist_size(Hex).

```

**Explanation:**

This uses changes in normalization rules between Unicode versions. It gets the NFKD canonical form of three code points, adds the number of hex digits in the result, and uses that as an index into a tuple with date ranges shamelessly stolen from Kevin Cruijssen's answer.

As of Unicode 9.0, the three characters all decompose to themselves, giving a starting length of 12. The characters are:

* ㋿, 32FF, SQUARE ERA NAME REIWA, which decomposes into 令和 (4EE4 548C) as of Unicode 12.1. The length goes up by 4, to 16. (This character was introduced when Naruhito became emperor of Japan and adopted the era name Reiwa, succeeding his father Akihito and ending the Heisei era.)
* ꭩ, AB69, MODIFIER LETTER SMALL TURNED W, which becomes ʍ (28D) as of Unicode 13.0. The length goes down by 1, to 15.
* ꟲ, A7F2, MODIFIER LETTER CAPITAL C, which becomes C (43) as of Unicode 14.0. The length goes down by 2, to 13.

The `unicode` module was added to Erlang in release 20.0, supporting Unicode 9.0. It was upgraded to Unicode 10.0 in release 21.0, to 11.0 in release 22.0, to 12.1 in release 23.0, to 13.0 in release 24.0, and to 14.0 in release 25.0. I couldn't find any suitable characters to distinguish versions 9 to 11.

Using a bunch of Erlang installations I had lying around, the output is:

```
21.3.8.2:
  A7F2 -> A7F2
  AB69 -> AB69
  32FF -> 32FF
v9.0:   June 21st, 2016 (up to and including May 6th, 2019)

23.0.2:
  A7F2 -> A7F2
  AB69 -> AB69
  32FF -> 4EE4, 548C
v12.1:  May 7th, 2019 (up to and including March 9th, 2020)

24.3.4.1:
  A7F2 -> A7F2
  AB69 -> 28D
  32FF -> 4EE4, 548C
v13.0:  March 10th, 2020 (up to and including September 13th, 2021)

25.0.1:
  A7F2 -> 43
  AB69 -> 28D
  32FF -> 4EE4, 548C
v14.0:  September 14th, 2021 (up to and including June 15th, 2022)

```

# Answer
> 5 votes
# Python, 22 date ranges (21 Unicode versions)

```
codepoints_dates = {
    b"\\u03F4": "2001 February 28",      #3.1
    b"\\u0220": "2002 March 22",         #3.2
    b"\\u0221": "2003 April 18",         #4.0
    b"\\u0240": "2005 March 30",         #4.1
    b"\\u0242": "2006 July 14",          #5.0
    b"\\u0370": "2008 April 4",          #5.1
    b"\\u0524": "2009 October 1",        #5.2
    b"\\u0526": "2010 October 11",       #6.0
    b"\\u058F": "2012 January 31",       #6.1
    b"\\u20BA": "2012 September 26",     #6.2
    b"\\u06A3": "2013 September 30",     #6.3
    b"\\u037F": "2014 June 16",          #7.0
    b"\\u08B3": "2015 June 17",          #8.0
    b"\\u1C80": "2016 June 21",          #9.0
    b"\\u0860": "2017 June 20",          #10.0
    b"\\u0560": "2018 June 5",           #11.0
    b"\\u0C77": "2019 March 5",          #12.0
    b"\\u32FF": "2019 May 7",            #12.1
    b"\\u08C0": "2020 March 10",         #13.0
    b"\\u061D": "2021 September 14",     #14.0
    b"\\u0CF3": "2022 September NN",     #15.0
}

prev_date = ""
for code, date in codepoints_dates.items():
    try:
        code.decode("unicode_escape")
    except:
        break
    prev_date = date
else:
    date = ""

print(prev_date, "-", date)

```

Each codepoint has been introduced in the corresponding Unicode version. The information is taken from the *Delta Code Charts* (here is the link to the Chart of version 14.0 as an example).

---
Tags: popularity-contest, date, polyglot, unicode
---


title: Generate Loopy puzzles

text:
# Question
Title: Generate Loopy puzzles
Loopy is a puzzle game from the collection of Simon Tatham. The previous link contains a javascript implementation of a Loopy puzzle generator. I suggest everybody who wants to attempt this challenge to solve a couple of puzzles manually to understand how they are supposed to work.

Here are instructions on how to solve a Loopy puzzle:

> ## Chapter 23: Loopy
>
> You are given a grid of dots, marked with yellow lines to indicate which dots you are allowed to connect directly together. Your aim is to use some subset of those yellow lines to draw a single unbroken loop from dot to dot within the grid.
>
> Some of the spaces between the lines contain numbers. These numbers indicate how many of the lines around that space form part of the loop. The loop you draw must correctly satisfy all of these clues to be considered a correct solution.
>
> In the default mode, the dots are arranged in a grid of squares; however, you can also play on triangular or hexagonal grids, or even more exotic ones.
>
> Credit for the basic puzzle idea goes to Nikoli \[10\].
>
> Loopy was originally contributed to this collection by Mike Pinna, and subsequently enhanced to handle various types of non-square grid by Lambros Lambrou.
>
> \[10\] http://www.nikoli.co.jp/puzzles/3/index-e.htm (beware of Flash)

The goal of this task is to write your own Loopy puzzle generator. Since graphics are way too complicated, you have to output a generated puzzle in ASCII like the example puzzle of size 7×7 below. The advantage of the output format described here is that you can output your puzzle into a line printer and solve it with a pen.

```
+ + + + + + + +
         2 3
+ + + + + + + +
 2       2   3
+ + + + + + + +
 2   2 1 3
+ + + + + + + +
 2         1 2
+ + + + + + + +
   2 1 2 3 3
+ + + + + + + +
     3 2   1
+ + + + + + + +
         2 2
+ + + + + + + +

```

## Input specification

Your program shall receive as input:

* An integer parameter in the range `2` to `99`, `x` (width)
* An integer parameter in the range `2` to `99`, `y` (height)
* An integer parameter in the range `0` to `9`, `d` (difficulty)

If you choose to implement the deterministic option, your program shall further receive as input:

* A positive integer parameter, `s` (seed)

In submissions written in languages that have the notion of program or command line arguments, the input shall be provided as a set of program arguments. The invocation will be like this:

```
program <x> <y> <d> <s>

```

where `<s>` is left out if you do not choose to implement the deterministic option.

In submissions written in languages that have the concept of an invocation URL (i.e. the URL the program is called at), input shall be provided as a set of URL parameters like this:

```
http://site.example/program?x=<x>&y=<y>&d=<d>&s=<s>

```

where the `&s=<s>` part is left out if you do not choose to implement the deterministic option.

In languages that fit into neither category, input is to be received in an implementation defined way. Hard coding input is not an acceptable implementation defined way, except if your language provides no mean to receive input.

Your program shall terminate and generate output as specified below for each combination of parameters with meaningful values. The behavior of your program is unspecified if any parameter is missing, invalid, or outside of the specified range.

## Output specification

Your program shall output a square-grid Loopy puzzle formatted as described above with an implementation-defined line terminator. Your implementation may fill each line with an arbitrary amount of trailing whitespace characters.

The grid shall have `x`×`y` cells where `x` and `y` are the width and height parameters specified further above. The puzzle your program generates shall have exactly one solution.

The difficulty of the problems your program generates shall depend on the `d` parameter, where a `d` value of `0` shall generate easy problems and a `d` value of `9` shall generate hard problems. Please document how the difficulty of the problems you generate changes depending on the `d` parameter.

If you choose to implement the deterministic option, the output of your program shall only depend on the value of the input. Different values for `s` shall yield different puzzles with a high probability for the same combination of `x`, `y`, and `d`. If you do not choose to implement the deterministic option, the output of your program shall be different every time the program is executed with a high probability. You can assume that the program is not executed more than one time per second.

## Scoring

The score of your program is the number of characters in its source except for omittable whitespace characters and omittable comments. You are encouraged to indent your submission so it's easier to read for the others and to comment your solution so its easier to follow.

Your submission may violate some of the rules described above. Please document specific rule violations and add the corresponding penalty to your score. Rule violations not documented here make your submission invalid.

* Your program contains instances of undefined behavior or violations of your language's rules (128)
* Your program ignores the `d` parameter but generates hard puzzles (256)
* Your program does not terminate or crashes in rare cases (512)
* Your program ignores the `d` parameter but generates easy puzzles (1024)
* Your program generates puzzles with more than one solution (2048)
* Your program generates unsolvable puzzles in rare cases (4096)

## Judgement

The winner of this contest is the submission with least score. I reserve the right to disregard submissions that violate the spirit of this contest or that cheat.

# Answer
> 2 votes
# Python3, 1004 bytes:

```
from random import*
from itertools import*
R=range
def U(D,B,x,y,X,Y):
 try:D[B[x][y]]=D.get(B[x][y],[])+[B[X][Y]]
 except:1
def O(b,s,e,x,y,n=[],r=[]):
 if[]==s:yield e;return
 j,k=s[0];J,X=j*(y+1)+k,(j+1)*(y+1)+k;K,Y=J+1,X+1
 if len(p:={(J,X),(K,Y),(J,K),(X,Y)}-{*r})>=b[j][k]:
  for i in combinations(p,b[j][k]):
   T=p-{*i}
   if all(q not in n for q in T):
    E=eval(str(e))
    for A,B in T:E[A].remove(B);E[B].remove(A)
    if all(len(E[A])>1 for A in E):yield from O(b,s[1:],E,x,y,n+[*i],r+[*T])
def f(x,y,d):
 while 1:
  s=[0]*(x*y-(L:=int((x*y/2)*d/10)))+[randint(1,3)for _ in R(L)];shuffle(s);b=[s[i:i+y]for i in R(0,len(s),y)];k=-1
  B=[[(k:=k+1)for _ in R(y+1)]for _ in R(x+1)];D={}
  for Y in R(y+1):
   for X in R(x+1):U(D,B,X,Y,X,Y+1);U(D,B,X,Y,X+1,Y);U(D,B,X,Y+1,X,Y);U(D,B,X+1,Y,X,Y)
  for _ in O(b,[(X,Y)for X in R(x)for Y in R(y)if b[X][Y]],D,x,y):return'\n'.join([' '.join(['+']*len(H))+'\n'+' '+' '.join([' ',str(u)][u>0]for u in G)for H,G in zip(B,b)]+[' '.join(['+']*len(B[0]))])

```

Try it online!

As `d` increases, the number of numeric cells also increases.

---
Tags: code-golf, ascii-art, generation
---


title: Convert CSV to Table

text:
# Question
Title: Convert CSV to Table
# The Challenge

Given a CSV input, output a proper unicode table using box characters.

# Formatting

The table will be formatted using the following rules:

* Column width will be equal to the longest value of that column
* All table data will be left justified
* Each table will assume the first csv row to be the header
* The table will use the following characters for its borders:

`┌ ┬ ┐ ├ ┼ ┤ └ ┴ ┘ ─ │`

# Example

```
Input:
Name,Age,Gender
Shaun,19,Male
Debra,19,Female
Alan,26,Male
George,15,Male

Output:
┌──────┬───┬──────┐
│Name  │Age│Gender│
├──────┼───┼──────┤
│Shaun │19 │Male  │
│Debra │19 │Female│
│Alan  │26 │Male  │
│George│15 │Male  │
└──────┴───┴──────┘

```

# Rules

* Standard loopholes apply
* You may submit a full program, a function or a lambda
* Input can be from a file, a program argument or any acceptable alternative
* Output can be to a file, returned or any acceptable alternative
* CSV input should take the same format as used in my example.
* Shortest answer in bytes wins.

CSV input should take the following form:

```
Header1,Header2,Header3 newline
Column1,Column2,Column3 newline
Column1,Column2,Column3 optional_newline

```

# Answer
> 10 votes
# Try (Dyalog) APL, ~~38~~ 43 bytes

Last input line must have a trailing newline.

```
{{(⊃⍵)⍪⍉⍪↑¨↓⍉↑1↓⍵}s¨',',¨(s←1↓¨⊢⊂⍨⊢=⊃)¯1⌽⍵}

```

Try it online! In the offline version of Dyalog APL, execute `]boxing ON -style=min` for the same effect.

### Explanation

`{` ... `}` an anonymous function where  represents the argument:

`¯1 ⌽ ⍵` rotate the trailing newline to the front

`(s ←`  ... `)` define the function *s* as follows, and apply it

`1 ↓¨` drop the first character of each

`⊢ ⊂⍨` line, split where

`⊃ = ⊢` the first character equals the characters in the string

`',' ,¨` then prepend a comma to each line

apply the function *s* to each line

`{` ... `}` now apply the following anonymous function:

`1 ↓ ⍵` drop the first element (the row headers)

`↓ ⍉ ↑` transpose the list of rows into list of columns

`↑¨` make each element (a list of entries) into a matrix of padded entries

`⍉ ⍪` make into one-column matrix, then transpose into one-row matrix

`(⊃⍵) ⍪` put the argument's first element (the list of headers) on top\`

**Note:** While the line drawing characters are not explicitly used in my solution, they are part of the APL character set, and would also be counted as single bytes.

# Answer
> 2 votes
# PowerShell 3+, 365 bytes

```
$d=$input|ipcsv
$h=$d[0].PSObject.Properties.Name|%{$_|Add-Member -type NoteProperty -na c -v(($d.$_+$_|measure Length -ma).Maximum)-pa}
"┌$(($h|%{'─'*$_.c})-join'┬')┐"
"│$(($h|%{$_.PadRight($_.c)})-join'│')│"
"├$(($h|%{'─'*$_.c})-join'┼')┤"
$d|%{$i=$_;"│$(($h|%{$i.$_.PadRight($_.c)})-join'│')│"}
"└$(($h|%{'─'*$_.c})-join'┴')┘"

```

I feel like this could be improved a lot but I ran out of time. All line endings are `\n` with no `\r`, encoding is UTF8 with no BOM.

# Answer
> 2 votes
# APL (Dyalog Extended), ~~36~~ 25 bytesSBCS

Full program. Assumes that `ABCDEFGHIJKLMNOPQRSTUVWXYZ` is the CSV file. Prints to stdout.

```
⌂disp(1↑m)⍪↑¨↓⍉1↓m←⎕CSV⎕A

```

Try it online!

`⎕A` the uppercase **A**lphabet (the shortest-to-reference built-in string)
`⎕CSV` read that file and convert from CSV to matrix
`m←` store as `m` (for **m**atrix)
`1↓` drop the first row
transpose
split into list of columns
`↑¨` mix each list of strings into a matrix
`(``)⍪` stack the following on top of that:
`1↑m` take the first row of `m`
`⌂disp` apply `dfns.disp` to that (draws line drawing characters)

# Answer
> 2 votes
# JavaScript, 261 bytes

```
(t,[H,...D]=T=t.split`
`.map(r=>r.split`,`),w=H.map((_,i)=>Math.max(...T.map(r=>r[i].length))),L=(x,i,_,[[[a,b=a,c=a]],p]=1/i?`│`:[x,'─'])=>a+w.map((n,j)=>(p?'':x[j]).padEnd(n,p)).join(b)+c+`
`)=>L`┌┬┐`+L(H,0)+L`├┼┤`+D.map(L).join``+L`└┴┘`

```

Try it online!

## Ungolfed and explained

```
(
  tableCSV,
  [header, ...data] = table = tableCSV.split(`\n`).map(row => row.split(`,`)),
  widths = header.map((_, i) => Math.max(...table.map(row => row[i].length))),
  drawLine = ( // create data row or border
    x, // either data array or singleton string array
    i, // either data index or undefined
    _, // ignored (data.map(drawLine) sets this to data)
    [[[a, b = a, c = a]], pad] = 1 / i ? `│` : [x, '─']
       // a = start, b = separator, c = end, pad = '─' if making border
  ) =>
    a +
    widths.map((n, j) => (pad ? '' : x[j]).padEnd(n, pad)).join(b) +
    c +
    `\n`
) =>
  drawLine`┌┬┐` +
  drawLine(header, 0) +
  drawLine`├┼┤` +
  data.map(drawLine).join(``) +
  drawLine`└┴┘`

```

# Answer
> 1 votes
# JavaScript (ES6|FireFox), 286 bytes

```
f=>(d=f.split`
`.map(a=>a.split`,`),s=d[0].map((a,i)=>d.reduce((b,c)=>(n=c[i].length)>b?n:b,0)),d=d.map(a=>`│${a.map((b,i)=>b.padEnd(s[i])).join`│`}│`),d.splice(1,0,(g=h=>h[0]+s.map(a=>'─'.repeat(a)).join(h[1])+h[2])('├┼┤')),g('┌┬┐')+`
${d.join`
`}
`+g('└┴┘'))

```

Uses `padEnd`, which is FireFox specific.

# Answer
> 1 votes
## Racket 578 bytes

```
(let*((ll(map(λ(x)(string-split x","))ll))(lr list-ref)(sl string-length)(d display)(dl displayln)(nc(length(lr ll 0)))
(nl(for/list((i nc))(apply max(for/list((j ll))(sl(lr j i))))))(pl(λ(sy)(d(lr sy 0))(for((n nc))(for((m(lr nl n)))(d(lr sy 1)))
(if(< n(sub1 nc))(d(lr sy 2))(dl(lr sy 3))))))(g(λ(i n)(for((m(-(lr nl n)(sl i))))(d" ")))))(pl'("┌""─""┬""┐"))
(for((i(lr ll 0))(n(in-naturals)))(d"│")(d i)(g i n))(dl"│")(pl'("├""─""┼""┤"))(for((j(range 1(length ll))))
(for((i(lr ll j))(n nc))(d"│")(d i)(g i n))(dl"│"))(pl'("└" "─" "┴" "┘")))

```

Ungolfed:

```
(define(f1 ll)
 (let* ((ll (map (λ (x)(string-split x ",")) ll))  ; use this to convert csv format to list of lists;
         (lr list-ref)                    ; make short names of standard fns
         (sl string-length)
         (d display)
         (dl displayln)
         (nc (length (lr ll 0)))          ; number of cols;
         (nl(for/list ((i nc))            ; get list of max string-length for each column
              (apply max
                     (for/list ((j ll))
                       (sl (lr j i))
                       ))))
         (pl (λ (sy)                      ; put lines using sent symbol list
               (d (lr sy 0))
               (for ((n nc))
                 (for ((m (lr nl n))) (d (lr sy 1)))
                 (if (< n (sub1 nc))
                     (d (lr sy 2))
                     (dl (lr sy 3))
                     ))))
         (g (λ (i n)                     ; pad with spaces if needed
              (for ((m (- (lr nl n) (sl i)))) (d " ")) )))
    ; put line above header:
    (pl '("┌" "─" "┬" "┐"))

    ; put header:
    (for ((i (lr ll 0)) (n (in-naturals)))
      (d "│")
      (d i)
      (g i n)
      )
    (dl "│")

    ; put line below header;
    (pl '("├" "─" "┼" "┤"))

    ; put rows:
    (for ((j (range 1 (length ll))))
      (for ((i (lr ll j))
            (n nc))
        (d "│")
        (d i)
        (g i n)
        )
      (dl "│")
      )

    ; put bottom line:
    (pl '("└" "─" "┴" "┘"))
    ))

```

Testing:

```
(f (list  "Name,Age,Gender"
          "Shaun,19,Male"
          "Debra,19,Female"
          "Alan,26,Male"
          "George,15,Male"))

```

Output:

```
┌──────┬───┬──────┐
│Name  │Age│Gender│
├──────┼───┼──────┤
│Shaun │19 │Male  │
│Debra │19 │Female│
│Alan  │26 │Male  │
│George│15 │Male  │
└──────┴───┴──────┘

```

# Answer
> 1 votes
# JavaScript (ES6), 281 bytes

Note: input as a single string with newlines - as requested by OP. Other answers use a string list - using a string array in input I can avoid the first split and cut 9 bytes.

```
l=>(l=l.split`
`.map(r=>r.split`,`.map((w,i)=>(v=w.length)<c[i]?w:(c[i]=v,w)),c=[k=0]),l=l.map(r=>r.map((v,i)=>(v+' '.repeat(c[i]-v.length)))),[h=c.map(x=>'─'.repeat(x)),l.shift(),h,...l,h].map(a=>'│┌├└'[j=a!=h?0:++k]+a.join('│┬┼┴'[j])+'│┐┤┘'[j]).join`
`)

```

*Less golfed*

```
l=>(
  // split input in an array of string arrays
  // meanwhile find the column widths and put them in *c*
  l = l.split`\n`.map(r=>r.split`,`.map((w,i)=>(v=w.length)<c[i]?w:(c[i]=v,w)),c=[]),

  // pad each column to the max column width
  l = l.map(r=>r.map((v,i)=>(v+' '.repeat(c[i]-v.length)))),

  // put in *h* the horizontal lines for top,bottom and head separator
  h = c.map(x => '─'.repeat(x) ),

  // add the *h* line at top, bottom and after head line
  l = [h, l.shift(), h, ...l, h],

  // rebuild a string, joining columns with '|' unless the row is *h*
  // if the row is *h* use different characters to join columns
  k = 0,
  l.map(a=> '│┌├└'[j=a!=h?0:++k] + a.join('│┬┼┴'[j]) + '│┐┤┘'[j])
  .join`\n`
)

```

**Test**

```
F=
l=>(l=l.split`
`.map(r=>r.split`,`.map((w,i)=>(v=w.length)<c[i]?w:(c[i]=v,w)),c=[k=0]),l=l.map(r=>r.map((v,i)=>(v+' '.repeat(c[i]-v.length)))),[h=c.map(x=>'─'.repeat(x)),l.shift(),h,...l,h].map(a=>'│┌├└'[j=a!=h?0:++k]+a.join('│┬┼┴'[j])+'│┐┤┘'[j]).join`
`)

function update() {
  O.textContent = F(I.value)
}
update()
```

```
#I { width:60%; height: 8em}
```

```
<textarea id=I>Name,Age,Gender
Shaun,19,Male
Debra,19,Female
Alan,26,Male
George,15,Male</textarea><br>
<button onclick='update()'>Go</button>
<pre id=O></pre>
```

# Answer
> 1 votes
# PowerShell for Windows, ~~256...236~~ 238 bytes

```
$v=$args-split'
'-ne''|%{,($_-split',')}
function z($b,$a){$b[1]+(($v[0]|%{@($a)[$x++]+''|% p*ht($v|%{$_[$x-1]}|% le*|sort -b 1)$b[0]})-join$b[2])+$b[3]}
z '─┌┬┐'
$v|%{z ' │││'$_;if(!$r++){z '─├┼┤'}}
z '─└┴┘'

```

Try it online!

Notes:

* The `Sort` alias defined for Windows only. It need `Sort-Object` for Linux instead `sort` or command `set-alias sort sort-object` before this script (TIO way).
* The `p*ht` shortcut expands to the `PadRight`-method for a string.
* The `le*` shortcut expands to the `Length`-method for a string.

An input csv contains:

* comma and newline are delimiters only (no comma and no newline inside values|headers)
* spaces in the values|headers are significant letter (keep due justifying)
* at least 2 not empty lines (headers and values)
* an "optional\_newline" at the end
* optional empty values|headers
* optional empty inner lines

# Answer
> 1 votes
# JavaScript (V8), 291 bytes

```
d=>([h]=r=d.split`
`.map(s=>s.split`,`),l=h.map((_,i)=>Math.max(...r.map(k=>k[i].length))),s=([[x,y,z]])=>h.reduce((a,_,i)=>a+"─".repeat(l[i])+(i==h.length-1?z:y),x)+`
`,[f,...t]=r.map(r=>r.reduce((s,x,i)=>s+x.padEnd(l[i])+z,z="│")+`
`),s`┌┬┐`+f+s`├┼┤`+t.join``+s`└┴┘`)

```

Try it online!

Not exactly a competitive score compared to the three other answers written in JS (???), but its as good as I can do.

Ungolfed/explained:

```
csvString => (
  // convert the string into an array of row content arrays (string[][])
  // extracting first element h to save a few bytes off of r[0] later
  [h] = rows = d.split(`\n`).map(s=>s.split(`,`)),
  // get the lengths of the longest entry of each column
  columnLengths = h.map((_, i) => Math.max(...rows.map(row => row[i].length))),
  // build strings for the top line, header separator, and bottom line
  // [[x,y,z]] to extract chars from tagged template literal
  // "─" repeated by the length of the column + correct separator if
  // last/middle character
  buildLine = ([[x,y,z]]) => h.reduce(
    (a,_,i) =>
      a + "─".repeat(columnLengths[i]) + (i === h.length - 1 ? z : y),
    x
  ) + `\n`,
  // get lines that contain data seperated by "│" - f is header, t is rest
  [header, ...rest] = rows.map(row =>
    row.reduce((s, x, i) => s + x.padEnd(l[i]) + z, z = "│") + `\n`
  ),
  // final return value: top row + header + header separator + rest of
  // data + bottom row
  buildLine`┌┬┐` + header + buildLine`├┼┤` + rest.join("") + buildLine`└┴┘`
)

```

# Answer
> 0 votes
# Python 3, 318 bytes

-3 bytes for using the `%` formatting and -1 for abbreviating `str.join`

```
L=[c.split(',')for c in input().split('\n')]
m=[max(len(x)for x in c)for c in zip(*L)]
L=[[""]+[d.ljust(n)for d,n in zip(c,m)]+[""]for c in L]
g=["─"*i for i in m]
J=str.join
print('\n'.join(["┌%s┐"%J("┬",g),J("│",L[0]),"├%s┤"%J("┼",g)]+[J("│",L[i])for i in range(1,len(L))]+["└%s┘"%J("┴",g)]))

```

Requires input enclosed in quotes.

# Answer
> 0 votes
# C#, 696 Bytes

Golfed:

```
string T(string[]f){int w=f.Max(r=>r.Length),a=f.Select(r=>r.Split(',')[0].Length).Max(),b=f.Select(r=>r.Split(',')[1].Length).Max(),c=f.Select(r=>r.Split(',')[2].Length).Max();string o="",n="\r\n",d="",j=string.Concat(Enumerable.Repeat("─",a)),k=string.Concat(Enumerable.Repeat("─",b)),l=string.Concat(Enumerable.Repeat("─",c));Func<string,int,string>z=(q,p)=>{return q.PadRight(p);};d="┌"+j+"┬"+k+"┬"+l+"┐";o+=d+n;var g=f.First().Split(',');o+="|"+z(g[0],a)+"|"+z(g[1],b)+"|"+z(g[2],c)+"|";d="├"+j+"┼"+k+"┼"+l+"┤";o+=n+d+n;for(int i=1;i<f.Length;i++){var h=f[i].Split(',');o+="|"+z(h[0],a)+"|"+z(h[1],b)+"|"+z(h[2],c)+"|"+n;}d="└"+j+"┴"+k+"┴"+l+"┘";o+=d;return o;}

```

Ungolfed (and nicer, because ^that is no use to anyone):

```
public string T(string[] c)
{
  int width = c.Max(r => r.Length),
    longestFirstColumn = c.Select(r => r.Split(',')[0].Length).Max(),
    longestSecondColumn = c.Select(r => r.Split(',')[1].Length).Max(),
    longestThirdColumn = c.Select(r => r.Split(',')[2].Length).Max();

  string o = "", lr = "\r\n", border = "",
    firstColumnFiller = string.Concat(Enumerable.Repeat("─", longestFirstColumn)),
    secondColumnFiller = string.Concat(Enumerable.Repeat("─", longestSecondColumn)),
    thirdColumnFiller = string.Concat(Enumerable.Repeat("─", longestThirdColumn));

  Func<string, int, string> padRight = (a, b) => { return a.PadRight(b); };

  border = "┌" + firstColumnFiller
    + "┬" +
    secondColumnFiller + "┬"
    + thirdColumnFiller
    + "┐";

  o += border + lr;

  var firstRow = c.First().Split(',');

  o += "|" + padRight(firstRow[0], longestFirstColumn) +
    "|" + padRight(firstRow[1], longestSecondColumn) +
    "|" + padRight(firstRow[2], longestThirdColumn) + "|";

  border = "├" +
    firstColumnFiller + "┼" +
    secondColumnFiller + "┼" +
    thirdColumnFiller
    + "┤";

  o += lr + border + lr;

  for (int i = 1; i < c.Length; i++)
  {
    var row = c[i].Split(',');

    o += "|" + padRight(row[0], longestFirstColumn) + "|"
    + padRight(row[1], longestSecondColumn) + "|" +
    padRight(row[2], longestThirdColumn) + "|" + lr;
  }

  border = "└" +
    firstColumnFiller + "┴" +
    secondColumnFiller + "┴" +
    thirdColumnFiller
    + "┘";

  o += border;

  return o;
}

```

Testing:

```
┌──────┬───┬──────┐         ┌──────────┬───────────────────────────┬─────┐
|Name  |Age|Gender|         |Name      |PPCG Challenge             |Votes|
├──────┼───┼──────┤         ├──────────┼───────────────────────────┼─────┤
|Shaun |19 |Male  |         |Pete Arden| Print all integers        | 4   |
|Debra |19 |Female|         |Pete Arden| Yes of course I'm an adult| 3   |
|Alan  |26 |Male  |         |Pete Arden| 5 Favorite Letters        | 1   |
|George|15 |Male  |         └──────────┴───────────────────────────┴─────┘
└──────┴───┴──────┘

```

# Answer
> 0 votes
# Perl, 273 + 9 (`-CS -nlaF,` flags) = 282 bytes

```
$v[$.-1]=[@F];map$l[$_]<($l=length$F[$_])&&($l[$_]=$l),0..$#F}sub p{printf$p,@_}sub o{p
pop,map{$\x$l[$_],$_-$#l?$_[0]:pop}0..$#l}$p=join'%s','',(map"\%-${_}s",@l),$/;($\,$c,@c)=map
chr$_*4+9472,0,.5,3..15;o@c[8,1,0];p($c,map{$_,$c}@$_),$i++||o@c[12,6,4]for@v;o@c[10,3,2];{

```

Using:

```
cat file.csv | perl -CS -nlaF, script.pl

```

Try it on Ideone.

# Answer
> 0 votes
# PHP, 313 bytes

```
for(;$r=fgetcsv(STDIN);$a[]=$r)foreach($r as$x=>$s)$e[$x]=max($e[$x],strlen($s));$t=["┬","┌","┐"];eval($L='foreach($e as$i=>$n)echo$t[!$i],str_repeat("─",$n);echo"$t[2]\n";');foreach($a as$k=>$r){foreach($r as$i=>$s)echo"│",str_pad($s,$e[$i]);echo"│\n";$t=["┼","├","┤"];if(!$k)eval($L);}$t=["┴","└","┘"];eval($L);

```

**breakdown**

```
for(;$r=fgetcsv(STDIN);$a[]=$r)                         // read csv from STDIN, append to array $a
    foreach($r as$x=>$s)$e[$x]=max($e[$x],strlen($s));  // remember max length in array $e
                                                        // print top border
$t=["┬","┌","┐"];eval($L='foreach($e as$i=>$n)echo$t[!$i],str_repeat("─",$n);echo"$t[2]\n";');
foreach($a as$k=>$r)
{
    foreach($r as$i=>$s)echo"│",str_pad($s,$e[$i]);echo"│\n";   // print row
    $t=["┼","├","┤"];if(!$k)eval($L);                           // print border below header
}
$t=["┴","└","┘"];eval($L);                              // print bottom border

```

Test it at ideone

# Answer
> 0 votes
# C (gcc), 588 bytes

```
#define H char
P(c,n){for(H*s[]={"\n","┌","┬","┐","├","┼","┤","└","┴","┘","─","│"};n--;)printf("%s",s[c]);}S(s,n)H*s;{printf("%-*s",n,s);}E(n,c,Z,i)int*Z;{for(i=P(3*n+1,1);i<c;P(3*n+(++i-c?2:3),1))P(10,Z[i]);P(0,1);}V(t,c,Z,r,i)H**t;int*Z;{for(i=P(11,1);i<c;i++,P(11,1))S(t[i+r],Z[i]);P(0,1);}f(s,p)H*s,*p;{int r,R,C,i,m,L;R=C=i=m=r=0;for(p=s;*p;*p++==44&&C++)!(p[1]&&*p^10)&&R++;C/=R;H*t[R*++C];for(p=s;i<R*C;*p++=0)for(t[i++]=p;*p^44&&*p^10;)p++;int Z[C];for(i=0;i<C;Z[i++]=m)for(m=r=0;r<R;m=m<L?L:m)L=strlen(t[i+C*r++]);E(0,C,Z);V(t,C,Z,0);for(E(i=1,C,Z);i<R;)V(t,C,Z,C*i++);E(2,C,Z);}

```

Try it online!

---
Tags: code-golf, unicode
---


title: 12 with no 1234567890, but polyglot

text:
# Question
Title: 12 with no 1234567890, but polyglot
This is my 12th question, so I thought of this idea.

Goal:

Your score is \\$\Large{\frac{\text{Bytes}}{\text{Languages}^2}}\\$. Obviously the lowest score wins. This means that you can't submit something that runs in no languages (wink).

# Answer
# 5 Languages - Keg, Vyxal, Python 3, 05AB1E and Curlyfrick, 114 bytes

```
"""
!+._\PC\DC-\CC\CC- [|,]#`"""
''' TT__D++,q'''
print(ord("P")-ord("D"))
'''
...{}   ({}+{}+{}+{})*({}+{}+{})
'''

```

100% ascii too

Try Keg online!

Try Python 3 online!

Try 05AB1E online!

Try Curlyfrick online!

Try Vyxal Online!

Explanation coming soon. Soon here means a time that *isn't* 21 minutes past midnight.
> 3 votes

# Answer
# 7+ languages, 24 bytes, score \< 0.49

## Haskell, OCaml, Coq, Common Lisp, Erlang, Octave/Matlab, PARI/GP, and many other functional languages

`(length("twelvetwelve"))`
> 3 votes

# Answer
# brainfuck, Headass, Javascript; 3 languages, 52 bytes

```
print("+++++++^[>D+++++P++<-]>:".length/"+?".length)

```

Three cussword titled languages

Javascript: Try it online!

brainfuck: Try it online!

Headass: Do stuff online

Javascript:

```
                  /             Divide
           .length     .length  The lengths
      "..."        "+?"         Of these strings (24/2)
print(                        ) Output the result

```

brainfuck (ignored characters removed)

```
+++++++[>+++++++<-]>    7*7 (canonical)
                    .+. print charcodes 49 and 50

```

Headass (ignored characters removed)

```
(        [>       ++<-]>:      nothing important
 +++++++^  D+++++P             print 12
                         .     halt
                          +?.) inaccessible code

```

Not sure what else I can add without drastically changing my approach. Just wanted to get a score up to start with for now.
> 2 votes

# Answer
# JavaScript (jsshell), Python 3, bash (core utils)?, brainfuck, 109 bytes

```
#!/usr/bin/env -S grep -c ^
e=">+++++++[->+"
print(True//True*len(e));"""++++++<]>
=e.length)//+."""

```

I'm not quite sure if this should be count as bash as it actually runs `grep` from its shebang. It does not work on TIO version of jsshell, as support shebang as comment requires a newer version.
> 1 votes

# Answer
# Example Submission, \\$1\\$ Language(s), \\$26\\$ Byte(s), Score \\$\frac{26}{1^2}=26\\$.

Language(s):

* Python

```
print(len('aaaaaaaaaaaa'))

```

# Explanation

Need I say more...?
> 0 votes

---
Tags: code-golf, code-challenge, restricted-source, polyglot, rosetta-stone
---


title: Reversible program

text:
# Question
Title: Reversible program
### Objective

Write a program that outputs some printable ASCII characters. The trick is that if the program is reversed byte-by-byte, it must output the same thing in the reverse order, byte-by-byte, too.

### Rules

* No standard loopholes.
* The program must **not** be a palindrome, nor can it be 1 byte in length (or empty). No restriction for patterns of the output as long as:
* The output is at least 2 bytes long. It must contain solely printable ASCII characters, including visible characters and newlines, tabs and spaces. It should not be empty.
* **Outputs to standard error is ignored.**
* **Quine programs are forbidden.**

For example, the following program makes no sense (HQ9+)

```
AQ

```

### Easy Mode

Paired parentheses/brackets/curly brackets are swapped after reversing source, so a reverse may be:

```
print("Hello");
;("olleH")tnirp  # not ;)"olleH"(tnirp

```

**Make a note in your answer** if your program uses this "Easy Mode".

### Example

These are theoretical examples and may not exist in any programming language.

```
input -> output

program -> abcd
margorp -> dcba

() -> 10
)( -> 01

print('yes')tnirp -> yes
print('sey')tnirp -> sey

```

This is a , so the program with the shortest source code (in bytes) in each language wins!

## Leaderboard

Here is a Stack Snippet to generate both a regular leaderboard and an overview of winners by language.

```
/* Configuration */

var QUESTION_ID = 142801; // Obtain this from the url
// It will be like https://XYZ.stackexchange.com/questions/QUESTION_ID/... on any question page
var ANSWER_FILTER = "!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe";
var COMMENT_FILTER = "!)Q2B_A2kjfAiU78X(md6BoYk";
var OVERRIDE_USER = 48934; // This should be the user ID of the challenge author.

/* App */

var answers = [], answers_hash, answer_ids, answer_page = 1, more_answers = true, comment_page;

function answersUrl(index) {
  return "https://api.stackexchange.com/2.2/questions/" +  QUESTION_ID + "/answers?page=" + index + "&pagesize=100&order=desc&sort=creation&site=codegolf&filter=" + ANSWER_FILTER;
}

function commentUrl(index, answers) {
  return "https://api.stackexchange.com/2.2/answers/" + answers.join(';') + "/comments?page=" + index + "&pagesize=100&order=desc&sort=creation&site=codegolf&filter=" + COMMENT_FILTER;
}

function getAnswers() {
  jQuery.ajax({
    url: answersUrl(answer_page++),
    method: "get",
    dataType: "jsonp",
    crossDomain: true,
    success: function (data) {
      answers.push.apply(answers, data.items);
      answers_hash = [];
      answer_ids = [];
      data.items.forEach(function(a) {
        a.comments = [];
        var id = +a.share_link.match(/\d+/);
        answer_ids.push(id);
        answers_hash[id] = a;
      });
      if (!data.has_more) more_answers = false;
      comment_page = 1;
      getComments();
    }
  });
}

function getComments() {
  jQuery.ajax({
    url: commentUrl(comment_page++, answer_ids),
    method: "get",
    dataType: "jsonp",
    crossDomain: true,
    success: function (data) {
      data.items.forEach(function(c) {
        if (c.owner.user_id === OVERRIDE_USER)
          answers_hash[c.post_id].comments.push(c);
      });
      if (data.has_more) getComments();
      else if (more_answers) getAnswers();
      else process();
    }
  });
}

getAnswers();

var SCORE_REG = /<h\d>\s*([^\n,]*[^\s,]),.*?(\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/;

var OVERRIDE_REG = /^Override\s*header:\s*/i;

function getAuthorName(a) {
  return a.owner.display_name;
}

function process() {
  var valid = [];

  answers.forEach(function(a) {
    var body = a.body;
    a.comments.forEach(function(c) {
      if(OVERRIDE_REG.test(c.body))
        body = '<h1>' + c.body.replace(OVERRIDE_REG, '') + '</h1>';
    });

    var match = body.match(SCORE_REG);
    if (match)
      valid.push({
        user: getAuthorName(a),
        size: +match[2],
        language: match[1],
        link: a.share_link,
      });

  });

  valid.sort(function (a, b) {
    var aB = a.size,
        bB = b.size;
    return aB - bB
  });

  var languages = {};
  var place = 1;
  var lastSize = null;
  var lastPlace = 1;
  valid.forEach(function (a) {
    if (a.size != lastSize)
      lastPlace = place;
    lastSize = a.size;
    ++place;

    var answer = jQuery("#answer-template").html();
    answer = answer.replace("{{PLACE}}", lastPlace + ".")
                   .replace("{{NAME}}", a.user)
                   .replace("{{LANGUAGE}}", a.language)
                   .replace("{{SIZE}}", a.size)
                   .replace("{{LINK}}", a.link);
    answer = jQuery(answer);
    jQuery("#answers").append(answer);

    var lang = a.language;
    if (/<a/.test(lang)) lang = jQuery(lang).text();

    languages[lang] = languages[lang] || {lang: a.language, user: a.user, size: a.size, link: a.link};
  });

  var langs = [];
  for (var lang in languages)
    if (languages.hasOwnProperty(lang))
      langs.push(languages[lang]);

  langs.sort(function (a, b) {
    if (a.lang > b.lang) return 1;
    if (a.lang < b.lang) return -1;
    return 0;
  });

  for (var i = 0; i < langs.length; ++i)
  {
    var language = jQuery("#language-template").html();
    var lang = langs[i];
    language = language.replace("{{LANGUAGE}}", lang.lang)
                       .replace("{{NAME}}", lang.user)
                       .replace("{{SIZE}}", lang.size)
                       .replace("{{LINK}}", lang.link);
    language = jQuery(language);
    jQuery("#languages").append(language);
  }

}
```

```
body { text-align: left !important}

#answer-list {
  padding: 10px;
  width: 290px;
  float: left;
}

#language-list {
  padding: 10px;
  width: 290px;
  float: left;
}

table thead {
  font-weight: bold;
}

table td {
  padding: 5px;
}
```

```
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b">
<div id="answer-list">
  <h2>Leaderboard</h2>
  <table class="answer-list">
    <thead>
      <tr><td></td><td>Author</td><td>Language</td><td>Size</td></tr>
    </thead>
    <tbody id="answers">

    </tbody>
  </table>
</div>
<div id="language-list">
  <h2>Winners by Language</h2>
  <table class="language-list">
    <thead>
      <tr><td>Language</td><td>User</td><td>Score</td></tr>
    </thead>
    <tbody id="languages">

    </tbody>
  </table>
</div>
<table style="display: none">
  <tbody id="answer-template">
    <tr><td>{{PLACE}}</td><td>{{NAME}}</td><td>{{LANGUAGE}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr>
  </tbody>
</table>
<table style="display: none">
  <tbody id="language-template">
    <tr><td>{{LANGUAGE}}</td><td>{{NAME}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr>
  </tbody>
</table>
```

# Answer
> 8 votes
# RProgN 2, 2 bytes

```
Ai

```

Forwards, produces `ZYXWVUTSRQPONMLKJIHGFEDCBA`, backwards, produces `ABCDEFGHIJKLMNOPQRSTUVWXYZ`.

`A` pushes the alphabet, and `i` reverses it, although if `i` doesn't have anything to reverse, it conveniently does nothing.

Try it online!

# Answer
> 7 votes
# Jelly, 5 bytes

```
22«33

```

Try it online!

The first is `min(22, 33)` and the reverse is `min(33, 22)`

# Also 5 bytes

```
.)25½

```

Try it online!

The `)` seems to discard everything before it. This is `sqrt(25)` which is `5.0` and the reverse is `.` which is `0.5`.

# Answer
> 3 votes
# Excel VBA, 11 Bytes

*(Ab)uses the fact that Excel has more than one STDOUT; Does not use Easy Mode*

Anonymous VBE immediate window function that takes no input and outputs `12` to the VBE immediate window.

```
?12'12=]1A[

```

### Reversed

Anonymous VBE immediate window function that takes no input and outputs `21` to the the range `[A1]` on the ActiveSheet Object.

```
[A1]=21'21?

```

Note: `?12'12?` works as well but feels a bit too close to palindromic to be within the spirit of the challenge

# Answer
> 3 votes
# Brain-Flak, ~~35~~ 28+1=29 bytes

```
((#)}{))
()()()()(
 )){})#((

```

1 extra byte because of the flag `-A` to print ascii. This prints "\n\n"

Try it online!

-6 bytes thanks to Riley pointing out that I can cleverly use newlines in order to not duplicate as much code for the reversed program. This works because the pound sign only starts a single line comment.

# Answer
> 3 votes
# Rain-Flak, ~~65~~ 59 bytes

```
((((((#)])([))(}{)}{))}{))
()()()()(
)){})){}){})())#((((((

```

Try it online!

This pushes

```

()

```

going forwards and

```

)(

```

going backwards.

It needs to pad the front with a newline because Brain-Flak's output automatically gets a newline added to the end of the output.

# Answer
> 3 votes
# Jelly, 2 bytes

```
0%

```

**Try it online!** ...or **try `%0`**

Both full programs output the palindromic `nan` as they both attempt to take a modulo of zero by zero and implicitly print the result.

# Answer
> 2 votes
# Mathematica, 5 bytes

```
44+55

```

or...

# Mathematica, 4 bytes

```
11*9

```

outputs `99`

# Answer
> 2 votes
# Pyth, 4 bytes

```
"Jj"

```

Outputs `Jj` and `jJ` when reversed.

# Answer
> 2 votes
# Python 2, ~~43~~ ~~42~~ 52 bytes

### Source

```
#1.,"n\"tnirp:tpecxe
#"""
print"\n",\
1.#"""cexe:yrt

```

Try it online!

### Reversed source

```
try:exec"""#.1
\,"n\"tnirp
"""#
except:print"\n",.1#

```

Try it online!

---

Inspired by i cri everytim's answer. Does, however, not require 'easy mode'.

The program's outputs now are true reverses of one another, not ignoring the new line character. Thanks to @Jonathan Allan for pointing it out.

# Answer
> 2 votes
# Japt, ~~4~~ 3 bytes

*-1 byte thanks to @ETHproductions*

### Normal

```
12C

```

Try it online! Prints `12`.

### Reversed

```
C21

```

Try it online! Prints `21`.

Only the last statement is printed, and `C` is the constant for `12`.

# Answer
> 1 votes
# Jelly, 3 bytes

```
1+³

```

Try it online!

This is `1 + 100` which is `101`. The reverse is just `100 + 1` which is also `101`. Replacing `+` with `_` works too.

# Also 3 bytes

```
11»

```

Try it online!

The first is `max(11, 0)`. The reverse is just `max(0, 11)`. The argument is `0` by default if not present.

# Answer
> 1 votes
# brainfuck, ~~67~~ ~~23~~ 21 bytes

* Saved two bytes thanks to 12Me21; using a tab instead of a new line.

```
+++++++++..+++++++++>
```

Try it online!

The program's ouput are two ~~spaces~~ ~~new lines~~ tabs. It is nearly a palindrome, apart from the trailing or leading cell shift (`>`).

# Answer
> 1 votes
# Perl 5 / Perl 6 / Ruby, 17 bytes

```
print 12#12 tnirp

```

Try it in Perl 5
Try it reversed in Perl 5

Try it in Perl 6
Try it reversed in Perl 6

Try it in Ruby
Try it reversed in Ruby

# Answer
> 1 votes
# Python 2, 20 bytes

```
print'\n';#'n\'tnirp

```

Try it online!

`print'\n'` prints both the single newline it instructs and an implicit newline after.

`print'\n';` does exactly the same - the `;` is just there to stop the program being a palindrome.

The `#` marks the start of a comment.

# Answer
> 1 votes
# Japt, 2 bytes

Both output `11`. `B` is the Japt constant for `11` and the `w` method, when applied to a number, returns the larger of that number and any number passed to it as an argument.

```
wB

```

Try it

```
Bw

```

Try it

# Answer
> 1 votes
## Charcoal, 2 bytes

The `-` is simply a string literal that implicitly prints itself. The `¹` is a numeric literal, and the default is to implicitly print one `-` too. Any ASCII character and non-zero Unicode superscript would work.

```
²←

```

Forwards, this prints two `-`s, then moves the cursor back one step (but this does not affect the output). Backwards, this prints two `-`s leftwards, but the output remains the same. Any subscript from 2 to 9 would work here, as would a right arrow or the reflect operator .

# Answer
> 1 votes
# Java 8, 132 bytes

Dang full program requirements..

```
interface M{static void main(String[]a){System.out.print("OK");}}//}};)"OK"(tnirp.tuo.metsyS{)a][gnirtS(niam diov citats{M ecafretni

```

Try it here. Prints `OK`.

Reversed:

```
interface M{static void main(String[]a){System.out.print("KO");}}//}};)"KO"(tnirp.tuo.metsyS{)a][gnirtS(niam diov citats{M ecafretni

```

Try it here. Prints `KO`.

# Answer
> 1 votes
# 05AB1E, 4 bytes

```
?RA?

```

Try it online! or Try it reversed!

# Answer
> 1 votes
# Javascript (ES6), 12 bytes

```
_=>12//12>=_

```

Reversed:

```
_=>21//21>=_

```

Code snippet:

```
a=_=>12//12>=_
b=_=>21//21>=_
console.log(a())
console.log(b())
```

# Answer
> 1 votes
# Neim, 2 bytes

```
γδ

```

Outputs 12. Reversed, outputs 21.

Try it online!

# Answer
> 1 votes
# Triangular, 6 bytes

```
%.%%%%

```

Prints `000`. Triangle looks like this:

```
  %
 . %
% % %

```

Reversed triangle looks like this:

```
  %
 % %
% . %

```

The IP starts travelling southeast from the topmost character, so in both triangles `%%%` is interpreted.

# Answer
> 1 votes
# SmileBASIC, 4 bytes

```
?12?

```

This will work in many BASIC dialects.

Prints "12" forwards, and "21" backwards.

# Answer
> 1 votes
# Zsh, 16 bytes

```
printf 12 ftnirp
```

Attempt This Online!

# Answer
> 0 votes
# Implicit, 2 bytes

```
À\

```

Same as the winning RProgN 2 answer. Try it online!

## You can use a tool in this language to print the reverse of your code.

# Answer
> 0 votes
# Cubically 2.1, 5 bytes

```
%0%1%

```

Prints `09`. Try it online! or Try it reversed!

The top (0-indexed) face is initialized to 0 and the left (1-indexed) face is initialized to 9. So printing (`%`) 0 prints 0 and printing 1 prints 9.

No longer works in Cubically 2.2 as `%` can be called implicitly.

# Answer
> 0 votes
# shortC, 18 bytes

```
AJ"hi")}//})"hi"JA

```

Prints `hi`. Exploits comments. Try it online!

# Answer
> 0 votes
# rk, 50 bytes

```
rk:start
dne:kr
print: "hi" :tnirp
trats:kr
rk:end

```

Reversed via this tool:

```
dne:kr
rk:start
print: "ih" :tnirp
rk:end
trats:kr

```

rk ignores everything before `rk:start` and `rk:end`. Of course, it ignores everything in the middle it doesn't understand anyway.

Try it online! vs Try it reversed!

# Answer
> -1 votes
## Unix sh, 15 bytes

```
echo ab#ab ohce

```

Reversed:

```
echo ba#ba ohce

```

Outputs `ab` and `ba`, respectively.

# Answer
> -3 votes
## RProgN 2, 3 bytes

```
1
0

```

Output:

```
0
1

```

Try it online!

---

Reversed source:

```
0
1

```

Reversed output:

```
1
0

```

Try it online!

---
Tags: code-golf, restricted-source, source-layout
---


title: Concatenatable numbers

text:
# Question
Title: Concatenatable numbers
Given a list of positive integers such as `[69, 420]`, your challenge is to generate the sequence of numbers that can be formed by concatenating numbers from the above set, in ascending numerical order.

For example, with `[69, 420]` the sequence begins:

```
69
420
6969
42069
69420
420420

```

Note that elements of the sequence should be unique.

The list will be nonempty and will not contain duplicates.

Standard rules apply.

## Testcases

In `list, 0-indexed number` format.

```
[69, 420], 4 -> 69420
[32, 33, 34], 8 -> 3334
[109, 5], 7 -> 10955
[2, 22, 222], 4 -> 22222

```

# Answer
# Python, 71 bytes (-3 thanks to @pxeger)

```
def f(A):
 o=A
 while o:=o-{x:=min(o,key=int)}|{x+i for i in A}:yield x
```

Attempt This Online!

This takes a set of strings as its input.

### Old Python, 77 bytes

```
def f(A):
 o=A
 while o:O,*o=sorted({*o},key=int);yield O;o+=map(O.__add__,A)
```

Attempt This Online!

A generator that walks through the sequence.

How does it work?

It maintains a list/set which always contains (or has yielded) all the concatenations of all numbers output so far with all numbers in the input list. At each iteration it yields the smallest element and adds its concatenations with the input list.
> 11 votes

# Answer
# JavaScript (V8), 60 bytes

Prints the sequence forever.

```
a=>{for(k=0;;)(++k+'').match(`^(${a.join`|`})+$`)&&print(k)}

```

Try it online!

### How?

We turn the list of integers into a regular expression:

```
[69, 420] ~~> /^(69|420)+$/

```

And we use it to identify the positive integers that belong to the sequence.
> 8 votes

# Answer
# Zsh `-F`, 30 bytes

```
seq inf|grep -xP (${(j"|")@})+
```

Attempt This Online!

Slow.
> 7 votes

# Answer
# Python 2, <sup>~~109~~ ~~108~~</sup> 104 bytes

```
a=input();i=0
m=lambda n:n*all(n.find(p)or m(n[len(p):])for p in a)
while 1:
 if""==m(`i`):print i
 i+=1
```

Attempt This Online!

-1 byte thanks to Jonathan Allan

---

# Python, 81 bytes

```
import re
def f(a,i=0):re.match(f'({"|".join(a)})+$',str(i))and print(i);f(a,i+1)
```

Attempt This Online!

Dies with the recursion limit, but works theoretically (or if you use a Python interpreter with TCO)
> 6 votes

# Answer
# 05AB1E, 7 bytes

```
иæJïê¹£

```

Given \\$n\\$ and the list, it outputs the first \\$n\\$ results.

Try it online or verify all test cases.

**Explanation:**

```
и        # Repeat the (implicit) second input-list the first (implicit)
         # input-integer amount of times as list
 æ       # Get the powerset of this list
  J      # Join each inner list together
   ï     # Cast each string to an integer
    ê    # Uniquify and sort the list
     ¹£  # Only leave the first first input amount of values
         # (after which this is output implicitly as result)

```

Too bad sorting builtins don't work on infinite lists, otherwise `ÞæJïê` would have been enough to output the infinite sequence given just an input-list.
> 6 votes

# Answer
# Brachylog, 13 bytes

```
tT&j₎⊇ᵘcᵐoh↙T

```

Try it online!

Extremely inefficient.

This returns the first N elements, 1-indexed.

### Explanation

```
tT               Input = [List, T]
  &j₎            Concatenate List T times to itself
     ⊇ᵘ          Find all unique subsets of this new list
       cᵐ        Map concatenate
         o       Sort
          h↙T    Return the first T elements

```
> 6 votes

# Answer
# Jelly, 8 bytes

```
xŒPḊVQṢḣ

```

A dyadic Link that accepts the list of positive integers on the left and the number of elements to get, `N`, on the right and yields a list of the first `N` concatenated integers.

**Try it online!** \- extremely inefficient!

### How?

```
xŒPḊVQṢḣ - Link: list of positive integers, L; positive integer, N
x        - repeat the elements of L N times each
 ŒP      - powerset
   Ḋ     - dequeue (remove the empty list)
    V    - evaluate as Jelly code (concatenates each and gives back the integer)
     Q   - deduplicate
      Ṣ  - sort
       ḣ - head -> the first N elements

```
> 5 votes

# Answer
# Charcoal, 26 bytes

```
≔θζＦη«⊞υ⌊⁻ζυ≔⁺ζＩ⁺Ｉ⌈υＩθζ»Ｉυ

```

Try it online! Link is to verbose version of code. Outputs the first `n` terms. Explanation: Based on @Albert.Lang's Python answer.

```
≔θζ

```

Start with the input list.

```
Ｆη«

```

Repeat `n` times.

```
⊞υ⌊⁻ζυ

```

Save the minimum value not collected so far.

```
≔⁺ζＩ⁺Ｉ⌈υＩθζ

```

Append all the concatenations of that value with the input list to the current list.

```
»Ｉυ

```

Output the collected terms.
> 4 votes

# Answer
# Vyxal, 9 bytes

```
ẋfṗvṅ⌊sUi

```

Try it Online!

Port of the Jelly answer. Yields a list of the first N concatenated integers.

## Explained (outdated - will fix soon)

```
ẋfṗvṅ⌊sUi
ẋf        # Repeat the input list N times
  ṗ       # take the powerset of that list
   vṅ⌊    # Concatenate each sublist into a single integer
      sUi # and get the Nth item in the sorted uniquified list

```
> 3 votes

# Answer
# Factor \+ `lists.lazy`, ~~95~~ 82 bytes

```
[ 0 lfrom swap "|"join "^(%s)+$"sprintf <regexp> '[ present _ matches? ] lfilter ]

```

Try it online!

-13 bytes from using @Arnauld's method. Takes input as a sequence of strings representing integers and returns an infinite lazy list of the sequence.
> 3 votes

# Answer
# Retina, 62 bytes

```
~(T`,`|
(\d+).(.+)
K`0¶$1{`.+¶$$.($*__¶/^($2)+$/^+`.+¶$$.($*__

```

Try it online! Takes `n` as the first input in the list and outputs the 1-indexed `n`th term. Explanation: Similar approach to @Arnauld's JavaScript answer.

```
T`,`|

```

Change the commas into `|`s.

```
(\d+).(.+)

```

Match the first number and the remaining numbers separately.

```
K`0¶$1{`.+¶$$.($*__¶/^($2)+$/^+`.+¶$$.($*__

```

Create a Retina program with them substituted in.

```
~(`

```

Evaluate that program.

For example, with the inputs `5,69,420` the following Retina program is created:

```
K`0

```

Set the current value to `0`.

```
5{`

```

Repeat `5` times.

```
.+
$.(*__

```

Increment the current value.

```
/^(69|420)+$/^+`

```

Repeat while the current value isn't a concatenation of `69`s and `420`s...

```
.+
$.(*__

```

... increment the current value.
> 3 votes

# Answer
# , 82 bytes

```
function(n)repeat grepl(sprintf("^(%s)+$",paste(n,collapse="|")),F<-F+1)&&print(F)

```

Try it online!

Port of @Arnauld's answer.
> 3 votes

# Answer
# Pip, 12 bytes

```
W1Ui~=+Xg&Pi

```

Try It Online! (link is to a safe version that only runs 1000 times)

-2 thanks to DLosc.

```
W1           # Forever
     ~=      # Check a regex match of...
        Xg   # Input regex'd
       +     # With a `+`
  Ui         # In (incrementing) i
         &Pi # If so, print i

```
> 3 votes

# Answer
# BQN, 37 bytes

```
{⊑∧⍷•Bqn¨∾¨•Fmt¨¨1↓(⥊(↕2˘)/¨<)∾/⋈}

```

Try it here!

Slow enough that you'll probably need a local interpreter to run most of the cases.

2 bytes saved thanks to @Razetime!

# Explanation

*w* is index, *x* is list of numbers.

* `∾/⋈` *x* repeated *w* times
* `(⥊(↕2˘)/¨<)` powerset
* `1↓` remove empty set
* `•Bqn¨∾¨•Fmt¨¨` for each element in powerset, concatenate numbers
    + Super-slow since we're "eval"ing each string to get the number (BQN doesn't have an easy way to convert strings to numbers)
* `∧⍷` Deduplicate and sort
* Get *w*th number
> 2 votes

# Answer
# Burlesque, 16 bytes

```
Jx/jcb)imNB><j!!

```

Try it online!

Takes block (L) and int (N)

```
J    # Duplicate N
x/j  # Make stack N,L,N
cb   # Combinations of L of length [1..N]
)im  # Concat each result
NB   # Remove duplicates
><   # Sort
j!!  # Select Nth

```
> 1 votes

---
Tags: code-golf, sequence
---


title: Big big numbers

text:
# Question
Title: Big big numbers
Whilst trying to golf several of my answers, I've needed to write large integers in as few characters as possible.

Now I know the best way to do that: I'll be getting *you* to be writing this program.

# The challenge

* Write a program that when given a positive integer, outputs a program that prints it to stdout or equivalent.
* The output programs don't have to be in the same language as the creator.
* The output must be at most 128 bytes.
* You may accept input from stdin or equivalent (not function input)
* You may output the resulting program to stdout or equivalent.
* The number output must be in decimal (base 10)

## Scoring

Your score is equal to the smallest positive integer your program can not encode.

The entry with the largest score wins.

# Answer
> 3 votes
# Python 3 → CJam, (163122 − 1)·255/162 + 1 ≈ 1.213·10270

```
import sys
n = int(input())
for b in range(163, 1, -1):
    s = []
    m = n
    while m:
        m, r = divmod(m - 93, b)
        if m < 0:
            break
        s.append(r + 93)
    else:
        sys.stdout.buffer.write(b'"%s"%db' % (bytes(s[::-1]), b))
        break
else:
    sys.stdout.buffer.write(b'%d' % n)

```

It turns out that every integer from 1023 through (163122 − 1)·255/162 can be represented in at least one way by a base *b* ≤ 163 conversion from a string of at most 122 characters with codes 93 through *b* \+ 92, rather than the usual 0 through *b* − 1. This avoids the troublesome characters 34 (double quote) and 92 (backslash) without any extra output code.

# Answer
> 12 votes
# Pyth, 252111 ≈ 3.593 × 10266

```
Js[
"ixL-rC1`H``N"
N
s@L-rC1`H``NjQ252
N
"252")$import sys$$sys.stdout.buffer.write(J.encode('iso-8859-1'))$

```

Had to use a little bit of Python syntax, because Pyth's `print` can't print in `iso-8859-1`.

The number gets encoded in base 252 and represent each digit in that base as an iso-8859-1 char. The chars `\` and `"` would need escaping, and therefore are not used. The char ``` isn't used because golfing... And additionally the null-byte is also not used, the Pyth compiler forbids it.

The output is a program with an overhead of 17 bytes:

```
ixL-rC1`H``N""252

```

Here's an example usage with the biggest number possible:

### Explanation

of the output program.

```
ixL-rC1`H``N""252
    rC1`H          create the range of chars: ['\x01', '\x02', ..., '{}']
         ``N       creates a string containing the 3 chars " ' \
   -               remove strings which consists of these 3 chars
 xL         ""     determine the index of each char in "" (encoded number)
i             252  convert from base 253 to base 10

```

# Answer
> 10 votes
# CJam, 254<sup>109</sup> ≈ 1.34 x 10<sup>262</sup>

```
q~254b{_33>+_91>+c}%`"{_'[>-_'!>-}%254b"

```

I'm encoding the number in base 254 and represent each digit in that base as an ISO 8859-1 character, skipping `"` and `\`. The output has an overhead of 19 bytes, `""{_'[>-_'!>-}%254b`, so I can represent everything less than 254<sup>128-19</sup>, or explicitly

```
13392914970384089616967895168962602841770234460440231501234736723328784159136966979592516521814270581662903357791625539571324435618053333498444654631269141250284088221909534717492397543057152353603090337012149759082408143603558512232742912453092885969482645766144

```

As an example, `6153501` would be encoded as

```
"abc"{_'[>-_'!>-}%254b

```

Here is a test program which prints the encoded integer, and then prints its length, and then executes it right away to show its validity (this avoids the trouble of having to copy the unprintable characters into a new program, which doesn't always work with the online interpreter).

# Answer
> 8 votes
# Perl, 10<sup>216</sup>

```
print"print unpack'h*',q{",(pack'h*',<>),"}"

```

Also base 100 encoding, slightly more elegant. Output for `12345678` would be:

```
print unpack'h*',q{!Ce‡}

```

The delimeters `{` and `}` correspond to hex values `b7` and `d7` respectively, which cannot appear in the input, and therefore do not need to be escaped.

There are 20 bytes of overhead, leaving 108 for encoding, reaching a maximum value of 10<sup>216</sup>-1.

---

### Perl, 10<sup>206</sup>

```
print"ord=~print\$' for'",(map chr"1$_",<>=~/.{1,2}/g),"'=~/.|/g"

```

Simple base 100 encoding. Output for `12345678` would look like this:

```
ord=~print$' for'p†œ²'=~/.|/g

```

There are 25 bytes of overhead, leaving 103 for encoding, reaching a maximum value of 10<sup>206</sup>-1.

# Answer
> 6 votes
# Common Lisp, 36<sup>114</sup> \- 1 ~ 2.62 × 10<sup>117</sup>

```
(lambda(x)(format t"(lambda()#36r~36r)"x))

```

The largest number is:

2621109035105672045109358354048170185329363187071886946329003212335230440027818091139599929524823562064749950789402494298276879873503833622348138409040138018400021944463278473215

Simply use base 36. For the largest input, the 128-bytes long output is:

```
(lambda()#36rzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz)

```

# Answer
> 4 votes
# Vyxal, 3 bytes ~\\$10^{305}\\$

```
øCṪ

```

Try it Online!

Thanks to emanresu A for 2 more orders of magnitude

Simple number compression builtin, then chop off the last char. Generates a Vyxal compressed number in base 255. Exceeds the 128 byte output limit at \\$10^{305}\\$, but can go up to \\$10^{308}\\$ if the ceiling is raised to 130 bytes.

# Answer
> 1 votes
# CJam, 233<sup>114</sup> ≈ 7.561⋅10<sup>269</sup>

```
ri233b{Kms/m]_34=+c}%s`"{iKms*}%233b"

```

The output program `"…"{iKms*}%233b` decodes the 8-bit characters of a string to base 233 digits with *n* ↦ ⌊*n* ⋅ sin 20⌋ = ⌊*n* ⋅ 0.913⌋. This transformation happens to be surjective without requiring the critical codepoints 34 (double quote) and 92 (backslash) as input.

---
Tags: code-challenge, number, compression, code-generation, integer
---


# Question
Title: Write the shortest program that generates the most compiler warnings and errors
## The challenge:

Write a very short program that, when compiled, creates the most amount of compiler warnings and errors. It can be written in any programming language.

## Scoring:

The score is determined by this equation: `errors_and_warnings_length/code_length`. Highest score wins.

## Example:

The C# program `class` is 5 chars long and generates 3 warnings, which is a score of (1/5)\*3 = 0.6.

## EDIT:

Because of some confusion, programs have to be at least 1 char long. Otherwise it would get a score of infinity.

# Answer
## GCC, score 2200 / 36 ≈ 4.5 × 1058

```
#include __FILE__
#include __FILE__

```

I have not actually finished compiling this code, but based on testing and simple mathematics, it should produce a total of 2200 `#include nested too deeply` errors.

Of course, the program is trivially extensible. Adding a third line brings the score up to **3200 / 54 ≈ 4.9 × 1093**. Four lines give **4200 / 72 ≈ 3.6 × 10118**, and so on.
> 101 votes

# Answer
## C, 0 characters - Score=(1/0)\*1=Infinity

generates 1 error:

```
/usr/lib/gcc/i686-pc-linux-gnu/4.7.0/../../../crt1.o: In function `_start':
(.text+0x18): undefined reference to `main'
collect2: error: ld returned 1 exit status

```

Note: http://ideone.com/xdoJyA
> 53 votes

# Answer
## GCC, score 5586.6 (and more if needed)

179 chars, 1000003 warnings/errors (using `-Wall`)

```
#define E a,a,a,a,a,a,a,a,a,a
#define D E,E,E,E,E,E,E,E,E,E
#define C D,D,D,D,D,D,D,D,D,D
#define B C,C,C,C,C,C,C,C,C,C
#define A B,B,B,B,B,B,B,B,B,B
_(){A,A,A,A,A,A,A,A,A,A}

```

This can be extended arbitrarily, of course. For example, using 10 `#define`s instead of 5 and a length of 20 "calls" instead of 10 would lead to a score of about (20\**10)/(179\*4) = 14301675977.65 (and would take quite some time to run ;)
> 20 votes

# Answer
## GCC twice, 86

22 chars, 1898 errors+warnings on my system.
I'm sure this approach can be much improved, by choosing longer files with shorter names.

```
#include</usr/bin/gcc>

```
> 13 votes

# Answer
## HQ9++, 1 (limit of (n+29)/n)

The following emits the warning `Warning: this is not a quine` for each Q in the code.

```
QQQQQ...Q
Warning: this is not a quine

```

Small is good, right? Hmm...
> 13 votes

# Answer
## C, .727

11 chars, 5 errors, 3 warnings, (1/11)\*8 = .727273

```
m(;){@,x}2

```

```
cc -g -Wall    er.c   -o er
er.c:1: error: expected declaration specifiers or '...' before ';' token
er.c:1: warning: return type defaults to 'int'
er.c: In function 'm':
er.c:1: error: stray '@' in program
er.c:1: error: expected expression before ',' token
er.c:1: error: 'x' undeclared (first use in this function)
er.c:1: error: (Each undeclared identifier is reported only once
er.c:1: error: for each function it appears in.)
er.c:1: warning: left-hand operand of comma expression has no effect
er.c:1: warning: control reaches end of non-void function
er.c: At top level:
er.c:1: error: expected identifier or '(' before numeric constant

```
> 11 votes

# Answer
## NASM, score 63/40 * 2^32 ≈ 2.905 * 10^19

```
%rep 1<<32
%rep 1<<32
!
%endrep
%endrep

```

Will output `c.asm:3: error: label or instruction expected at start of line` 2^64 times. Again this is easily extensible to much bigger outputs.
> 8 votes

# Answer
**C++98 (211 bytes)** g++-5 (Ubuntu 5.2.1-23ubuntu1~12.04) 5.2.1 0151031

I wanted to see how well I could do in C++ without using the preprocessor at all. This program produces 2,139,390,572 bytes of output, most of which is a single error message.

```
template<int i,class S,class T>struct R{typedef R<i,typename R<i-1,S,S>::D,typename R<i-1,S,S>::D>D;};template<class S,class T>struct R<0,S,T>{typedef S D;};void f(){R<27,float,R<24,int*const*,int>::D>::D&E=4;}

me@Basement:~/src/junk$ ls -l a.C
-rw-rw-r-- 1 me me 211 Apr 27 21:44 a.C
me@Basement:~/src/junk$ g++-5 a.C -fmax-errors=1 2>a.C.errors.txt
me@Basement:~/src/junk$ ls -l a.C.errors.txt
-rw-rw-r-- 1 me me 2139390572 Apr 27 22:01 a.C.errors.txt

```

Ungolfed:

```
template <int i, class S, class T>
struct R {
    typedef R<i, typename R<i-1,S,S>::D, typename R<i-1,S,S>::D> D;
};
template <class S, class T>
struct R<0, S, T> {
    typedef S D;
};
void f() {
    R<27, float, R<24, int*const*, int>::D>::D &E = 4;
}

```

This program works by defining a recursive struct template R which holds a typedef D containing two copies of R. This results in an type name which grows exponentially, which is printed out in full in the error message. Unfortunately, g++ seems to choke while attempting to print an error message longer than (1\<\<31) bytes. 2,139,390,572 bytes was the closest I could get to the limit without going over. I'm curious if anyone can adjust the recursion limits and parameter types `27, float, 24, int*const*` to get closer to the limit (or find a compiler which can print an even longer error message).

Excerpts from the error message:

```
a.C: In function ‘void f()’:
a.C:1:208:  error:  invalid  initialization  of non-const reference of type
‘R<27, float, R<24, R<23, R<22, R<21, R<20, R<19, R<18, R<17, R<16, R<15,
R<14,  R<13, R<12, R<11, R<10, R<9, R<8, R<7, R<6, R<5, R<4, R<3, R<2, R<1,
int* const*, int* const*>, R<1, int* const*, int* const*> >, R<2, R<1, int*
const*,  int*  const*>,  R<1, int* const*, int* const*> > >, R<3, R<2, R<1,
int* const*, int* const*>, R<1, int* const*, int* const*> >, R<2, R<1, int*
const*,  int* const*>, R<1, int* const*, int* const*> > > >, R<4, R<3, R<2,
R<1, int* const*, int* const*>, R<1,
...
int*  const*,  int*  const*>  > > > > > > > > > > > > > > > > > > > > > > >
>::D& {aka R<27, R<26, R<25, R<24, R<23,  R<22,  R<21,  R<20,  R<19,  R<18,
R<17,  R<16,  R<15,  R<14, R<13, R<12, R<11, R<10, R<9, R<8, R<7, R<6, R<5,
R<4, R<3, R<2, R<1, float, float>, R<1, float, float> >, R<2,  R<1,  float,
float>,  R<1,  float, float> > >, R<3, R<2, R<1, float, float>, R<1, float,
float> >, R<2, R<1, float, float>, R<1, float, float> > > >, R<4,
...
, R<1, float, float>, R<1, float, float> > >, R<3, R<2, R<1, float, float>,
R<1, float, float> >, R<2, R<1, float, float>, R<1, float, float> > > > > >
>  >  >  >  >  >  > > > > > > > > > > > > > > >&}’ from an rvalue of type
‘int’
    template<int    i,class   S,class   T>struct   R{typedef   R<i,typename
R<i-1,S,S>::D,typename  R<i-1,S,S>::D>D;};template<class  S,class  T>struct
R<0,S,T>{typedef                         S                         D;};void
f(){R<27,float,R<24,int*const*,int>::D>::D&E=4;}

                                                        ^
compilation terminated due to -fmax-errors=1.

```

2,139,390,572 bytes / 211 bytes = 10,139,291.8
> 5 votes

# Answer
## Rust, 206 chars, 220+2 errors, score 5090, tunable.

```
macro_rules! e {
    ($e:expr, $($es:expr),+) => {
    compile_error!(stringify!($e, $($es),+));
        e! { $(a + $es),+ }
        e! { $(b + $es),+ }
    };
}
e! {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}

```

And you can actually see it finish compilation, in about 3 minutes for me:

```
error: could not compile `a` due to 1048578 previous errors

```

Like the C `#include __FILE__` example above, it is tunable, but

* if you want to go beyond 2256, you need to set `#![recursion_limit = "9999999"]`
* rustc will OOM long before you can reach that
* longer expressions mean slower execution, so the more errors you want, the slower they will be printed

What I actually wanted to do is implement the Péter's variant of the Ackermann function. But I don't quite grok macros well enough to do that with the unary encoding. Anyone help?
> 5 votes

# Answer
# SmileBASIC, 1/1 = 1

```
A

```

Generates the error `Syntax Error in 0:1`
> 2 votes

---
Tags: code-challenge, kolmogorov-complexity, error-message
---


title: Find Abecedarian Words

text:
# Question
Title: Find Abecedarian Words
An **Abecedarian Word** is a word whose letters are in alphabetical order. Your goal is to write a program that outputs all abecedarian words from a given lexicon.

## Rules:

1. **Standard Loopholes** are forbidden.
2. If a word contains punctuation, diacritical marks, or any characters other than ASCII alphabet characters (`A-Za-z`), remove the entire word.
3. Words that are abecedarian in ASCII are not necessarily abecedarian for this challenge. For example 'Maddox' shouldn't be considered abecedarian.
4. Your program should work with any lexicon, but for testing purposes, this one can be used. (If my code works properly) It contains ~~588~~ 587 abecedarian words that follow the above rules. The lexicon does not count towards your byte total. https://gist.githubusercontent.com/wchargin/8927565/raw/d9783627c731268fb2935a731a618aa8e95cf465/words
5. As per the request of @Olivier Grégoire, here are the Abecedarian words from the lexicon:

```
A Abbott Abby Abe Abel Ac Acrux Aden Ag Ainu Al Alps Am Amos Amy Ann Apr Ar Art As At Au Av B BMW Be Begin Bell Bellow Ben Benny Benz Berry Bert Bess Best Betty Bi Biko Bill Billy Bk Blu Boru Br Btu C Cd Celt Cf Chi Chimu Chou Ci Cl Cm Co Coors Cory Cox Coy Cr Crux Cruz Cs Cu D Dee Deimos Deity Del Dell Dem Denny Depp Di Dino Dior Dis Dix Dot Dow Dr E Eggo Elmo Eloy Emmy Emory Enos Er Es Eu F Finn Finns Flo Flory Fm Fox Fr Fry G Gil Gill Ginny Gino Ginsu Gipsy Guy H Hill Hiss Ho Hz I Ill In Io Ir It Ivy J Jo Joy Jr K Knox Kory Kr L Ln Lot Lott Lou Lr Lt Lu Luz M Mn Mo Moor Moors Mort Moss Mott Mr Mrs Ms Mt N Nov Np O Oort Orr Os Oz P Pt Pu Q R Ru Rx S St Stu T Ty U V W X Y Z a abbess abbey abbot abet abhor abhors ably abort abuzz accent accept access accost ace aces achoo achy act ad add adder adders adds adept ado adopt ads adz aegis aery affix afoot aft aglow ago ah ahoy ail ails aim aims air airs airy all allot allow alloy ally almost alms am ammo amp amps an annoy ant any apt art arty as ass at ax ay b be bee beef beefs beefy been beep beeps beer beers bees beet befit beg begin begins begot begs bell bellow bells belly below belt bent berry best bet bevy bill billow billowy bills billy bin bins biopsy bit blot blow boo boor boors boos boost boot booty bop bops boss bossy bow box boy brr buy buzz by c cell cello cellos cells cent chi chill chills chilly chimp chimps chin chino chinos chins chintz chip chips chit choosy chop choppy chops chow city clop clops clot cloy coo coop coops coos coot cop cops copy cost cosy cot cow cox coy crux cry cs d deem deems deep deeps deer deers deft defy deity dell dells demo demos den dens dent deny dew dewy dill dills dilly dim dims din dins dint dip dips dirt dirty dis diss ditty divvy do door doors dopy dory dos dot dotty dry e eel eels eery effort egg eggs egis ego egos eh ell ells elm elms em empty ems emu envy err errs es ex f fill fills filly film films filmy fin finny fins fir firs first fist fit fix fizz floor floors flop floppy flops floss flow flu flux fly foot fop fops for fort forty fox foxy fry fuzz g ghost gill gills gilt gimpy gin gins gipsy girt gist glop glory gloss glossy glow gnu go goo goop gory got gs guy h hi hill hills hilly hilt him hims hint hip hippy hips his hiss hit ho hoop hoops hoot hop hops horsy hos host hot how i ill ills imp imps in inn inns ins is it ivy j jot joy k kW knot knotty know ks l lo loop loops loopy loot lop lops lorry loss lost lot low lox ls m moo moor moors moos moot mop mops moss mossy most mow ms mu my n no nor nosy not now nu o oops opt or ow ox p pry psst q r rs s sty t tux u v w x y z

```
6. This is , so the shortest code in bytes wins!

# Answer
# 05AB1E, 6 bytes

*Ties a stone arachnid's Vyxal answer for #1.*

```
áʒlD{Q

```

Try it online!

```
áʒlD{Q  # full program
áʒ      # all elements of...
        # implicit input...
á       # containing only letters...
 ʒ      # where...
        # (implicit) current element in filter...
  l     # in lowercase...
     Q  # is equal to...
   D    # (implicit) current element in filter...
  l     # in lowercase...
    {   # sorted
        # (implicit) exit filter
        # implicit output

```
> 5 votes

# Answer
# Jelly, 9 bytes

```
fØẠŒlÞ$ƑƇ

```

Try it online!

-3 bytes thanks to Nick Kennedy

```
fØẠŒlÞ$ƑƇ  Main Link
        Ƈ  Keep elements that are
       Ƒ   Invariant when
.[][.]$    Last two links combined, but [ØẠ][ŒlÞ] is an LCC, so it takes another
f          Filtered to keep
 ØẠ        Alphabetical characters
     Þ     And sorted by
   Œl      Lowercase

```

Basically, "keep elements that are invariant when you filter out non-alphabetical characters and sort alphabetically". Jelly's sort is stable.
> 8 votes

# Answer
# JavaScript (ES6), 68 bytes

```
a=>a.filter(w=>(w=w.toLowerCase())==w.match(/[a-z]/g).sort().join``)

```

Try it online!
> 5 votes

# Answer
# Raku, ~~32~~ 36 bytes

```
*.grep:{!/<-[a..z]>/&[le] .comb}o&lc

```

Try it online!

`*.grep:` filters the input list on the provided predicate function, which is combined from two other functions using the `o` function composition operator. The right function (the first to be applied) is the built-in lowercasing function `lc`. The left, brace-delimited function contains the main logic for this challenge. That function contains two checks, separated by `&`.

`/<-[a..z]>/` is a regex that matches any character other than the lowercase Latin letters "a" through "z". The leading `!` negates that test, matching only words containing no such characters.

`.comb` splits the input string into individual characters. `[le]` reduces that list of characters with `le`, which is the less-than-or-equal operator for strings. That's equivalent to `char₁ le char₂ le ... le charₙ`, which is true if the sequence of characters is lexically monotonically nondecreasing.
> 5 votes

# Answer
# , ~~89~~ 76 bytes

```
function(d,`+`=lapply)d[gsub('[^A-Z]',21,d+toupper)+utf8ToInt+is.unsorted<1]

```

Try it online!

Implemented as function taking a strings vector and filtering non-abecedarians out

Steps:

1. make the string uppercase
2. replace any non letter character with `'21'` (i.e. two descending ASCII char)
3. turn strings into ASCII code points
4. take only the strings where the code points are sorted
> 5 votes

# Answer
# , 34 32 bytes

```
#~(-:-.&Alpha_j_-.~[/:toupper)&>

```

Try it online!

-2 thanks to xash

* `#~` Filter by...
* `(-:]/:toupper)&>` Words that are equal to themselves when sorted by their uppercase values...
* `-.` And then removing...
* `-.&Alpha_j_` All characters not in `[A-Z][a-z]`.
> 4 votes

# Answer
# \>\<\>, 86 bytes

```
10i::}:0(?;a=?v:'['(?v::'`{'@)@(*@:@1+(@}**{10.
+$0.?v0[>100. >~~31. >' ␕'@
  =0l< o^?

```

Try it online! (The  represents the character 0x15.)

## Verification

It takes a few minutes, but it works:

```
C:\Users\conorob\Programming\fish
λ time python fish.py abc.fish <words.txt >out.txt

real    5m18.932s
user    0m0.000s
sys     0m0.031s

C:\Users\conorob\Programming\fish
λ wc out.txt
 587  587 3209 out.txt

```

## Process

First, I like to get a functional program working, even if it is not golfy. 133 bytes:

```
1001.
>i::}:0(?;a=?v:'['(?v    >::'`{'@)@(*@:@1+(@}**{
                    >' '+^
             >~~?v0[ >1001.
                 >l?!^o

```

There's a *lot* of wasted whitespace in this one. So, first, I'll flip line 3 up onto line 1. Then, I'll reorganize the last two lines to occupy more of the trailing spaces, including reversing the last line. 113 bytes:

```
1001.               >' '+v
>i::}:0(?;a=?v:'['(?^    >::'`{'@)@(*@:@1+(@}**{
     0[>1001.>~~?v
      o^!?l      <

```

Now that the last line is more flexible, we can move even more of the last two lines into the leading whitespace. 101 bytes:

```
1001.               >' '+v
>i::}:0(?;a=?v:'['(?^    >::'`{'@)@(*@:@1+(@}**{
 ~~?v0[>1001.>
   l< o^!?

```

I tried reversing lines 3/4, but that ended up longer because the direction changed. But, now that we made more room on line 3, we can reverse the lowercase procedure back onto line 2. However, to do this, we need to make line 3 jump back to its start before it reaches the lowercase procedure. This is easy to do, since we have a spare leading whitespace. 92 bytes:

```
1001.
>i::}:0(?;a=?v:'['(?v    >::'`{'@)@(*@:@1+(@}**{
 ~~?v0[>1001.>02.   >' '+^
   l< o^!?

```

We can shave that wasted space in the loop using a very questionable technique. 91 bytes:

```
1001.
>i::}:0(?;a=?v:'['(?v::'`{'@)@(*@:@1+(@}**{
 ~~?v0[>1001.>02.   >' ␔'@+$1.
   l< o^!?

```

I've replaced the unprintable 0x14 here with its unicode equivalent . This bit works by generating a string `' ␔'`, which gives the values on the stack `[char, 32, 20]`. The original code computed `[char+32]`, then resumed control flow. We want to use a jump instead of arrow directions, and the point we want to jump to is (1, 20) in the codebox. `@` permutes these three values to give us `[20, char, 32]`. We then perform the sum and move it below 20 (`+$`), giving us `[char+32, 20]`. Then, we push 1 and jump to (1, 20) (`1.`).

We can shave 1 more byte, by using the last bit of extra space on line 4 to save on the `!` character. 90 bytes:

```
1001.
>i::}:0(?;a=?v:'['(?v::'`{'@)@(*@:@1+(@}**{
 ~~?v0[>1001.>02.   >' ␔'@+$1.
 =0l< o^?

```

We can reorganize this once again, to eliminate the first line. This, however, is still, 90 bytes:

```
10i::}:0(?;a=?v:'['(?v::'`{'@)@(*@:@1+(@}**{10.
  ~~?v0[>100. >01.   >' ␕'@+$0.
  =0l< o^?

```

However, this gives us a little more whitespace to play with, allowing us to tuck more of our code into the leading whitespace. 86 bytes:

```
10i::}:0(?;a=?v:'['(?v::'`{'@)@(*@:@1+(@}**{10.
+$0.?v0[>100. >~~31. >' ␕'@
  =0l< o^?

```

This has reduced our Unnecessary Space Count™ to 5. At this point, I'm not quite sure where to go. By my reckoning, either the logic (`'`{'@)@(*@:@1+(@}**{`) must be golfed, or the fundamental structure/approach to the problem must be reworked.
> 4 votes

# Answer
# Ruby -p, 29 + 1 = 30 bytes

```
$_=$_[/^#{[*?a..?z]*?*}*\s/i]

```

Try it online!

Uses a regex composed by the letters "a" to "z" joined by "\*" to find the words.
> 4 votes

# Answer
# Java (JDK), 74 bytes

```
l->l.filter(s->{int p=65,r=1;for(var c:s)r=p>(p=c&95)?0:r;return p<r*91;})

```

Try it online!

## Credits
> 4 votes

# Answer
# Vyxal `a`, ~~9~~ ~~8~~ 6 bytes

*-2 thanks to @Aaron Miller*

```
'⇩:sǍ=

```

Try it Online!

```
'⇩:sǍ=   # Full program
         # All inputs (implicit)
'        # where...
 ⇩       # the lowercase version...
     =   # is equal to...
 ⇩:s     # the sorted lowercase version...
    Ǎ    # with only alphabetical characters
         # Implicit output

```
> 4 votes

# Answer
# Zsh `-F`, 28 bytes

```
grep -xi `printf %s* {a..z}`
```

Attempt This Online!

An abecederian word is one which matches the regular expression `^a*b*c*d*e*f*g*h*i*j*k*l*m*n*o*p*q*r*s*t*u*v*w*x*y*z*$` (case insensitively).

This regex is constructed by `printf %s* {a..z}`, and then matched using `grep`. The `-x` implicitly adds the `^` `$`; the `-i` option makes matching case-insensitive.
> 4 votes

# Answer
# BQN, 28 bytes

```
("a{"⊸⍋⊸/≡∧)∘+⟜(32×'a'⊸>)¨⊸/

```

Try it here!

Thanks to @DLosc for 3+4 bytes saved!

## Explanation

BQN doesn't have builtins for string manipulation, so I had to manually recreate lowercasing/filtering non-alphabetical chars.

* `...¨⊸/` Filter lexicon of words...
* `+⟜(32×'a'⊸>)` Lowercase word
* `≡∧` Check if sorted lowercased word matches...
* `"a{"⊸⍋⊸/` Remove `[^a-z]` from unsorted lowercased word
> 4 votes

# Answer
# APL (Dyalog Extended), ~~18~~ 14 bytes

-4 bytes thanks to Adám!

```
⊢⌿⍨(∧≡∩∘⎕A)¨∘⌈

```

Try it online!

`¨∘⌈` for each uppercased word:
`∩∘⎕A` the word intersected with `'AB ... YZ'`, keeping duplicate letters.
the word sorted ascending.
are those strings equal?

`⊢⌿⍨` select words from the input where the result is a `1`.
> 3 votes

# Answer
# Pip `-rl`, 14 bytes

```
$LE"az"JLC_FIg

```

Try it online!

### Explanation

```
             g  List of lines read from stdin (due to -r flag)
           FI   Filter on this function:
        LC_      The string, lowercased
   "az"J         and inserted between "a" and "z"
$LE              is sorted in ascending ASCII order (fold on string-less-than-or-equal)
                Output each element of the result list on a separate line (-l flag)

```
> 3 votes

# Answer
# Python 3.8 (pre-release), 68 bytes

```
lambda x:[y for y in x if y.isalpha()and sorted(f:=y.upper())==[*f]]

```

Try it online!

Yeah! now Python ties with Javascript!

-24 thanks to @makonede

-5 thanks to @hyper-neutrino
> 2 votes

# Answer
### perl, 59

```
say if /^[A-Za-z]+$/ and lc($_) eq join "",sort map {lc} @F

```

Try it online!
> 2 votes

# Answer
# Factor \+ `math.unicode`, 68 bytes

```
[ [ >upper dup [ LETTER? ] ∀ swap [ <= ] monotonic? and ] filter ]

```

Try it online!

* `[ ... ] filter` Take words from the lexicon for which the quotation returns `t`.
* `>upper` Uppercase the word so case doesn't mess with the test for monotonicity later.
* `dup [ LETTER? ] ∀` Does it only consist of (uppercase) letters?
* `swap [ <= ] monotonic? and` And is it also sorted?
> 2 votes

# Answer
# Retina 0.8.2, 61 bytes

```
^
$'¶
T`L`l`^.+
^
$%'¶
O`\G.
%)`^(.+¶)(\1|.+¶.+)

Gi`^[A-Z]+$

```

Try it online! Link includes test cases. Explanation:

```
^
$'¶

```

Duplicate the word.

```
T`L`l`^.+

```

Lowercase the duplicate.

```
^
$%'¶

```

Duplicate the lowercased word.

```
O`\G.

```

Sort the letters of the lowercase duplicate.

```
^(.+¶)(\1|.+¶.+)

```

If the sorted lowercase equals the lowercase word, delete the lowercase and sorted lowercase, otherwise delete everything.

```
%)`

```

Run the above stages on each word separately.

```
Gi`^[A-Z]+$

```

Keep only words containing letters.
> 2 votes

# Answer
# Charcoal, 18 bytes

```
ΦＡ⬤↧ι›№βλ∧μ‹λ↧§ι⊖μ

```

Try it online! Link is to verbose version of code. Explanation:

```
 Ａ                  Input as an array
Φ                   Filtered where
    ι               Current element
   ↧                Lowercased
  ⬤                 All characters satisfy
      №             Count of
        λ           Current character in
       β            Predefined variable lowercase alphabet
     ›              Is greater than
          μ         Current index
         ∧          Logical And
            λ       Current character
           ‹        Is less than
               ι    Current element
              §     Indexed by
                 μ  Current index
                ⊖   Decremented
             ↧      Lowercased

```
> 2 votes

# Answer
# Python 3, 68 bytes

```
lambda x:re.findall(f"^{26*'%c*'}$"%(*range(65,91),),x,10)
import re

```

Try it online!

Python had already a solution (here) but it didn't worked on tests with char like (éèàÈ...).

## How it works :

* `re.findall` returns all the occurences of a given pattern in a given string.
* `f"^{26*'%c*'}$"%(*range(65,91),)` produce the pattern `^A*B*C*...Y*Z*$` which will match any upper abecedarian word.
* `10` (`=2|8`) passed in argument to `re.findall` sets the flag `re.IGNORECASE` (`=2`) to disable caseCheck in the string and the flag `re.MULTILINE` (`=8`) which apply the pattern to each line of the string.
> 2 votes

# Answer
# Perl 5 \+ `-lF -M5.10.0`, 28 bytes

```
/@{[sort map lc,@F]}/xi&&say
```

Try it online!
> 2 votes

# Answer
# Red, 88 bytes

```
func[b][a: charset[#"a"-#"z"]remove-each w b[any[w <> sort copy w not parse w[any a]]]b]

```

Try it online!
> 1 votes

# Answer
# Japt v2.0a0 `-f`, 7 bytes

Not entirely sure I've understood the spec correctly.

```
¶ñv o\l

```

Try it
> 1 votes

# Answer
# Java 8, 127 bytes

```
l->l.filter(s->(s=s.toLowerCase()).matches("[a-z]+")&java.util.Arrays.equals(s.chars().toArray(),s.chars().sorted().toArray()))

```

Full Program (must be run locally)

# Java 16, 124 bytes

```
l->l.filter(s->(s=s.toLowerCase()).matches("[a-z]+")&s.chars().boxed().toList().equals(s.chars().sorted().boxed().toList()))

```

Java 16 added the `Stream#toList` method.
> 1 votes

# Answer
# Julia, 55 bytes

```
x->x[@.all(isletter,x)isascii(x)issorted(lowercase(x))]

```

Try it online!
> 1 votes

# Answer
# C (gcc), 164 bytes

```
#include<stdio.h>
a;main(){for(char*s,w[99];!feof(stdin);!a&&printf("%s\n",w),a=0)for(scanf("%s",s=w);*s;a|=tolower(*s++)>tolower(*s)&&isalpha(*s))a|=!isalpha(*s);}

```

Try it online!
> 1 votes

# Answer
# Wolfram Language (Mathematica), 67 bytes

Assumes the Notebook environment. Otherwise an extra `Print` needs to be added around the last part of the code (as is done in the TIO link).

```
f=(a=Characters@ToLowerCase@#;a==AlphabeticSort@a)&/@#&;l~Pick~f[l]

```

This code assumes a lexicon has been defined previously and saved in the variable `l`. It maps the function `f` over each word in the lexicon and keeps only words for which `f` returns `True`. `f` in turn takes in a word, lowercases it, and then puts the letters in the string individually into a list. It returns true if the list does not change when `AlphabeticSort` is run on it. `AlphabeticSort` takes in a list of strings and sorts them in alphabetic order into a new list. The `ToLowerCase` function call is needed because `AlphabeticSort` sorts lowercase letters before their uppercase version, and so `f` fails to find "Oort" because it gets sorted into {"o","O","r","t"}, which doesn't match the original character order.

Try it online!
> 1 votes

# Answer
# Burlesque, 9 bytes

```
)zz:aa:so

```

Try it online!

```
)zz # Map to lower case
:aa # Filter all alpha
:so # Filter sorted

```
> 1 votes

# Answer
# brev 166 bytes!

```
(import srfi-13(chicken sort))(for-each print(filter(o(fn(equal? x(strse x "^[a-z]+$"(as-list(fn(sort x(bi-each < char->integer))))#f)))string-downcase)(read-lines)))

```
> 1 votes

---
Tags: code-golf, alphabet
---