.2 - GKS Round B 2022 - 04.23.2022

Hey! I participated in Google's Kickstart coding competition today. I was not able to attend for most of it due to another activity that I had to attend to. However, I was able to solve the first two questions w/ Python. Optimized code as well as Java ports of the code will be available soon.

INFINITY AREA (PY)

import sys
import math

rounds = int(input())

for i in range(1, rounds+1):
	R, A, B = [int(s) for s in input().split(" ")]

	res = 0
	dir = 0

	while R > 0:
		if dir % 2 == 0:
			if res != 0: # everything else right
				R = R//B
			res += (R**2)*math.pi # first

		else:
			R = R*A # left
			res += (R**2)*math.pi
		dir += 1

	print("Case #{}: {}".format(i, res))

PALINDROMIC FACTORS (PY)

import sys
import math

rounds = int(input())

for i in range(1, rounds+1):
	factors = []
	res = 0

	A = int(input())

	# get factors
	# use a more efficient but still kinda brute force method
	# O(sqrt(n))

	iter = 1
	while iter**2 <= A:
		if A % iter == 0:
			factors.append(iter)

			if A//iter != iter:
				factors.append(A//iter)
		iter += 1

	# palin?
	for k in factors:
		k = str(k)
		if k == k[::-1]:
			res += 1
	
	
	print("Case #{}: {}".format(i, res))

Obviously, the comments were added in later and I cleaned up how the code looked in order for presentation. I feel like there was certainly a better way to find the factors, but for now this solution works.


Contact me!

DISCORD: justanotherinternetguy#6982

a button you can add to your page, and link to yesterweb.org a button that says 'keep the web free, say no to web3', linking to a page about web3

a button that links to the justanotherinternetwebring webring.