# Anti-golfscript anti-golf: create a task where GolfScript or J is outgolfed by your (conventional) lang [closed]

You need to make three things:

1. Statement of a task, T.
2. Solution of the task in language not typically used for golfing, A.
3. Solution of the task in language typically used for golfing, B. Don't try to just bloat up B to pump up the score, instead think as if B was written by your competitor.

Use common sense in defining typically used for golfing, try to maximize fun for other users.

Other users may propose better Bs (maybe including in other "golfy" languages).

Scoring is (length_in_bytes(B)+5)/(length_in_bytes(A)+5), more is better. (Maybe the scoring formula should be changed?..)

The main idea is to invent a task where languages that typically perform well in codegolf meet a problem. It can be sudden strength of a usual language in the given task or sudden weakness of some golflang.

Avoid tasks that mention specific programming languages, like Input a string and execute it as a Scheme code.

• I suppose that you make this a popularity-contest instead of a code-golf. Otherwise people will complain that it is not a "shortest-code-wins". – Victor Stafusa Jan 17 '14 at 19:36
• OK, changing to popularity-contest. You can also suggest better title or better scoring. – Vi. Jan 17 '14 at 19:38
• Do we get to specify lang B (as long as it is good at golfing)? Or can anyone say "here is a program in language <insert language name> and it has a very short solution of length <n>:"? – Justin Jan 17 '14 at 19:49
• BTW some languages like Perl can be both on A side and on B side, depending on context. – Vi. Jan 17 '14 at 20:02
• Why was this closed as off-topic? It seems to have an objective winning criterion to me? – pppery Apr 14 '19 at 16:19

My previous question, Print a sinusoidal wave (vertically), qualifies at this moment. I'm posting it here as a solution, also hoping that you guys can come up with some shorter solutions to my original question.

As required by Vi., I will post a summary of the question.

Print a continuous sinusoidal wave scrolling vertically on a terminal. The program should not terminate and should continuously scroll down the wave (except until SIGINT). You may assume overflow is not a problem (i.e. you may use infinite loops with incrementing counters, or infinite recursion).

The wave should satisfy the following properties:

• Amplitude = 20 chars (peak amplitude)
• Period = 60 to 65 lines (inclusive)
• The output should only consist of spaces, newline and |
• After each line of output, pause for 50ms

There is a sample output on my original question, but I'm not posting it here, because this will make my answer ridiculously long. My original question can be seen here: Print a sinusoidal wave (vertically)

Shortest A currently: a Perl solution with 48 chars: https://codegolf.stackexchange.com/a/18655/12205

print$"x(25+20*sin).'| ';$_+=.1;sleep .05;do$0  Shortest B currently: a J solution with 54 chars: https://codegolf.stackexchange.com/a/18649/12205 ($:+&0.1[6!:3@]&0.05[2:1!:2~' |'#~1,~[:<.20*1+1&o.)0


Currently, the score of this answer is 1.113 (an awfully low score)

• The current score according to current formula is approximately 1.113 – Vi. Jan 17 '14 at 19:54
• @Vi. should I delete this answer or should I wait some time and see what happens? If the latter, how long should I wait? – user12205 Jan 17 '14 at 20:23
• The statement states bytes, not characters. Converted to UTL-8, the APL solution made 61 bytes (70 for UTF-16). – Vi. Jan 17 '14 at 20:26
• You're claiming that Perl is not a language typically used for golfing, but it's the language which was first associated with the word golf! Ruby, at 56, looks like the real language A in the current answers to your questions. – Peter Taylor Jan 18 '14 at 10:44

Get two numbers from STDIN, and add them together. You have to support floating point numbers, so 0.5 + 1.5 has to equal 2.

## Perl 5 (with -E)

say<>+<>


## GolfScript

n%'+'*'"#{
}"'n/\*~

