OpenLLM-France/wikimedia huggingface dataset:
# King's Indian Attack
### 2. g3

A sound, but very unambitious opening move where white almost certainly intends to fianchetto his bishop and enable castling. Black has the choice to continue to mirror white's move once more with g6 or begin a more aggressive attempt to control the center.

## Theory table

For explanation of theory tables, see theory table and for notation, see algebraic notation. .
1. Nf3 Nf6 2.g3
| 2 | 3 | 4 | 5 | 6 |
| g3 d5 | Bg2 c6 | O-O Bg4 | d3 Nbd7 | Nbd2 e5 | = |
| g3 g6 | Bg2 Bg7 | O-O O-O | d3 d5 | Nbd2 Nc6 | = |
When contributing to this Wikibook, please follow the Conventions for organization.

## See also

* 1. Nf3 d5 2.g3
* King's Indian Defence

## References

* Kasparov, Garry, & Keene, Raymond 1989 Batsford chess openings 2. ISBN 0-8050-3409-9.
* Flank Openings (1990), Bruno Carlier, Trends Publications, No ISBN
* This Chess related article is a stub. Please assist Wikibooks by expanding it.
# Chess Opening Theory/1. Nf3/1...c5/2. g3/2...Nc6/3. Bg2
### 3. Bg2

Black can try to mirror White with 3...g6 or play a bit more aggressively with 3...e5. The unusual 3...d5 transposes to the French Variation of the King's Indian Attack.

## Theory table

For explanation of theory tables, see theory table and for notation, see algebraic notation.
1. Nf3 c5 2. g3 Nc6 3. Bg2
| | 3 | 4 |
| | ... g6 | O-O Bg7 | = |
| | ... e5 | c4 g6 | = |
| Reversed Grünfeld | ... d5 | d4 Nf6 | = |
When contributing to this Wikibook, please follow the Conventions for organization.
# King's Indian Attack
### 2...g6
## Theory table

For explanation of theory tables, see theory table and for notation, see algebraic notation. .
1. Nf3 Nf6 2. g3 g6
| | 3 |
| King's Indian, Fianchetto without c4 | d4 Bg7 | to 1.d4 Nf6 2.Nf3 g6 3.g3 |
| English | c4 Bg7 | to 2.c4 g6 3.g3 |
| King's Indian Attack | Bg2 Bg7 | zz |
When contributing to this Wikibook, please follow the Conventions for organization.

## See also

* King's Indian Defence

## References

* Kasparov, Garry, & Keene, Raymond 1989 Batsford chess openings 2. ISBN 0-8050-3409-9.
* Flank Openings (1990), Bruno Carlier, Trends Publications, No ISBN
* This Chess related article is a stub. Please assist Wikibooks by expanding it.
# Chess Opening Theory/1. Nf3/1...c5/2. g3/2...Nc6
### 2...Nc6

White will most likely play 3. Bg2 to justify the g3 push. Transpositions with 3. c4 and 3. e4 are possible.

## Theory table

For explanation of theory tables, see theory table and for notation, see algebraic notation. .
1. Nf3 c5 2. g3 Nc6
| 3 | 4 |
| Bg2 g6 | O-O Bg7 | = |
| c4 g6 | Bg2 Bg7 | = |
| e4 g6 | Bg2 Bg7 | = |
When contributing to this Wikibook, please follow the Conventions for organization.
# English Opening
### 3.Nc3
## Theory table

For explanation of theory tables, see theory table and for notation, see algebraic notation. .
1.Nf3 Nf6 2.c4 g6 3.Nc3
| | 3 |
| King's Indian Defense | ... Bg7 | d4 |
| Grunfeld, Russian | ... d5 | d4 |
When contributing to this Wikibook, please follow the Conventions for organization.
# Sicilian Invitation (Réti Opening)
### 1...c5

Black invites White to transpose into the Sicilian Defence with 2. e4 White has a number of other choices here. 2. c4 transposes into a Symmetrical English. Many other moves are possible—the position is still very flexible for both sides.

## Theory table

