Sort by

recency

|

3130 Discussions

|

  • + 0 comments

    Mi solucion en C# con bucle y LINQ

    public static void countApplesAndOranges(int s, int t, int a, int b, List<int> apples, List<int> oranges)
        {
            int countApple = 0, countOrange = 0;
            foreach(int apple in apples){
                if((apple + a) >= s && (apple + a) <=t){
                    countApple++;
                }
            }
            countOrange = oranges.Count(orange => (b + orange) >= s && (b + orange) <=t);
    
            Console.WriteLine($"{countApple}\n{countOrange}");
        }
    
  • + 0 comments

    Mi solución en Python 3:

    def countApplesAndOranges(s, t, a, b, apples, oranges):
        # Write your code here 
        man = 0
        nar = 0
    
        for i in apples:
            if a+i in range(s,t+1):
                man += 1
        for j in oranges:
            if b+j in range(s,t+1):
                nar += 1
        print (man)
        print (nar)
    
  • + 0 comments

    def countApplesAndOranges(s, t, a, b, apples, oranges): line1 = 0 line2 = 0

    for i in range(m):
        if t >= (apples[i] + a) >= s:
            line1 += 1
    
    for j in range(n):
        if t >= (oranges[j] + b) >= s:
            line2 += 1
    
    print(line1)
    print(line2)
    
  • + 0 comments

    co=0 for i in apples : if(i+a)>=s and (i+a)<=t: ca+=1 for i in oranges : if(i+b)>=s and (i+b)<=t: co+=1 print(ca) print(co)

    • ****

  • + 0 comments

    co=0 for i in apples : if(i+a)>=s and (i+a)<=t: ca+=1 for i in oranges : if(i+b)>=s and (i+b)<=t: co+=1 print(ca) print(co)

        ****