57
\$\begingroup\$

Input must not be required, and output must read "All your base are belong to us".

Restrictions

  • No external resources.

    Plus a minimum of two of the following:

  • You cannot use "a", "b", "t", "u", or "y" in any case in your code (bonus -10 to your golf score if you can do this)

  • You cannot use "l", "o", "s", "e", or "r" in any case in your code (bonus -20 to your golf score if you can do this)

  • You cannot use "n", "g", "0", "1", or "2" in any case in your code (bonus -30 to your golf score if you can do this)

So for example, if you manage to get the code done with 40 characters and use rules 1 and 2, your golf score is 40 - 10 - 20 = 10 chars.

Smallest code golf score wins... Good luck!

\$\endgroup\$
  • 5
    \$\begingroup\$ So much as declaring a string breaks all three restrictions, and char, var and Write break two of them each. This is going to be tough to get valid answers, bar maybe Barinfuck. \$\endgroup\$ – Hand-E-Food Jan 23 '14 at 2:28
  • 7
    \$\begingroup\$ "no input required". Doesn't that mean that I could, for example, do something like print(input()) (python)? The user would be required to input the correct string, but that isn't forbidden. \$\endgroup\$ – Justin Jan 23 '14 at 6:40
  • 5
    \$\begingroup\$ @Quincunx I wouldn't accept such a solution, as the code is not guaranteed to output a correct solution. Also, stdin is arguably an "external source". \$\endgroup\$ – nitro2k01 Jan 23 '14 at 18:39
  • 2
    \$\begingroup\$ @PranavHosangadi There is a deleted answer to this question with a score of -6 which is essentially the same as that. It's been done before a number of times in various questions and is explicitly disallowed in the code-golf tag. \$\endgroup\$ – Gareth Jan 24 '14 at 10:31
  • 1
    \$\begingroup\$ According to code-golf standard rules answers in latin1/unicode/name you charmap is rated in bytes after conversion to utf-8. Are we to count like that or have you chosen a different score method? Current leader would then be at 0 instead of -40. \$\endgroup\$ – Sylwester Jan 30 '14 at 1:27

39 Answers 39

4
\$\begingroup\$

SOGL V0.12, 15 - 60 = -45

šz█P'zUS½█│β3‘⁾

Try it Here!

šz█P'zUS½█│β3‘ is a compressed string of all your base are belong to us, but because that exact string compressed contained 0, it's split into 3 parts: all your base are, , belong to us (which cost one byte but gave a -30 byte bonus). The first and last strings are compressed with SOGLs English dictionary, and implicitly joined with spaces. The remaining is a simple sentence case built-in.
Note that SOGL postdates this challenge, but that's allowed now.

\$\endgroup\$
  • \$\begingroup\$ I just have to ask... How??? Are we dealing with some clever compression technique here? I know nothing about SOGL... \$\endgroup\$ – WallyWest Oct 6 '17 at 23:51
45
\$\begingroup\$

GolfScript, -22 (38 characters, -60 bonus)

"„¯¯c¼²¸µc¥¤¶¨c¤µ¨c¥¨¯²±ªc·²c¸¶"{67-}%
\$\endgroup\$
  • 4
    \$\begingroup\$ How does this work? \$\endgroup\$ – The Guy with The Hat Jan 23 '14 at 14:57
  • 37
    \$\begingroup\$ @RyanCarlson Magic. \$\endgroup\$ – Howard Jan 23 '14 at 15:18
  • 4
    \$\begingroup\$ "..." defines a string and the block {}% performs a mapping operation over all characters. Inside the block the ascii value is available on the stack and 67- subtracts 67 from each ascii value. \$\endgroup\$ – Howard Jan 23 '14 at 15:19
  • 4
    \$\begingroup\$ OK, case is probably the wrong word to use, but you know what I mean. I'm pretty sure superscript 2 is still a 2, so Rule 3 hasn't been met. \$\endgroup\$ – Trent Jan 24 '14 at 5:48
  • 3
    \$\begingroup\$ @FizzBuzz I know what you're trying to say, but I think what matters is that 2 and ² are different glyphs with distinct codepoints. You can make the argument that, in a denotational sense, they are the same symbol, but I think that's a far more abstract interpretation than the question merits. \$\endgroup\$ – Jordan Gray Jan 24 '14 at 14:46
36
\$\begingroup\$

Sclipting, −40

뀖롬긇땯덗긠눦굳뉒걡댦넠눦녬닶멧긇끯긇녳
  • = 20 characters − 60 bonus
  • Only works if the input is empty, which I take to be the case; if not, add in front, changing the score to −39.
  • If I can assume the input to be what I want (as this answer apparently does), then the empty program is a solution and my score is −60.
