I get this reasoning question in Klarna pre test. Please help me to solve this. Question is in image
You are correct 'B' is the answer
1). Center 3 Dots , that is the 3rd column Will stay the same
2). 4th and 5th Column moves from right to left one at a time, as soon 2 black dots merged it will be come white, if the black moves it will become white again
3). Try the entire sequence filled with Numbers ( 1 to 10 ) in place of black dots to avoid confusion and solve the problem
if you have more questions, please do let me know
The correct Answer is B
Its because the middle column black squares remain constant while the two right columns move left. When they merge they become white. At separation restore to black.
Related
Please help me to solve this problem efficiently and calculate its time complexity.
We have an NxM grid there are two animals one is ‘Horse’ and another is ‘Bishop’ which has different moving abilities. A ‘Horse’ can move 2.5 steps and a ‘Bishop’ can move only diagonal but not horizontally or vertically. Some grids are marked as inactive. Return 1 position where these animals can meet at any point. In the following image 0,3 & 2,0 are represented as an inactive grid where none of the animals can visit and ‘Bishop’ is at 3,2 position and possible direction are represented as arrow and ‘Horse’ is available at 6,6 and possible direction where horse can move are represented as arrow and circles. One of the possible point where the Bishop and Horse can meet is 4,5 as represented by yellow color. You need to use your own data structure, data types and test cases asper the requirement. (Hint: use graph algorithm - BFS). PS: Chess knowledge is not required to solve this problem *
I want to program a dice which show me the right numbers like a real one. I know that the added numbers across from each other are 7.
But when I know 4 opposite numbers of the dice, how do I figure out where the two last one belongs?
For example:
https://de.wikipedia.org/wiki/Spielw%C3%BCrfel#/media/Datei:Craps.jpg
I know that on the top is a 6, and on the left side is 2. How do I know that on the right side is a 4 and not a 3?
Is there a possibility to figure this out without hardcode all possibilities?
Typical dice are "right-handed" (see: en.wikipedia/Dice#Construction). That is, one way to see it is:
Star with a blank cube (whatever way you'll represent it)
Pick any face, label it "1"
Move to any adjacent face, label it "2"
Turn 90º in the positive direction
positive defined by the right-hand rule, meaning rotate to the left (yes, confusing, and don't get me started on counter-clockwise... :-))
Move forward to the next face, label it "3".
Label the remaining faces by the "opposites add to 7" rule
I know this is not much of a question but a seek of help, but I wanted to give it a shot too since I'm really blocked with this.
I want to create a sort of map (representend by a string) that is filled with numbers in a way similar to this example:
000000000000000000
001111000000011000
011111100000111110
000111110001111100
000011000000011000
000000000000000000
So the idea is that 0 would be like "nothing" or imagine this is a world map and 0s are grass tiles while 1s could be for example ground tiles.
I want to be able to generate something like that (on a bigger scale) with lots of small and big patches of "ground". But obviously it can't just be random 1s and 0s everywhere as it wouldn't look natural, it has to be somewhat natural looking shapes.
My maths are just too bad to think of a way to achieve this out of my head,
I'm not asking for the code, just seeking some help.
If you guys could point me in the right direction it would help a lot :)
Do you just want to generate this for fun, you might be looking for ascii art generator. There are lot of online tools available, just a search away for the phrase ascii art generator.
Background: Every image is made up of pixels. Every one of these pixels have a color defined by (R,G,B) with each component ranging from 0-255.
Defined Problem: You want to convert each pixel of an image to 0 or 1 based on their color. Color would be the defining attribute here as we expect the 0 attribute and 1 attribute to be visually different.
Solution: You'll need to create a function which will map each pixel of an image based on their RGB values to either 0 or 1. You'll have to classify ranges for them according to which every pixel will either be converted to a 0 or 1 as per their weight.
Implementation: I'll probably be looking towards Python Libraries. There are tons of them and I'm certain there must be one to access an image at a bit level. When you have the number of pixels in length and width, use those parameters to construct an array of that size and loop your function over the image pixels and go on filling the results in the array.
Crude Way: You can alternatively visit this website which will do it for you. Just in case you want it done at the easiest way possible: https://www.text-image.com/convert/
There are many more like this if you search for them.
If you want an algorithm you could probably start with all 0s. Then randomly and sparsely place some 1s into the field. Now take each of the placed 1s and randomly select a direction (up, down, left, right) and a number n of steps between 0 and a small number m, e.g. 3. Let the selected 1 "grow" in that direction n times. i.e. cover the n spots in that direction with 1s. Repeat for any newly placed 1s (maybe omit those which were already placed over previously existing 1s) until no newly placed 1 is unprocessed. That should at least give you some "connected patches", maybe similar to plants e.g. grass might spread. And maybe play with m a little, to vary the size of the "patches".
I found what I was looking for,
I'll do it with Perlin Noise :)
I'm doing a program in C but I got stuck in math :D
I have a square divided by quadrants. 4 squares inside a square
For each quadrant I can have a color. Red,Blue,Green and Yellow.
In how many ways I can combine this?
I thought it was 4*4*4*4 but I need to subtract some possibilities( for example: green,green,blue,blue is the same when I trade blue for blue or green for green. It's the same combination.
I think you are asking for a permutation without repetition, which in your case would be 4! = 24.
Not sure how to describe this exactly but here goes:
I have a 3 column design, and there is a list of items in each of the columns.
I need to have:
1) Each column's list items must aligned so that the left side of each word lines up
2) Each list itself must be centered within its column. (This of course means that list items on their own won't necessarily be dead center inside their respective column)
I would prefer a CSS solution without javascript/jQuery.
I have an example of bootstrap code that I am working on here to help explain what doesn't work for me:
http://bootply.com/112003
The first row is what happens when the text is centered within each column. Condition 2 passes, condition 1 fails.
The second row is what happens when I divide up each of the three colums into 3 subcolumns. Condition 1 passes, but condition 2 fails. This is subtle. While each list item is in the center subcolumn, overall the list isn't in the dead center of that column. (Imagine the list is one item if that helps think about the problem.)
Thanks to anyone who can try to help me out. This one is driving me a little bit crazy :)