42
3
The printable ASCII characters (hex codes 20 to 7E) in order are:
!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~
(Note that space is in there.)
This string clearly contains all the printable ASCII characters at least once in increasing order when read from left to to right, but not in decreasing order.
The string
REVERSED:~}|{zyxwvutsrqponmlkjihgfedcba`_^]\[ZYXWVUTSRQPONMLKJIHGFEDCBA@?>=<;:9876543210/.-,+*)('&%$#"! NORMAL: !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~
contains all the printable ASCII characters at least once both in increasing and decreasing order. In other words, when the characters are valued with their numeric code, the longest increasing and longest decreasing subsequences have length 95 (the number of printable ASCII characters).
Challenge
Choose a contiguous subset of N printable ASCII characters, such as LMNOP
(N = 5). Write a program using only those N characters whose output contains all 95 ASCII characters in increasing and decreasing order like the example above.
The winner is the submission with the lowest N. In case of ties the shortest code in bytes wins.
Notes
- A contiguous subset means a set of the printable ASCIIs that all appear in an unbroken line, such as
LMNOP
or89:;<=>
. - Your contiguous subset may "loop around" from
~
to space, but this incurs a +3 penalty on N. So{|}~
has N = 4, but{|}~ !
has N = 6 + 3 = 9. - Your program may only contain the N printable ASCII characters from the contiguous subset you've selected. They do not all have to appear and may appear multiple times in any order. (All non-printable ASCII and all non-ASCII is not allowed. This means tabs and newlines are not allowed.)
- Your output may only contain printable ASCII characters and must be less than 10000 characters long.
- Your output's longest increasing and decreasing subsequences must both have length 95 (as explained above).
- Output to stdout. There is no input.
- N is a positive integer less than 96.
45At last, a challenge built for Brainfuck! – Level River St – 2014-08-05T22:26:51.043
{|}~ !
is 6 + 3 = 9. – Timtech – 2014-08-05T22:51:48.020I think that the only thing that'll beat the current entries is something that will accept 0s and 1s as input; that'd give you N = 2 – Derek Tomes – 2014-08-06T01:47:42.030
1Given the kinds of answers this is attracting (which are clearly the optimal way), it might be interesting for the score to be some combination of program shortness and number of characters used. Perhaps minimizing n*m where n is the size of the subset of ascii, and m is the length of the program? – J.P. – 2014-08-06T10:52:38.970
1@J.P. "The winner is the submission with the lowest N. In case of ties the shortest code in bytes wins." General consensus is that it is bad form to change the rules at a late stage. The winning answer will be the shortest program in Unary (which is basically the shortest program in Brainfuck, just coded differently.) – Level River St – 2014-08-06T12:36:32.677
1I would suggest, though, that those posting in Unary might like to put an approximation of their code length in scientific notation, rather than making us squint to count the digits. – Level River St – 2014-08-06T12:40:11.960
@J.P. Yeah, it's too late to change the scoring method now. – Calvin's Hobbies – 2014-08-06T12:42:04.927
@steveverrill - Done. – Comintern – 2014-08-07T01:47:48.970
1Welcome to CodeGolf, where 90% of all questions are hijacked. ;) – TwoThe – 2014-08-07T10:29:54.800
If no non-printable ASCII is allowed, that means no newlines, which pretty much excludes any language that requires newlines, right? – Gabe – 2014-08-07T20:04:04.400
@Gabe That's right. – Calvin's Hobbies – 2014-08-07T20:08:01.633