NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

var readline = require('readline');
var textO = "";
var logoTemplate = {name : "", pattern: ""};
var logoArray = [];
var Size = 0;
var booleanY = "yes";
var booleanN = "no";
var myarray=[];
for (i=0; i <21; i++)
myarray[i]=[];

for(i = 0; i<21;i++){
for(j = 0; j<21;j++){
myarray[i][j] = ' ';

}

}

var myarrayDot=new Array(21)
for (i=0; i <21; i++)
myarrayDot[i]=new Array(21)

for(i = 0; i<21;i++){
for(j = 0; j<21;j++){
myarrayDot[i][j] = ".";

}

}
var rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
terminal: false
});

function text(txt) {

textO = textO +txt;

}




function SAME(name1,name2){

logo1Positions= [[]];
logo2Positions= [[]];
var indexOfRef = 0;
var indexOfOther = 0;
var base = ({x : 0, y: 0});
var pos1 = ({x : 0,y : 0});
var pos2 = ({x : 0,y : 0});
var finalPos1 = ({x : 0, y : 0});
var finalPos2 = ({x : 0, y : 0});
for(i = 0; i< Size; i++){
if(logoArray[i].name === name1){
for(k = 0; k<logoArray[i].pattern.length; k++){
indexOfRef = i;
if(logoArray[i].pattern.charAt(k)==="D"){
pos1.x = pos1.x +1;
}else if(logoArray[i].pattern.charAt(k)==="U"){
pos1.x = pos1.x-1;
}else if(logoArray[i].pattern.charAt(k)==="R"){
pos1.y = pos1.y+1;
}else if(logoArray[i].pattern.charAt(k)==="L"){
pos1.y = pos1.y-1;
}

}
}else if(logoArray[i].name === name2){
indexOfOther = i;
for(k = 0; k<logoArray[i].pattern.length; k++){

if(logoArray[i].pattern.charAt(k)==="D"){
pos2.x = pos2.x +1;
}else if(logoArray[i].pattern.charAt(k)==="U"){
pos2.x = pos2.x-1;
}else if(logoArray[i].pattern.charAt(k)==="R"){
pos2.y = pos2.y+1;
}else if(logoArray[i].pattern.charAt(k)==="L"){
pos2.y = pos2.y-1;
}
}



}

}

console.log(indexOfOther);
var pattern90;
var pattern180;
var pattern270;


for(y =0; y<logoArray[indexOfOther].pattern.length; y++){

if(logoArray[indexOfOther].pattern.charAt(y) === "D"){
pattern90 = pattern90+"L";
}else if(logoArray[indexOfOther].pattern.charAt(y) === "U"){
pattern90 = pattern90+"R";
}else if(logoArray[indexOfOther].pattern.charAt(y) === "R"){
pattern90 = pattern90+"D";
}else if(logoArray[indexOfOther].pattern.charAt(y) === "L"){
pattern90 = pattern90+"U";
}

}

for(y =0; y<logoArray[indexOfOther].pattern.length; y++){

if(logoArray[indexOfOther].pattern.charAt(y) === "D"){
pattern180 = pattern180+"U";
}else if(logoArray[indexOfOther].pattern.charAt(y) === "U"){
pattern180 = pattern180+"D";
}else if(logoArray[indexOfOther].pattern.charAt(y) === "R"){
pattern180 = pattern180+"L";
}else if(logoArray[indexOfOther].pattern.charAt(y) === "L"){
pattern180 = pattern180+"R";
}

}
for(y =0; y<logoArray[indexOfOther].pattern.length; y++){

if(logoArray[indexOfOther].pattern.charAt(y) === "D"){
pattern270 = pattern270+"R";
}else if(logoArray[indexOfOther].pattern.charAt(y) === "U"){
pattern270 = pattern270+"L";
}else if(logoArray[indexOfOther].pattern.charAt(y) === "R"){
pattern270 = pattern270+"U";
}else if(logoArray[indexOfOther].pattern.charAt(y) === "L"){
pattern270 = pattern270+"D";
}

}

finalPos1.x = base.x - pos1.x;
finalPos1.y = base.y - pos1.y;
finalPos2.x = base.x - pos2.x;
finalPos2.y = base.y - pos2.y;

console.log(finalPos1);
console.log(finalPos2);
engrave2(logoArray[indexOfRef].name,5,5);
countBlok = 0;
countTire =0;
for(o = 0; o<21; o++){
for(k =0; k<21; k++){
if(myarray[o][k] === "|"){
countBlok++;
}else if(myarray[o][k] === "-"){
countTire++;
}
}
}
countBlok2 = 0;
countTire2 =0;
if( (Math.abs(finalPos1.x)+Math.abs(finalPos1.y)) === (Math.abs(finalPos2.x)+Math.abs(finalPos2.y))){

engrave2(logoArray[indexOfOther].name,5+finalPos2.x,5+finalPos2.y);
for(o = 0; o<21; o++){
for(k =0; k<21; k++){
if(myarray[o][k] === "|"){
countBlok2++;
}else if(myarray[o][k] === "-"){
countTire2++;
}
}
}
}else{
engrave2(logoArray[indexOfOther].name,5+finalPos1.x,5+finalPos1.y);
for(o = 0; o<21; o++){
for(k =0; k<21; k++){
if(myarray[o][k] === "|"){
countBlok2++;
}else if(myarray[o][k] === "-"){
countTire2++;
}
}
}
}



if(countBlok === countBlok2 && countTire === countTire2){
console.log("yes");
}else{


countBlok2deg90 = 0;
countTire2deg90 =0;
logoArray[indexOfOther].pattern = pattern90;
if( (Math.abs(finalPos1.x)+Math.abs(finalPos1.y)) === (Math.abs(finalPos2.x)+Math.abs(finalPos2.y))){

engrave2(logoArray[indexOfOther].name,5+finalPos2.x,5+finalPos2.y);
for(o = 0; o<21; o++){
for(k =0; k<21; k++){
if(myarray[o][k] === "|"){
countBlok2deg90++;
}else if(myarray[o][k] === "-"){
countTire2deg90++;
}
}
}
}else{
engrave2(logoArray[indexOfOther].name,5+finalPos1.x,5+finalPos1.y);
for(o = 0; o<21; o++){
for(k =0; k<21; k++){
if(myarray[o][k] === "|"){
countBlok2deg90++;
}else if(myarray[o][k] === "-"){
countTire2deg90++;
}
}
}
}
if(countBlok === countBlok2deg90 && countTire === countTire2deg90){
console.log("yes");
}else{
countBlok2deg180 = 0;
countTire2deg180 =0;
logoArray[indexOfOther].pattern = pattern180;
if( (Math.abs(finalPos1.x)+Math.abs(finalPos1.y)) === (Math.abs(finalPos2.x)+Math.abs(finalPos2.y))){

engrave2(logoArray[indexOfOther].name,5+finalPos2.x,5+finalPos2.y);
for(o = 0; o<21; o++){
for(k =0; k<21; k++){
if(myarray[o][k] === "|"){
countBlok2deg180++;
}else if(myarray[o][k] === "-"){
countTire2deg180++;
}
}
}
}else{
engrave2(logoArray[indexOfOther].name,5+finalPos1.x,5+finalPos1.y);
for(o = 0; o<21; o++){
for(k =0; k<21; k++){
if(myarray[o][k] === "|"){
countBlok2deg180++;
}else if(myarray[o][k] === "-"){
countTire2deg180++;
}
}
}
}

if(countBlok === countBlok2deg180 && countTire === countTire2deg180){
console.log("yes");
}else{
countBlok2deg270 = 0;
countTire2deg270 =0;
logoArray[indexOfOther].pattern = pattern270;
if( (Math.abs(finalPos1.x)+Math.abs(finalPos1.y)) === (Math.abs(finalPos2.x)+Math.abs(finalPos2.y))){

engrave2(logoArray[indexOfOther].name,5+finalPos2.x,5+finalPos2.y);
for(o = 0; o<21; o++){
for(k =0; k<21; k++){
if(myarray[o][k] === "|"){
countBlok2deg270++;
}else if(myarray[o][k] === "-"){
countTire2deg180++;
}
}
}
}else{
engrave2(logoArray[indexOfOther].name,5+finalPos1.x,5+finalPos1.y);
for(o = 0; o<21; o++){
for(k =0; k<21; k++){
if(myarray[o][k] === "|"){
countBlok2deg270++;
}else if(myarray[o][k] === "-"){
countTire2deg270++;
}
}
}




}


if(countBlok === countBlok2deg270 && countTire === countTire2deg270){
console.log("yes");
}else{
console.log("no");

}

}

}
}



/** Başlangıç noktası referans alınan noktanın başlangıç noktasından finalPosun çıkarılması. Üstüne yazdır, eğer fazladan çizgi veya blok varsa false yoksa true; */
}




