Did you read through all the posts here? You may find some hints relevant to you.
It is something weird, I have read the whole thread, even so I cannot identify the error, the validators of case 4 and 5 fail me, when other similar validators are passing.
edit: have iddentified the problem, was the size of the string for those two cases.
Hi, Can i have the datas of the Validator 2.
I am passing all the tests and validators but this one not.
Iβm using javascript
Hi, I have the same problem that aisak7, I have passed all tests but Iβm having 66% after submitting because case 4 and 5 failβ¦ I canβt find the issue, I think I respect all the constraints so would it be possible to get the values from the other tests to understand what happens ?
Iβm using java.
Thanks
Do the previous answers here help you?
Iβve read all the thread, and I probably misunderstood some messages but aisak7 was the one who seemed the closest of my problem but I canβt tellβ¦ Iβve tried to change my code but it didnβt have any effect on the post-tests
Maybe some suggestions above will help you even though their original questions arenβt the same as yours? If not, then you can always test your code using some custom cases. Probably a good idea to test the whole alphabet.
Initially, I thought the problem was the length of the message but I checked and it seems ok (maybe Iβm doing it the wrong way ?Idk), Iβve tested with a custom message with lowercase letter (the whole alphabet) and longer than 50 characters, Iβm running out of ideas ^^
Did you try custom test cases with different starting shifts too?
After several attempts, I did it !!
It was a specific error due toβ¦length in one lineβ¦
Thanks a lot @5DN1L to keep asking me
Hello,
Iβm trying to understand the βcaesarβ. From the description, I know that if βcaesarβ applied to βAAAβ, it results βEFGβ
Iβm wondering what the result of βcaesarβ when applied to βXYZβ or βZZZβ?
When you reach the end of the alphabet, you go back to the start of the alphabet again. You may refer to the explanation and examples here:
https://en.wikipedia.org/wiki/Caesar_cipher
Hi, I think I found an error in JavaScript because I deduce someone put 1 rotor where it should be the message and 1 of the rotors is the message, I attach images proofs and the code
const operation = readline();
const pseudoRandomNumber = parseInt(readline());
var alphabet = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"];
const message = readline();
let myMessage = message.split("");
let newMessage = [];
var splitRotor = [];
var prueba = [];
console.log("Mensaje a desifrar")
console.log(myMessage);
console.log("Numero aleatoreo: " + pseudoRandomNumber);
console.log("Primer Cifrado:");
console.log(newMessage = firstCaesarShift(myMessage, pseudoRandomNumber));
for (let i = 0; i < 3; i++) {
const rotor = readline();
splitRotor = rotor.split("");
switch (operation) {
case 'ENCODE':
for (let k = 0; k < newMessage.length; k++) {
var index = alphabet.indexOf(newMessage[k]);
if (index < splitRotor.length) {
newMessage[k] = splitRotor[index];
}
}
console.log(newMessage);
break;
case 'DECODE':
// do something
break;
}
console.log("Rotor " + (i + 1) + ": " + rotor);
}
function firstCaesarShift(myText = [], number = 0) {
for (let i = 0; i < myText.length; i++) {
var index = alphabet.indexOf(myText[i]);
if (~index) {
myText[i] = alphabet[((index + number) + i) % alphabet.length];
}
}
return myText;
}
---------------------------------OUTPUT OF THE CODE------------------------------------------`
Standard Output Stream:
Mensaje a desifrar
[
βBβ, βDβ, βFβ, βHβ, βJβ, βLβ,
βCβ, βPβ, βRβ, βTβ, βXβ, βVβ,
βZβ, βNβ, βYβ, βEβ, βIβ, βWβ,
βGβ, βAβ, βKβ, βMβ, βUβ, βSβ,
βQβ, βOβ
]
Numero aleatoreo: 4
Primer Cifrado:
[
βFβ, βIβ, βLβ, βOβ, βRβ, βUβ,
βMβ, βAβ, βDβ, βGβ, βLβ, βKβ,
βPβ, βEβ, βQβ, βXβ, βCβ, βRβ,
βCβ, βXβ, βIβ, βLβ, βUβ, βTβ,
βSβ, βRβ
]
[
βIβ, βXβ, βHβ, βMβ, βGβ, βPβ,
βWβ, βAβ, βKβ, βRβ, βHβ, βLβ,
βCβ, βSβ, βQβ, βVβ, βDβ, βGβ,
βDβ, βVβ, βXβ, βHβ, βPβ, βNβ,
βZβ, βGβ
]
Rotor 1: AJDKSIRUXBLHWTMCQGZNPYFVOE
[]
[
βVβ, βRβ, βQβ, βOβ, βDβ, βHβ,
βBβ, βEβ, βNβ, βUβ, βQβ, βTβ,
βMβ, βSβ, βXβ, βIβ, βFβ, βDβ,
βFβ, βIβ, βRβ, βQβ, βHβ, βWβ,
βJβ, βDβ
]
Rotor 2: EKMFLGDQVZNTOWYHXUSPAIBRCJ
[]
[
βVβ, βRβ, βQβ, βOβ, βDβ, βHβ,
βAβ, βEβ, βNβ, βUβ, βQβ, βTβ,
βMβ, βSβ, βXβ, βIβ, βFβ, βDβ,
βFβ, βIβ, βRβ, βQβ, βHβ, βWβ,
βJβ, βDβ
]
Rotor 3: AAA
[]
Would you format your src and IN/OUT-puts
to make them
easier to read?
sure, I just donβt know how to do it, and honestly, i thought nobody would respond haha, but let me figure out how to do it and ill send it to you
Do not send anything to me. Do write in public.
For formatting source codes:
i tried, seem it looks better now could you see if you can read it easily
Iβve reformatted your code and also moved your posts to the correct thread. Please search for old posts before creating a new topic in the future, thanks.
The issue with your code is that you have not read all the inputs properly. Lines 3 to 5 are the rotor strings. The message is in input line 6. You may refer to the Input section of the puzzle statement for more details.
Also, for debugging on CodinGame, you use console.error
.
console.log
is for outputting the final answer only.
Hope this helps.
Excellent code exercise, thank you for this and it was an interesting project to work on!