\$\endgroup\$
  • \$\begingroup\$ Well, "input is not required" as I said, so I'd throw the 丟 in front and alter the score to -39, but great effort! Especially considering you invented the language, dude! \$\endgroup\$ – WallyWest Jan 29 '14 at 23:10
  • 1
    \$\begingroup\$ As a Korean seeing Korean syllables in code is amazing. \$\endgroup\$ – Matthew Roh Apr 1 '17 at 15:39
29
\$\begingroup\$

JavaScript - 140 bytes - 60 bonus = 80 points

(x="Ǎľľ y̌ǒǔř b̌ǎšě ǎřě b̌ěľǒňǧ ťǒ ǔš")[x[3*9]+x[34]+"p"+x[4]+x[5*5]+"c"+x[34]]("̌","",x[6*7])

Run in Firefox.

I know what you're thinking. No, those aren't the characters that are listed in the question. Those are characters with a caron, or háček (picked randomly from a list of diacritics). Even though they're combining marks, they aren't two separate characters.

\$\endgroup\$
  • \$\begingroup\$ Node.js REPL: String.fromCharCode(65,108,108,32,121,111,117,114,32,98,97,115,101,32,97,114,101,32,98,101,108,111,110,103,32,116,111,32,117,115); \$\endgroup\$ – nick indiessance May 4 '18 at 8:00
28
\$\begingroup\$

APL (43 - 30 - 20 = -7)

⎕AV['⊥┤┤ ø┼&┐ `∣┘û ∣┐û `û┤┼─ù ´┼ &┘'⍳⍨⌽⎕AV]

This satisfies rules 2 and 3.

\$\endgroup\$
  • \$\begingroup\$ This is going to be hard to beat! \$\endgroup\$ – Paul Prestidge Jan 23 '14 at 3:33
  • 1
    \$\begingroup\$ does this return the result or print it? \$\endgroup\$ – Aaron Davies Jan 23 '14 at 4:10
  • \$\begingroup\$ @AaronDavies: both, the result is automatically printed \$\endgroup\$ – marinus Jan 23 '14 at 19:37
  • \$\begingroup\$ @marinus I tried this in TryAPL.com and got an INVALID TOKEN error.... perhaps from the initial and tailing character before AV... Is there any other place I can test this...? \$\endgroup\$ – WallyWest Jan 29 '14 at 23:02
  • \$\begingroup\$ @WallyWest: use Dyalog APL (dyalog.com). Get the unregistered version, it's free. TryAPL is so limited it's nearly useless. \$\endgroup\$ – marinus Jan 30 '14 at 17:23
28
\$\begingroup\$

Brainfuck, 267 - 60 = 207

++++++++[>++++++++<-]>+.<+++++++[>++++++<-]>+..>>++++++[<+++++>-]<++.<+++++++++
++++.----------.++++++.---.>.<<++++[>----<-]>.-.<+++[>++++++<-]>.--------------
.>.<----.<++++[>++++<-]>+.-------------.>.<---.+++.+++++++.+++.-.-------.>.<+++
++++++++++.-----.>.<++++++.--.
\$\endgroup\$
  • \$\begingroup\$ Can that be reduced any further, I wonder? :) \$\endgroup\$ – WallyWest Jan 29 '14 at 23:00
  • 2
    \$\begingroup\$ fbonetti did better in his Brainfuck answer. \$\endgroup\$ – Hand-E-Food Jan 30 '14 at 3:05
  • 2
    \$\begingroup\$ And FIQ did even better 4 days later \$\endgroup\$ – schnaader Dec 11 '14 at 12:41
22
\$\begingroup\$

HTML/CSS 70

<p style="transform:rotate(.5turn)">sn oʇ ƃuoləq əɹɐ əsɐq ɹnoʎ llɐ</p>

http://jsbin.com/EjekuvuF/1/

I thought I was being clever with the upside down type but then realized I couldn't meet any of the ancillary rules with the actual HTML/CSS. Oh well.

UPDATE:

User Flame suggested a more cross-browser compliant solution:

<p style="transform:rotate(180deg)">sn oʇ ƃuoləq əɹɐ əsɐq ɹnoʎ llɐ</p>  

http://jsbin.com/EjekuvuF/6

\$\endgroup\$
  • \$\begingroup\$ I guess you can use XML character references to salvage the situation. \$\endgroup\$ – MvG Jan 24 '14 at 9:51
  • 3
    \$\begingroup\$ I like the idea behind the solution though. \$\endgroup\$ – Sumurai8 Jan 25 '14 at 10:39
  • \$\begingroup\$ I'll give props to it too... thought for some reason transform:rotate(.5turn) resolves to a Syntax error... I like the imagination put into this... \$\endgroup\$ – WallyWest Jan 29 '14 at 23:12
  • \$\begingroup\$ @WallyWest I didn't test in all browsers. I bet that might be browser-specific rather than the official W3C syntax. (Does work in Chrome, though) \$\endgroup\$ – DA. Jan 29 '14 at 23:33
  • 3
    \$\begingroup\$ You should use ∀ instead of ɐ :) \$\endgroup\$ – Timwi Feb 6 '14 at 13:39
