36
\$\begingroup\$

There are 97 ASCII characters that people encounter on a regular basis. They fall into four categories:

  1. Letters (52 total)

    ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
    
  2. Numbers or Digits (10 total)

    0123456789
    
  3. Symbols & Punctuation (32 total)

    !"#$%&'()*+,-./:;<=>?@[\]^_`{|}~
    
  4. Whitespace (3 total)

    Space , tab \t, and newline \n. (We'll treat newline variants like \r\n as one character.)

For conciseness, we'll call these categories L, N, S, and W respectively.

Choose any of the 24 permutations of the letters LNSW you desire and repeat it indefinitely to form a programming template for yourself.

For example, you might choose the permutation NLWS, so your programming template would be:

NLWSNLWSNLWSNLWSNLWS...

You need to write a program or function based on this template, where:

  1. Every L is replaced with any letter (ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz).

  2. Every N is replaced with any number (0123456789).

  3. Every S is replaced with any symbol (!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~).

  4. Every W is replaced with any whitespace character ( \t\n).

Basically, your code must follow the pattern

<letter><number><symbol><whitespace><letter><number><symbol><whitespace>...

as the question title suggests, except you may choose a different ordering of the four character categories, if desired.

Note that:

  • Replacements for a category can be different characters. e.g. 9a ^8B\t~7c\n] validly conforms to the template NLWSNLWSNLWS (\t and \n would be their literal chars).

  • There are no code length restrictions. e.g. 1A +2B - and 1A +2B and 1A and 1 all conform to the template NLWSNLWSNLWS....

What your template-conformed code must do is take in one unextended ASCII character and output a number from 0 to 4 based on what category it is a member of in the categorization above. That is, output 1 if the input is a letter, 2 if a number, 3 if a symbol, and 4 if whitespace. Output 0 if the input is none of these (a control character).

For input, you may alternatively take in a number 0 to 127 inclusive that represents the code of the input ASCII character.

The input (as char code) and output pairs your code must have are precisely as follows:

in out
0 0
1 0
2 0
3 0
4 0
5 0
6 0
7 0
8 0
9 4
10 4
11 0 or 4
12 0 or 4
13 0 or 4
14 0
15 0
16 0
17 0
18 0
19 0
20 0
21 0
22 0
23 0
24 0
25 0
26 0
27 0
28 0
29 0
30 0
31 0
32 4
33 3
34 3
35 3
36 3
37 3
38 3
39 3
40 3
41 3
42 3
43 3
44 3
45 3
46 3
47 3
48 2
49 2
50 2
51 2
52 2
53 2
54 2
55 2
56 2
57 2
58 3
59 3
60 3
61 3
62 3
63 3
64 3
65 1
66 1
67 1
68 1
69 1
70 1
71 1
72 1
73 1
74 1
75 1
76 1
77 1
78 1
79 1
80 1
81 1
82 1
83 1
84 1
85 1
86 1
87 1
88 1
89 1
90 1
91 3
92 3
93 3
94 3
95 3
96 3
97 1
98 1
99 1
100 1
101 1
102 1
103 1
104 1
105 1
106 1
107 1
108 1
109 1
110 1
111 1
112 1
113 1
114 1
115 1
116 1
117 1
118 1
119 1
120 1
121 1
122 1
123 3
124 3
125 3
126 3
127 0

Inputs 11, 12, and 13 correspond to characters that are sometimes considered whitespace, thus their outputs may be 0 or 4 as you desire.

The shortest code in bytes wins.

\$\endgroup\$
  • 5
    \$\begingroup\$ Cookies to the first answer in a 2d language. \$\endgroup\$ – Calvin's Hobbies Feb 26 '17 at 12:05
  • 2
    \$\begingroup\$ So just use BF and use letters SSSS \$\endgroup\$ – Christopher Feb 26 '17 at 12:33
  • 2
    \$\begingroup\$ This basically excluded all conventional programming languages 🙄 Also, what to do with languages that uses its own code page e.g. Jelly? \$\endgroup\$ – kennytm Feb 26 '17 at 14:51
  • 1
    \$\begingroup\$ Other characters are not allowed. \$\endgroup\$ – Calvin's Hobbies Feb 27 '17 at 5:25
  • 2
    \$\begingroup\$ Unary will win! \$\endgroup\$ – Christopher Feb 27 '17 at 23:18