For explanation of theory tables, see theory table and for notation, see algebraic notation. .
1. Nf3 c5
| | 2 |
| English | c4 ... | = |
| Sicilian Defence | e4 ... | = |
| | g3 ... | = |
| | d4 ... | = |
| | b3 ... | = |
When contributing to this Wikibook, please follow the Conventions for organization.

## References

* Kasparov, Garry, & Keene, Raymond 1989 Batsford chess openings 2. ISBN 0-8050-3409-9.
* Nunn's Chess Openings. 1999. John Nunn (Editor), Graham Burgess, John Emms, Joe Gallagher. ISBN 1-8574-4221-0.
# Chess Opening Theory/1. Nf3/1...c5/2. g3
### 2. g3

White plans to fianchetto the light-squared bishop.

## Theory table

For explanation of theory tables, see theory table and for notation, see algebraic notation. .
1. Nf3 c5 2. g3
| 2 |
| ... Nc6 | = |
| ... g6 | = |
When contributing to this Wikibook, please follow the Conventions for organization.
# English Opening, Anglo-Indian Defense, King's Indian Formation
## 2...g6
## Theory table

For explanation of theory tables, see theory table and for notation, see algebraic notation. .
1.Nf3 Nf6 2.c4 g6
| | 2 |
| King's Indian Defense | d4 Bg7 | to 1.d4 Nf6 2.c4 g6 3.Nf3 |
| King's Indian | Nc3 Bg7 | |
| English | g3 Bg7 | |
When contributing to this Wikibook, please follow the Conventions for organization.

## References

* Kasparov, Garry, & Keene, Raymond 1989 Batsford chess openings 2. ISBN 0-8050-3409-9.
# C++ Programming/Exercises/Standard IO
## Exercises for beginners : The Standard IO Stream
### EXERCISE 1

The following challenge will help to reinforce what you've learned, and give you a springboard from which to start experimenting:
Write a simple program which, when run, asks the user for their name and age, and then displays this back to them. Sample input/output and possible wording are provided below:
# C++ Programming/Exercises/Static arrays