12
\$\begingroup\$

MATLAB, All bonuses: Score of -20 (40-60)

['' '¤ÏÏèÜÒØÕèÅÄÖÈèÄÕÈèÅÈÏÒÑÊè×ÒèØÖ'-99]

EDIT:

Note that I am not sure of what the system requirements are to run this, tested on windows. For those struggeling to copy, a similar code can be generated like so:

char('All your base are belong to us' + 99)

If it would have been allowed to ask anything as input, a solution with less characters (but also missing the bonus) would of course be possible.

input('')
\$\endgroup\$
  • \$\begingroup\$ Please explain how you plan to output anything using only input. The second answer is (afaik) just not true. \$\endgroup\$ – DJSpud Jan 23 '14 at 19:01
  • 2
    \$\begingroup\$ @Jhawins: MATLAB outputs the result of each expression that doesn't end in a semicolon. The input('') call doesn't end in a semicolon, hence it will generate output. \$\endgroup\$ – Ben Voigt Jan 23 '14 at 19:07
  • 6
    \$\begingroup\$ If that's correct, then my JS answer is "prompt()" \$\endgroup\$ – DJSpud Jan 23 '14 at 19:08
  • \$\begingroup\$ And shell would be dd, but perhaps that counts as an external resource. So would user input, of course. \$\endgroup\$ – gerrit Jan 23 '14 at 20:19
  • \$\begingroup\$ I tried running this and got the following: _A,,E9/52E"!3%E!2%E"%,/.'E4/E5`3 I can understand the first answer, but the second answer requires input, which I said was not "required" \$\endgroup\$ – WallyWest Jan 29 '14 at 23:16
10
\$\begingroup\$

k (-7 = 53 - 60)