38
+500
\$\begingroup\$

Haskell 300 bytes

This code should have no trailing newline. The function m1 takes the input as a Char and returns the answer as a Char.

f1 (l1 :n1 :p1 :y1 :l2 :n2 :p2 :y2 :r3 )x1 |y1 >p1 =b1 (x1 )y2 (f1 (r3 )x1 )y1 (n1 )n2 |p2 <p1 =b1 (x1 )y1 (n1 )p2 (f1 (p2 :y2 :r3 )x1 )l2 |p2 >p1 =b1 (x1 )p1 (l2 )l1 (n2 )n1
;b1 (x1 )s1 (r1 )b1 (r2 )r3 |x1 <s1 =r1 |x1 >b1 =r2 |s1 <b1 =r3
;m1 =f1 "d0 \t4 \r0 ~d3 {d1 `d3 [d1 @d3 :d2 /d3 !d4 \n0 ?d0 "

I couldn't resist a challenge that someone claimed was impossible for "conventional" languages.

You may dispute whether Haskell counts, but the majority of keywords and identifiers are multiple characters and cannot be used. However, top level function definitions, lists, string literals, strict comparisons, pattern matching and branching with guards work, as long as letters come just before digits, and if symbols also come just before letters we have escape characters like \t and \r. Unfortunately the permutations that work for general programming don't allow numeric literals, so I couldn't get numbers in any useful way.

How it works:

  • The intervals of character classes are encoded in the string on the last line, with boundary characters at most of the symbol places and the results in most of the digit places, although some at the ends are padding.
  • The main function is m1.
  • x1 is the character being analyzed.
  • The f1 function breaks up the string with list pattern matching, and has three branches: for when the boundaries are symbols larger than space, for when the boundaries are escaped control characters smaller than space, and for handling the final comparison to space itself. The names of the list pieces are mnemonic for the first branch: Letter, Number, sPace, sYmbol, Remainder.
  • The b1 function handles branching for two boundary characters s1 < b1 at a time.

Try it online

\$\endgroup\$
  • 1
    \$\begingroup\$ Welcome to the site! My guess is this will be shorter than most non-conventional languages that can actually achieve the required result. \$\endgroup\$ – Jonathan Allan Feb 28 '17 at 7:26
  • \$\begingroup\$ Gret answer! I tried using Haskell but gave up after a short while ... \$\endgroup\$ – Laikoni Feb 28 '17 at 7:35
14
\$\begingroup\$

Retina, 113 bytes

Letter, Number, Space, Symbol, Repeat

T1 `a0 @a0 `b1	:D0
+T1 `d9 `a2
+T1 `a9	\n9 `a4
+T1 `l9 @L9 `a1
+T1 `d9 @p9 `d3
\b4
$n3
\b3
$n2
\b2
$n1
\b1
$n0
\n

Try it online!

Test it on itself!

Retina seems like a nice tool for this job: we can use all types of characters flexibly in stage configuration, and we have some predefined character classes that can be useful.

I think this problem could be solved with either Replacement stages or Transliteration stages; I've chosen the Transliterations because they are more flexible and they have the most useful character classes. Regarding the pattern of the source, I was forced to put symbols right before letters in order to use \n for newlines (I actually had a shorter solution using the more practical ¶ for newlines, but non-ascii characters are banned).

Explanation

The first stages are transliterations. We use + and 1 as options to keep the pattern going but they won't affect the result of the stage. The syntax is T`from`to to map each character of from to the character in the same position in to. If to is shorter than from, its final character is repeated as much as needed. If from has repeated characters, only the first occurrence of each one is considered. Some letters correspond to character classes, e.g. d is equivalent to 0123456789.

T1 `a0 @a0 `b   :D0

With this we map some characters to other characters of the same class in order to "make some room" for following transliterations. (a->b,0->1,space->tab,@->;). The final :D0 is just a smiley :D0

+T1 `d9 `a2

