pnm wrote:

paulv66 wrote:

Patrick, can you clarify please? Also, is zero allowed as the denominator in a mod cell? For example, could you give 2 mod 0 as a solution for a cage with value mod 2? Or will a mod cage with zero in it always have to have value zero?

No, for a divisor zero the modulo operation is not defined, so it's not allowed.

(

When the divisor is negative, the result is "implementation dependent" as they say

(so it depends on the programming language used). In my case, the language is C++:

here the remainder has the same sign as the dividend.

that the remainder has the same sign as the divisor..

I need to check if this causes any problems for the puzzle generation, will keep you posted.

Hi Patrick

Did you get a chance to look into this? I only have four puzzles left to solve in your latest book, but I'm going round in circles on these four puzzles. One thing they all have in common is that they include negative numbers (or at least one negative number) and zero and they all include the mod function. I'm unsure how the mod function is supposed to work with negative values and zero.

Jpoos clarified how it works where there is a negative value in the numerator and a positive value in the denominator and his explanation makes sense and is consistent with how ithe mod function works with two positive numbers. What is unclear is whether it is permitted to have a negative denominator in a mod function and, if so, how is the value calculated?

It's also unclear whether you can have zero in the denominator (as discussed earlier in one of your responses to this thread) and, if so, how is the value calculated (e.g. is x mod 0 = x)?

It would also be helpful to have some clarity around how the bitwise functions deal with negative numbers. In an earlier post, you said that minus 1 is effectively treated as 7, although you admitted that this is not entirely logical. Further clarification would be most welcome.

Thanks

Paul

]]>

paulv66 wrote:

Patrick, can you clarify please? Also, is zero allowed as the denominator in a mod cell? For example, could you give 2 mod 0 as a solution for a cage with value mod 2? Or will a mod cage with zero in it always have to have value zero?

No, for a divisor zero the modulo operation is not defined, so it's not allowed.

(

When the divisor is negative, the result is "implementation dependent" as they say

(so it depends on the programming language used). In my case, the language is C++:

here the remainder has the same sign as the dividend.

that the remainder has the same sign as the divisor..

I need to check if this causes any problems for the puzzle generation, will keep you posted.

]]>

paulv66 wrote:

Thanks jpoos. My reasoning where -3 is the denominator was faulty - too many double negatives!

Perhaps Patrick could clarify whether a negative denominator is permitted in mod cages?

Patrick, can you clarify please? Also, is zero allowed as the denominator in a mod cell? For example, could you give 2 mod 0 as a solution for a cage with value mod 2? Or will a mod cage with zero in it always have to have value zero?

]]>

Perhaps Patrick could clarify whether a negative denominator is permitted in mod cages?

]]>

paulv66 wrote:

Thanks jpoos. That clears things up for me. I guess where the negative number is the denominator, repeated subtraction (i.e. double negative) of the denominator is required until you reach the lowest possible positive number? Therefore mod (-3,7) could be either 4 (where 7 is the denominator) or 2 (where -3 is the denominator). Or am I missing something?

I don't think it's formally possible to have a negative number in the denominator, even though you could certainly extend the definition of the mod function to make that happen.

If you were to do this, you would say either 7 mod -3 = 1, since 7+(-3)+(-3)=1, or 7 mod -3 = -2, since 7+(-3)+(-3)+(-3)=-2, depending on the representatives you use.

The other calculation is definitely correct: -3 mod 7 = 4.

]]>

Also, moved this from the "what should volume IV have" thread..

]]>

Am going to print this and keep it with the mod tables

]]>

Usually, one may say that 7 mod 3 is equal to 1, since 7 divided by 3 leaves a remainder of 1. Another way of saying this is: if we repeatedly substract 3 from 7 until we have a number between 0 and 3 (0 included), we get 1, since 7-3-3=1.

Similarly, you would say that -1 mod 3 is equal to 2, since if we repeatedly

In this way, you can also pull negative numbers (or even fractions) through the mod function. Some more examples:

-6 mod 2 = 0

