Project Euler #163: Cross-hatched triangles

Sort by

recency

|

6 Discussions

|

  • + 0 comments

    public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int n = scanner.nextInt(); int result = calculateTriangleCount(n); System.out.println(result); }

    public static int calculateTriangleCount(int n) {
        return (1678 * n * n * n + 3117 * n * n + 88 * n - n % 2 * 345 - n % 3 * 320 - n % 4 * 90 - (n * n * n - n * n + n) % 5 * 288) / 240;
    }
    
  • + 1 comment

    scince it is an equilateral triangle all straight lines drawn from each vertex to the middle of the opposite side is also a height.Pay attention on the directions formed by the divisions,parallel segments will help to count those triangles.It is not possible to find a close formula for this problem

  • + 0 comments

    Can anybody help me in this problem...?

  • + 1 comment

    As in the size two triangles we will be having 4 size 1 triangles i.e minimum number of triangle of any size will be 16*4=64. I am not getting how to find the rest as per the discussion below considering angles also apart from 30,60,90 which is the case of special triangle we can judge that rest triangle will be having minimum two angles equal so as to make two two opposite sides euqal. But How we can consider the angle parameter...

    Please help me in solving this.

  • + 1 comment

    Failing the testcases 2,3,8,9. Any hints on what could be the cause. I have tried some small numbers for which I calculated the triangles and I got correct results through my code.