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

Commonmark migration
Source Link

AWK - 11 bytes

##AWK - 11 bytes TheThe code:

{0ドル=1ドル+2ドル}1

Can run as:

awk '{0ドル=1ドル+2ドル}1' <<< "98.342 77.123"

Could also store the code in a file sum.awk and run as:

awk -f sum.awk <<< "98.342 77.123"

If you wanted a program that wouldn't require knowing that you were using awk, you could create a file sum that looks like:

#!/bin/awk -f
{0ドル=1ドル+2ドル}1

Assuming of course that the awk executable is located at /bin/awk. If this file is made executable, it could simply be run as:

 sum <<< "98.342 77.123"

or

echo "98.342 77.123" | sum

Or place the numbers in a file, DATA, and run as:

sum DATA

A tiny bit of explanation. 0ドル represents a single line of input that is also automatically split into numbered fields. This line is then overwritten by the assignment. The lone 1 acts as a label that always evaluates to true and its default action is to simply print the current 0ドル.

##AWK - 11 bytes The code:

{0ドル=1ドル+2ドル}1

Can run as:

awk '{0ドル=1ドル+2ドル}1' <<< "98.342 77.123"

Could also store the code in a file sum.awk and run as:

awk -f sum.awk <<< "98.342 77.123"

If you wanted a program that wouldn't require knowing that you were using awk, you could create a file sum that looks like:

#!/bin/awk -f
{0ドル=1ドル+2ドル}1

Assuming of course that the awk executable is located at /bin/awk. If this file is made executable, it could simply be run as:

 sum <<< "98.342 77.123"

or

echo "98.342 77.123" | sum

Or place the numbers in a file, DATA, and run as:

sum DATA

A tiny bit of explanation. 0ドル represents a single line of input that is also automatically split into numbered fields. This line is then overwritten by the assignment. The lone 1 acts as a label that always evaluates to true and its default action is to simply print the current 0ドル.

AWK - 11 bytes

The code:

{0ドル=1ドル+2ドル}1

Can run as:

awk '{0ドル=1ドル+2ドル}1' <<< "98.342 77.123"

Could also store the code in a file sum.awk and run as:

awk -f sum.awk <<< "98.342 77.123"

If you wanted a program that wouldn't require knowing that you were using awk, you could create a file sum that looks like:

#!/bin/awk -f
{0ドル=1ドル+2ドル}1

Assuming of course that the awk executable is located at /bin/awk. If this file is made executable, it could simply be run as:

 sum <<< "98.342 77.123"

or

echo "98.342 77.123" | sum

Or place the numbers in a file, DATA, and run as:

sum DATA

A tiny bit of explanation. 0ドル represents a single line of input that is also automatically split into numbered fields. This line is then overwritten by the assignment. The lone 1 acts as a label that always evaluates to true and its default action is to simply print the current 0ドル.

Corrected syntax flaw
Source Link
Robert Benson
  • 1.8k
  • 11
  • 13

##AWK - 11 bytes The code:

{0ドル=1ドル+2ドル}1

Can run as:

awk '{0ドル=1ドル+2ドル}1' <<< "98.342 77.123"

Could also store the code in a file sum.awk and run as:

awk -f sum.awk <<< "98.342 77.123"

If you wanted a program that wouldn't require knowing that you were using awk, you could create a file sum that looks like:

#!/bin/awk -f
{0ドル=1ドル+2ドル}1

Assuming of course that the awk executable is located at /bin/awk. If this file is made executable, it could simply be run as:

 sum 98<<< "98.342 77.123123"

or

echo "98.342 77.123" | sum

Or place the numbers in a file, DATA, and run as:

sum DATA

A tiny bit of explanation. 0ドル represents a single line of input that is also automatically split into numbered fields. This line is then overwritten by the assignment. The lone 1 acts as a label that always evaluates to true and its default action is to simply print the current 0ドル.

##AWK - 11 bytes The code:

{0ドル=1ドル+2ドル}1

Can run as:

awk '{0ドル=1ドル+2ドル}1' <<< "98.342 77.123"

Could also store the code in a file sum.awk and run as:

awk -f sum.awk <<< "98.342 77.123"

If you wanted a program that wouldn't require knowing that you were using awk, you could create a file sum that looks like:

#!/bin/awk -f
{0ドル=1ドル+2ドル}1

Assuming of course that the awk executable is located at /bin/awk. If this file is made executable, it could simply be run as:

 sum 98.342 77.123

A tiny bit of explanation. 0ドル represents a single line of input that is also automatically split into numbered fields. This line is then overwritten by the assignment. The lone 1 acts as a label that always evaluates to true and its default action is to simply print the current 0ドル.

##AWK - 11 bytes The code:

{0ドル=1ドル+2ドル}1

Can run as:

awk '{0ドル=1ドル+2ドル}1' <<< "98.342 77.123"

Could also store the code in a file sum.awk and run as:

awk -f sum.awk <<< "98.342 77.123"

If you wanted a program that wouldn't require knowing that you were using awk, you could create a file sum that looks like:

#!/bin/awk -f
{0ドル=1ドル+2ドル}1

Assuming of course that the awk executable is located at /bin/awk. If this file is made executable, it could simply be run as:

 sum <<< "98.342 77.123"

or

echo "98.342 77.123" | sum

Or place the numbers in a file, DATA, and run as:

sum DATA

A tiny bit of explanation. 0ドル represents a single line of input that is also automatically split into numbered fields. This line is then overwritten by the assignment. The lone 1 acts as a label that always evaluates to true and its default action is to simply print the current 0ドル.

Source Link
Robert Benson
  • 1.8k
  • 11
  • 13

##AWK - 11 bytes The code:

{0ドル=1ドル+2ドル}1

Can run as:

awk '{0ドル=1ドル+2ドル}1' <<< "98.342 77.123"

Could also store the code in a file sum.awk and run as:

awk -f sum.awk <<< "98.342 77.123"

If you wanted a program that wouldn't require knowing that you were using awk, you could create a file sum that looks like:

#!/bin/awk -f
{0ドル=1ドル+2ドル}1

Assuming of course that the awk executable is located at /bin/awk. If this file is made executable, it could simply be run as:

 sum 98.342 77.123

A tiny bit of explanation. 0ドル represents a single line of input that is also automatically split into numbered fields. This line is then overwritten by the assignment. The lone 1 acts as a label that always evaluates to true and its default action is to simply print the current 0ドル.

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