(#`)"c"$(465%3)-6h$"Z//{\",&){9:(6{:)6{96/,-4{',{&(";

doesn't include trailing newline, can be added at cost of one additional char:

(-#`)"c"$(465%3)-6h$"Z//{\",&){9:(6{:)6{96/,-4{',{&(";

annoyingly, the only offsets that work for this trick are 154 and 155

edit:

if it's sufficient to display the string (rather than printing it), as i suspect the APL solution does (it doesn't work in http://tryapl.com/, so i can't test it properly), it's

  "c"$(465%3)-6h$"Z//{\",&){9:(6{:)6{96/,-4{',{&("
"All your base are belong to us"

which is -12 = 48 - 60. can i get a ruling on whether this is sufficient?

\$\endgroup\$
  • \$\begingroup\$ I never asked for a trailing newline... :) \$\endgroup\$ – WallyWest Jan 29 '14 at 23:16
10
\$\begingroup\$

dc, 97 - 60 = 37 91 - 60 = 31 88 - 60 = 28 81 - 60 = 21

3C87596P4d^8/P7958389P7479394P6386533P7C89P749698CP644848CP459 8^699 7^3849736388974773333 86-++P

Improved version (the main idea here is to vary the input base, to increase the chances of finding a useful big number with no problematic digits):

IDi67793554D647F84C836645D6569F69Pi6385C77P9i35PDdi6^I9^+6D59CD83D664D34+P8CPFi98CCF5PCi97P

In base 7, the whole thing can become a single number! Lower bases are naturally less compact, but the lack of fix-up operations here makes up for it.

7i4398873968644388737548444897643735447698675366869556798538985674336396359936458859886P

My first solution used base 10. My second used a mix of base 9, 10, 12, 13, and 15. This one is in base 7. I truly feel like all the base are belong to me.

Last one, seriously: Base 13 does a great job on the first segment, then base 7 for the rest.

Di67793554D647F84C836645D6569F69P7i798789699638355733695878558396339387963789536P
\$\endgroup\$
  • \$\begingroup\$ So in other words, all your base 7 are belong to you, @Wumpus? \$\endgroup\$ – WallyWest Jul 15 '15 at 15:03
10
\$\begingroup\$

Python REPL, 122 116 98 characters - 30 bonus = 92 86 68 points

>>> '\x41\x6c\x6c \x79\x6f\x75\x72 \x62\x61\x73\x65 \x61\x72\x65 \x62\x65\x6c\x6fng \x74\x6f \x75\x73'

'All your base are belong to us'

I could get rid of the zeroes in Python 3.3 by replacing '\40' with \N{SP}, but alas, the N is not permitted.

Edit: Inspired by this answer, I've shortened it further by replacing \x40 by . Moreover, since I already use the 1, replacing \156 by n and \x67 by g shortens it by another 6 characters while incurring no extra penalty.

\$\endgroup\$
  • 1
    \$\begingroup\$ I wonder if this is this a valid entry, because it only works the interactive shell. If you put this in a .py file and execute it, there is no output. \$\endgroup\$ – Daniel Hepper Jan 23 '14 at 13:00
  • 1
    \$\begingroup\$ It depends... I believe there is no general rule. Some questions allow interactive mode, others don't. \$\endgroup\$ – Bakuriu Jan 23 '14 at 13:05
  • 1
    \$\begingroup\$ I've posted the question on meta. \$\endgroup\$ – gerrit Jan 23 '14 at 13:15
  • 1
    \$\begingroup\$ This works in R too \$\endgroup\$ – Zach Jan 23 '14 at 18:22
  • 1
    \$\begingroup\$ @AaronHall And after my edit, I brought mine down to 68! \$\endgroup\$ – gerrit Jan 26 '14 at 15:24
8
\$\begingroup\$

Brainfuck, 205 203 - 60 = 145 143 bytes

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

Readable version:

++++[->++++<]>[->++++>++>+++++++>++++++>++++++++<<<<<]
64 32 112 96 128

>+.>>----..<.                     All                 65 108 108  32
>>>-------.<<+++.>>----.---.<<<.  your           121 111 117 114  32
>>++.-.>+.<++++.<<.               base            98  97 115 101  32
>>----.>-.<++++.<<.               are                 97 114 101  32
>>---.+++.<---.>>---.-.<<-----.<. belong  98 101 108 111 110 103  32
>>>++++++.-----.<<<.              to                     116 111  32
>>>++++++.--.                     us                     117 115
\$\endgroup\$
  • \$\begingroup\$ Good effort! \$\endgroup\$ – Timwi Feb 6 '14 at 13:38
  • \$\begingroup\$ I kinda half-expected a Brainfuck solution eventually... Nice work! \$\endgroup\$ – WallyWest Sep 10 '14 at 23:37
7
\$\begingroup\$

Befunge 98 : 122 - 60 = 62

5f8+*:53-+:' \6-:5+' 91+:*3+::7+\8+:3-:7-:3-:' \3+::3-4+',' -+\4-:' \:4+\6+c+:f3+-:4+3-' '&3*:3+:6-:f+5-:' \d-:' '!+ff+k,@

Computes the ascii values, then prints them. I still need to try out other methods of forming the numbers to see if there are shorter ways.

\$\endgroup\$
  • \$\begingroup\$ I was wondering when you were gonna put your 2 bytes in... Nice work! \$\endgroup\$ – WallyWest Jan 29 '14 at 23:20
7
\$\begingroup\$

Python, 195-40 = 155

x,w,y,z,v=4*8,55,56,57,58;exec(("%c"*38)%(y+y,z+z,49+y,w+w,v+v,39-7,34,65,54+54,54+54,x,v+63,48+63,48+69,z+z,x,98,97,59+y,45+y,x,97,z+z,45+y,x,98,45+y,54+54,w+y,w+w,45+v,x,v+v,w+y,x,v+59,z+v,34))
\$\endgroup\$
6
\$\begingroup\$

Ruby, 121 - 50 = 71

A bit brute force, but most of the cute methods are ruled out:

$><<[65,c=36*3,c,d=8*4,363/3,f=c+3,c+9,c+6,d,x=98,97,j=c+7,k=3+x,d,97,c+6,k,d,x,k,c,f,j-5,5+x,d,c+8,f,d,c+9,j].pack('C*')

Breaks rule #1 because of the A in pack, the other two should be OK.

\$\endgroup\$
  • \$\begingroup\$ I can save 6 chars if we're just returning the result rather than printing it, I wasn't clear on that after looking at the other answers. \$\endgroup\$ – Paul Prestidge Jan 23 '14 at 4:07
  • 1
    \$\begingroup\$ Extremely long, but no more “a”: pastebin.com/wnsvcAMh \$\endgroup\$ – manatwork Jan 23 '14 at 10:39
  • \$\begingroup\$ @manatwork I love it! Somehow I never thought of that, even though I'm using << in my answer. \$\endgroup\$ – Paul Prestidge Jan 23 '14 at 21:59
  • \$\begingroup\$ So you either use the 154 character solution @manatwork has used and claim the 60 point discount which gives you 94, or stick with the non-Rule 1 version and go with the 71... I know which I'd use :) \$\endgroup\$ – WallyWest Jan 29 '14 at 23:19
6
\$\begingroup\$

{ba,z}sh, 67 - 40  72 - 60 61 - 40 = 21

$'\x74r' K-~\#-\; _@-~\^-j<<<'Mxx ){%~ 3m#q m~q 3qx{z8 ${ %#'

Darn it, turns out I had a r in there that I hadn't noticed, so the 20 bonus doesn't apply!

\$\endgroup\$
  • 1
    \$\begingroup\$ In the zsh and bash versions I have handy, $'\x74\x72' can be used directly as a command name, saving you 8 characters for the $(m4<<<). Doesn't it work that way for you? \$\endgroup\$ – user15244 Jan 24 '14 at 14:50
  • \$\begingroup\$ And after looking at it again... using \x72 as a replacement for r gets you the 20 point bonus at the cost of losing the 30 point bonus (for the 2) \$\endgroup\$ – user15244 Jan 24 '14 at 15:10
  • \$\begingroup\$ @WumpusQ.Wumbley oh, you're right on both accounts. I didn't think of the 2 used there, let me see if I can find a way to get rid of it and avoid losing any bonuses. \$\endgroup\$ – FireFly Jan 24 '14 at 15:33
  • \$\begingroup\$ Holy sh#t, that was ingenious! This looks like a Reverse ROT12 ASCII cypher... (am I right?) nicely done! \$\endgroup\$ – WallyWest Jan 29 '14 at 23:29
  • \$\begingroup\$ Nice answer. But does tr count as an external resource? \$\endgroup\$ – Digital Trauma Jan 29 '14 at 23:59
5
\$\begingroup\$

C, 75 bytes - 60 = 15

Thanks to @gastropner for getting the score down from 50 to 33 and from 19 to 15!

*q,i;f(p){(*(q=p)="\v&&j3%?8j(+9/j+8/j(/&%$-j>%j?9J"[i++]^74)?i=!f(++p):i;}

Takes the address of a char array as input and writes the string to the array.

Try it online!

Call with:

int main()
{
    char s[128];
    f(s);
    puts(s);
}

Output:

Old version (90 bytes - 40 = 50):

*q,i,j;f(p){for(i=3-3;j="Epp$}s v$fewi$evi$fipsrk$xs$ w"[i++];*q=j!=35-3?j-4:353/3)q=p++;}
\$\endgroup\$
  • 1
    \$\begingroup\$ Riffing on this, using the powers of XOR and recursion, you can reach 93 - 60 = 33 bytes: *q,i,j;x(p){if(j="\v&&j3%?8j(+9/j+8/j(/&%$-j>%j?9"[i++])*(q=p)=j^74,x(++p);}f(p){i=3-3;x(p);} \$\endgroup\$ – gastropner Jan 14 '18 at 14:07
  • \$\begingroup\$ @gastropner Thanks! \$\endgroup\$ – Steadybox Jan 14 '18 at 14:36
  • \$\begingroup\$ Could go with i=i<30 for another 2 bytes off. \$\endgroup\$ – gastropner Jan 14 '18 at 15:51
  • \$\begingroup\$ @gastropner Can't use 0. \$\endgroup\$ – Steadybox Jan 14 '18 at 15:51
  • \$\begingroup\$ Ah, yes, of course! \$\endgroup\$ – gastropner Jan 14 '18 at 16:00
4
\$\begingroup\$

JavaScript

(306 characters - 60 bonus = 246) (206 characters - 50 bonus = 156)

(123 chars = 173 chars - 50 bonus)

Kind of nooby, probably could get more off... Let me know if I've stuffed something up, this alerts "All your base are belong to us". This is also ASCII-only.

(c=(''+!'')[4-3],x=([][3]+c)[6])[a='c\x6F'+x+'\x73t'+c+'uct\x6F'+c][a]('a\x6C\x65'+c+'t("A\x6C\x6C y\x6Fu'+c+' ba\x73\x65 a'+c+'\x65 b\x65\x6C\x6F'+x+'\x67 t\x6F u\x73")')()

If you count the console itself as output, this would also count (57 with bonus):

'A\x6C\x6C y\x6Fu'+(c=(''+!'')[4-3])+' ba\x73\x65 a'+c+'\x65 b\x65\x6C\x6F'+([][3]+c)[6]+'\x67 t\x6F u\x73'
\$\endgroup\$
  • \$\begingroup\$ Great approach, though a few letter subsitutions could have also allowed you the Rule-1 bonus as well... Good work. \$\endgroup\$ – WallyWest Jan 29 '14 at 23:34
  • \$\begingroup\$ @WallyWest: Thanks! The problem in JavaScript is that it's rather hard to get an "A" without breaking the other rules or using up way too many characters -- it would take up more than 10 characters alone. \$\endgroup\$ – Qantas 94 Heavy Jan 29 '14 at 23:43
  • \$\begingroup\$ True, you have to outweight the additional letters against the bonuses... Nice work though! \$\endgroup\$ – WallyWest Jan 29 '14 at 23:44
  • \$\begingroup\$ x=(c.t+c)[6] is a bit shorter \$\endgroup\$ – Not that Charles Apr 13 '16 at 17:04
  • \$\begingroup\$ also, eval might be easier to hack \$\endgroup\$ – Not that Charles Apr 13 '16 at 17:09
4
\$\begingroup\$

Brainfuck, (227 - 60 = 167)

+++++ +++++[>+++>++++++>+++++++++>++++++++++<<<<-]>>+++++.>>++++++++..<<<++.>>>+++++++++++++.----------.++++++.---.<<<.>>++++++++.-.>+.<++++.<<.>>----.>-.<++++.<<.>>---.+++.>------.+++.-.<++.<<.>>>++++++.-----.<<<.>>>++++++.--.
\$\endgroup\$
  • \$\begingroup\$ I dont think the space at the start, +++++ +++++ is needed? It could be 226 bytes. \$\endgroup\$ – FinW Feb 18 '17 at 11:07
3
\$\begingroup\$

PHP (35 - 60 = -25 bytes)

HOW LOW CAN YOU GET ?[1][2]

$ xxd yourbase.php 
0000000: 3c3f 3d7e be93 93df 8690 8a8d df9d 9e8c  <?=~............
0000010: 9adf 9e8d 9adf 9d9a 9390 9198 df8b 90df  ................
0000020: 8a8c 3b                                  ..;

[1] This program can be decoded using xxd -r.
[2] Yeah, heavy solution reuse here. I think it's... third problem I solved this way. Perhaps I should move to something else, but it's not that this is not great for problems that forbid you from using most characters.

\$\endgroup\$
  • \$\begingroup\$ I don't get it, what are you trying to do here? \$\endgroup\$ – WallyWest Jan 29 '14 at 23:34
  • \$\begingroup\$ @WallyWest He bit-inverted the string; resulting in 31 extended ASCII chars, which PHP tries to interprete as a constant name and because it finds no such constant interpretes as a string. This string gets negated back with ~. \$\endgroup\$ – Titus Apr 18 '17 at 16:21
3
\$\begingroup\$

Bash, 52 - 10 - 30 = 12

The following is to be executed in a (still pretty common) ISO-8859-1 environment:

$'\x74r' À-þ  @-~<<<'Áìì ùïõò âáóå áòå âåìïîç ôï õó'

This calls tr, which translates the characters in a suitable way. I had to either use the r and violate rule 2, or use a digit in the escape and violate rule 3. Since 3 gives more bonus, I chose the former.

\$\endgroup\$
  • 1
    \$\begingroup\$ Yes he did :) You cannot use "a", "b", "t", "u", or "y" in any case Also you need minimum two of the conditions \$\endgroup\$ – cowls Jan 24 '14 at 9:24
  • \$\begingroup\$ @cowls: Seems I completely missed that point, thanks for making it clear. Rewrote my answer to comply with that. \$\endgroup\$ – MvG Jan 24 '14 at 9:49
  • \$\begingroup\$ @MvG great re-work... Well done! \$\endgroup\$ – WallyWest Jan 29 '14 at 23:36
  • \$\begingroup\$ Does tr constitute an external resource? \$\endgroup\$ – Digital Trauma Jan 30 '14 at 0:02
  • \$\begingroup\$ @DigitalTrauma: More like a standard library, I'd say, although this is sure subject to interpretation. But it's specified in the POSIX standard, so I guess any POSIX system has to have it, so it's part of the system. \$\endgroup\$ – MvG Jan 30 '14 at 6:50
