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

Jelly, 6 bytes

żSṀE?€

A dyadic link taking a list of numbers on each side and returning the resulting list.

Try it online! or see a test-suite*.

How?

żSṀE?€ - Link: list of numbers L, list of numbers R e.g. [1,3,3.2,2.3], [3,1,3.2,2.6]
ż - zip - interleave L & R [[1,3],[3,1],[3.2,3.2],[2.3,2.6]]
 € - for each pair:
 ? - { if:
 E - ...condition: equal 0 0 1 0
 S - ...then: sum 6.4
 Ṁ - ...else: maximum 3 3 2.6
 - } ... -> [3 ,3 ,6.4 ,2.6]

An alternative is this monadic link taking a list of the two lists, also 6 bytes:

+»=?"/

* I don't think I've ever created a test-suite footer almost three times the byte count of the code before!

Jelly, 6 bytes

żSṀE?€

A dyadic link taking a list of numbers on each side and returning the resulting list.

Try it online! or see a test-suite*.

How?

żSṀE?€ - Link: list of numbers L, list of numbers R e.g. [1,3,3.2,2.3], [3,1,3.2,2.6]
ż - zip - interleave L & R [[1,3],[3,1],[3.2,3.2],[2.3,2.6]]
 € - for each pair:
 ? - { if:
 E - ...condition: equal 0 0 1 0
 S - ...then: sum 6.4
 Ṁ - ...else: maximum 3 3 2.6
 - } ... -> [3 ,3 ,6.4 ,2.6]

An alternative is this monadic link taking a list of the two lists, also 6 bytes:

+»=?"/

* I don't think I've ever created a test-suite footer almost three times the byte count of the code before!

Jelly, 6 bytes

żSṀE?€

A dyadic link taking a list of numbers on each side and returning the resulting list.

Try it online! or see a test-suite*.

How?

żSṀE?€ - Link: list of numbers L, list of numbers R e.g. [1,3,3.2,2.3], [3,1,3.2,2.6]
ż - zip - interleave L & R [[1,3],[3,1],[3.2,3.2],[2.3,2.6]]
 € - for each pair:
 ? - { if:
 E - ...condition: equal 0 0 1 0
 S - ...then: sum 6.4
 Ṁ - ...else: maximum 3 3 2.6
 - } ... -> [3 ,3 ,6.4 ,2.6]

An alternative is this monadic link taking a list of the two lists, also 6 bytes:

+»=?"/

* I don't think I've ever created a test-suite footer almost three times the byte count of the code before!

added 225 characters in body
Source Link
Jonathan Allan
  • 115.4k
  • 8
  • 68
  • 293

Jelly, 6 bytes

żSṀE?€

A dyadic link taking a list of numbers on each side and returning the resulting list.

Try it online! or see a test-suite*.

How?

żSṀE?€ - Link: list of numbers L, list of numbers R e.g. [1,3,3.2,2.3], [3,1,3.2,2.6]
ż - zip - interleave L & R [[1,3],[3,1],[3.2,3.2],[2.3,2.6]]
 € - for each pair:
 ? - { if:
 E - ...condition: equal 0 0 1 0
 S - ...then: sum 6.4
 Ṁ - ...else: maximum 3 3 2.6
 - } ... -> [3 ,3 ,6.4 ,2.6]

An alternative is this monadic link taking a list of the two lists, also 6 bytes:

+»=?"/

* I don't think I've ever created a test-suite footer almost three times the byte count of the code before!

Jelly, 6 bytes

żSṀE?€

A dyadic link taking a list of numbers on each side and returning the resulting list.

Try it online! or see a test-suite*.

How?

żSṀE?€ - Link: list of numbers L, list of numbers R e.g. [1,3,3.2,2.3], [3,1,3.2,2.6]
ż - zip - interleave L & R [[1,3],[3,1],[3.2,3.2],[2.3,2.6]]
 € - for each pair:
 ? - { if:
 E - ...condition: equal 0 0 1 0
 S - ...then: sum 6.4
 Ṁ - ...else: maximum 3 3 2.6
 - } ... -> [3 ,3 ,6.4 ,2.6]

* I don't think I've ever created a test-suite footer almost three times the byte count of the code before!

Jelly, 6 bytes

żSṀE?€

A dyadic link taking a list of numbers on each side and returning the resulting list.

Try it online! or see a test-suite*.

How?

żSṀE?€ - Link: list of numbers L, list of numbers R e.g. [1,3,3.2,2.3], [3,1,3.2,2.6]
ż - zip - interleave L & R [[1,3],[3,1],[3.2,3.2],[2.3,2.6]]
 € - for each pair:
 ? - { if:
 E - ...condition: equal 0 0 1 0
 S - ...then: sum 6.4
 Ṁ - ...else: maximum 3 3 2.6
 - } ... -> [3 ,3 ,6.4 ,2.6]

An alternative is this monadic link taking a list of the two lists, also 6 bytes:

+»=?"/

* I don't think I've ever created a test-suite footer almost three times the byte count of the code before!

added 295 characters in body
Source Link
Jonathan Allan
  • 115.4k
  • 8
  • 68
  • 293

Jelly, 6 bytes

żSṀE?€

A dyadic link taking a list of numbers on each side and returning the resulting list.

Try it online! or see a test-suite*.

How?

żSṀE?€ - Link: list of numbers L, list of numbers R e.g. [1,3,3.2,2.3], [3,1,3.2,2.6]
ż - zip - interleave L & R [[1,3],[3,1],[3.2,3.2],[2.3,2.6]]
 € - for each pair:
 ? - { if:
 E - ...condition: equal 0 0 1 0
 S - ...then: sum 6.4
 Ṁ - ...else: maximum 3 3 2.6
 - } ... -> [3 ,3 ,6.4 ,2.6]

* I don't think I've ever created a test-suite footer almost three times the byte count of the code before!

Jelly, 6 bytes

żSṀE?€

Try it online! or see a test-suite*.


* I don't think I've ever created a test-suite footer almost three times the byte count of the code before!

Jelly, 6 bytes

żSṀE?€

A dyadic link taking a list of numbers on each side and returning the resulting list.

Try it online! or see a test-suite*.

How?

żSṀE?€ - Link: list of numbers L, list of numbers R e.g. [1,3,3.2,2.3], [3,1,3.2,2.6]
ż - zip - interleave L & R [[1,3],[3,1],[3.2,3.2],[2.3,2.6]]
 € - for each pair:
 ? - { if:
 E - ...condition: equal 0 0 1 0
 S - ...then: sum 6.4
 Ṁ - ...else: maximum 3 3 2.6
 - } ... -> [3 ,3 ,6.4 ,2.6]

* I don't think I've ever created a test-suite footer almost three times the byte count of the code before!

added 295 characters in body
Source Link
Jonathan Allan
  • 115.4k
  • 8
  • 68
  • 293
Loading
Source Link
Jonathan Allan
  • 115.4k
  • 8
  • 68
  • 293
Loading

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