• Calculated score as (24+5)/(8+2+5) = 1.9(3). -E also counted as program bytes. – Vi. Jan 18 '14 at 13:15
• The same comment as I made to ace: you're claiming that Perl is not a language typically used for golfing, but it's the language which was first associated with the word golf! – Peter Taylor Jan 18 '14 at 13:55
• And your GolfScript program doesn't work. A working program would be n%'+'*'"#{ }"'n/\*~ where the character between {} is a literal newline (not supported in comments). – Peter Taylor Jan 18 '14 at 13:56
• @PeterTaylor, Compared with GolfScript, Perl is a "usual" language; compared with Java, it's a "golf" language. – Vi. Jan 18 '14 at 14:33
• The J for this isn't too bad, actually: +/".1!:1,~1. APL would probably be even smaller. – algorithmshark Mar 25 '14 at 23:55

# Print 'Hello, World!' to the stdout.

PHP, 13 bytes

Hello, World!


Golfscript, 15 bytes

'Hello, World!'


Pyth, 14 bytes

"Hello, World!

• Nicely topical. :) – AdmBorkBork Aug 28 '15 at 14:39
• New B: In HQ9+ H – Not that Charles Aug 28 '15 at 15:31
• But it's spelt incorrectly, @NotthatCharles – galexite Aug 28 '15 at 15:35
• @georgeunix Good point. You capitalized your "W". – Not that Charles Aug 28 '15 at 15:52

## Score 48/37 or 1.(297)

T: write a code snippet that ends the program after exactly one hour (as close as possible, like within a second) of running. Don't worry about exceptions, they can be unhandled.

A: Java (32)

Thread.sleep(3600000);int a=1/0;


B: is for Befunge 98, requires the TIME fingerprint (43)

