Skip to main content
Commonmark migration
Source Link

Python 3, 64 55 51 bytes

-9 bytes thanks to @ovs

lambda s:choice((s*2)[1:]+s[1])
from random import*

Try it online!


##Explanation

Explanation

random.choice() gets a random character of the String, while (s*2)[1:]+s[1] creates BCDABCDB for an input of ABCD, which has 1/8 As, 2/8 Cs, 2/8 Ds and 3/8 Bs.

Python 3, 64 55 51 bytes

-9 bytes thanks to @ovs

lambda s:choice((s*2)[1:]+s[1])
from random import*

Try it online!


##Explanation

random.choice() gets a random character of the String, while (s*2)[1:]+s[1] creates BCDABCDB for an input of ABCD, which has 1/8 As, 2/8 Cs, 2/8 Ds and 3/8 Bs.

Python 3, 64 55 51 bytes

-9 bytes thanks to @ovs

lambda s:choice((s*2)[1:]+s[1])
from random import*

Try it online!


Explanation

random.choice() gets a random character of the String, while (s*2)[1:]+s[1] creates BCDABCDB for an input of ABCD, which has 1/8 As, 2/8 Cs, 2/8 Ds and 3/8 Bs.

added 180 characters in body
Source Link
Mr. Xcoder
  • 42.5k
  • 9
  • 81
  • 214

Python 3, 64 55 51 bytes

-9 bytes thanks to @ovs

lambda s:choice((s*2)[1:]+s[1])
from random import*

Try it online!


##Explanation

random.choice() gets a random character of the String, while (s*2)[1:]+s[1] creates BCDABCDB for an input of ABCD, which has 1/8 As, 2/8 Cs, 2/8 Ds and 3/8 Bs.

Python 3, 64 55 51 bytes

-9 bytes thanks to @ovs

lambda s:choice((s*2)[1:]+s[1])
from random import*

Try it online!

Python 3, 64 55 51 bytes

-9 bytes thanks to @ovs

lambda s:choice((s*2)[1:]+s[1])
from random import*

Try it online!


##Explanation

random.choice() gets a random character of the String, while (s*2)[1:]+s[1] creates BCDABCDB for an input of ABCD, which has 1/8 As, 2/8 Cs, 2/8 Ds and 3/8 Bs.

added 180 characters in body
Source Link
Mr. Xcoder
  • 42.5k
  • 9
  • 81
  • 214

Python 3, 5564 55 51 bytes

-9 bytes thanks to @ovs

lambda s:choice((s[0]+s[1:]*3s*2)[[1:8]]+s[1])
from random import*

Try it online!


#Explanation

random.choice() picks a random character of the String, (s[0]+s[1:]*3)[:8] generates a new string with the following structure: ABCDBCDB, for an input of ABCD.Try it online!

Python 3, 55 bytes

-9 bytes thanks to @ovs

lambda s:choice((s[0]+s[1:]*3)[:8])
from random import*

Try it online!


#Explanation

random.choice() picks a random character of the String, (s[0]+s[1:]*3)[:8] generates a new string with the following structure: ABCDBCDB, for an input of ABCD.

Python 3, 64 55 51 bytes

-9 bytes thanks to @ovs

lambda s:choice((s*2)[1:]+s[1])
from random import*

Try it online!

added 180 characters in body
Source Link
Mr. Xcoder
  • 42.5k
  • 9
  • 81
  • 214
Loading
Post Undeleted by Mr. Xcoder
Post Deleted by Mr. Xcoder
added 180 characters in body
Source Link
Mr. Xcoder
  • 42.5k
  • 9
  • 81
  • 214
Loading
Post Undeleted by Mr. Xcoder
Post Deleted by Mr. Xcoder
Source Link
Mr. Xcoder
  • 42.5k
  • 9
  • 81
  • 214
Loading