-10 mod 7 = 4

-6.5 mod 3 =2.5

3 mod 2.5 = 0.5

pi mod 2 = 1.1415926535897932384626433832795028841.....

Hopefully this clarifies things a bit.

]]>

paulv66 wrote:

I have a question about the mod function where negative numbers are included. Two of the puzzles in the new book have numbers from -1 to +7 and include some cells with the mod function. I'm trying to figure out the logic where one of these cells includes -1.

if we look at a 'normal' cell with positive only values - say 2,5 - the answer can be either 1 or 2. If zero is included, the only answer can be 0 as division by 0 is undefined. If we take a cell with -1 and 4 (for example), -1 divided by 4 leaves a remainder of -1, while 4 divided by -1 leaves a remainder of 0. Is this correct? Or should -1 divided by 4 leave a remainder of 3?

EDIT; I've just had another look at the puzzles and I notice that none of the non zero mod cells can contain a -1. So I guess the question is moot as far as those puzzles are concerned.

I would be interested to know the answer to my question above. Should I post it as a new topic?

]]>

0 and 0 make 0

1 and 1 make 0

Imagine that we wanted to combine the numbers 1 and 2 with XOR.

1.......0001

2.......0010

Following the rules above, we get a final result of 0011 which equals

Now suppose we had a 3-cell XOR cage containing the digits 1, 2, and 3. How exactly would that work?

1.......0001

2.......0010

3.......0011

The XOR operator takes binary strings 2 at a time, so we'll need to use an intermediate result for this calculation.

As shown in the 2-cell example above, adding 1 and 2 gives a result of 0011. Now we're going to take that intermediate result of 0011 and add the binary representation of 3 to it like so.....

Working from left to right, we get a final answer of 0000 which of course equals

Having given a brief explanation and examples, I now present my XOR tables.

2 cell table

1: 01 23 45 67

2: 02 13 46 57

3: 03 12 47 56

4: 04 15 26 37

5: 05 14 27 36

6: 06 17 24 35

7: 07 16 25 34

8: 08

9: 18

10: 28

11: 38

12: 48

13: 58

14: 68

15: 78

3 cell table

0: 011 022 033 044 055 066 077 088 123 145 167 246 257 347 356

1: 001 023 045 067 122 133 144 155 166 177 188 247 256 346 357

2: 002 013 046 057 112 147 156 233 244 255 266 277 288 345 367

3: 003 012 047 056 113 146 157 223 245 267 344 355 366 377 388

4: 004 015 026 037 114 127 136 224 235 334 455 466 477 488 567

5: 005 014 027 036 115 126 137 225 234 335 445 467 566 577 588

6: 006 017 024 035 116 125 134 226 237 336 446 457 556 677 688

7: 007 016 025 034 117 124 135 227 236 337 447 456 557 667 788

8: 008 118 228 338 448 558 668 778

9: 018 238 458 678

10: 028 138 468 578

11: 038 128 478 568

12: 048 158 268 378

13: 058 148 278 368

14: 068 178 248 358

15: 078 168 258 348

I did NOT differentiate between L-shaped and in-line 3-cell cages in the tables above. Even if you guys don't see any XOR operators in Advanced Calcudoku volume IV, this post may very well inspire Patrick to include it in subsequent volumes. And if you DO have to tussle with XOR, now you've got tables to help you out! As always, it's my pleasure making these tables for you guys and best of luck with Advanced Calcudoku volume IV.

]]>

2 cells

1| 01

2| 02

3| 03 12 13 23

4| 04

5| 05 14 15 45

6| 06 24 26 46

7| 07 16 17 25 27 34 35 36 37 47 56 57 67

8| 08

9| 18

10| 28

11| 38

12| 48

13| 58

14| 68

15| 78

3 cells

1| 001 011

2| 002 022

3| 003 012 013 023 033 112 113 122 123 133 223 233

4| 004 044

5| 005 014 015 045 055 114 115 144 145 155 445 455