using namespace std;
void enterNumbers(int arr, int n) {
void countAndTotal(int arr, int n, int& pos, int& neg, int& total) {
int main {
# C++ Programming/Exercises/Variables and types/Pages
## Exercises for beginners : Variables and types
### EXERCISE 1

Write a program that asks the user to type the width and the height of a rectangle and then outputs to the screen the area and the perimeter of that rectangle.
Solution #1
Solution #2
Solution #3
Solution #4
Solution #5
Solution #6
solution #7
Solution #8

### EXERCISE 2

Write a program that asks the user to type 5 integers and writes the average of the 5 integers. This program can use only 2 variables.
Solution #1
Solution #2
Solution #3
Solution #4
Solution #5
Solution #6
Solution #7
Solution #8
Solution #9
Solution #10
Solution #11
Solution #12

### EXERCISE 3

Write a program that asks the user to type 2 integers A and B and exchange the value of A and B.
Solution #1
Solution #2
Solution #3
Solution #4
Solution #5
Solution #6
Solution #7
Solution #8
Solution #9
Solution #10
Solution #11

### EXERCISE 4

Write a program that asks the user to type the price without tax of one kilogram of tomatoes,the number of kilograms you want to buy and the tax in percent units. The program must write the total price including taxes.
Solution #1
Solution #2
Solution #3:
Solution #4:
Solution #5
Solution #6
Solution #7
Solution #8
Solution #9

### EXERCISE 5

Write a program that asks the user to type the coordinate of 2 points, A and B (in a plane), and then writes the distance between A and B.
Solution #1:
Solution #2:
Solution #3
Solution #4
Solution #5
Solution #6

### EXERCISE 6

Find the Answer to 100C10 ; Find the Answer to 20C5 ; Find the Answer to 40C30 ; Find the Answer to 90C10.6 ; Find the Answer to 120C30 ; Find the Answer to 150C32.32 ;
Write a program in C++ ISO/IEC or C++/CLI without ever closing down the program find the answers to all above questions.
Solution #1
Solution #2

### EXERCISE 7

Write a program which asks for a student score. Score is a number from 0-100. Translate the score into grade according to the next limits: score >= 90 ==> "A" score >= 80 ==> "B" score >= 70 ==> "C" score >= 60 ==> "D" anything else ==> "F"
if the score is 100 print "Perfect score!".
Solution #1
Solution #2: Here is an example that refrains from copying string data by tying directly into std::cout.
# C++ Programming/Idioms
## Idioms
### Handling self-assignment in an assignment operator

T::operator= that handles the case where the LHS and the RHS refer to the same object.
Notes:
* Keep in mind the differences between identity (the LHS and the RHS are the same object) and equality (the LHS and the RHS have the same value). T::operator= has to protect itself against identity since then, the code for assigning can conveniently and safely assume that the LHS and the RHS refer to different objects.
* There are other techniques that are superior but not applicable in all situations. For example, if all the members of the class T (say, mem1, mem2, ..., memN) provide a swap function, one could use the following code instead:

### Pointer To Implementation (pImpl)

The "pointer to implementation" (pImpl) idiom, also called the "opaque pointer" idiom, is a method of providing data and thus further implementation abstraction for Classes.
In C++ you have to declare member variables within the class definition which is then public and that this is necessary so that an appropriate memory space is allocated means that abstraction of implementation is not possible in "all" classes.
However, at the cost of an extra pointer dereference and function call, you can have this level of abstraction through the Pointer to Implementation.
So somebody who works with the Book class only really needs to know about print, but what happens if you wish to add more detail to your book class.
Now all the users of book have to recompile because the object they know about got bigger, yet they still only call print.
pImpl would implement the following pattern so that this would not be a problem.
and in a separate 'internal' header
The body of the Book class then would look something like
then invoked from a main function:
You could also use std::unique_ptr<BookImpl> or equivalent to manage the internal pointer.

## Further reading

* More C++ Idioms
* Wikipedia: opaque pointer
# C++ Programming/Exercises/Variables and types

* include<iostream>
* include<cstdio>
using namespace std; int main { char name[100]; int count=0; cout<<"enter a string"; gets(name); while(name[count]!='10') { count++; } cout<<"length of the string is"<<count; }
# C++ Programming/Exercises/Functions/Pages

using namespace std;
int main {

### EXERCISE 1

Write a program that performs arithmetic division. The program will use two integers, a and b (obtained by the user) and will perform the division a/b, store the result in another integer c and show the result of the division using cout. In a similar way, extend the program to add, subtract, multiply, do modulo and power using integers a and b. Modify your program so that when it starts, it asks the user which type of calculation it should do, then asks for the 2 integers, then runs the user selected calculation and outputs the result in a user friendly formatted manner.
Sample run:
Solution #1
Solution #2
The solution in C++.

### EXERCISE 2

Basically the same as exercise 1, but this time, the function that adds the numbers should be void, and takes a third, pass by reference parameter; then puts the sum in that.
Solution #1
Solution #2
Solution #3

### EXERCISE 3

Write a recursive function that finds the #n integer of the Fibonacci sequence. Then build a minimal program to test it. For reference see Wikipedia:Fibonacci number.
Solution #1

### EXERCISE 4

Basically the same as exercise 3, although this time you mustn't use recursion.
Solution #1
For extra exercise, give a big number (like 1000000) to both exercise 3 and 4 solutions and compare the execution times. Ponder on the results ;)

### EXERCISE 5

Create a calculator that takes a number, a basic math operator (+,-,*,/,^), and a second number all from user input, and have it print the result of the mathematical operation. The mathematical operations should be wrapped inside of functions.
Solution #1
Hammad city university
Solution #2
Soln #3
# C++ Programming/Exercises/Static arrays/Pages

programing 1
integers, a and b (obtained by the user) and will perform the division a/b, store the result in another integer c and show the result of the division using cout. In a similar way, extend the program to add, subtract, multiply, do modulo and power using integers a and b. Modify your program so that when it starts, it asks the user which type of calculation it should do, then asks for the 2 integers, then runs the user selected calculation and outputs the result in a user friendly formatted manner. Solution #1
Solution #2
Solution #3
Solution #4
Solution #5:
Solution #6:
Solution #7:

### EXERCISE 2

Write a program that uses a “for” loop to count from 0-10 and show the numbers on the screen. In the same file, re-write this program without using a “for” loop.
Solution #1
Solution #2
Solution #3
Solution #4
Solution #5
Solution #6
solution #7
* include<iostream>
* include<windows.h>
* define MAX 50
using namespace std;
void NumbersToEnter; void LoopNumbers; void NumberSearch;
int numbersToEnter, number[MAX], numberSearch, lookNumber, i;
int main{
void NumbersToEnter{
} void LoopNumbers{
} void NumberSearch{
} <by: VR>

### EXERCISE 4

Write a program that asks the user to type 10 integers of an array and an integer value V. The program must search if the value V exists in the array and must remove the first occurrence of V, shifting each following element left and adding a zero at the end of the array. The program must then write the final array.
Solution #1
Solution #2
Solution #3
Solution #4

### EXERCISE 5

Write a program that asks the user to type 10 integers of an array and an integer value V and an index value i between 0 and 9. The program must put the value V at the place i in the array, shifting each element right and dropping off the last element. The program must then write the final array.
Solution #1
Solution #2
Solution #3
Solution #4
Solution #5
Solution #6
Solution #7

### EXERCISE 6

Write a program that search for a number in an int type array of length 10, using binary search. The program repeatedly asks the user to enter a number for searching unless the user press ‘N’ as a sentinel value.
Solution #1
Solution #2
Solution #3
Solution #4:
Solution #5:
Solution #6:

### EXERCISE 8

Write a program which takes 2 arrays of 10 integers each, a and b. c is an array with 20 integers. The program should put into c the appending of b to a, the first 10 integers of c from array a, the latter 10 from b. Then the program should display c.
Solution #1
Solution #2
Solution #3
Solution #4
Solution #5
# Canadian Criminal Law/Defences/Abandonment
## General Principles

Abandonment requires that there be a "change of intention on the part of the accused and, where practical and reasonable, a timely communication of the accused’s intention to abandon the common unlawful purpose".
Where group have jointly planned to commit a rape and murder and the accused assisted in the initial part of the illegal plan but then leaves part way through does not abandon the offence and can still be convicted of murder.
* ↑ R. v. S.R.B., 2009 ABCA 45 (CanLII) at para. 24 per dissent, dissent aff'd on appeal R. v. Bird, 2009 SCC 60 (CanLII), [2009] 3 SCR 638
* ↑ R. v. S.R.B., 2009 ABCA 45 (CanLII) overturned on appeal R. v. Bird, 2009 SCC 60 (CanLII), [2009] 3 SCR 638
# Canadian Criminal Law/Defences/Accident and Mistake
## Accident

An accident is a "mishap or untoward event not expected or designed", or "unforeseen contingency or occurrence" Its meaning varies depending on the type of charge. Where it is a specific intent offence, an accident relates to a denial of voluntariness of the act or denial of intention to cause the outcome. General intent offence claims the act was unexpected or chance that was not foreseeable.
The effect in law is that the mens rea is not present. This is distinctive from mistake which occurs in “the realm of perception”.
Once the accused establishes there is an "air of reality" to the defence, the crown must disprove the availability of the defence.
* ↑ R v Whitehorne 2005 CanLII 34553 (NLPC) Hill v. R., 1973 CanLII 36, [1975] 2 SCR 402, (1974) 14 CCC (2d) 505 (SCC) at p. 510
* ↑ Criminal Pleading & Practice, Ewaschuck, (2nd Edition) at para. 21.0030 R. v. Mathisen, 2008 ONCA 747 at 70
* ↑ R v Whitehorne
* ↑ R. v. Sutherland, 1993 CanLII 6614 (SK CA), (1994) 84 CCC (3d) 484 (Sask. C.A.) per Vanscise, J.A., at pp. 497-498

## Reflex

It is permissible to argue that the action of accused was not voluntary as it was a reflexive act.
* ↑ R. v. Pirozzi (1987), 34 C.C.C. (3d) 376 (Ont. C.A.) R. v. Mullin (1990), 56 C.C.C. (3d) 476 (P.E.I.C.A.) R. v. Wolfe, (1974) 20 CCC (2d) 382 (Ont. C.A.): accused hits victim on head with telephone by reflex
# Canadian Criminal Law/Defences/Due Diligence
## General Principles

Once the Crown proves the elements of a regulatory or provincial offence or otherwise establishes a duty upon the accused, the onus is on the accused to establish due diligence. This must be proven on a balance of probabilities.
Due diligence requires the accused to "take all reasonable steps" to avoid the harm that resulted.
It is not necessary that the accused take all conceivable steps, however.
In assessing due diligence, WD test for credibility does not apply.
The accused must show that he took “all reasonable care” to avoid committing the offence.
This is considered from the perspective of a reasonable person in similar circumstances. This does not mean that the accused would be required to perform acts that would put the accused in unreasonable danger.
Industry Standards and Practices Compliance with industry standard practice is a factor that weighs in favour of due diligence but it not determinative.
Industry standards and practice cannot be of any value to due diligence if it is established that the standard is insufficient. It then cannot be used as a shield against responsibility.
* ↑ e.g. R. v. Ariganello, 2013 ONCJ 13 (CanLII)
* ↑ R. v. British Columbia Hydro and Power Authority, [1997] B.C.J. No. 1744 (S.C.), at para. 55 ("In other words, an accused must take all reasonable steps to avoid harm. However, that does not mean an accused must take all conceivable steps.")
* ↑ BC Hydro and Power Authority at para. 55
* ↑ R. v. Carpentier 2005 MBCA 134 (CanLII) at para. 27 Ariganello at para. 18 R. v. Defaria [2008] O.J. No. 5427, 2008 ONCJ 687 (CanLII) at para. 16
* ↑ see R. v. Emil K. Fishing Corp.; R. v. Kukuljan, 2008 BCCA 490 (CanLII), [2008] B.C.J. No. 2326; 304 D.L.R. (4th) 725 leave refused R. v. Bui, [2005] O.J. No. 1456(C.J.)
* ↑ R. v. London Excavators & Trucking Ltd. reflex, (1997) 26 C.C.E.L.(2d) 132(Ont. P.C.) R. v. Pilen Construction of Canada Ltd. [1999] O.J. No. 5650, affd [2001] O.J. No. 2980 (S.C.J.) Libman, Regulatory Offences in Canada, at page 7-27 (“…a defendant cannot hide behind commonly accepted standards of care if, in the circumstances, due diligence warrants a higher level of care.”)

## See Also

* Canadian Criminal Law/Regulatory and Provincial Prosecutions
# Canadian Criminal Law/Defences/Acting in Authority
## General Principles

   Protection of persons acting under authority 25. (1) Every one who is required or authorized by law to do anything in the administration or enforcement of the law
       (a) as a private person,
       (b) as a peace officer or public officer,
       (c) in aid of a peace officer or public officer, or
       (d) by virtue of his office,
   is, if he acts on reasonable grounds, justified in doing what he is required or authorized to do and in using as much force as is necessary for that purpose.
   – CCC
When considering the use of potential excessive force, the court should consider "the reasonable belief of the officer in all the circumstances as they existed at the time which belief must be justified by the facts at the time." The belief must be subjectively held as well as objectively reasonable.
* ↑ R. v. Hannibal, 2003 BCPC 504 at 143
# Canadian Criminal Law/Defences/Corrective Force
## Correction of child by force

   Correction of child by force 43. Every schoolteacher, parent or person standing in the place of a parent is justified in using force by way of correction toward a pupil or child, as the case may be, who is under his care, if the force does not exceed what is reasonable under the circumstances.
   R.S., c. C-34, s. 43.
   – CCC
Section 43, sets out three requirements
* The force must have been intended for corrective purposes.
* The child must have been capable of benefiting from the correction.
* The force used must have been objectively reasonable under the circumstances.
The first requirement implies that the actions of the child called for corrective action.
* ↑ R. v. Gervin, 2012 MBQB 44 at para 5 see also R. v. Sinclair 2008 MBCA 15
# Canadian Criminal Law/Defences/Alibi
## General Principles

Evidence constitutes an "alibi" where "the evidence at issue [is] determinative of the final issue of guilt or innocence of the accused." The evidence suggests that "it was impossible for the accused to have committed the crime charged because, at the time of its commission, the accused was elsewhere"
An alibi does not need to be proven, but rather it must simply raise a doubt.
All alibi evidence must be disclosed to the crown. This is an exception to the rule of the right to remain silent. This is due to "the ease with which alibi evidence may be fabricated; and the diversion of the alibi inquiry from the central inquiry at trial". Where the defence does not give enough notice and not sufficiently particularized for the police to investigate prior to trial, an adverse inference may be drawn from this.
Disclosure must be adequate and timely. If the disclosure does not satisfy these requirements, the trier of fact may draw an adverse inference when weighing the alibi evidence at trial.
The failure of the accused to testify on alibi may be used to draw an adverse inference about credibility of the defence. The reason for this is that aibi evidence is "not directly related to the guilt of the accused" so the determination of the credibility of the alibi does not go to the ultimate issue of guilt.
* ↑ R. v. M. R., 2005 CanLII 5845 (ON CA) at para 31 R. v. C.(T.W.) 2006 CanLII 12286, (2006), 209 O.A.C. 119 R. v. Hill 1995 CanLII 271 (ON CA), (1995), 102 C.C.C. (3d) 469 (Ont. C.A.) at 478-79
* ↑ Lizotte v. The King, 1950 CanLII 48 (S.C.C.), [1951] S.C.R. 115 R. V .J.B.J., 2011 NSCA 16 at para 40 to 45
* ↑ R. v. Cleghorn, [1995] 3 S.C.R. 175
* ↑ R v Noble [1997] 1 S.C.R. 874
* ↑ R v Noble at 111
* ↑ R v Noble at para 112
# Canadian Criminal Law/Defences/Automatism
## General Principles

The defence of "non-insane automatism" is a defence available at common law.
Automatism is the "involuntary behaviour, the state of a person who, though capable of action is not conscious of what he is doing. It means an unconscious involuntary act where the mind does not go with what is being done." It is a state of consciousness where the persons is capable of action, but has not voluntary control over the action.
The burden is on the accused to prove involuntariness on a balance of probabilities.
* ↑ R. v. Rabey (1977) 37 C.C.C. 2d 461 at 155
* ↑ Rabey at 156
* ↑ R v Stone at 179 (“The foregoing leads me to the conclusion that the legal burden in cases involving claims of automatism must be on the defence to prove involuntariness on a balance of probabilities to the trier of fact.”)
# Canadian Criminal Law/Defences/De Minimus
## De Minimus Principle

The principle of de minimus non curat lex excludes certain acts from criminal sanctions due to their trivial nature. The principle is based on the premise that the law should not concern itself with trifling matters.
In general, the least touching of another person without their consent constitutes an assault. The strength of the force is immaterial to consideration of guilt.
The principle cannot be applied in the context of domestic violence.
The defence can be invoked in relation to the possession of drugs where the amounts alleged are merely residual particles of a controlled substance.
Non-consensual touching that amounts to an assault, or that was trivial, is subject to the legal maxim de minimus non curat lex.
Light strikes can fall within the meaning of trifling.
* ↑ see R. v. Dawydiuk (2010), 253 C.C.C. (3d) 493, 2010 BCCA 162
* ↑ see R. v. Palombi (2007), 222 C.C.C. (3d) 528 (Ont. C.A.)
* ↑ R. v. Downey, 2002 NSSC 226 at para. 38
* ↑ R. v. Marusiak, 2002 ABQB 774
* ↑ R. v. Juneja, 2009 ONCJ 572 R v Hinchey (1996) 111 CCC 3d 353 (SCC) at P 380-81
* ↑ R. v. Merasty, 2002 SKPC 86, R. v. Wiebe, 2001 SKQB 389