Skip to main content
deleted 2878 characters in body
Source Link
Martin Ender Mod
  • 198.2k
  • 14
  • 181
  • 311

#8: Shuffle an infinite listShuffle an infinite list

You should write a function or program which takes an infinite list as input and returns a shuffled version of that list.

About infinite I/O

There are several ways you can take input and produce output for this challenge:

  • You can either take a list of positive integers, or a string representation thereof, or a string or list of printable ASCII characters (0x20 to 0x7E, inclusive). The output format must match the input format. I'll just refer to the data as "the list" from now on, regardless of which option you choose.
  • You can read the list from an infinite standard input stream and write the output continuously to an infinite standard output stream. The solution should not depend on any particular value or sequence of values to ensure that the output stream is regularly written and flushed (e.g. you can't just write output whenever there's a 5 in the input list). Of course, if you read a string representation of a list, it's fine to wait until encountering the list separator.
  • In languages that support them, you can write a function that takes and returns a lazy infinite list or string.
  • In languages that support them you may implement an infinite generator that takes another generator as input.
  • Alternatively, you can write a function which takes no arguments and returns one output value each time it is called. In this case, you can assume that a function has been defined which takes no arguments and returns the next input value each time it is called. You may freely choose that function's name.

About the randomness

For any value v which is read at a position i of the infinite input, there must be a positive probability for it to end up in any of the positions i-9 to i+9 of the infinite output (unless that position would be negative). These probabilities don't have to be the same for different output positions or even for different input positions. It's fine if your solution can also shuffle the values to other position that are further away.

Hence, it's not necessary that your solution can shuffle the first value very far down the list, or that it can shuffle a very late value up to the first position, although it's fine if it does, as long as all positions 9 steps from the input are possible.

E.g. if you took the following string as input, the ___ indicates all the positions the X must be able to end up in the output:

 ___________________ abcdefghijklmnopqrstuvwxyzXabcdefghijklmnopqrstuvwxyz... 

If your language lacks a built-in random number generator, you may take an additional seed value as input.

Regardless of the actual distribution your solution uses, it must almost surely produce the next value after a finite (but arbitrary) time.

Scoring

This is , so the shortest valid answer – measured in bytes – wins.

#8: Shuffle an infinite list

You should write a function or program which takes an infinite list as input and returns a shuffled version of that list.

About infinite I/O

There are several ways you can take input and produce output for this challenge:

  • You can either take a list of positive integers, or a string representation thereof, or a string or list of printable ASCII characters (0x20 to 0x7E, inclusive). The output format must match the input format. I'll just refer to the data as "the list" from now on, regardless of which option you choose.
  • You can read the list from an infinite standard input stream and write the output continuously to an infinite standard output stream. The solution should not depend on any particular value or sequence of values to ensure that the output stream is regularly written and flushed (e.g. you can't just write output whenever there's a 5 in the input list). Of course, if you read a string representation of a list, it's fine to wait until encountering the list separator.
  • In languages that support them, you can write a function that takes and returns a lazy infinite list or string.
  • In languages that support them you may implement an infinite generator that takes another generator as input.
  • Alternatively, you can write a function which takes no arguments and returns one output value each time it is called. In this case, you can assume that a function has been defined which takes no arguments and returns the next input value each time it is called. You may freely choose that function's name.

About the randomness

For any value v which is read at a position i of the infinite input, there must be a positive probability for it to end up in any of the positions i-9 to i+9 of the infinite output (unless that position would be negative). These probabilities don't have to be the same for different output positions or even for different input positions. It's fine if your solution can also shuffle the values to other position that are further away.

Hence, it's not necessary that your solution can shuffle the first value very far down the list, or that it can shuffle a very late value up to the first position, although it's fine if it does, as long as all positions 9 steps from the input are possible.

E.g. if you took the following string as input, the ___ indicates all the positions the X must be able to end up in the output:

 ___________________ abcdefghijklmnopqrstuvwxyzXabcdefghijklmnopqrstuvwxyz... 

If your language lacks a built-in random number generator, you may take an additional seed value as input.

Regardless of the actual distribution your solution uses, it must almost surely produce the next value after a finite (but arbitrary) time.

Scoring

This is , so the shortest valid answer – measured in bytes – wins.