6| 006 024 026 046 066 224 226 244 246 266 446 466

7| 007 016 017 025 027 034 035 036 037 047 056 057 067 077 116 117 124 125 126 127 134 135 136

137 146 147 156 157 166 167 177 225 227 234 235 236 237 245 247 255 256 257 267 277 334 335

336 337 344 345 346 347 355 356 357 366 367 377 447 456 457 467 477 556 557 566 567 577 667

677

8| 008 088

9| 018 118 188

10| 028 228 288

11| 038 128 138 238 338 388

12| 048 448 488

13| 058 148 158 458 558 588

14| 068 248 268 468 668 688

15| 078 168 178 258 278 348 358 368 378 478 568 578 678 778 788

I will not go into detail as to how the bitwise OR operator works, since clm has already done just that.

Anyhow, I hope these tables give you guys a boost with the book puzzles.

]]>

if we look at a 'normal' cell with positive only values - say 2,5 - the answer can be either 1 or 2. If zero is included, the only answer can be 0 as division by 0 is undefined. If we take a cell with -1 and 4 (for example), -1 divided by 4 leaves a remainder of -1, while 4 divided by -1 leaves a remainder of 0. Is this correct? Or should -1 divided by 4 leave a remainder of 3?

EDIT; I've just had another look at the puzzles and I notice that none of the non zero mod cells can contain a -1. So I guess the question is moot as far as those puzzles are concerned.

]]>

https://github.com/lucrae/kenken-solve

]]>

First, 3 important caveats:

A) Unlike clm, I did NOT distinguish between L-shaped and straight-line cages for my 3-cell bitwise AND table.

B) I only compiled tables for cages with 2 or 3 cells.

C) My tables do not include the numbers 9 or above.

A list of the numbers 1-15 represented in binary can be found in the post "Full tables: MOD and bitwise OR" by clm under the "Solving strategies and tips" section of the forum. You'll need to scroll down for a bit to see it, and I strongly recommend keeping a copy of that list close at hand when working with bitwise AND/OR operators.

Without further ado, here are my bitwise AND tables.

2 cells

0& 01 02 03 04 05 06 07 08 12 14 16 18 24 25 28 34 38 48 58 68 78

1& 13 15 17 35

2& 23 26 27 36

3& 37

4& 45 46 47 56

5& 57

6& 67

3 cells

0& 001 002 003 004 005 006 007 008 011 012 013 014 015 016 017 018 022 023 024 025 026 027 028 033 034 035 036 037 038 044 045 046 047 048 055 056 057 058 066 067 068 077 078 088 112 114 116 118 122 123 124 125 126 127 128 134 136 138 144 145 146 147 148 156 158 166 167 168 178 188 224 225 228 234 235 238 244 245 246 247 248 255 256 257 258 268 278 288 334 338 344 345 346 347 348 356 358 368 378 388 448 458 468 478 488 558 568 578 588 668 678 688 778 788

1& 113 115 117 133 135 137 155 157 177 335 355 357

2& 223 226 227 233 236 237 266 267 277 336 366 367

3& 337 377

4& 445 446 447 455 456 457 466 467 477 556 566 567

5& 557 577

6& 667 677

Suppose, for example, that someone were to submit a 6x6 twin puzzle using the bitwise AND operator. Imagine that we've got a 2-cell cage that needs 12x on one side and 0& on the other. In a 6x6 calcudoku, there are only 2 ways to achieve a product of 12 - either 2x6 or 3x4. The question is, which of those combos gives the required 0&? To find out, the 2x6 and 3x4 combos will be combined with bitwise AND.

First, though, let's see what 2, 3, 4, and 6 look like in binary code.

2………0010

3………0011

4………0100

6………0110

2………0010

6………0110

adding up each column, we get

3………0011

4………0100

adding up each column, we get

A brief reminder as to how bitwise AND works:

0 and 1 make 0

1 and 1 make 1

It was my pleasure taking the time to compile these tables for you guys, and I hope this post helps you to solve bitwise AND puzzles.

]]>