3
\$\begingroup\$

Pure Bash (no external resources), 141 chars - 50 bonus = 91

Z=({k..v})
f=$'\x65'
h=$'\x6c'
i=$'\x6f'
j=${Z[7]}
k=$'\x73'
m=$'\x75'
$f$'\x63'h$i A$h$h y$i$m$j ba$k$f a$j$f b$f$h$i${Z[3]}$'\x67' t$i u$k

Intentionally dropping the 10-point bonus to get a better overall score.

This works on any bash version 3.00.15 or later that I have tried.

How does it work

There's no rocket science here - just bash expansions of one form or another:

  • Simple hex expansion to obtain required character. This works for characters whose hex representation doesn't contain [012]. e.g. $'\x65' gives us e
  • For other characters, we generate a bash array of sequential characters using brace expansion into an array initialization (Z=({k..v})). The start of the brace expansion is chosen carefully so that the indexes of the characters we require don't contain [012]. e.g. ${Z[7]} gives us r.
  • bash is flexible enough to allow its commands to be constructed from the contents of multiple strings. So $f$'\x63'h$i expands to echo.
  • For characters that are required only once, the expansion is inserted inline to the echo command string.
  • For characters that are required twice or more it is more efficient to expand them to variables, then reference the variables.

Previous answer with full bonus, but worse overall score:

