The Symbols vs. The Letters

17

6

The Symbols vs. The Letters

The ASCII characters have been divided once again! Your sets are The Letters and The Symbols.

The Letters

ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz

The Symbols

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

The task is to write two programs:

  1. Print each of The Letters exactly once without using any of them in your program.

  2. Print each of The Symbols exactly once without using any of them in your program.

Rules

  • Whitespace may appear in your program or the output.
  • Non-ASCII characters are not allowed.
  • Output goes to standard out or to a file as either the contents or name of the file.
  • No input.
  • Output must only contain ASCII characters from one set or the other.
  • The programs can be written in different languages or the same language with one exception:
  • The Whitespace language may only be used for one of the programs.
  • Standard loopholes apply.

Scoring

# of characters in program 1 +# of characters in program 2 = Score

Lowest score wins!

Note:

To encourage more submissions, you may still post an answer with a solution for only one of the programs. You won't be able to win, but you would still be able to show off something cool.

Thanks to Calvin's Hobbies for inspiring the idea with his previous question.

hmatt1

Posted 2014-08-22T15:59:12.967

Reputation: 3 356

4This isn't possible in most languages... For example in Haskell = is inescapable – proud haskeller – 2014-08-22T16:10:51.320

1@proudhaskeller part of the challenge is picking a language where it is possible. – hmatt1 – 2014-08-22T16:54:58.417

