logo
Tags down

shadow

How can I make my code find solution while working at specific coordination?


By : Hasib
Date : October 17 2020, 06:10 AM
I hope this helps you . When you do backtracking, you probe the adjacent cells, but first, you set the properties of your current cell as if the probed directions led to a valid path. If probing succeeds, just report success ( return 1) and leave everything as it is. If not, clean up after yourself by resetting the cell to its initial state. You must do that, so that you don't revisit already visted cells, which are marked as 2.
code :
if (maze[i][j] == 0) {    
    maze[i][j] = 2;

    if (findpath(i, j + 1)) return 1;
    if (findpath(i - 1, j)) return 1;
    if (findpath(i + 1, j)) return 1;
    if (findpath(i, j - 1)) return 1;

    maze[i][j] = 0;
}
if (maze[i][j] == 1 && abilcnt > 0) {
    maze[i][j] = 2;
    abilcnt--;

    if (findpath(i, j + 1)) return 1;
    if (findpath(i - 1, j)) return 1;
    if (findpath(i + 1, j)) return 1;
    if (findpath(i, j - 1)) return 1;

    abilcnt++;
    maze[i][j] = 1;
}
int findpath(int i, int j)
{
    if (i < 0 || j < 0 || i >= mazesize || j >= mazesize) {
        return 0;
    }

    if (i == mazesize - 1 && j == mazesize - 1) {  
        maze[i][j] = 2;
        return 1;
    }  

    if (maze[i][j] == 0) {    
        maze[i][j] = 2;

        if (findpath(i, j + 1)) return 1;
        if (findpath(i - 1, j)) return 1;
        if (findpath(i + 1, j)) return 1;
        if (findpath(i, j - 1)) return 1;

        maze[i][j] = 0;
        return 0;
    }

    if (maze[i][j] == 1 && abilcnt > 0) {
        maze[i][j] = 2;
        abilcnt--;

        if (findpath(i, j + 1)) return 1;
        if (findpath(i - 1, j)) return 1;
        if (findpath(i + 1, j)) return 1;
        if (findpath(i, j - 1)) return 1;

        abilcnt++;
        maze[i][j] = 1;
    }

    return 0;
}


Share : facebook icon twitter icon

Any alternative solution for getting this work? Php code is not working right but mysql code is working


By : DCM
Date : March 29 2020, 07:55 AM
may help you . There are several problems with your sql code (e.g. never mix DISTINCT and GROUP BY, use WHERE in inner select etc). That being said your query should look something like
code :
SELECT regd, Roll_no, Name_of_Student, Test_date,
       English, f_eng, 
       Mizo, f_mz,  
       Hindi, f_hn,  
       Mathematics,  f_maths, 
       SS, f_ss, 
       Science, f_sc, 
       score, fmscore, perc, Rank 
FROM 
(
  SELECT t.*, IF(@p = score, @n, @n := @n + 1) AS Rank, @p := score 
    FROM
  (
    SELECT regd, Roll_no, Name_of_Student, Test_date,
            SUM(IF(Subject = 'English'    , Mark_score, 0)) English,
            SUM(IF(Subject = 'English'    , Full_mark,  0)) f_eng, 
            SUM(IF(Subject = 'Mizo'       , Mark_score, 0)) Mizo,
            SUM(IF(Subject = 'Mizo'       , Full_mark,  0)) f_mz, 
            SUM(IF(Subject = 'Hindi'      , Mark_score, 0)) Hindi,
            SUM(IF(Subject = 'Hindi'      , Full_mark,  0)) f_hn, 
            SUM(IF(Subject = 'Mathematics', Mark_score, 0)) Mathematics, 
            SUM(IF(Subject = 'Mathematics', Full_mark,  0)) f_maths, 
            SUM(IF(Subject = 'SS'         , Mark_score, 0)) SS,
            SUM(IF(Subject = 'SS'         , Full_mark,  0)) f_ss, 
            SUM(IF(Subject = 'Science'    , Mark_score, 0)) Science,
            SUM(IF(Subject = 'Science'    , Full_mark,  0)) f_sc,
            SUM(Full_mark) fmscore,
            SUM(Mark_score) score, 
            SUM(Mark_score) / SUM(Full_mark) * 100 perc 
      FROM cxexam, (SELECT @n := 0, @p := 0) n 
     WHERE Test_date BETWEEN '2013-07-01' AND '2013-07-31'
     GROUP BY regd 
     ORDER BY score DESC
  ) t
) r 
$link = mysql_connect('localhost', 'user', 'password');
if (!$link) {
    die('Could not connect: ' . mysql_error());
}
$db_selected = mysql_select_db('dbname', $link);
if (!$db_selected) {
    die ('Can\'t use db : ' . mysql_error());
}

