Hexagonal Grid Discussions | Algorithms | HackerRank

Sort by

recency

|

39 Discussions

|

  • + 0 comments

    I remember struggling with a similar grid puzzle a while back. At first, it seemed impossible to cover all the cells, especially with those blackened spots messing up potential placements. But after some trial and error, I figured out how to fit the tiles just right—kind of like when I was trying to buy tretinoin cream online and had to navigate all the different options to find the right one. Some grids just work out, and others? Well, they’re doomed from the start!

  • + 0 comments

    Show appreciation with unique corporate gifts like a "Hexagonal Grid" while fostering creativity and innovation. These gifts inspire collaboration and problem-solving skills, ideal for team-building activities or office decor. Enhance workplace dynamics with thoughtful items that encourage productivity and aesthetic appeal. Whether used for brainstorming sessions or as a decorative element, Hexagonal Grids symbolize forward-thinking and synergy within your organization. Elevate your corporate culture with meaningful gifts that reflect your commitment to excellence and teamwork.

  • + 0 comments

    ~10 lines Python, 100%, cool bit things

    If you figure out what the numbers mean I'll buy you a virtual coffee :D

    @cache
    def f(a,b):
        x=((a&3)<<2)|(b&3)
        if a==b:
            return True
        if (a,b)==(0,1) or (a,b)==(1,0) or x in {6,11,14}:
            return False
        if x in {2,7,8,13}:
            return f(a>>1,b>>1)
        if x in {0,3,5,9,10,12,15}:
            return f(a>>2,b>>2)
        return f(a>>1,(b>>1)|1) or f((a>>1)|1,b>>1)
    
    def hexagonalGrid(a, b):
        return "YES" if f(int(a,2),int(b,2)) else "NO"
    
  • + 0 comments

    Here is Hexagonal Grid problem solution - https://programs.programmingoneonone.com/2021/07/hackerrank-hexagonal-grid-problem-solution.html

  • + 0 comments

    My python3 example with O(n) complexity:

    def hexagonalGrid(a, b):
        if ((a.count('1') + b.count('1')) % 2 != 0):
            return 'NO'
        white = 0
        block = False
        for i in range(len(a)):
            if (a[i] == '1'):
                if block and white % 2 != 0:
                    return 'NO'
                block = True
            elif (a[i] == '0'):
                block = False
                white += 1
            if (b[i] == '1'):
                if block and white % 2 != 0:
                    return 'NO'
                block = True
            elif (b[i] == '0'):
                block = False
                white += 1          
        return 'YES'