Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added a poker question #16

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions questions/Poker_game.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Pick a card

## Question

Welcome to **divine**! Here is the problem statement:

You are playing a poker game and the final round that could cost you millions of dollars is to pick a card from a list of cards which is arranged in ascending order that contains a number that is given to you in the shortest amount of time, which way would you take to pick that card and in the shortest amount of time possible so that you can cash out millions of dollars!!!!
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would rewrite this question. It isn't very clear on what it is asking. Why do you have to pick a card quickly?

Suggested change
You are playing a poker game and the final round that could cost you millions of dollars is to pick a card from a list of cards which is arranged in ascending order that contains a number that is given to you in the shortest amount of time, which way would you take to pick that card and in the shortest amount of time possible so that you can cash out millions of dollars!!!!
You are playing a card game. This final round could win you millions of dollars. You are given a card number and a list of cards. The list is in ascending order. Your task is to find the card number you are given in that list of cards in the shortest time possible. If you're too slow you will not win.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the change of framing @OfErosAngel suggested is a great idea. Poker is not usually done in this way so moving to just "a card game" makes this more intuitive.

18 changes: 18 additions & 0 deletions util/divine-quest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
def pick_a_card(list_cards, card_number):
mid = len(list_cards)//2
first_pos = 0
last_pos = len(list_cards)-1

while first_pos <= last_pos:
if list_cards[mid] > card_number:
last_pos = mid
new_cards = list_cards[first_pos,last_pos+1]
if mid == card_number:
return mid

else:
first_pos = mid
list_cards = list_cards[first_pos,last_pos+1]
if mid == card_number:
return mid