Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

Return to Answer

added 241 characters in body
Source Link
PurkkaKoodari
  • 17.9k
  • 2
  • 37
  • 92

6(削除) 6 (削除ここまで) 7 languages, 32(削除) 32 (削除ここまで) 37 bytes, score 32(削除) 0.148... (削除ここまで) 37/673 ≈ 0.148148107872...

#+#7+!#@6"@\"6.@;n5
print(4--int(-3/2)#"
)

###Brainfuck-ng

+ increments current cell, ! prints as integer, @ exits. #'s and " are NOPs.

###Python 2

First line is comment. Using integer division, calculates 4 - -int(-3 / 2) = 4 - -int(-2) = 4 - -(-2) = 4 - 2 = 2 and prints the result.

###Python 3

Same as previous, but with float division. 4 - -int(-3 / 2) = 4 - -int(-1.5) = 4 - -(-1) = 4 - 1 = 3.

###Lua

-- starts a comment, and # on the first line is a comment, so basically print(4).

###><>

# reflects IP, 5 pushes 5, n prints a number and ; quits.

###Befunge

# skips over the +, ! logically negates the top of the stack, another #"@\" skipspushes the string @@\, 6 pushes 6, . prints a number and @ quits.

###Pyth

# starts an infinite loop, dismissing any errors. 7 prints 7, then follows +!"string") which basically causes an error for not having two operands for +, terminating the program.

6 languages, 32 bytes, score 32/63 ≈ 0.148148...

#+!#@6.@;n5
print(4--int(-3/2)
)

###Brainfuck-ng

+ increments current cell, ! prints as integer, @ exits. #'s are NOPs.

###Python 2

First line is comment. Using integer division, calculates 4 - -int(-3 / 2) = 4 - -int(-2) = 4 - -(-2) = 4 - 2 = 2 and prints the result.

###Python 3

Same as previous, but with float division. 4 - -int(-3 / 2) = 4 - -int(-1.5) = 4 - -(-1) = 4 - 1 = 3.

###Lua

-- starts a comment, and # on the first line is a comment, so basically print(4).

###><>

# reflects IP, 5 pushes 5, n prints a number and ; quits.

###Befunge

# skips over the +, ! logically negates the top of the stack, another # skips the @, 6 pushes 6, . prints a number and @ quits.

(削除) 6 (削除ここまで) 7 languages, (削除) 32 (削除ここまで) 37 bytes, score (削除) 0.148... (削除ここまで) 37/73 ≈ 0.107872...

#7+!"@\"6.@;n5
print(4--int(-3/2)#"
)

###Brainfuck-ng

+ increments current cell, ! prints as integer, @ exits. # and " are NOPs.

###Python 2

First line is comment. Using integer division, calculates 4 - -int(-3 / 2) = 4 - -int(-2) = 4 - -(-2) = 4 - 2 = 2 and prints the result.

###Python 3

Same as previous, but with float division. 4 - -int(-3 / 2) = 4 - -int(-1.5) = 4 - -(-1) = 4 - 1 = 3.

###Lua

-- starts a comment, and # on the first line is a comment, so basically print(4).

###><>

# reflects IP, 5 pushes 5, n prints a number and ; quits.

###Befunge

# skips over the +, ! logically negates the top of the stack, "@\" pushes the string @\, 6 pushes 6, . prints a number and @ quits.

###Pyth

# starts an infinite loop, dismissing any errors. 7 prints 7, then follows +!"string") which basically causes an error for not having two operands for +, terminating the program.

Source Link
PurkkaKoodari
  • 17.9k
  • 2
  • 37
  • 92

6 languages, 32 bytes, score 32/63 ≈ 0.148148...

#+!#@6.@;n5
print(4--int(-3/2)
)

###Brainfuck-ng

+ increments current cell, ! prints as integer, @ exits. #'s are NOPs.

###Python 2

First line is comment. Using integer division, calculates 4 - -int(-3 / 2) = 4 - -int(-2) = 4 - -(-2) = 4 - 2 = 2 and prints the result.

###Python 3

Same as previous, but with float division. 4 - -int(-3 / 2) = 4 - -int(-1.5) = 4 - -(-1) = 4 - 1 = 3.

###Lua

-- starts a comment, and # on the first line is a comment, so basically print(4).

###><>

# reflects IP, 5 pushes 5, n prints a number and ; quits.

###Befunge

# skips over the +, ! logically negates the top of the stack, another # skips the @, 6 pushes 6, . prints a number and @ quits.

AltStyle によって変換されたページ (->オリジナル) /