We start with digits, d is the character class 0-9, here we're transforming 0->a,1-9->2,space->2: the transliterations for 0 and space are wrong, but those characters have been eliminated by the previous transliteration.

+T1 `a9 \n9 `a4

Whitespace, transform a->a,(9,tab,\n,space)->4. 9 was already removed in the previous stage.

+T1 `l9 @L9 `a1

Letters, here we use two different character classes (for lack of a more complete one): l for lowercase letters and L for uppercase letters. They all get mapped to 1, along with some other characters which have been dealt with in the previous stages

+T1 `d9 @p9 `d3

Symbols. Since every other class has been turned into a digit, here we map all digits to themselves with d->d, and then all printable characters to 3 with p->3. Digits are also among printable characters, but the first transliteration wins.

Now we need to assign 0 to control characters, but I've found no valid way to explicitly address that class. Instead, we'll convert each digit to unary: control characters are not digits and so they are considered as the empty string, which equals 0 in unary. Unfortunately, the unary conversion command in retina is $*, which are two symbols near each other, so we'll instead convert "manually" using substitutions.

\b4
$n3
\b3
$n2
\b2
$n1
\b1
$n0

Our unary digit is $n, which is a replacement pattern for newlines. \b matches a "boundary", where an alphanumeric word starts or ends: in our case this will always match before any number. We are basically replacing each number n with a newline plus n-1.

\n

In the end, we count the number of newlines and get the desired result.

\$\endgroup\$
11
\$\begingroup\$

Cardinal 2240 2224 bytes

Template used LSNW

a%1
a:1 a.0 a.0 a.0 a.0 a.0 a.0 a.0 a.0 a.0 a.0 a.0 a.0 a.0 a.0 a.0 a.0 a.0 a.0 a>0 a>0 a>0 a>0 a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-1 J^1 a-1 J^1 a-1 J^1 a-1 J^1 a-1 J^1 a>1 a-1 J^1 a-1 J^1 a-1 J^1 a-1 J^0 a.0

The code has a trailing newline.

How it works:

This code has a lot of characters that aren't used.
% releases a pointer in all directions. 3 of them just hit the end of a line and die.
The last pointer takes in an input at the :
This input is then compared to each value from 0 to 127.

Prints:
0 for 0-8
4 for 9-12
0 for 13-31
4 for 32
3 for 33-47
2 for 48-57
3 for 58-64
1 for 65-90
3 for 91-96
1 for 97-122
3 for 123-126
0 for 127

Operations used:
J = Skip next operation if non-zero
^ = Change direction to up
> = Change direction to left
- = Decrement
+ = Increment
: = Take input
% = Create pointers at start of program
x = Remove pointer
0 = Set active value of pointer to 0

Try it online

\$\endgroup\$
7
\$\begingroup\$

Perl 5, 293 bytes

291 bytes code + 2 for -0p.

I have been advised the command-line flags are free, but I've added them here for visibility, as the TIO link doesn't include -0, for easier testing.

y 0-a 1"a 1#a 1$a 1%a 1&a 1'a 1(a 1)a 1*a 1+a 1,a 1.a 1/a 1_a 1{a 1|a 1}a 1~a 0!a 1!a 1!a 1!a 1!a 1!a 1!a 1!a 1!a 1!a 1!a 1!a 1!a 1!a 1!a 1!a 1!a 1!a 1!a 0;s 0\s
0\t
0;s 0\d
0\r
0;s 0\w
0\n
0;y 1!a 9-a 1_a 0-Z 1;s 0\w
0\u 3\u 0;s 1\S
1\u 0\u 1;s 0\t
0\u 4\u 0;s 0\r
0\u 2\u 0;s 0\n
0\u 1\u 0

Try it online!

This is a particularly tricky challenge to solve in almost any language, so I'm pretty happy I was able to (finally, lots of tinkering on and off for quite some time) get this working in Perl. Hopefully the additional whitespace before and after the number isn't an issue.

Selecting the sequence order was particularly tricky, but forunately s/// and y/// can accept any other character as a delimiter so it was possible to use letter, space, number, symbol, which allows for s 0...0...0; and y 0...0...0;.