"EMIT"4(HMS00p01p02p#;gS-!01gM-!H-!++3-!j;@


This takes the Hour, Minute, and Second at the time of running, and puts the at cells 02, 01, and 00. Then, it skips over the ; to the second part. The second part works as follows:

g          get the value at 00
"EMIT"4(S) get the current time in seconds
-!         subtracts the values and changes a 0 to 1, anything else to 0


similarly for the Minute and Hour.

++  sums up the values
3-! i the sum is 3, we get a 1, otherwise, we get a 0.
j   jump over the next that many cells
;   skip code execution until the next ;
@   end program


Note that Befunge will automatically go back to the beginning of the line when the end of a line is reached.

As we can see, Befunge is not good when it comes to waiting for specific times. However, Java is not bad.

• APL: ⎕DL 3600 – marinus Jan 17 '14 at 21:54
• Java usually reads as class Main{public static void main... – Vi. Jan 17 '14 at 22:00
• @Vi. see "code snippet". Basically, it requires the code that actually does the work, not more than that. – Justin Jan 17 '14 at 22:01
• I don't know Befunge, but the Java snippet doesn't "end the program" as required by the spec. That would require either a System.exit(0); or wrapping your sleep in a main method. – Peter Taylor Jan 18 '14 at 9:40
• @DoorknobofSnow Fails to compile: error: not a statement – Bob Jan 18 '14 at 14:12

# Output a certain text file (498.388888 points)

The goal output is here.

The Python 3.4.3 script to print it is 49 bytes:

for b in dir(__builtins__):print(eval(b).__doc__)


The naive CJam program equal to the goal output, by wrapping the output string in "..." and escaping each " that occurs in it, would be 26908 bytes.

• Very clever, though it may run afoul of the "specific languages" restriction (which is vague, admittedly). – BMac Aug 27 '15 at 21:34
• The closest rule is "avoid mentioning specific language". Python is not mentioned, but is clearly meaned. – Vi. Aug 28 '15 at 0:35
• Yeah, this answer is a bit tongue-in-cheek, I sort of just wanted to point out that the rule is sort of a slippery slope. Imagine if I had "mangled" the output more -- say, taking the SHA1 checksum of each docstring -- it would be very weird to claim "this garbled bunch of hex digits is too language-specific" :) – Lynn Aug 28 '15 at 17:23
• If I wanted to do a more "fair" answer, I'd probably use Mathematica. You can do a lot of extremely domain-specific things in it that would take thousands of bytes of CJam/Pyth/anything else. But sadly, I don't know the language. – Lynn Aug 28 '15 at 17:24
• Link to output is dead. – pppery Oct 19 '19 at 16:42

# Say "Hello world!" (50 / 26 ≈ 1.92)

Show a message box to say "Hello world!"

## JavaScript

alert('Hello world!')


In a browser with support for DOM Level 0+.

## Perl

use Win32;Win32::MsgBox('Hello world!','',48)


Running on ActivePerl with Win32::GUI.

• alert isn't inherently part of JS, and the GolfScript program is just a comment. – Peter Taylor Jan 26 '14 at 22:31
• I've changed the answer to use plain Perl. – Toothbrush Jan 27 '14 at 12:41

# Output "Hello world!" until user presses "q", 1.842 105/44 = 2.386

1. Print "Hello world!" (including newline).
2. The user presses a key, which is not echoed to the screen.
3. Repeat until the key pressed was "q".

## QBasic (52 39 characters)

1?"Hello world!":IF"q"<>INPUT$(1)THEN 1  Since posting my original answer, I discovered that I could turn off autoformatting in QB64. :^D With the line number and ? shortcut for PRINT, this looks rather like a ternary expression in C-like languages. First version: PRINT "Hello world!" IF INPUT$(1) <> "q" THEN RUN


## Perl 5 (100 characters)

while("q"ne$e){print"Hello world!\n";system"stty cbreak -echo";$e=getc;system"stty -cbreak echo";}


The above will only work on (certain?) UNIX systems (tested on Ubuntu 12.04). It's possible that one could go cross-platform and get it down to 91 characters using the Term::ReadKey module, but I haven't tested it:

use Term::ReadKey;while("q"ne$e){print"Hello world!\n";ReadMode 3;$e=ReadKey 0;ReadMode 0;}


# Hello, world (3 1/3 points)

Write program that outputs Hello World..

## HQ9+ (1 character)

This is not language "typically used for golfing", so I believe it fits here. Works in this interpreter, by the way.

H


## GolfScript (15 characters)

I doubt it can get any shorter, even if it's GolfScript.

"Hello World."

• I don't think HQ9+ suits as A language. It is designed for tricks/riddles/fun. Brainfuck/unlambda/other esoterical languages also does not seem to suit as A. – Vi. Jan 19 '14 at 21:02
• @Vi.: But it's not typically used for golfing. – Konrad Borowski Jan 19 '14 at 21:03
• You can hovewer try to use HQ9+ as B language and beat it by Java or such... – Vi. Jan 19 '14 at 21:03
• Looks like there's a hierarchy: Compared to Java, Perl's a golflang. Compared to Perl, GolfScript is a golflang. Compared to GolfScript, HQ9+ is a golflang... – Vi. Jan 19 '14 at 21:06
• @Vi.: I carefully checked your task description. HQ9+ is never used for golfing, except for two particular tasks - "99 bottles", and "Hello, world". Unless you can show some other task in which HQ9+ wins with any other programming language, I still think it fits the definition, even if it abuses it (hey, it's popularity-contest). HQ9+ is simply not used for golfing stuff not related to those two tasks. So, it's not typically used for golfing. The second is obviously designed for CodeGolf - it's GolfScript. – Konrad Borowski Jan 19 '14 at 21:09

## Output "Hello world!", 33/97 = 2.94

Write a program that outputs Hello world!

## Arduino or GML

Serial.print("Hello world!")


or

show_message("Hello world!")


Both are 28 characters.

## GTB

I use GTB for golfing a lot (especially since I created it myself, and it is Turing complete). Unfortunately, there is only limited support for lowercase characters (because TI-84 calculator can't deal with it). This is probably the shortest GTB program that can output Hello world!

S;"lower",1,1)→_~"H"+S;"expr(",1,1)+_+_+S;"cos(",2,1)+" W"+S;" or ",2,2)+_+S;" and ",4,1)+"!


92 characters.

• Does GTB version also output it to serial port? – Vi. Jan 20 '14 at 1:59
• Is GTB version intentionally bloated up with various coss and exprs or it genuintely can't just output something in regular way? Or " character is actually not a string literal and confusing me... – Vi. Jan 20 '14 at 2:01
• @Vi. It's not bloated up at all... it has to strip e from expr, two l from lower, o from cos, or from or, l from lower, and d from and. – Timtech Jan 20 '14 at 11:10
• 'Other users may propose better Bs (maybe including in other "golfy" languages). ' --- let me try golfscript: "Hello world!" – John Dvorak Apr 13 '14 at 9:01
• @JanDvorak You're probably right. – Timtech Apr 13 '14 at 22:00