Skip to content
Advertisement

Tag: algorithm

A* pathfinding algorithm is being semi-greedy

So I have been trying to implement the A* pathfinding algorithm for a 2D tilemap in Java from this video: https://www.youtube.com/watch?v=-L-WgKMFuhE. I tried following the pseudocode and not enough details, I felt, were not explained greatly, especially the idea of the G cost. So, I decided to go into the actual code the video creator wrote and used a lot

How to get all one and two letter combinations in order from a word?

For example, there is a line It is necessary to get all possible combinations, such as: p-r-o-g-r-a-m p-r-o-g-r-am p-r-o-g-ra-m pr-og-r-am and so on. How do I do this in java? Or at least tell me a general algorithm (with an example)? It is not a problem to break the deadline, at least one character at a time, at least two,

How do I count numbers that contain one digit, but not another?

I recently came across an interview question which although had an immediately obvious solution, I struggled to find a more efficient one. The actual question involved counting numbers from a to b (up to 2^64) which satisfied having either the digit 6 or 8, but not both. They called it a ‘lucky number’. So for example: The obvious thought was

Something wrong with BigInteger

when i test this function with base16 :F0F0F0F0F0F0F0, it return right result = 67818912035696880 BUT when i test with base16: F0F0F0F0F0F0F0F0, it returns wrong result: 17361641481138401580 which right result must be 17361641481138401520 please help me! Answer Math.pow delivers a double, 8 bytes. So from some huge double value, it becomes imprecise in the less significant digits. You could have used

calculate the percentage increase or decrease in a list of values in java

i’m trying to build an data structures and algorithms program using java. and i wanna ask if anyone know How do i calculate the percentage increase or decrease in a array. i try this code–but apparently its not the correct way Run-> Percentage change is = Infinity % Answer Here you’re dealing with the numbers, which could go in the

Advertisement