parent
7eae065b61
commit
1890db68dd
@ -1,2 +1,3 @@
|
||||
java temurin-21.0.3+9.0.LTS
|
||||
maven 3.9.6
|
||||
pyton 3.13.3
|
||||
|
@ -0,0 +1,32 @@
|
||||
def do_foo():
|
||||
if n % 2 == 1:
|
||||
print('Weird')
|
||||
return
|
||||
if 1 < n < 6:
|
||||
print('Not Weird')
|
||||
if 5 < n < 12:
|
||||
print('Weird')
|
||||
if 19 < n:
|
||||
print('Not Weird')
|
||||
|
||||
|
||||
def log_base_10(n):
|
||||
if n == 0:
|
||||
return float('-inf') # Logarithm of 0 is undefined
|
||||
count = 0
|
||||
while n >= 1:
|
||||
n /= 10
|
||||
count += 1
|
||||
return count
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
n = 102
|
||||
out = 0
|
||||
for i in range(1, n + 1):
|
||||
power = (i // 10 + 1)
|
||||
|
||||
# print(i, i / 10, log_base_10(i), pow(10, log_base_10(i) - 1), pow(10, power))
|
||||
out = out * pow(10, log_base_10(i)) + i
|
||||
|
||||
print(out)
|
@ -0,0 +1,11 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.olexyn</groupId>
|
||||
<artifactId>field-kit</artifactId>
|
||||
<version>1.0</version>
|
||||
</parent>
|
||||
<artifactId>py-kit</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<!-- dummy -->
|
||||
</project>
|
@ -0,0 +1,20 @@
|
||||
def log_base_10(n):
|
||||
if n == 0:
|
||||
return float('-inf') # Logarithm of 0 is undefined
|
||||
count = 0
|
||||
while n >= 1:
|
||||
n /= 10
|
||||
count += 1
|
||||
return count
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
n = 102
|
||||
out = 0
|
||||
for i in range(1, n + 1):
|
||||
power = (i // 10 + 1)
|
||||
|
||||
# print(i, i / 10, log_base_10(i), pow(10, log_base_10(i) - 1), pow(10, power))
|
||||
out = out * pow(10, log_base_10(i)) + i
|
||||
|
||||
print(out)
|
Loading…
Reference in new issue