The first thing required for the appraoch was to replace _ with ! so that \w would only match [0-9a-zA-Z], then replace all whitespace (\s) with \t, all digits with \r and all remaining word characters (\w) with \n for easy matching later on. Then, using the y/// operator, all remaining symbols are converted to word characters ! to _ and all other chars (between 9 and a) are shifted down 9 places, turning them into letters or numbers. These are then replaced via \w with 3 and the other, previously made substitutions are replaced with their numbered values.

\$\endgroup\$
1
\$\begingroup\$

Whitespace, 1332 bytes

Y0! Y0! Y0! Y0!
Y0! Y0!
Y0! Y0! Y0!
Y0! Y0! Y0! Y0! Y0! Y0! Y0!
Y0! Y0! Y0!
Y0! Y0! Y0!
Y0! Y0! Y0!
Y0! Y0! Y0!
Y0! Y0! Y0!
Y0! Y0! Y0!
Y0! Y0! Y0!
Y0! Y0! Y0!
Y0! Y0! Y0!
Y0! Y0! Y0! Y0! Y0! Y0! Y0! Y0! Y0!
Y0! Y0! Y0! Y0! Y0!
Y0! Y0! Y0! Y0!
Y0! Y0! Y0! Y0! Y0! Y0! Y0! Y0!
Y0! Y0! Y0! Y0! Y0!
Y0! Y0! Y0! Y0!
Y0! Y0! Y0! Y0! Y0! Y0! Y0! Y0! Y0! Y0!
Y0! Y0! Y0! Y0! Y0! Y0!
Y0! Y0!
Y0! Y0! Y0! Y0!
Y0!
Y0! Y0! Y0! Y0! Y0!
Y0! Y0! Y0! Y0! Y0! Y0! Y0! Y0! Y0! Y0!
Y0! Y0! Y0! Y0! Y0!
Y0! Y0! Y0!
Y0! Y0! Y0! Y0! Y0! Y0! Y0! Y0! Y0! Y0!
Y0! Y0! Y0! Y0! Y0!
Y0! Y0! Y0! Y0! Y0!
Y0! Y0! Y0! Y0! Y0! Y0! Y0! Y0! Y0! Y0! Y0!
Y0! Y0! Y0! Y0! Y0!
Y0! Y0! Y0!
Y0! Y0! Y0! Y0! Y0! Y0! Y0! Y0! Y0! Y0! Y0!
Y0! Y0! Y0! Y0! Y0!
Y0! Y0! Y0! Y0!
Y0! Y0! Y0! Y0! Y0! Y0! Y0! Y0! Y0! Y0! Y0!
Y0! Y0! Y0! Y0! Y0!
Y0! Y0! Y0!
Y0! Y0! Y0! Y0! Y0! Y0! Y0! Y0! Y0! Y0! Y0!
Y0! Y0! Y0! Y0! Y0!
Y0! Y0! Y0! Y0!
Y0! Y0! Y0! Y0! Y0! Y0! Y0! Y0! Y0! Y0! Y0!
Y0! Y0! Y0! Y0! Y0!
Y0! Y0! Y0!
Y0!
Y0! Y0!
Y0! Y0! Y0!
Y0!
Y0! Y0! Y0! Y0!
Y0! Y0! Y0! Y0! Y0! Y0! Y0!
Y0! Y0!
Y0! Y0! Y0!
Y0!
Y0!
Y0!
Y0! Y0! Y0!
Y0! Y0! Y0! Y0! Y0! Y0!
Y0! Y0!
Y0! Y0! Y0!
Y0!
Y0!
Y0!
Y0! Y0! Y0! Y0! Y0!
Y0! Y0! Y0! Y0! Y0! Y0!
Y0! Y0!
Y0! Y0! Y0!
Y0!
Y0!
Y0!
Y0! Y0! Y0! Y0!
Y0! Y0! Y0! Y0! Y0!
Y0! Y0!
Y0! Y0! Y0!
Y0!
Y0!
Y0!
Y0! Y0! Y0! Y0! Y0!
Y0! Y0! Y0! Y0!
Y0! Y0!
Y0! Y0! 

Order is 1234/LNSW (letter, digit, symbol, whitespace).

