Skip to main content
deleted 912 characters in body
Source Link
Seggan
  • 6.6k
  • 8
  • 22

Repeat List Until LongerRepeat List Until Longer

The Challenge

The challenge is simple: given an input list a and another list b, repeat a until it is longer than b. Call the repeated list ra. Then the following condition must hold true: len(b) < len(ra) <= len(b) + len(a). That is, a must not be repeated more than is required.

Sample Python Implementation

def repeat(a, b):
    ra = a.copy()
    while len(b) >= len(ra):
        ra += a
    return ra

Try it online!

Examples

[1,2,3] [2,4] -> [1,2,3]
[1,2,3] [2,3,4] -> [1,2,3,1,2,3]
[1,2,3] [18,26,43,86] -> [1,2,3,1,2,3]
[2,3,5] [1,2,3,4,5,6,7] -> [2,3,5,2,3,5,2,3,5]

Scoring

This is , shortest answer in bytes wins. Have fun!

Repeat List Until Longer

The Challenge

The challenge is simple: given an input list a and another list b, repeat a until it is longer than b. Call the repeated list ra. Then the following condition must hold true: len(b) < len(ra) <= len(b) + len(a). That is, a must not be repeated more than is required.

Sample Python Implementation

def repeat(a, b):
    ra = a.copy()
    while len(b) >= len(ra):
        ra += a
    return ra

Try it online!

Examples

[1,2,3] [2,4] -> [1,2,3]
[1,2,3] [2,3,4] -> [1,2,3,1,2,3]
[1,2,3] [18,26,43,86] -> [1,2,3,1,2,3]
[2,3,5] [1,2,3,4,5,6,7] -> [2,3,5,2,3,5,2,3,5]

Scoring

This is , shortest answer in bytes wins. Have fun!

edited body
Source Link
Seggan
  • 6.6k
  • 8
  • 22

Repeat List Until Longer

The Challenge

The challenge is simple: given an input list a and another list b, repeat a until it is longer than b. Call the repeated list ra. Then the following condition must hold true: len(b) < len(ra) <= len(b) + len(a). That is, a must not be repeated more than is required.

Sample Python Implementation

def repeat(a, b):
    ra = a.copy()
    while len(b) >= len(ra):
        ra += a
    return ra

Try it online!

Examples

[1,2,3] [2,4] -> [1,2,3]
[1,2,3] [2,3,4] -> [1,2,3,1,2,3]
[1,2,3] [18,26,43,86] -> [1,2,3,1,2,3]
[2,3,5] [1,2,3,4,5,6,7] -> [1,2[2,3,15,2,3,15,2,3]3,5]

Scoring

This is , shortest answer in bytes wins. Have fun!

Repeat List Until Longer

The Challenge

The challenge is simple: given an input list a and another list b, repeat a until it is longer than b. Call the repeated list ra. Then the following condition must hold true: len(b) < len(ra) <= len(b) + len(a). That is, a must not be repeated more than is required.

Sample Python Implementation

def repeat(a, b):
    ra = a.copy()
    while len(b) >= len(ra):
        ra += a
    return ra

Try it online!

Examples

[1,2,3] [2,4] -> [1,2,3]
[1,2,3] [2,3,4] -> [1,2,3,1,2,3]
[1,2,3] [18,26,43,86] -> [1,2,3,1,2,3]
[2,3,5] [1,2,3,4,5,6,7] -> [1,2,3,1,2,3,1,2,3]

Scoring

This is , shortest answer in bytes wins. Have fun!

Repeat List Until Longer

The Challenge

The challenge is simple: given an input list a and another list b, repeat a until it is longer than b. Call the repeated list ra. Then the following condition must hold true: len(b) < len(ra) <= len(b) + len(a). That is, a must not be repeated more than is required.

Sample Python Implementation

def repeat(a, b):
    ra = a.copy()
    while len(b) >= len(ra):
        ra += a
    return ra

Try it online!

Examples

[1,2,3] [2,4] -> [1,2,3]
[1,2,3] [2,3,4] -> [1,2,3,1,2,3]
[1,2,3] [18,26,43,86] -> [1,2,3,1,2,3]
[2,3,5] [1,2,3,4,5,6,7] -> [2,3,5,2,3,5,2,3,5]

Scoring

This is , shortest answer in bytes wins. Have fun!

Source Link
Seggan
  • 6.6k
  • 8
  • 22

Repeat List Until Longer

The Challenge

The challenge is simple: given an input list a and another list b, repeat a until it is longer than b. Call the repeated list ra. Then the following condition must hold true: len(b) < len(ra) <= len(b) + len(a). That is, a must not be repeated more than is required.

Sample Python Implementation

def repeat(a, b):
    ra = a.copy()
    while len(b) >= len(ra):
        ra += a
    return ra

Try it online!

Examples

[1,2,3] [2,4] -> [1,2,3]
[1,2,3] [2,3,4] -> [1,2,3,1,2,3]
[1,2,3] [18,26,43,86] -> [1,2,3,1,2,3]
[2,3,5] [1,2,3,4,5,6,7] -> [1,2,3,1,2,3,1,2,3]

Scoring

This is , shortest answer in bytes wins. Have fun!