Programming :: Sudoku - Calculate The Correct Box For A Given Square?

Apr 8, 2011

Im doing a sudoku-solver as a school assigment in Java. It is supposed to solve both 6x6, 9x9 and 12x12 boards.Im pretty much done with my algorithm(brute force), but I'm having a hard time figuring out how to calculate the right Box for a Square. I found this snippet:

Code:

// calculate BoardPos for index, where index is 0..80
void loadBoardPosFromIndex(BoardPos &pos, int index) {
pos.index = index;

[code]...

This works on 9x9 boards, but I really dont get the math behind this, and how I can create a generic rule for both 6x6, 9x9 and 12x12 boards.

View 4 Replies


ADVERTISEMENT

Debian Programming :: Square Bracket Operator?

Sep 1, 2014

Is there a way to achieve the following with the square bracket operator?I have a class:

Code: Select allclass A
{
public:
    void SetValue(int index, Item* B);
private:
    int m_iCount;
    ItemCollection Item_Collection;

[code]....

The probelm is that I am not just blindly assigning whatever given on the right hand side to the returned value from operator [], I need to verify it's not NULL, and it is not already there in the Item_Collection, and I also need to increase the count.

View 5 Replies View Related

Programming :: Calculate Length Of My Array?

Jun 30, 2010

I want to calculate length of my array, say Unix here.

Code:
[linux1@HMLINUX1 abc]$ declare -a Unix=('Debian' 'Red Hat' 'Suse' 'Fedora');
[linux1@HMLINUX1 abc]$
[linux1@HMLINUX1 abc]$ echo ${#Unix[@]}
5

This should be ideally 4, but somehow it is showing as 5. However, when I am removing the space as RedHat instead of Red Hat, it is working perfectly.

Code:
[linux1@HMLINUX1 abc]$ declare -a Unix=('Debian' 'Redhat' 'Suse' 'Fedora');
[linux1@HMLINUX1 abc]$ echo ${#names[@]}
4

View 4 Replies View Related

Fedora :: F15: Gnome - Sudoku Won't Start?

Jun 4, 2011

Starting gnome-sudoku (after installing the packages gnome-games and gnome-games-extra) only results in the following message in my messages log :

Code:
gnome-sudoku: abrt: detected unhandled Python exception in /usr/local/bin/gnome-sudoku
Is there any way to fix this?

View 1 Replies View Related

Programming :: Calculate Data And Make It Into New Column Using Awk?

May 24, 2011

i've been using a awk script to calculate my data... i have 3 files:

file a1.txt:

2
3
4

[code]....

the results were (3.5, 6 and 3) which is pretty easy.. now i want to combine all this into 1 file and each have different columns and called it avg.txt which have something like this in the end:

3.5 6 3

View 1 Replies View Related

Programming :: Bash Calculate The Repeated Lines?

Jan 28, 2010

i have a sorted file with many repeated lines like this:

1ujw
1ujw
1ul1
1us7

[code].....

i need to calculated haw many times each line is repeated, for ex

1ujw 2
1ul1 1
1us7 5
etc.

View 5 Replies View Related

Programming :: Calculate Logarithm In Bash Script?

Dec 12, 2008

I want to calculate log in bash script. I searched but could not find any bash command to directly do it. I am also thinking to send the variable in C program, calculate in C and get the answer back in bash script.But I think it is a long process. as I have to do this

i) gcc -o log log.c

ii) ./log > log_result.txt

iii) then read the result from log_result.txt

View 5 Replies View Related

Programming :: Clock() - Calculate How Much Time Does My Program Run?

May 11, 2011

im trying to calculate how much time does my program run, use very simple script

clock_t end, start;
start= clock();
int i;
printf("initial %d
",(int)start);
[Code]....

but it outputs 0 all the time. cant figure out where could be the problem.

View 2 Replies View Related

Programming :: Calculate The Time Taken For A Sample Program To Run?

Apr 24, 2011

i have the example code below, i want to calculate the time taken for a sample program to run. but i keep getting undefined reference error.

#include <sys/time.h>
#include <iostream>
int main(int argc, char **argv) {
struct timeval startTime;
struct timeval endTime;

[Code]...

View 9 Replies View Related

Programming :: Calculate The Amount Of Data Had Been Download?

May 3, 2011

i'm trying to write a program with c socket programming,what i am trying to reach is a program which will calculate a computer's downloaded data from the internet,just to know how much he/she download?

View 1 Replies View Related

Programming :: Calculate The Number Of - Necessary - Bits In A Byte ?

Jun 11, 2010

E.g. 98 is represented as 1100010 (number of valid bits is 7)

What is the formula to calculate the number of valid bits in a byte ?

View 14 Replies View Related

Programming :: Calculate How Many Nanosecond The Process Takes

Apr 10, 2011

ı need to calculate how many nanosecond the process takes . must give the same value every time (c++) ubuntu 10.10 my system information:

*-cpu
description: CPU
product: Intel(R) Core(TM)2 Duo CPU T7300 @ 2.00GHz
vendor: Intel Corp.
physical id: 400

[code]...

View 6 Replies View Related

Programming :: Calculate The Blade Offset In Python?

Dec 30, 2010

I'm using pyqt3 for my app and am lost on even how to attempt this task... On a vinyl cutter to have the blade pivot it must be offset from the center of the shaft it's on so say for example a .25mm offset would leave a .25mm unwanted vinyl attachment when the cutting is done. I somehow have to average or extrapolate that .25mm xy coordinate and add it to the hpgl plot file as a PUx,y; command? I have enclosed a simple sample file that has three images in it. In the corresponding hpgl file everything between the PU commands that are starting with PD are the code for that image (star for eg the pu to move to next image and then all PD for the next image and so on, so once the formula or procedure is figured out it can be applied to as many images there are in the file. Placing the new command at the head of each image PD group. Since there are absolute and relative cutters I enclosed the same exact plot for both types as the coordinates on relative can be negative numbers. Only PU and PD commands and a ";" as a command delimiter as sometimes many commands are on one line.The offset variable will come from a spinbox but .25 is good for an example.

View 14 Replies View Related

Programming :: Awk - Calculate The Number Of Words Containing Letter E In A Textfile?

Oct 12, 2010

i need to calculate the number of words containing letter e in a textfile.

View 9 Replies View Related

Programming :: Write A Script That Will Calculate A Directory Size?

Jan 20, 2009

I'm trying to write a script that will calculate a directory size and if the size is greater than 4GB, it will send out an email. But I am getting the "integer operation expected" error when it tries to calculate the current disk size. Here's my script.

Code:

TO="user@email.com"
SUBJ="Ready for DVD burning on `hostname`"
MAIL="/bin/mail"

[code]....

View 1 Replies View Related

Programming :: Calculate Flash Memory End Address Of A Certain File?

Mar 9, 2011

how to calculate (if possible) the end address of an image file in a flash memory. I'm trying to create a checksum and checkheader function and the info that I got is the file's offset, how many sector it consumes and its size. I kinda need the end address, sad thing is, I don't know how to calculate it.test.img's start address is 0, the size is 0x20000 and consumes 3 sectors.

View 6 Replies View Related

Programming :: Calculate The Minutes Difference Between Two Dates Using The Function Mktime() On C++?

Jul 28, 2010

I'm trying to calculate the minutes difference between two dates using the function mktime() on c++. The dates will be passed to me as struct tm, and I will use this function many many times. The example below shows what I wanna do:

Code:

int main(int argc, char** argv) {
while (1) {
tm date2;
tm date1;

[code]...

I read the mktime() description on c++ reference, searched google... but there is no light

View 4 Replies View Related

Programming :: Write A Script To Calculate The Total Amount Of Installed Memory?

Apr 4, 2011

I am trying to write a script to calculate the total amount of installed memory to use during an anaconda kickscript, so the swap file is created at 2 x the installed memory. I so far have the amount of installed RAM DIMMS but need a way to total them up and produce a varible I can use in the pre section of the install.

Code:

dmidecode -t 17 | grep Size | awk ' { print $2 }'
Output:
2048
2048

Note: on some servers there could be from 1 DIMM up to 16 DIMMS installed so the script needs to be able to handle this. I also can not use bc as it does not exist during the install stage. I am guessing I need a while loop to do this and use expr but do not know where to start for this logic.

View 3 Replies View Related

Programming :: In Correct File Is Empty?

Jun 17, 2010

I am using embedded Linux. File open is successful. The file has all the permissions. It is present in current directory too. The size is about 27KB. But s.st_size says it is zero.

inputFileName = "abc.mp3";
FILE* inFile = NULL;
inFile = fopen(inputFileName, "r+b");

[code]...

View 2 Replies View Related

Programming :: Javascript To Verify Correct URL?

May 31, 2011

Lets say I have a site "Website1.com"

On that site I want to run a little javascript that verifies that the site was accessed as "Website1.com" and not "dev-Website1.com"

If it was accessed correctly, nothing happens. If it was accessed incorrectly, it displays an error saying "You are trying to access this site incorrectly."

What is the simplest way to accomplish this?

View 1 Replies View Related

Programming :: Atoi() Not Giving Correct Answer?

Jun 20, 2010

i m using atoi() to convert char value to int. and then passing that int as a swtich variable.switch goes in a case and exectuing that particualr function but returning 0 value....for example: i am finding no of process() and system up time().when switch program goes in system up time it gives right values means correct no of days, hrs , min and sec but when it goes in no of process() it gives 0 answer.

View 8 Replies View Related

Programming :: Correct Way Of Spawning Parallel Jobs?

Mar 18, 2010

I need to spawn 2 processes in parallel and each takes an hour or so to finish. Is the following one of the correct ways of using `at` in a script run by crontab?

Code:
#!/bin/bash
# define the env var, cd, etc... assume everything ok up to this point
date +"The start time is %H:%M:%S"
rm -f a.fin
at now <<END_OF_AT
do_a &> a.log

[Code]....

View 2 Replies View Related

Programming :: Expect/TCL - Unable To Get The Correct Results

Feb 8, 2011

I'll post the entire code here, and then specifically highlight what is just failing in a fashion I'm apparently incapable of fixing a few hours later:

Code:

#!/usr/bin/expect
# The script should be called with a file in the directory called sshServerList
# That file has the following format:
# Line # | Contents of line

[code]....

I've had all kinds of different results and problems, but I've never been able to successfully log into multiple servers, though the first server in the list most times works okay (though might not on this iteration). I'm a bit hack and slash and I would be very greatful not only for a solution, but any tips on how I should have done this and places where I could clean up my code.

View 1 Replies View Related

Programming :: Bash Script To Correct The Filenames

Apr 11, 2011

I have a directory that has a bunch of files and directories under it that I need to correct the filenames of. In fact, I plan on running this as a cronjob to keep checking filenames for certain characters. I want directories and filenames with spaces or pluses (+) to have those certain characters replaced with underscores (_). I know that this will involve sed but I'm not sure what else. A simple shell script would handle it.

View 1 Replies View Related

Programming :: Not Getting Right Output To Correct Terminal Window

Jun 17, 2010

I have a server client prog in which server is my 'agent' and client is 'manager'. Following is the code for both agent and manager. I want my agent to send what manager is requesting. But it is not working the way I want. The parameters which manager is requesting, agent has to send to manager but in this program result for those parameters is shown on agent's own terminal window. Where as I want them on manager's window. Secondly, there result is not correct, means it is giving ' 0 K ram and 0 no of process....

Code:
//code for MANAGER
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <stdio.h>
#include <unistd.h>
#include <errno.h> .....

View 2 Replies View Related

Programming :: Wcslen / _tcslen Not Returning Correct Value?

Feb 12, 2010

I have having some trouble working with wide characters, which is,

Sample code:
TCHAR fname[512];
_tcslcpy(fname, L"/root/Desktop/all/TheGrandTunnels.fgc", 512);

[code]...

View 4 Replies View Related

Programming :: Correct Package To Install Javadoc On Fedora?

Nov 2, 2010

Anyone knows what is the correct package to install javadoc on Fedora???

View 3 Replies View Related

Programming :: Simple Bash Script Not Returning Correct Value?

Sep 14, 2010

I have a very simple bash script:echo -n Create home directory?:

read HOMEDIR
if [ $homedir="y" ] || [ $homedir="yes" ]; then
homeval=" --makehomedir"

[code]...

View 6 Replies View Related

Programming :: GDB Doesn't Provide The Correct Line In The Source Code

Jan 23, 2011

I found a strange problem when I use gdb in eclipse to debug. When I step in the program, the register RIP(I'm using x86_64 machine and that's EIP in 32 bit mode) shows correctly but the line stepping in the source code may be far from the correct line. For example, when there is no loop in the source code, the RIP keeps on increasing and the current instruction pointer goes back to several lines back. I'm sure the source code is the right one because I when I checked the memory and local variables after several lines the values are all correct. The source code has many empty lines and does it matters with GDB?

View 3 Replies View Related

Programming :: Correct / Common Directory Tree For Software Packages?

Mar 16, 2011

I found it easiest to embed narp into the gtk+-2.0 installation because all I needed to do was tweak the Makefile.am and Makefile.in files and let configure do the rest.This is a hack. I've failed at getting my own makefiles to work.

Would anyone point me in the right direction on how to properly make an installer for Linux? Also, what is the correct/common directory tree for Linux software packages? Any more suggestions on proceeding with this project using community standards?

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved