Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

151 - Power Crisis solution

def power_crisis(n,k):
    if n == 1:
        return 1
    else:
        return (power_crisis(n-1,k)+k-1)%n+1

while True:
    n = int(input())
    if n == 0:
        break
    i = 1
    while power_crisis(n-1,i) != 12:
        i += 1
    print(i)
Comment

PREVIOUS NEXT
Code Example
Python :: 151 uva problem solution 
Python :: change a coolumn datatype in pandas 
Python :: def total_missing(df,column_name) 
Python :: Merge 2 or more notebooks into one 
Python :: Python Print Variable Using the f-string in the print statement 
Python :: turtle screen 
Python :: pdfs in django 
Python :: get all subarrays of an array python 
Python :: how to extract keys from dictreader python 
Python :: python toupls 
Python :: np.array_equal 
Python :: speech to text function in python 
Python :: lambda example python 
Python :: Write a simple python program that adds 2 numbers togethe 
Python :: python json nan 
Python :: python casting float to int 
Python :: python create pem file 
Python :: rank function in pandas 
Python :: installing intel-numpy 
Python :: random forest classifier classification report 
Python :: compare dates in python 
Python :: set method in python 
Python :: install python 3.4 mac terminal 
Python :: 12 month movinf average in python for dataframe 
Python :: django form action 
Python :: geopandas change column name 
Python :: all combinations 
Python :: if-else Conditional Statement in Python 
Python :: date to timestamp python 
Python :: retry on exception python 
ADD CONTENT
Topic
Content
Source link
Name
8+2 =