Post Closed as "duplicate" by betseg, dzaima, ბიმო, Stephen Leppik, H.PWiz of
    Notice removed Reward existing answer by msh210
    Bounty Ended with Ton Hospel's answer chosen by msh210
    Notice added Reward existing answer by msh210
    Bounty Started worth 50 reputation by msh210
3 deleted 64 characters in body
source | link

The rules are as follows:

  • Take in a string of integers separated by spaces. Add the first and last numbers, the second and second-last numbers, and so on.
  • The program must output the numbers separated by newlines.
  • The program must handle negative numbers, but may not handle decimals.
  • If an odd amount of integers are inputted, just print the lone integer at the end.
  • This is code golf, fewest bytes wins.

Here are some test cases:

> input
output
more output
etc.
-------------------
> 2 2
4

> 1 2 3 4 5 6
7
7
7

> 3 4 2 6
9
6

> 1 2 3 4 5
6
6
3

> -5 3 -8 2
-3
-5

EDIT: Loosened some requirements, can I have my rep back ;-;

The rules are as follows:

  • Take in a string of integers separated by spaces. Add the first and last numbers, the second and second-last numbers, and so on.
  • The program must output the numbers separated by newlines.
  • The program must handle negative numbers, but may not handle decimals.
  • If an odd amount of integers are inputted, just print the lone integer at the end.
  • This is code golf, fewest bytes wins.

Here are some test cases:

> input
output
more output
etc.
-------------------
> 2 2
4

> 1 2 3 4 5 6
7
7
7

> 3 4 2 6
9
6

> 1 2 3 4 5
6
6
3

> -5 3 -8 2
-3
-5

EDIT: Loosened some requirements, can I have my rep back ;-;

The rules are as follows:

  • Take in a string of integers separated by spaces. Add the first and last numbers, the second and second-last numbers, and so on.
  • The program must output the numbers separated by newlines.
  • The program must handle negative numbers, but may not handle decimals.
  • If an odd amount of integers are inputted, just print the lone integer at the end.
  • This is code golf, fewest bytes wins.

Here are some test cases:

> input
output
more output
etc.
-------------------
> 2 2
4

> 1 2 3 4 5 6
7
7
7

> 3 4 2 6
9
6

> 1 2 3 4 5
6
6
3

> -5 3 -8 2
-3
-5
    Tweeted twitter.com/StackCodeGolf/status/975920492359102464
2 Loosened some requirements, can I have my rep back ;-;
source | link

The rules are as follows:

  • Take in a standard inputstring of integers and addseparated by spaces. Add the first and last numbers, the second and second-last numbers, and so on.
  • The program must output the numbers separated by spaces all on one linenewlines.
  • The program must handle negative numbers, but may not handle decimals.
  • If an odd amount of integers are inputted, just print the lone integer at the end.
  • The program must deal with invalid input. If a non-integer is inputted, the program must exit without printing anything.
  • This is code golf, fewest bytes wins.

Here are some test cases:

"input" -> "output"input
output
more output
etc.
-------------------
"2> 2"2 -2
4

> "4"
"11 2 3 4 5 6" -> "7 6
7 7"
"37
7

> 3 4 2 6" -6
9
6

> "9 6"
"11 2 3 4 5"5
6
6
3

> ->5 "73 7-8 3"2
"one two wait these are strings" -> ""3
"3.14 6.28" -> ""5

EDIT: Loosened some requirements, can I have my rep back ;-;

The rules are as follows:

  • Take in a standard input of integers and add the first and last numbers, the second and second-last numbers, and so on.
  • The program must output the numbers separated by spaces all on one line.
  • If an odd amount of integers are inputted, just print the lone integer at the end.
  • The program must deal with invalid input. If a non-integer is inputted, the program must exit without printing anything.
  • This is code golf, fewest bytes wins.

Here are some test cases:

"input" -> "output"
-------------------
"2 2" -> "4"
"1 2 3 4 5 6" -> "7 7 7"
"3 4 2 6" -> "9 6"
"1 2 3 4 5" -> "7 7 3"
"one two wait these are strings" -> ""
"3.14 6.28" -> ""

The rules are as follows:

  • Take in a string of integers separated by spaces. Add the first and last numbers, the second and second-last numbers, and so on.
  • The program must output the numbers separated by newlines.
  • The program must handle negative numbers, but may not handle decimals.
  • If an odd amount of integers are inputted, just print the lone integer at the end.
  • This is code golf, fewest bytes wins.

Here are some test cases:

> input
output
more output
etc.
-------------------
> 2 2
4

> 1 2 3 4 5 6
7
7
7

> 3 4 2 6
9
6

> 1 2 3 4 5
6
6
3

> -5 3 -8 2
-3
-5

EDIT: Loosened some requirements, can I have my rep back ;-;

1
source | link

Add Rainbow Pairs

The rules are as follows:

  • Take in a standard input of integers and add the first and last numbers, the second and second-last numbers, and so on.
  • The program must output the numbers separated by spaces all on one line.
  • If an odd amount of integers are inputted, just print the lone integer at the end.
  • The program must deal with invalid input. If a non-integer is inputted, the program must exit without printing anything.
  • This is code golf, fewest bytes wins.

Here are some test cases:

"input" -> "output"
-------------------
"2 2" -> "4"
"1 2 3 4 5 6" -> "7 7 7"
"3 4 2 6" -> "9 6"
"1 2 3 4 5" -> "7 7 3"
"one two wait these are strings" -> ""
"3.14 6.28" -> ""