Penney's game: Difference between revisions
Added 11l
(→{{header|Common Lisp}}: Add implementation) |
Alextretyak (talk | contribs) (Added 11l) |
||
Line 29:
* [https://www.youtube.com/watch?v=U9wak7g5yQA The Penney Ante Part 2] (Video).
<br><br>
=={{header|11l}}==
{{trans|Python}}
<lang 11l>V first = random:choice([1B, 0B])
V you = ‘’
V me = ‘’
V ht = ‘HT’ // to get round ‘bug in MSVC 2017’[https://developercommunity.visualstudio.com/t/bug-with-operator-in-c/565417]
I first
me = random:sample(Array(‘HT’ * 3), 3).join(‘’)
print(‘I choose first and will win on first seeing #. in the list of tosses’.format(me))
L you.len != 3 | any(you.map(ch -> ch !C :ht)) | you == me
you = input(‘What sequence of three Heads/Tails will you win with: ’)
E
L you.len != 3 | any(you.map(ch -> ch !C :ht))
you = input(‘After you: What sequence of three Heads/Tails will you win with: ’)
me = (I you[1] == ‘T’ {‘H’} E ‘T’)‘’you[0.<2]
print(‘I win on first seeing #. in the list of tosses’.format(me))
print("Rolling:\n ", end' ‘’)
V rolled = ‘’
L
rolled ‘’= random:choice(‘HT’)
print(rolled.last, end' ‘’)
I rolled.ends_with(you)
print("\n You win!")
L.break
I rolled.ends_with(me)
print("\n I win!")
L.break
sleep(1)</lang>
{{out}}
<pre>
I choose first and will win on first seeing THH in the list of tosses
What sequence of three Heads/Tails will you win with: THT
Rolling:
THT
You win!
</pre>
=={{header|AutoHotkey}}==
Line 112 ⟶ 153:
return
;-----------------------------------------------</lang>
=={{header|BASIC}}==
|