Hi, I need help in solving Python programming problem below:



Thank you.
Best Regards
Answer: I am posting code and its outputs. Please comment in case of any modifications.
def fun(n,k):
allin = 0
d1 = dict()
while(1):
if n==2:
d1[n] = "he bet 1"
break
if n%2==0 and allin<k:
d1[n] = "all in"
allin+=1
n=int(n/2)
else:
d1[n] = "he bet 1"
n-=1
print("at the beginning: 1\n")
count=1
for key in sorted(d1):
if count%10==2:
temp = str(count)+"nd"
elif count%10==3:
temp = str(count)+"rd"
elif count==1:
temp = str(count)+"st"
else:
temp = str(count)+"th"
print("After {} round: {} ({})".format(temp,key,d1[key]))
count+=1
print("\nHe played all-in {} times".format(allin))
print("Enter N and K: ")
a = [int(x) for x in input().split()]
fun(a[0],a[1])
Code Pic:
Output:

public class Solution3
{
public int solution(int N, int K)
{
int n=N;
int k=K;
int rounds=0;
System.out.println(n);
while ( n>1 )
{
if (n % 2 == 0 && k>0)
{
n >>= 1;
k--;
}
else
{
n--;
}
System.out.println(n);
rounds++;
}
return rounds;
}Hi, I need help in solving Python programming problem below: Thank you. Best Regards When John...
Problem Statement: A company intends to offer various versions of roulette game and it wants you to develop a customized object-oriented software solution. This company plans to offer one version 100A now (similar to the simple version in project 2 so refer to it for basic requirements, but it allows multiple players and multiple games) and it is planning to add several more versions in the future. Each game has a minimum and maximum bet and it shall be able...
In need of some help with a LCR C++ game. The code will run, but I need it to cycle through the turns automatically so that the only input from the user is the number of players. It's also showing the winner as the person with 0 chips which is incorrect and I can't figure out why. Any help is greatly appreciated as this is already late. Game rules: Develop a program that follows the rules of Left Center Right...
Hi, I have programming problem related to array, sorting, and.
swap operation
Thank you,
Best Regards..
A non-empty array A consisting of N integers is given. You can perform a single swap operation in array A. This operation takes two indices I and J, such that 0 S13 J<N, and exchanges the values of A[i] and A[J]. The goal is to check whether array A can be sorted into non-decreasing order by performing at most one swap operation. For example,...
Please i need helpe with this JAVA code. Write a Java program simulates the dice game called GAMECrap. For this project, assume that the game is being played between two players, and that the rules are as follows: Problem Statement One of the players goes first. That player announces the size of the bet, and rolls the dice. If the player rolls a 7 or 11, it is called a natural. The player who rolled the dice wins. 2, 3...
"Blackjack 40" my teacher created this assignment and I need help. He is using c++ and has provided this template: Further instructions are below the template! #include <iostream> #include <cmath> #include <cstdlib> using namespace std; //Will return a number from 1 to 13, representing the face of a card int draw_card() { return rand() % 13 + 1; } int main() { const int BET = 10; //This will allow you to control chance, to make testing easier cout <<...
I really need help with this python programming assignment Program Requirements For part 2, i need the following functions • get floats(): It take a single integer argument and returns a list of floats. where it was something like this def get_floats(n): lst = [] for i in range(1,n+1): val = float(input('Enter float '+str(i)+': ')) lst.append(val) return lst • summer(): This non-void function takes a single list argument, and returns the sum of the list. However, it does not use...
please use python and provide run result, thank you!
click on pic to make it bigger
For this assignment you will have to investigate the use of the Python random library's random generator function, random.randrange(stop), randrange produces a random integer in the range of 0 to stop-1. You will need to import random at the top of your program. You can find this in the text or using the online resources given in the lectures A Slot Machine Simulation Understand...
Python 3.7 Card Game: In this assignment you will be creating ‘card game’ with specific rules. Rules of the game are fairly simple. The game will be played with 3 players, two AI players and 1 Human player. Rules of the game: 1- Will have 3 players (2 AI, and 1 Human player). 2- The cards we have for this game is three ones (1), three twos (2), and three three’s (3). 3- Need to shuffle the cards randomly so...
1) Echo the input: First, you should make sure you can write a program and have it compile and run, take input and give output. So to start you should just echo the input. This means you should prompt the user for the plaintext, read it in and then print it back out, with a message such as "this is the plaintext you entered:". [4 points, for writing a working program, echoing the input and submitting the program on the...
1) Let x be a continuous random variable that is normally distributed with a mean of 21 and a standard deviation of 7. Find to 4 decimal places the probability that x assumes a value a. between 24 and 30. Probability = b. between 17 and 31. Probability = ------------------------------------------------------------------------------------------------------------------------------------------------------ 2) Let x be a continuous random variable that is normally distributed with a mean of 65 and a standard deviation of 15. Find the probability that x assumes a...