We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Counter game
Counter game
Sort by
recency
|
402 Discussions
|
Please Login in order to post a comment
!/bin/python3
import math import os import random import re import sys
#
Complete the 'maximumClusterQuality' function below.
#
The function is expected to return a LONG_INTEGER.
The function accepts following parameters:
1. INTEGER_ARRAY speed
2. INTEGER_ARRAY reliability
3. INTEGER maxMachines
#
def maximumClusterQuality(speed, reliability, maxMachines): from itertools import combinations
if name == 'main': speed = [3, 6, 1, 3, 4] reliability = [2, 1, 3, 4, 5] maxMachines = 3 print(maximumClusterQuality(speed, reliability, maxMachines))
def maximumClusterQuality(speed, reliability, maxMachines): from itertools import combinations
if name == 'main': speed = [3, 6, 1, 3, 4] reliability = [2, 1, 3, 4, 5] maxMachines = 3 print(maximumClusterQuality(speed, reliability, maxMachines))
link bhejo
TS Solution
function counterGame(n: number): string { let turns = 0; while (n > 1) { // If
n
is a power of 2, right-shift it by 1 (divide by 2) if ((n & (n - 1)) === 0) { n >>= 1; //console.log(bit shifting right. dividing by two
) } else { // Ifn
is not a power of 2, subtract the largest power of 2 less thann
let nBigInt = BigInt(n); let binary = nBigInt.toString(2);}
Python 3 - broke it up into 2 functions for readability