Category "logic"

How updated object with child component should reflect on parent component

I want to add the macchines in machine array so I defined a specific component with add function in it. So when I add the "process" in "processes" array then it

For Wumpus World model, why is the probability of pits in squares assumed to be 0.2?

At the beginning of the probability derivation for a pit in square (1,3), it is stated that "there would be a 'prior' assumption for the placement of pits in th

How to optimise function logic to avoid duplication - python

I have some code below, for a given name that matches pattern with 2 lower case letters (such as 'aa'), the valid name can be V-aa or X-aa def verify_helper(val

Having a loop issue

I am running the following code for pi value to calculate the first value which yields 3.14. I used manual values for range which works, but I want the values t

Unity Tetris Game blocks sometimes not colliding

I am creating a version of Tetris which uses pentominoes instead of tetrominoes (5 square blocks instead of 4 square blocks). Some of the blocks will sometimes

Find the nth character of an increasing sequence

Recently i saw a competitive coding question, the bruteforce approach doesn't meet the time complexity, Is there any other solution for this, Question: An expan

hallway problem - is there a way to solve in python?

hallway problem picture There is a some rooms and a hallway. Two of the rooms are connected to the hallway. Each of those rooms have one room connected to them.

Why docplex optimization gives no answer

I am working on an optimizatiom model which is set to maximize NPV. I am getting some results, however my cap_ele should represent the max value in the el_to_el

Using operators, how to set a variable equal to one of two other variables depending on which one has a value, in Ruby? [closed]

When there are only two states for instance variable "a", either it has a value or not, and there is only one possible state for instance vari

Place the first value of Column B in Column C if Column A has same names in python pandas with loop [duplicate]

I have the following data set in python, Input I want to bring the first value of Column B that belongs to column Column A for a unique A val

Convert a Python block of code into a single line

Below is the python block code, def compute_hcf(x, y): while(y): x, y = y, x % y return x which I wanted to convert into single line like below, d

Hive query to find conversion ratio

I am trying this query in Hive and it's not working. select ( ( select count(*) from click_streaming where page_

Python Script To Continually Run (Better)

The below script is a working prototype of a script that runs on a rasberry pi and its job is to grab files from a specified folder on a flashdrive when plugged

States Matching Logic Corda

We need a logic for the following scenario: Say for example, we have three parties, Party A, B and C. We have two states, state X and state Y. Party A, and Part

How do I best control activity flow?

I am tasked with building an app that does not have a fixed screen order. When started the app will contact a server an get a list of actions to perform. So one

Combine Pagination of Two Different Entities With different size

I'm working on a problem where i have to do pagination of two data lists. ex. psudo code int recordsPerPage = 100; // this is dynamic int currentPage = 1; // th

Activity Conditional Flow

I have a movie ticket booking app. My initial activity is the login activity where there is a "continue as guest" option in case he doesn't want to sign in or r

Program to reverse a number without using an array

This is the code that I used. It works perfectly, but I don't understand why it works. I just kept changing my original logic until I started using -1 in the co

Infinite Loop when a character is entered [duplicate]

I am trying to restrict the user to enter only '1' or '2'. int ch; do { cout<<"Enter: \n"; cin>>ch; switch(ch) {

What is the correct input to have the program print the sentence: Exactly! Good Job

Read and understand the following code. Provide the correct input to have the program print the sentence: Exactly! Good Job. Before submitting your answer, plea