Skip to main content
Commonmark migration
Source Link

#JavaScript (ES6), 72 bytes

JavaScript (ES6), 72 bytes

f=x=>x%17^2?['doko ','zun '][j=Math.random()*2|0]+f(x<<7|j):'ki-yo-shi!' 

Try it online!

###How?

How?

We keep track of the last 5 words in a 32-bit integer stored in \$x\$ (which is initially undefined). At each iteration, we left-shift it by 7 positions and set the LSB to \$0\$ for doko or \$1\$ for zun.

The sequence zun, zun, zun, zun, doko results in:

x = 10000001000000100000010000000

or \$270549120\$ in decimal, which is the only value for which we have \$x\equiv 2\pmod{17}\$, as shown in this table. This is our halt condition.

#JavaScript (ES6), 72 bytes

f=x=>x%17^2?['doko ','zun '][j=Math.random()*2|0]+f(x<<7|j):'ki-yo-shi!' 

Try it online!

###How?

We keep track of the last 5 words in a 32-bit integer stored in \$x\$ (which is initially undefined). At each iteration, we left-shift it by 7 positions and set the LSB to \$0\$ for doko or \$1\$ for zun.

The sequence zun, zun, zun, zun, doko results in:

x = 10000001000000100000010000000

or \$270549120\$ in decimal, which is the only value for which we have \$x\equiv 2\pmod{17}\$, as shown in this table. This is our halt condition.

JavaScript (ES6), 72 bytes

f=x=>x%17^2?['doko ','zun '][j=Math.random()*2|0]+f(x<<7|j):'ki-yo-shi!' 

Try it online!

How?

We keep track of the last 5 words in a 32-bit integer stored in \$x\$ (which is initially undefined). At each iteration, we left-shift it by 7 positions and set the LSB to \$0\$ for doko or \$1\$ for zun.

The sequence zun, zun, zun, zun, doko results in:

x = 10000001000000100000010000000

or \$270549120\$ in decimal, which is the only value for which we have \$x\equiv 2\pmod{17}\$, as shown in this table. This is our halt condition.

added a link to a table
Source Link
Arnauld
  • 205.5k
  • 21
  • 187
  • 670

#JavaScript (ES6), 72 bytes

f=x=>x%17^2?['doko ','zun '][j=Math.random()*2|0]+f(x<<7|j):'ki-yo-shi!' 

Try it online!

###How?

We keep track of the last 5 words in a 32-bit integer stored in \$x\$ (which is initially undefined). At each iteration, we left-shift it by 7 positions and set the LSB to \$0\$ for doko or \$1\$ for zun.

The sequence zun, zun, zun, zun, doko results in:

x = 10000001000000100000010000000

or \$270549120\$ in decimal, which is the only value for which we have \$x\equiv 2\pmod{17}\$, as shown in this table. This is our halt condition.

#JavaScript (ES6), 72 bytes

f=x=>x%17^2?['doko ','zun '][j=Math.random()*2|0]+f(x<<7|j):'ki-yo-shi!' 

Try it online!

###How?

We keep track of the last 5 words in a 32-bit integer stored in \$x\$ (which is initially undefined). At each iteration, we left-shift it by 7 positions and set the LSB to \$0\$ for doko or \$1\$ for zun.

The sequence zun, zun, zun, zun, doko results in:

x = 10000001000000100000010000000

or \$270549120\$ in decimal, which is the only value for which we have \$x\equiv 2\pmod{17}\$. This is our halt condition.

#JavaScript (ES6), 72 bytes

f=x=>x%17^2?['doko ','zun '][j=Math.random()*2|0]+f(x<<7|j):'ki-yo-shi!' 

Try it online!

###How?

We keep track of the last 5 words in a 32-bit integer stored in \$x\$ (which is initially undefined). At each iteration, we left-shift it by 7 positions and set the LSB to \$0\$ for doko or \$1\$ for zun.

The sequence zun, zun, zun, zun, doko results in:

x = 10000001000000100000010000000

or \$270549120\$ in decimal, which is the only value for which we have \$x\equiv 2\pmod{17}\$, as shown in this table. This is our halt condition.

added an explanation
Source Link
Arnauld
  • 205.5k
  • 21
  • 187
  • 670

#JavaScript (ES6), 72 bytes

  
f=x=>x%17^2?['doko ','zun '][j=Math.random()*2|0]+f(x<<7|j):'ki-yo-shi!' 

Try it online!

###How?

We keep track of the last 5 words in a 32-bit integer stored in \$x\$ (which is initially undefined). At each iteration, we left-shift it by 7 positions and set the LSB to \$0\$ for doko or \$1\$ for zun.

The sequence zun, zun, zun, zun, doko results in:

x = 10000001000000100000010000000

or \$270549120\$ in decimal, which is the only value for which we have \$x\equiv 2\pmod{17}\$. This is our halt condition.

#JavaScript (ES6), 72 bytes

 
f=x=>x%17^2?['doko ','zun '][j=Math.random()*2|0]+f(x<<7|j):'ki-yo-shi!' 

Try it online!

#JavaScript (ES6), 72 bytes

 
f=x=>x%17^2?['doko ','zun '][j=Math.random()*2|0]+f(x<<7|j):'ki-yo-shi!' 

Try it online!

###How?

We keep track of the last 5 words in a 32-bit integer stored in \$x\$ (which is initially undefined). At each iteration, we left-shift it by 7 positions and set the LSB to \$0\$ for doko or \$1\$ for zun.

The sequence zun, zun, zun, zun, doko results in:

x = 10000001000000100000010000000

or \$270549120\$ in decimal, which is the only value for which we have \$x\equiv 2\pmod{17}\$. This is our halt condition.

Source Link
Arnauld
  • 205.5k
  • 21
  • 187
  • 670
Loading