diff options
| author | Syndamia <kami02882@gmail.com> | 2019-07-29 11:46:36 +0300 |
|---|---|---|
| committer | Syndamia <kami02882@gmail.com> | 2019-07-29 11:46:36 +0300 |
| commit | bc09da5a7b65b08b5d5dcd1e90173ad3b6081c23 (patch) | |
| tree | c66cebc02aac30ff859c06ca462f3dd58b6809b0 /Java/Beginer training/src/VampireNumber explanation.txt | |
| parent | 65edf7296baf48aad1b4e0c09b57f1a7f48791a8 (diff) | |
| download | Self-learning-bc09da5a7b65b08b5d5dcd1e90173ad3b6081c23.tar Self-learning-bc09da5a7b65b08b5d5dcd1e90173ad3b6081c23.tar.gz Self-learning-bc09da5a7b65b08b5d5dcd1e90173ad3b6081c23.zip | |
Did some more work in Python and started officially learning Java
Diffstat (limited to 'Java/Beginer training/src/VampireNumber explanation.txt')
| -rw-r--r-- | Java/Beginer training/src/VampireNumber explanation.txt | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/Java/Beginer training/src/VampireNumber explanation.txt b/Java/Beginer training/src/VampireNumber explanation.txt new file mode 100644 index 0000000..10ac553 --- /dev/null +++ b/Java/Beginer training/src/VampireNumber explanation.txt @@ -0,0 +1,39 @@ +VampireNumber Java task, code explanation with the number 1827: + +1827 (Number that we are checking) +0123 (Indexes of digits, in code they are named: first, second, third & fourth) + +The first and second number that are multiplied are illustrated combined as one (the first half of the calculated numbers is the first multiple, and the second half - the second) +For example, the number 1278 is actually 12 and 78 and they are multiplied to check for the result +This is done like that to better illustrate how the numbers change + +Cycle: Swap 1 with 3 (indexes): +1827 1728 +1782 1287 +1278 1872 + +2178 2871 +2817 2718 +2781 2187 NOTE: 2187 is the answer, so the code would stop here, but this example is continued to the end + +7281 7182 +7128 7821 +7812 7218 + +8712 8217 +8271 8172 +8127 8721 + +1827 (Here the cycles end) + +Cycle: it rotates the last 3 digits, for example if we have 123,the 3 gets in the front and the others move back, i.e. 312 + + 1 2 3 => 3 1 2 + ^-----' + +Swap 1 with 3: as the name suggests, it makes a second version of the number by swapping the 1st (index) and 2nd (index) digit + + 0 1 2 3 => 0 3 2 1 + ^---^ + + -the swap is there because with the cycle we miss out on half of the possible numbers
\ No newline at end of file |
