Browse Source

become immortal

master
killruana 4 months ago
commit
6cd5883632
3 changed files with 38 additions and 0 deletions
  1. +1
    -0
      codewars/become_immortal/README.md
  2. BIN
      codewars/become_immortal/analysis.ods
  3. +37
    -0
      codewars/become_immortal/main.py

+ 1
- 0
codewars/become_immortal/README.md View File

@@ -0,0 +1 @@
[URL](https://www.codewars.com/kata/become-immortal/train)

BIN
codewars/become_immortal/analysis.ods View File


+ 37
- 0
codewars/become_immortal/main.py View File

@@ -0,0 +1,37 @@
import itertools


def elder_age_naive(m, n, l, t):
return sum(filter(lambda z: z > 0, ((x ^ y) - l for x, y in itertools.product(range(m), range(n))))) % t



def decompose(width, height):
"""Decompose a rectangle in tiles

Try to extract biggest squares of size % 8 == 0, then the remaining rectangles

:param width: Width of the rectangle
:param height: Height of the rectangle
:return: an iterable list of tiles
"""
pass


def solve(m, n, l, t):
# If m is smaller than n, swap the values
# Thit step is optional, but it give me less brain knots ;)
if m < n:
m, n = n, m

for tile in decompose(m, n):
print(tile)



if __name__ == '__main__':
m = 8
n = 5
l = 1
t = 100
print(solve(m, n, l, t), elder_age_naive(m, n, l, t))

Loading…
Cancel
Save