[Solved] Find size of rectangles to fill area

As far as I understand, you want to place n rectangles with fixed C=W/H ratio on the wall with given Width and Height Let rectangle height is h (unknown yet), width is w = C * h Every row of grid contains nr = Floor(Width / (C * h)) // rounding down Every column contains … Read more

[Solved] Shortest path using php [closed]

As Mark Baker pointed out, you’ll need to use something like Dijkstra’s algorithm to traverse a weighted graph (which is what you’ll have when you include distances). Here’s a simple distance function I found here: <?php /*::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::*/ /*:: :*/ /*:: This routine calculates the distance between two points (given the :*/ /*:: latitude/longitude of those … Read more

[Solved] Pattern Programmings

#include<stdio.h> #include<conio.h> int main() { int n=3,i,j,k,l,m; clrscr(); for(i=0;i<n;i++) { for(j=0;j<n-i-1;j++) printf(” “); for(k=0;k<=i-1;k++) printf(“*”,k+1); for(m=0;m<1;m++) { if(i<=0) printf(“*”); else printf(” “); } for(l=i-1;l>=0;l–) printf(“*”,l+1); printf(“\n”); } for(i=0;i<n-1;i++) { for(j=0;j<=i;j++) printf(” “); for(k=0;k<n-i-2;k++) printf(“*”,k+1); for(m=0;m<1;m++) { if(i==1) {} else printf(” “); } for(l=1;l>0;l–) printf(“*”,l+1); printf(“\n”); } getch(); return 0; } Finally I got my solution … Read more

[Solved] Pattern Programmings

Introduction Solved pattern programming is a type of programming that involves solving a problem by breaking it down into smaller, more manageable pieces. It is a powerful tool for problem solving and can be used to solve a wide variety of problems. Solved pattern programming is often used in computer science, engineering, and mathematics. It … Read more

[Solved] simulating pawn jump in the array/vector [closed]

#include <algorithm> void myfunction (int &i) { // function: i=1000001; } int arrayJmp ( const vector<int> &A ) { int N=A.size(); vector<int> indexes; for_each (indexes.begin(), indexes.end(), myfunction); int index=0; while(std::find(indexes.begin(), indexes.end(), index) == indexes.end()){ indexes.push_back(index); index+=A[index]; if (index==(N-1)&&A[index]>0) return indexes.size()+1; } return -1; } 9 solved simulating pawn jump in the array/vector [closed]

[Solved] How to understand this C++ palindrome code?

Taking a look at the string constructor: … (7) template <class InputIterator> string (InputIterator first, InputIterator last); You can see it is possible to create a string via iterators. The rbegin/rend iterators are InputIterators that points to the reverse positions that they refer: rend() –>”My string”<– rbegin() That said, when you pass the rbegin() and … Read more

[Solved] How to approach this hackerrank puzzle?

I could not post it to comment section. Please see below: List<Integer> integers = Arrays.asList(1, 2, 3, 4); int i = 0; StringBuilder sb = new StringBuilder(“[“); for (int value : integers) { sb.append((i == 0) ? “” : (i % 2 == 0 ? “,” : “:”)).append(value); i++; } sb.append(“]”); System.out.println(sb.toString()); Output is: [1:2,3:4] … Read more

[Solved] time complexity of recursion function

We have: 1 : if statement 3 : * operator 3 : function statement Totally: 7 So we have: T(n)=t(n-1) + t(n-2) + t(n-3) + 7 T(99)=1 T(98)=1 … T(1)=1 Then to reduce T(n), we have T(n-3)<T(n-2)<T(n-1) therefore: T(n) <= T(n-1)+T(n-1)+T(n-1) + 7 T(n) <= 3T(n-1) + 7 So we can solve T(n) = 3T(n-1) … Read more

[Solved] compile it by suing the root

There is a problem in this line: double v[k] = log(log(sqrt(e[k]+1)+1)+1); in the first iteration k == 0 so you are trying to declare a zero sized array. I dont understand the code enough to tell you how to fix it, but a zero sized array is definitely not what you want in that place. … Read more