Pure Bash (no external resources), 193 chars - 60 bonus = 133

I know this won't win, but I wanted to prove to myself this is possible in bash, while satisfying all requirements:

Z=({3..8} {C..z})
c=${Z[36]}
d=${Z[37]}
f=$'\x65'
h=$'\x6c'
i=$'\x6f'
j=${Z[53]}
k=$'\x73'
m=$'\x75'
$f$'\x63'h$i ${c^}$h$h $'\x79'$i$m$j $d$c$k$f $c$j$f $d$f$h$i${Z[49]}$'\x67' $'\x74'$i $m$k

This does require a fairly recent version of bash for the ${c^} parameter expansion. 4.2.25 is fine, but 3.2.48 is a no-go.

\$\endgroup\$
  • \$\begingroup\$ I take my hat off to you... I just executed this... nice work... Very nice work. \$\endgroup\$ – WallyWest Jan 29 '14 at 23:39
  • \$\begingroup\$ @WallyWest - I just edited in a shorter version. \$\endgroup\$ – Digital Trauma Jan 30 '14 at 1:19
3
\$\begingroup\$

Postscript, 364 - 40 = 324

I couldn't do it without loser, of course. :)

/${cvx exec}def
/+{<3C7E4F6F597E3E>$ $}def
/*{<~P&(~>$}def
/-{( )<3C7E4F754E7E3E>$ $ 3 4<~P#;~>$ 4 3<~P)#3FP'-~>$}def
/_{36(      )<~OoP~><3C7E4F754E7E3E>$ $ 4 3<~P,S~>$ 48<~P'?~>$
${96 3<~P#;~>$ + -}<~P">~>$}def
/.{_ 96 3<~P#;~>$ -}def
65 - 777 .
895 353 + _ 774 333 + .
74933 333 + 7 * 3 + 333 + .
9593 4353 + .
689653949 335 + .
735 333 + .
775 333 + _ 5 5 + -

This starts with encoding the text as base-36 strings:

%-=Encoding strings as base-36 numbers=-
%All your base are belong to us
% handle uppercase A separately
%36#ll = %777
%36#your = %1618515
%36#yo = 36#ur = 36#base = 36#are = 36#belong = 36#to = 36#us =
%1248 1107 527198 13946 689654284 1068 1108

And then removing the 1s and 0s and 2s arithmetically. The strings can then be regenerated with 36 <string-buf> cvrs, but this yields upper-case letters, so we then need to iterate through and add 0x20 to make them lowercase.

The operators cvx exec allow us to execute string fragments of binary-encoded operator tokens in various encodings. Simplest is to encode an operator in hex <92??> but there's a 2 in there! So the "first-level" encoding is ascii85. Then any strings that still contained forbidden characters went through extra levels of hex -> ascii85 -> hex -> ascii85.

\$\endgroup\$
2
\$\begingroup\$

Brainfuck, 306 - 60 = 246

----[---->+<]>++.[--->+<]>+..[++>---<]>--.--[->++++<]>+.----------.++++++.---.[-->+++++<]>+++.[--->+<]>++.-.--[--->+<]>--.++++[->+++<]>.--[--->+<]>-.[--->+<]>+.--[--->+<]>---.-------------.--[--->+<]>-.[--->+<]>++.+++.+++++++.+++.-.-------.-[--->+<]>--.---[->++++<]>.-----.[--->+<]>-----.---[->++++<]>+.--.
\$\endgroup\$
  • \$\begingroup\$ Surely this could be reduced somehow? \$\endgroup\$ – WallyWest Jul 15 '15 at 14:09
  • \$\begingroup\$ @WallyWest I don't have the time to reduce a program like this by 5% for no reason :P feel free to post improvements, though! \$\endgroup\$ – Timtech Jul 16 '15 at 3:48
  • \$\begingroup\$ No obligation needed here :) \$\endgroup\$ – WallyWest Jul 16 '15 at 6:48
  • \$\begingroup\$ @WallyWest You're right about shortening it though. It could use some major improvements. \$\endgroup\$ – Timtech Jul 17 '15 at 11:22
2
\$\begingroup\$

PHP, 186 - 10 - 30 = 146

I had to get a little creative ;)

 <?=chr(65).'ll '.chr(88+33).'o'.chr(39*3).'r '.chr(98).chr(97).'s'.chr(68+33).' '.chr(97).chr(38*3).chr(68+33).' '.chr(98).'elo'.chr(77+33).chr(69+34).' '.chr(83+33).'o '.chr(39*3).'s'?>
\$\endgroup\$
  • \$\begingroup\$ you could still golf it a little and mantain the answer idea: echo doesn't require parentheses(1), you can use <?= instead of echo(4), you can save the repeated letters in variables ('l', ' '). use 54*2 instead of 54+54 \$\endgroup\$ – Einacio Jan 24 '14 at 15:31
  • 1
    \$\begingroup\$ Fixed. I could only do multiplying on certain ones. I can't do 54*2 because that it has a 2 in it, so I could only do it with ones that had 3 or higher has a factor. If I use a decimal, then there's no less characters. \$\endgroup\$ – ub3rst4r Jan 24 '14 at 17:26
  • \$\begingroup\$ a few golfing tips taking 50 bytes off. Most of it (23+9 bytes): You can replace the remaining chr(68+33) and chr(38*3) with literal e and r. \$\endgroup\$ – Titus Apr 18 '17 at 16:56
1
\$\begingroup\$

Python, 181 - 40 = 141

[I'm using version 2.7.2 YMMV - the builtin, file is gone in python 3.X]

f=file.__doc__;c=5-3;l=f[c];s=' ';e=f[3];h=f[6+7];i=f[c*87];j=3**3;f[j*c*5]+l+l+s+f[-57]+h+f[j-7]+f[j-3]+s+f[j-8]+f[6]+i+e+s+f[6]+f[j-3]+e+s+f[j-8]+e+l+h+f[5]+f[j]+s+f[45]+h+s+f[j-7]+i
\$\endgroup\$
1
\$\begingroup\$

Python (104 - 30 = 74)

>>> '\x41\x6c\x6c \x79\x6f\x75\x72 \x62\x61\x73\x65 \x61\x72\x65 \x62\x65\x6c\x6f\156\x67 \x74\x6f \x75\x73'
'All your base are belong to us'

And score:

>>> len(r"'\x41\x6c\x6c \x79\x6f\x75\x72 \x62\x61\x73\x65 \x61\x72\x65 \x62\x65\x6c\x6f\156\x67 \x74\x6f \x75\x73'")-30
74
\$\endgroup\$
  • \$\begingroup\$ Nicely done, but you really didn't need to do the same for determining the score... ;) \$\endgroup\$ – WallyWest Jan 29 '14 at 23:17
1
\$\begingroup\$

Mumps, 150 - 60 = 90. 40 = 110

S J=" ",Z=36*3,C=37*3,D=38*3,Q=39*3,I=35*3-4 W *65,*Z,*Z,J,*484/4,*C,*Q,*D,J,*98,*97,*C+4,*I,J,*97,*D,*I,J,*98,*I,*Z,*C,*D-4,*Z-5,J,*C+5,*C,J,*Q,*C+4

I'm not sure if it could have been done shorter (overall) by not getting one of the code bonuses - my goal was a bit less on shortness and a bit more on the -60... I liked the challenge of not using any of the restricted characters.

And... I goofed it up - missed the beginning 'S' command. :-/

Anyway, here's a "no rules" version - expanding the variables.

W *65,*36*3,*36*3," ",*484/4,*37*3,*39*3,*38*3," ",*98,*97,*37*3+4,*35*3-4," ",*97,*38*3,*35*3-4," ",*98,*35*3-4,*36*3,*37*3,*38*3-4,*36*3-5," ",*37*3+5,*37*3," ",*39*3,*37*3+4

And that gives it a score of 177-60 = 117. So breaking the center rule still gave me a lower overall score.

\$\endgroup\$
  • \$\begingroup\$ Interesting answer... Is there an online emulator I can access to execute this code? \$\endgroup\$ – WallyWest Jul 15 '15 at 14:05
  • 1
    \$\begingroup\$ Not to my knowledge, but there are versions for Mumps that run on just about every platform - there's even versions that will run on a Raspberry Pi if you want a very small Mumps machine... :-) \$\endgroup\$ – zmerch Jul 15 '15 at 14:25
1
\$\begingroup\$

Perl 5, 99 − 50 = 49

A subroutine that returns the required string:

{A.($c=h|d)."$c y".($f=f|k).u.($k=p|b)." ba".($j=c|p).($d=d|a)." a$k$d b$d$c$f".(jf|fc)." t$f u$j"}

See it printed thus:

perl -e'print sub{...}->().$/'
\$\endgroup\$
1
\$\begingroup\$

BF-RLE, 146 - 30 = 116

+5[>+5<-]>+.<+4[>+3<-]>+..>>+3[<+2>-]<++.<+A.-7.+3.-0.>.<<+1[>-1<-]>.-.<+0[>+3<-]>.-B.>.<-1.<+1[>+1<-]>+.-A.>.<-0.+0.+4.+0.-.-4.>.<+A.-2.>.<+3.--.
\$\endgroup\$
  • \$\begingroup\$ This can be shortened significantly \$\endgroup\$ – Timtech Feb 16 '17 at 0:09

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