(I realise I should've thought of this while the question was in the sandbox, but) given the "whitespace may appear in the output" rule, does this mean the order of the (letters|symbols) doesn't matter? – FireFly – 2014-08-22T17:04:05.950

@FireFly any order is fine. – hmatt1 – 2014-08-22T17:08:01.833

Is it allowed to have control characters (codepoints 0 to 31 and 127) in your program? – FUZxxl – 2014-08-22T20:13:38.247

I'm waiting for the Whitespace answer. – Ray – 2014-08-22T20:14:03.333

@FUZxxl yeah, you can use ASCII characters 0-31 and 127 in either program. – hmatt1 – 2014-08-22T20:19:39.653

Answers

7

Total: 53 characters

Total in a single language: 230 characters, Pyth

Part 1: Golfscript, 15

91,65>123,97>++

Outputs:

ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz

Explanation:

91,           Make the list, [0 1 .. 90]
65>           Take elements after the 65th, [65 66 .. 90]
123,97>       Same, but [97 98 .. 122]
+             Add the list above to the newline character that is automatically pushed to 
              the stack. List + str coerces to string by ascii encoding.
+             Same, for the other list.

Part 2: Pyth, 38

JhCeGLjkmCdbsrCdCPhGsrhCPeGChGsrJhhhhJ

Outputs:

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

Explanation:

G = "abcdefghijklmnopqrstuvwxyz"   Implicit.
k = ""                             Implicit.
d = " "                            Implicit.
JhCeG                              J = 1 + chr(end(G))          # J = 123
L                                  def d(b): return
 jk                                                k.join(
   m                                                      map(lambda d:
    Cd                                                                 chr(d),
    b                                                                  b))
s                                  print(s(                    #print is implicit.
 rCd                               range(chr(d),                 # chr(d) = 32
 CPhG                                    chr(upper(head(G))))    # chr("A") = 65
srhCPeGChG                         print(s(range(1+chr(upper(end(G))),chr(head(G)))
srJhhhhJ                           print(s(range(J, 1+1+1+1+J)))

Bonus solution:

Part 1: Pyth, 192

%*$"%\143"$52(65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122

Explanation:

$"%\143"$ => "%c". $ switches to and from Python parsing style, and in Python string parsing, \143 is the octal escape sequence for c. This answer is thus equivalent to the following Python-style code:

("%c" * 52) % (65, 66, 67, ...)

Of course, this doesn't work in Python, because printing in Python uses print, but printing in Pyth is implicit, so it works.


Pyth solutions do not use any of the features added since the question was asked.

isaacg

Posted 2014-08-22T15:59:12.967

Reputation: 39 268

Where do I learn Pyth? From the examples? – Soham Chowdhury – 2014-09-13T05:46:50.633

@SohamChowdhury The examples are a good place to start. Reading the docs is probably the next step - doc.txt in the primary directory. The final step is to start playing with it yourself, using the -d (debug) flag. The software is very new and so nothing better exists. As far as I know, only 3 people have ever used it, and I'm the only one to have used it regularly. Good luck, enjoy. – isaacg – 2014-09-13T06:12:31.253

23

Python (Symbols, 87 82)

from string import punctuation
from string import digits
print digits
print punctuation

I just love Python's string module...

Edit:

from string import punctuation as p
from string import digits as d
print d
print p

Output:

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

FALSE (Letters, 21) DUP (Letters, 20):

FALSE solution:

65[$91\>][$,$32+,1+]#

DUP sollution (1 char shorter)

65[$91<][$,$32+,1+]#

Output (for both):

AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz

Interpreter for FALSE.


Total: 102

ɐɔıʇǝɥʇuʎs

Posted 2014-08-22T15:59:12.967

Reputation: 4 449

1wow nice! I've seen people say this couldn't be done in python, well done. – hmatt1 – 2014-08-22T20:13:11.533

from string import* works equally well and cuts down the byte count. – aglasser – 2014-08-22T20:41:37.433

5@aglasser ... but using * is forbidden in this context... – ɐɔıʇǝɥʇuʎs – 2014-08-22T20:43:12.037

4You're right, can't believe I forgot * was a symbol haha. That explains why you didn't do from string import punctuation, digits either. Nice solution that follows the rules. Sorry about my mistake! – aglasser – 2014-08-22T20:45:41.923

13

GolfScript (14 chars) + Deadfish x (116 chars) = 130 chars

91,65>{.32+}%+

and

xxcxxcdddKxKxKxKxKxKxKxKxKxKxKxKxKxKxKxKxKxKxKxKxKxKxKxKxKxKxKxKxKxKxKxKDxxxccxxxxxxxxxxKxKxKxKxKxKDxxxcxxcxxKxKxKxK

Peter Taylor

Posted 2014-08-22T15:59:12.967

Reputation: 41 901

2+1 for being the first of four posts so far actually answer both parts. – Geobits – 2014-08-22T18:51:04.827

10

Parts 1 and 2 in Ruby 2, 56 + 484 = 540

Part 1:

__=->_{(91..96)===_||$><<(''<<_);_>121||__[-~_]}
__[65]

For more on this style of Ruby, check out narfnme.

Part 2 (this bit is Ruby 2.0+ only, works perfectly with ruby-2.1.0 but may give warnings in earlier versions):

class Fixnum
def c
String def a
end
end
def b
String def A
end
end
def x
String def z
end
end
def y
String def Z
end
end
def inspect
case chr
when c
when b
when y
p succ
else
print chr
p succ
end
p
rescue
p
end
end
def x
String def z
end
end
def y
String def Z
end
end
class String
def inspect
p size
p
end
end
p String p
class String
def inspect
p ord
p
end
end
p y
class Fixnum
def inspect
case chr
when x
p succ
else
send chr
print chr
p
end
p
rescue
print chr
p succ
p
end
end
p x

That one was hard. Calling built-in Fixnum methods like chr and succ requires opening up the Fixnum class and redefining inspect, since I can trigger a call to x.inspect with p x. I need inspect to return nil so that p will only print a newline, any string will be framed in double quotes. But as a side effect, it loops. I can terminate the first loop and second loops using a string comparison to see when I've reached a letter range, but since I can't write a string literal I need to get one by calling String() on the symbol returned (in Ruby 2) by the def keyword. Since that's a multiline syntax and I can only do string comparison via case, which can't take multiline expressions, I need to wrap the literal in a method (since I obviously can't do assignment). The last loop is harder to terminate. I need it to stop at ~. Luckily, of the ascii characters in that range, ~ is the only one that can be called on a Fixnum with no arguments without raising an error, so I can use send chr to detect when I'm at the end and stop looping.

Not the best score in this thread, but thus far the only one that uses the same language for both parts. Yay Ruby.

histocrat

Posted 2014-08-22T15:59:12.967

Reputation: 20 600

1+1'ed even before your 2nd answer, cuz' knew that it will come. Respect for pushing the flexibility of Ruby to the limits. – Vectorized – 2014-08-23T16:18:22.207

+1 for the first/only answer that provides both programs in the same language. So far this is the clear winner IMO. I haven't installed Ruby 2, but trust this works. – Digital Trauma – 2014-08-23T19:06:17.103

8

Part 2 in Applescript, 654

wait... where's the "tips for golfing in Applescript" page?

global a
global b
global c
global s
on f at n
set end of b to a
end
on g at n
f at a
f at a
end
on h at n
g at a
g at a
end
on i at n
h at a
h at a
end
on j at n
repeat with t in system info
f at a
end
end
on m at n
set end of b to a
set c to count of b
set end of s to ASCII character c
end
on n at n
m at a
m at a
m at a
end
on o at n
repeat with t in system info
m at a
end
end
set a to random number
set b to a as list
j at a
j at a
set c to count of b
set s to ASCII character c
set s to s as list
o at a
n at a
n at a
n at a
n at a
n at a
j at a
i at a
g at a
f at a
n at a
m at a
m at a
j at a
i at a
g at a
n at a
m at a
display dialog s as text

Output:

enter image description here

Digital Trauma

Posted 2014-08-22T15:59:12.967

Reputation: 64 644

1I knew there would be an Applescript sollution. Here, have a +1. – ɐɔıʇǝɥʇuʎs – 2014-08-23T08:53:45.920

4

CJam + AlphaBeta, 62 bytes


Letters, CJam, 12 bytes

"[{"{,-26>}/

Try it online!

Output

ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz

How it works

"[{"{     }/   For each of the characters "[" and "{",
     ,         push an array of all ASCII characters before it
      -26>     and discard all but the last 26 characters.

Symbols, AlphaBeta, 50 bytes

ZaaAccctFUaCLOrEbbCLbCLbCLbCLdddACLbCLbCLgDLgDLgDL

Try it online!

The official C++ interpreter has a bug that makes loops impossible and I can't figure out how to use the Lua interpreter. I fixed that bug. You can verify that it works as intended by running the example programs from the EsoLang page.

Output

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

How it works

Z      Switch register 4 to the position register.
aa     Set registers 1 to 2.
A      Copy the value from register 1 to register 2.
ccc    Add 30 to register 1 (result: 31).
tF     Set register 2 to the product of registers 1 and 2 (result: 64).
U      Add 10 to the position register (result: 10, i.e., the position of the next byte).
aCL    Add 1 to register 1 and print the corresponding ASCII character.
O      If register 1 != register 2, go to the position in the position register.
rEb    Set register 1 to the sum of registers 1 and 2 minus 1 (result: 127).
bCL    Subtract 1 from register 1 and print the corresponding ASCII character.
bCL    Subtract 1 from register 1 and print the corresponding ASCII character.
bCL    Subtract 1 from register 1 and print the corresponding ASCII character.
bCL    Subtract 1 from register 1 and print the corresponding ASCII character.
ddd    Subtract 30 from register 1 (result: 93).
A      Copy the value from register 1 to register 2.
CL     Print the ASCII character corresponding to register 1.
bCL    Subtract 1 from register 1 and print the corresponding ASCII character.
bCL    Subtract 1 from register 1 and print the corresponding ASCII character.
gDL    Add 1 to register 2 and print the corresponding ASCII character.
gDL    Add 1 to register 2 and print the corresponding ASCII character.
gDL    Add 1 to register 2 and print the corresponding ASCII character.

Dennis

Posted 2014-08-22T15:59:12.967

Reputation: 196 637

3

Part 1 in BrainFuck: 80 74 bytes

>-[+>+<[+<]>]>+.<<+++++[>+++++[>+.<-]<-]>>+++++++.<<+++++[>+++++[>+.<-]<-]

spocot

Posted 2014-08-22T15:59:12.967

Reputation: 606

You might have lost the first > due to missing code indentation. So it's rendered as a quotation. – Falko – 2014-08-22T18:07:13.077

@Falko Thanks for noticing, I missed that. – spocot – 2014-08-22T18:19:15.063

3

Total 318 bytes

I was really hoping to figure out an answer with both programs in the same language, but so far nothing. Here's this instead:

Part 1: Pure bash, 129 bytes

_0=`$ 2>&1`
_0=${_0##*:}
_1=${_0:5:1}
_5=${_0:1:1}$_1${_0:11:1}
. <($_5<<<_2=\({${_1^}..$_1}\))
_3=${_2[@]:0:26}
$_5<<<$_3${_3,,}

Output:

$ ./letsym.sh
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 Za 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
$ 

Part 2: GNU dc, 189 bytes

zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzPzzPzzPzzPzzPzzPzzPzzPzzPzzPzzPzzPzzPzzPzzPzzPzzPzzPzzPzzPzzPzzPzzPzzPzzPzzPzzPzzPzzPzzPzzPzzPzzzzzzzzzzzzzzzzzzzzzzzzzzzzPzzPzzPzzPzzPzzPzzBDPBEdPBFPdkvZP

Output:

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

Digital Trauma

Posted 2014-08-22T15:59:12.967

Reputation: 64 644

2

Well, you know, someone should get it going.

Part 1 in BrainFuck: 174 bytes

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+++++++
.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.+.

yasen

Posted 2014-08-22T15:59:12.967

Reputation: 322

1

Part 1: Ruby, 45 bytes

_=[*?@...?[,*?`...?{]
_[0],_[27]=*$_
$><<_*''

Explanation

  • A Range containing a-z (?@...?[) and a Range containing A-Z (?`...?{) become the elements of the array _ using the splat operator (*).
  • The 0th element ("@") and 27th element ("`") of the array _ are set to nil.
  • The array _ is joined together using Array#* and printed to stdout ($>)

britishtea

Posted 2014-08-22T15:59:12.967

Reputation: 1 189

You can replace *$_ on the second line with p (or []). – Jordan – 2018-01-23T16:19:51.553