function LOGO(name1, pattern1){
logoTemplate.name = name1;
logoTemplate.pattern = pattern1
logoArray[Size] = Object.assign({},logoTemplate);
Size++;
console.log(logoTemplate.name + " defined");

}
function engrave(enteredLogo, x,y){

x= 2*parseInt(x)-2;
y= 2*parseInt(y)-2;
for(i = 0; i<Size;i++){

if(logoArray[i].name === enteredLogo){


for(k = 0; k<logoArray[i].pattern.length; k++){

if(logoArray[i].pattern.charAt(k) === "D"){

myarray[x+1][y] = "|";
x= x+2;
}else if(logoArray[i].pattern.charAt(k) === "U"){

myarray[x-1][y] = "|";
x=x-2;

}else if(logoArray[i].pattern.charAt(k) === "R"){

myarray[x][y+1] = "-";
y=y+2

}else if(logoArray[i].pattern.charAt(k) === "L"){

myarray[x][y-1] = "-";
y=y-2;



}
}

}
}
for(i = 0; i<21;i++){
if(i%2 === 0){
for(j = 0; j<21;j++){
if(j%2=== 0){
text(myarrayDot[i][j]);
}else{
text(myarray[i][j]);
}

}
}else{

for(j = 0; j<21;j++){

text(myarray[i][j]);

}
}
text("n");

}
console.log(textO);


}
function engrave2(enteredLogo, x,y){

x= 2*parseInt(x)-2;
y= 2*parseInt(y)-2;
for(i = 0; i<Size;i++){

if(logoArray[i].name === enteredLogo){


for(k = 0; k<logoArray[i].pattern.length; k++){

if(logoArray[i].pattern.charAt(k) === "D"){

myarray[x+1][y] = "|";
x= x+2;
}else if(logoArray[i].pattern.charAt(k) === "U"){

myarray[x-1][y] = "|";
x=x-2;

}else if(logoArray[i].pattern.charAt(k) === "R"){

myarray[x][y+1] = "-";
y=y+2

}else if(logoArray[i].pattern.charAt(k) === "L"){

myarray[x][y-1] = "-";
y=y-2;



}
}

}
}


}

var recursiveAsyncReadLine = function () {
rl.question("", function (line) {
var inputArray = [];
inputArray = line.split(" ");
console.log(inputArray);
switch (inputArray[0]){
case "LOGO":
LOGO(inputArray[1],inputArray[2]);
break;
case "ENGRAVE":
engrave(inputArray[1],parseInt(inputArray[2]),parseInt(inputArray[3]));
break;
case "SAME":
SAME(inputArray[1],inputArray[2]);
break;
case "exit":
return rl.close();

default:
console.log("No such option. Please enter another: ");
}
recursiveAsyncReadLine(); //Calling this function again to ask new question
});
};




recursiveAsyncReadLine();
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.