Try it online (input as integer representing the unicode of a character).

Explanation:

Whitespace is a stack-based language where every character except for spaces, tabs and new-lines are ignored. Here is the same program without the YO! (333 bytes):

[S S S N
_Push_0][S N
S _Duplicate_0][T   N
T   T   _Read_STDIN_as_integer][T   T   T   _Retrieve][S N
S _Duplicate_input(9)][S N
S _Duplicate_input(10][S N
S _Duplicate_input(32)][S N
S _Duplicate_input(33-47)][S N
S _Duplicate_input(48-57)][S N
S _Duplicate_input(58-64)][S N
S _Duplicate_input(65-90)][S N
S _Duplicate_input(91-96)][S N
S _Duplicate_input(97-122)][S N
S _Duplicate_input(123-126)][S S S T    S S T   N
_Push_9][T  S S T   _Subtract][N
T   S S N
_If_0_Jump_to_Label_WHITESPACE][S S S T S T S N
_Push_10][T S S T   _Subtract][N
T   S S N
_If_0_Jump_to_Label_WHITESPACE][S S S T S S S S S N
_Push_32][T S S T   _Subtract][S N
S _Duplicate][N
T   S S N
_If_0_Jump_to_Label_WHITESPACE][N
T   T   S T N
_If_negative_Jump_to_Label_NONE][S S S T    T   S S S S N
_Push_48][T S S T   _Subtract][N
T   T   N
_If_negative_Jump_to_Label_SYMBOL][S S S T  T   T   S T S N
_Push_58][T S S T   _Subtract][N
T   T   S S N
_If_negative_Jump_to_Label_DIGIT][S S S T   S S S S S T N
_Push_65][T S S T   _Subtract][N
T   T   N
_If_negative_Jump_to_Label_SYMBOL][S S S T  S T T   S T T   N
_Push_91][T S S T   _Subtract][N
T   T   T   N
_If_negative_Jump_to_Label_LETTER][S S S T  T   S S S S T   N
_Push_97][T S S T   _Subtract][N
T   T   N
_If_negative_Jump_to_Label_SYMBOL][S S S T  T   T   T   S T T   N
_Push_123][T    S S T   _Subtract][N
T   T   T   N
_If_negative_Jump_to_Label_LETTER][S S S T  T   T   T   T   T   T   N
_Push_127][T    S S T   _Subtract][N
T   T   N
_If_negative_Jump_to_Label_SYMBOL][N
S N
S T N
_Jump_to_Label_NONE][N
S S S N
_Create_Label_WHITESPACE][S S S T   S S N
_Push_4][T  N
S T _Print_as_integer][N
N
N
_Exit][N
S S N
_Create_Label_SYMBOL][S S S T   T   N
_Push_3][T  N
S T _Print_as_integer][N
N
N
_Exit][N
S S S S N
_Create_Label_DIGIT][S S S T    S N
_Push_2][T  N
S T _Print_as_integer][N
N
N
_Exit][N
S S T   N
_Create_Label_LETTER][S S S T   N
_Push_1][T  N
S T _Print_as_integer][N
N
N
_Exit][N
S S S T N
_Create_Label_NONE][S S S N
_Push_0][T  N
S T _Print_as_integer]

Letters S (space), T (tab), and N (new-line) added as highlighting only.
[..._some_action] added as explanation only.

Try it online.

Program in pseudo-code:

If the input is 9, 10 or 32: call function WHITESPACE()
Else-if the input is below 32: call function NONE()
Else-if the input is below 48: call function SYMBOL()
Else-if the input is below 58: call function DIGIT()
Else-if the input is below 65: call function SYMBOL()
Else-if the input is below 91: call function LETTER()
Else-if the input is below 97: call function SYMBOL()
Else-if the input is below 123: call function LETTER()
Else-if the input is below 127: call function SYMBOL()
Else (the input is 127 or higher): call function NONE()

WHITESPACE():
  Print 4
  Exit program
SYMBOL():
  Print 3
  Exit program
DIGIT():
  Print 2
  Exit program
LETTER():
  Print 1
  Exit program
NONE():
  Print 0
  (Implicit exit with error: Exit not defined)
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.