$sql = "
    SELECT regd, Roll_no, Name_of_Student, Test_date,
           English, f_eng, 
           Mizo, f_mz,  
           Hindi, f_hn,  
           Mathematics,  f_maths, 
           SS, f_ss, 
           Science, f_sc, 
           score, fmscore, perc, Rank 
    FROM 
    (
      SELECT t.*, IF(@p = score, @n, @n := @n + 1) AS Rank, @p := score 
        FROM
      (
        SELECT regd, Roll_no, Name_of_Student, Test_date,
                SUM(IF(Subject = 'English'    , Mark_score, 0)) English,
                SUM(IF(Subject = 'English'    , Full_mark,  0)) f_eng, 
                SUM(IF(Subject = 'Mizo'       , Mark_score, 0)) Mizo,
                SUM(IF(Subject = 'Mizo'       , Full_mark,  0)) f_mz, 
                SUM(IF(Subject = 'Hindi'      , Mark_score, 0)) Hindi,
                SUM(IF(Subject = 'Hindi'      , Full_mark,  0)) f_hn, 
                SUM(IF(Subject = 'Mathematics', Mark_score, 0)) Mathematics, 
                SUM(IF(Subject = 'Mathematics', Full_mark,  0)) f_maths, 
                SUM(IF(Subject = 'SS'         , Mark_score, 0)) SS,
                SUM(IF(Subject = 'SS'         , Full_mark,  0)) f_ss, 
                SUM(IF(Subject = 'Science'    , Mark_score, 0)) Science,
                SUM(IF(Subject = 'Science'    , Full_mark,  0)) f_sc,
                SUM(Full_mark) fmscore,
                SUM(Mark_score) score, 
                SUM(Mark_score) / SUM(Full_mark) * 100 perc 
          FROM cxexam, (SELECT @n := 0, @p := 0) n 
         WHERE Test_date BETWEEN '2013-07-01' AND '2013-07-31'
         GROUP BY regd 
         ORDER BY score DESC
      ) t
    ) r";

$result = mysql_query($sql);
if(!$result) {
    die(mysql_error()); // TODO: better error handling
}

while($row = mysql_fetch_assoc($result)) {
    echo "{$row['regd']} - {$row['Rank']}<br>";
}
40 - 1
2  - 2
3  - 2
20 - 3

Trying to find specific word inside string without contain method. code isn't working the way it should


By : dmoyers
Date : March 29 2020, 07:55 AM
I wish this help you StackOverflow is actually not a place where people DO something for you. They help you and tell you HOW to do this. This issue contains only the wrong piece of code and question "what's wrong".
First of all, I need to tell you that the first problem is, obviously, the algorithm. I can't understand what is your code supposed to do because even you don't understand it.
code :
using System;
using System.Text;

namespace ConsoleApplication18
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Where to search -->");
            string text = Console.ReadLine();
            string pattern = "ja"; // Probably, it is better to get it from Console as well      

            for (int i = 0; i < text.Length; i++)
            {
                for (int j = 0; j < pattern.Length; j++)
                {
                    if (text[i+j] == pattern[j] && j == pattern.Length - 1)
                        Console.WriteLine(i);
                    if (text[i+j] != pattern[j]) break;
                }
            }
        }
    }
}

I'm trying to read a text file and find specific matches and print it , but my code does not working


By : Helen
Date : March 29 2020, 07:55 AM
Does that help I've put this to find string matches , just showing build successfully nothing else.I've put this to find string matches , just showing build successfully nothing else.I've put this to find string matches , just showing build successfully nothing else. , contains() doesn't work like that.
code :
String key = "(int|float|if|else|double)"; // is a regex to check if one of the words exist
Pattern pattern = Pattern.compile(key);
Matcher matcher = pattern.matcher(r);
while (matcher.find()) { // Checks if the matcher matches r.
  System.out.println(matcher.group()); // return all the words which matched
}
List<String> keys = Arrays.asList("int", "float", "if", "else", "double");

