diff options
author | Jari Vetoniemi <jari.vetoniemi@indooratlas.com> | 2020-03-16 18:49:26 +0900 |
---|---|---|
committer | Jari Vetoniemi <jari.vetoniemi@indooratlas.com> | 2020-03-30 00:39:06 +0900 |
commit | fcbf63e62c627deae76c1b8cb8c0876c536ed811 (patch) | |
tree | 64cb17de3f41a2b6fef2368028fbd00349946994 /jni/ruby/sample/trick2013/kinaba/remarks.markdown |
Fresh start
Diffstat (limited to 'jni/ruby/sample/trick2013/kinaba/remarks.markdown')
-rw-r--r-- | jni/ruby/sample/trick2013/kinaba/remarks.markdown | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/jni/ruby/sample/trick2013/kinaba/remarks.markdown b/jni/ruby/sample/trick2013/kinaba/remarks.markdown new file mode 100644 index 0000000..e35550e --- /dev/null +++ b/jni/ruby/sample/trick2013/kinaba/remarks.markdown @@ -0,0 +1,37 @@ +### Remarks + +Just run it with no argument: + + ruby entry.rb + +I confirmed the following implementations/platforms: + +* ruby 2.0.0p0 (2013-02-24) [i386-mswin32\_100] + +### Description + +The program prints each ASCII character from 0x20 ' ' to 0x7e '~' exactly once. + +The program contains each ASCII character from 0x20 ' ' to 0x7e '~' exactly once. + +### Internals + +The algorthim is the obvious loop "32.upto(126){|x| putc x}". + +It is not so hard to transform it to use each character *at most once*. Only the slight difficulty comes from the constraint that we cannot "declare and then use" variables, because then the code will contain the variable name twice. This restriction is worked around by the $. global variable, the best friend of Ruby golfers. + +The relatively interesting part is to use all the charcters *at least once*. Of course, this is easily accomplished by putting everything into a comment (i.e., #unsed...) or to a string literal (%(unused...), note that normal string literals are forbidden since they use quotation marks twice). Hey, but that's not fun at all! I tried to minimize the escapeway. + +* "@THEqQUICKbBROWNfFXjJMPSvVLAZYDGgkyz". Trash box of unused alphabet. I with I could have used "gkyz" somewhere else. + +* "%r{\"}mosx". Regex literal, with %-syntax. I don't even know what each m,o,s,x means... + +* "?'" Symbol literal. The quote characters (' " \`) are the first obstacle to this trial because they have to be used in pair usually. These are escaped as \" and ?' and :\`. + +* "4>6" "3\_0-~$.+=9/2^5" "18\*7". I had to consume many arithmetic operators +-\*/^~<>, but I only have ten literals 0 to 9 and $. as operands. Besides I have to express the print loop. This is an interesting puzzle. + +* "(putc ...;)<18*7". Trail semicolon doesn't change the value of the expression. + +### Limitation + +n/a. |