added 78 characters in body
Source Link
Martin Ender Mod
  • 198.2k
  • 14
  • 181
  • 311
  • You can either take a list of positive integers, or a string representation thereof, or a string or list of printable ASCII characters (0x20 to 0x7E, inclusive). The output format must match the input format. I'll just refer to the data as "the list" from now on, regardless of which option you choose.
  • You can read the list from an infinite standard input stream and write the output continuously to an infinite standard output stream. The solution should not depend on any particular inputvalue or sequence of values to ensure that the output stream is regularly written and flushed (e.g. you can't just write output whenever there's a 5 in the input list). Of course, if you read a string representation of a list, it's fine to wait until encountering the list separator.
  • In languages that support them, you can write a function that takes and returns a lazy infinite list or string and return the same.
  • In languages that support them you may implement an infinite generator that takes another generator as input.
  • Alternatively, you can write a function which takes no arguments and returns one output value each time it is called. In this case, you can assume that a function has been defined which takes no arguments and returns the next input value each time it is called. You may freely choose that function's name.
  • You can either take a list of positive integers, or a string representation thereof, or a string or list of printable ASCII characters (0x20 to 0x7E, inclusive). The output format must match the input format. I'll just refer to the data as "the list" from now on, regardless of which option you choose.
  • You can read the list from an infinite standard input stream and write the output continuously to an infinite standard output stream. The solution should not depend on any particular input to ensure that the output stream is regularly written and flushed.
  • In languages that support them, you can write a function that takes and returns a lazy infinite list or string and return the same.
  • In languages that support them you may implement an infinite generator that takes another generator as input.
  • Alternatively, you can write a function which takes no arguments and returns one output value each time it is called. In this case, you can assume that a function has been defined which takes no arguments and returns the next input value each time it is called. You may freely choose that function's name.
  • You can either take a list of positive integers, or a string representation thereof, or a string or list of printable ASCII characters (0x20 to 0x7E, inclusive). The output format must match the input format. I'll just refer to the data as "the list" from now on, regardless of which option you choose.
  • You can read the list from an infinite standard input stream and write the output continuously to an infinite standard output stream. The solution should not depend on any particular value or sequence of values to ensure that the output stream is regularly written and flushed (e.g. you can't just write output whenever there's a 5 in the input list). Of course, if you read a string representation of a list, it's fine to wait until encountering the list separator.
  • In languages that support them, you can write a function that takes and returns a lazy infinite list or string.
  • In languages that support them you may implement an infinite generator that takes another generator as input.
  • Alternatively, you can write a function which takes no arguments and returns one output value each time it is called. In this case, you can assume that a function has been defined which takes no arguments and returns the next input value each time it is called. You may freely choose that function's name.
added 2817 characters in body
Source Link
Martin Ender Mod
  • 198.2k
  • 14
  • 181
  • 311

#8: Shuffle an infinite list

You should write a function or program which takes an infinite list as input and returns a shuffled version of that list.

About infinite I/O

There are several ways you can take input and produce output for this challenge:

  • You can either take a list of positive integers, or a string representation thereof, or a string or list of printable ASCII characters (0x20 to 0x7E, inclusive). The output format must match the input format. I'll just refer to the data as "the list" from now on, regardless of which option you choose.
  • You can read the list from an infinite standard input stream and write the output continuously to an infinite standard output stream. The solution should not depend on any particular input to ensure that the output stream is regularly written and flushed.
  • In languages that support them, you can write a function that takes and returns a lazy infinite list or string and return the same.
  • In languages that support them you may implement an infinite generator that takes another generator as input.
  • Alternatively, you can write a function which takes no arguments and returns one output value each time it is called. In this case, you can assume that a function has been defined which takes no arguments and returns the next input value each time it is called. You may freely choose that function's name.

About the randomness

For any value v which is read at a position i of the infinite input, there must be a positive probability for it to end up in any of the positions i-9 to i+9 of the infinite output (unless that position would be negative). These probabilities don't have to be the same for different output positions or even for different input positions. It's fine if your solution can also shuffle the values to other position that are further away.

Hence, it's not necessary that your solution can shuffle the first value very far down the list, or that it can shuffle a very late value up to the first position, although it's fine if it does, as long as all positions 9 steps from the input are possible.

E.g. if you took the following string as input, the ___ indicates all the positions the X must be able to end up in the output:

 ___________________ abcdefghijklmnopqrstuvwxyzXabcdefghijklmnopqrstuvwxyz... 

If your language lacks a built-in random number generator, you may take an additional seed value as input.

Regardless of the actual distribution your solution uses, it must almost surely produce the next value after a finite (but arbitrary) time.

Scoring

This is , so the shortest valid answer – measured in bytes – wins.

Further ideas (still unordered):

Further ideas (still unordered):

#8: Shuffle an infinite list