Optional<String> possibleMatch = keys.stream()
    .filter(a::contains) // if a contains one of the keys return true
    .findFirst(); // find the first match 

if (possibleMatch.isPresent()) { // if a match is present
  System.out.println(possibleMatch.get()); // print the match
}

Make the coordination system of all entities of the STEP file up-z


By : user1400571
Date : March 29 2020, 07:55 AM
Does that help There is no such thing as UpZ or UpX in Solidworks. Everything is UpY.
When you make an assembly all parts are either positioned manually or using mates (99% of the time). This process will nearly all the time rotate and translate the part.

where can i find an implementation of the coordination language linda in c?


By : Mahedi Hassan
Date : March 29 2020, 07:55 AM
may help you . So directly to your question:
Where can i find an implementation of the coordination language linda in c?
Related Posts Related Posts :
  • Semantics of sem_getvalue() in POSIX
  • What does the [x,y] symbol mean in a multidimensional array access?
  • compilation error: cast from pointer to integer of different size
  • why am i getting compilation error "error: conflicting types for ‘ptr’ " for the following code? static int va
  • Why does getw return -1 when trying to read a character?
  • Why C program in whch two functions call each other recursively gives segmentation fault on linux?
  • ssize_t is undefined
  • Passing a generic argument in a C function
  • Restoring stdout after redirecting it via freopen()
  • Tuples "cannot be marshalled in a foreign call" when trying to export a Haskell function to C
  • Dereferencing double pointer to pass to recursive function
  • Why is the output different in these two scenarios
  • what will happen if we dont use free() for allocated memory
  • counting words from user input
  • Why am I not getting the concatenated string?
  • not understandable pointers errors
  • Issue with function memory allocation
  • /usr/bin/ld: cannot find -lioutil in Makefile
  • Segmentation Fault when finding longest word in input
  • undefined reference to `palloc'
  • DMA transfer taking more time than CPU transfer
  • How to fix implicit declaration of function?
  • Writing a file line by line in C
  • "accept" always returns 1, but no descriptor has been closed
  • How to fix 'Bad file descriptor' after implementing here-string redirection in my own shell
  • Why this output string to number?
  • Is there any way to make this adding an infinite?
  • for loop is iterating printf written after scanf only once
  • How to efficienty count from 0000 to 9999 in a digit display?
  • Implicit conversion and explicit conversion in c
  • Attempting to convert a value into 2s complement in C
  • else statement is resulting in identifier expected in c 13
  • Thread-safety vs atomicity in C
  • Segmentation fault - Trying to read binary file into memory
  • How to make a variable declared in constructor visible in the main file
  • What is the fastest way to reverse a power of two in C?
  • Reading and writing structure to binary file in C, then print structure elements
  • Why casting double to int might give different results?
  • Greedy algorithm in C not returning any values?
  • How to find base address of same char in string array using pointers in C language?
  • Quick question, why is scanf_s throwing an exception in runtime here? I am very confused
  • How can I compare two array of characters?
  • How should I avoid naming collisions with included libraries in C?
  • Code after while loop terminates does not run
  • How to capitalize first character of a word with all the characters in lower case previously and then print it
  • I need help to understand the syntax of pointers
  • How can I find the size of a const declared array in C?
  • Uninitialized C structure field
  • Hello World driver won't compile correctly
  • Is there a Gtk3 Widget that can display text as a terminal does?
  • How does the relational operator == work in C?
  • why value of parameter inside void main function in C is initialised with 1?
  • Dereferencing an Array of Pointers
  • Need help compiling .c file into shellcode
  • How can I store the 50ms before and after an audio event in a circular buffer?
  • This code is not calculating things right, any ideas why?
  • Difference between using a pointer to assign a value/just assigning it normally?
  • How to force compiler to promote variable to float when doing maths
  • Can these C codes be refactored this way?
  • c syntax error on common variables between different .c files
  • shadow
    Privacy Policy - Terms - Contact Us © 35dp-dentalpractice.co.uk