You should write a function or program which takes an infinite list as input and returns a shuffled version of that list.

About infinite I/O

There are several ways you can take input and produce output for this challenge:

  • You can either take a list of positive integers, or a string representation thereof, or a string or list of printable ASCII characters (0x20 to 0x7E, inclusive). The output format must match the input format. I'll just refer to the data as "the list" from now on, regardless of which option you choose.
  • You can read the list from an infinite standard input stream and write the output continuously to an infinite standard output stream. The solution should not depend on any particular input to ensure that the output stream is regularly written and flushed.
  • In languages that support them, you can write a function that takes and returns a lazy infinite list or string and return the same.
  • In languages that support them you may implement an infinite generator that takes another generator as input.
  • Alternatively, you can write a function which takes no arguments and returns one output value each time it is called. In this case, you can assume that a function has been defined which takes no arguments and returns the next input value each time it is called. You may freely choose that function's name.

About the randomness

For any value v which is read at a position i of the infinite input, there must be a positive probability for it to end up in any of the positions i-9 to i+9 of the infinite output (unless that position would be negative). These probabilities don't have to be the same for different output positions or even for different input positions. It's fine if your solution can also shuffle the values to other position that are further away.

Hence, it's not necessary that your solution can shuffle the first value very far down the list, or that it can shuffle a very late value up to the first position, although it's fine if it does, as long as all positions 9 steps from the input are possible.

E.g. if you took the following string as input, the ___ indicates all the positions the X must be able to end up in the output:

 ___________________ abcdefghijklmnopqrstuvwxyzXabcdefghijklmnopqrstuvwxyz... 

If your language lacks a built-in random number generator, you may take an additional seed value as input.

Regardless of the actual distribution your solution uses, it must almost surely produce the next value after a finite (but arbitrary) time.

Scoring

This is , so the shortest valid answer – measured in bytes – wins.

Further ideas (still unordered):

replaced http://codegolf.stackexchange.com/ with https://codegolf.stackexchange.com/
Source Link
Loading
added 133 characters in body
Source Link
Martin Ender Mod
  • 198.2k
  • 14
  • 181
  • 311
Loading
deleted 8188 characters in body
Source Link
Martin Ender Mod
  • 198.2k
  • 14
  • 181
  • 311
Loading
deleted 10 characters in body
Source Link
Martin Ender Mod
  • 198.2k
  • 14
  • 181
  • 311
Loading
edited body
Source Link
Martin Ender Mod
  • 198.2k
  • 14
  • 181
  • 311
Loading
added 180 characters in body
Source Link
Martin Ender Mod
  • 198.2k
  • 14
  • 181
  • 311
Loading
added 15 characters in body
Source Link
Martin Ender Mod
  • 198.2k
  • 14
  • 181
  • 311
Loading
added 4948 characters in body
Source Link
Martin Ender Mod
  • 198.2k
  • 14
  • 181
  • 311
Loading
deleted 220 characters in body
Source Link
Martin Ender Mod
  • 198.2k
  • 14
  • 181
  • 311
Loading
added 64 characters in body
Source Link
Martin Ender Mod
  • 198.2k
  • 14
  • 181
  • 311
Loading
added 14 characters in body
Source Link
Martin Ender Mod
  • 198.2k
  • 14
  • 181
  • 311
Loading
added 3189 characters in body
Source Link
Martin Ender Mod
  • 198.2k
  • 14
  • 181
  • 311
Loading
deleted 308 characters in body
Source Link
Martin Ender Mod
  • 198.2k
  • 14
  • 181
  • 311
Loading
deleted 1985 characters in body
Source Link
Martin Ender Mod
  • 198.2k
  • 14
  • 181
  • 311
Loading
edited body
Source Link
Martin Ender Mod
  • 198.2k
  • 14
  • 181
  • 311
Loading
deleted 3637 characters in body
Source Link
Martin Ender Mod
  • 198.2k
  • 14
  • 181
  • 311
Loading
edited body
Source Link
Martin Ender Mod
  • 198.2k
  • 14
  • 181
  • 311
Loading
added 5959 characters in body
Source Link
Martin Ender Mod
  • 198.2k
  • 14
  • 181
  • 311
Loading
Mod Removes Wiki by Martin EnderMod
Post Made Community Wiki by Martin EnderMod
deleted 4735 characters in body
Source Link
Martin Ender Mod
  • 198.2k
  • 14
  • 181
  • 311
Loading
deleted 2 characters in body
Source Link
Martin Ender Mod
  • 198.2k
  • 14
  • 181
  • 311
Loading