ASCII art puzzle discussion

So maybe someone could give me a hint on how to start the puzzle? I don’t even have a clue how to make several chars look like a “big” (ASCII-Art) char. Is there some literature I can read to get prepared? Thank you guys.

Think about the parts from the ASCII artwork your program has to print and in what order, to produce the output.

Keep in mind that you don’t have to print everything at once. You can print chunks and when needed a newline till the output is complete.

I personally (without any clou how to to it) would say I try to print out every letter by it’s own - but how could I define how a letter has to look like? Especially if the height and width is variable its pretty hard to figure out how to tell te program “hey, an A in ASCII-Art has to look like this”. I thought I got it when defining points in an array for each letter / symbol came to my mind - but I don’t think thats the right way. I’d be really thankfull when someone could give me a hi(n)t in the right direction :slight_smile: Thanks in advance!

But it is! :slight_smile:

You have to realize that you can’t print every letter on its own, because the output has to be line by line, like a typewriter. So instead of printing every letter on its own, you print the first line of every letter. Then the second line of every letter, and so on.

You have to calculate what elements from the array to print for a specific letter and line.

Thank you, you really helped me getting towards beating this puzzle :slight_smile: Now I got that every letter consists of a two dimensional array (or 1 dimensional string array) - but doing this I’ll automatically define the heigth of every single letter. How do I expand the height dynamically?

If I got it right a char would look like this:

string[5] c = new string[5]();
c[0] = "     CCCCC";
c[1] = "   C      ";
c[2] = "  C       ";
c[3] = "   C      ";
c[4] = "     CCCCC";

(If this is not allowed please delete it)

So if the puzzle requires me to expand the letter to a height of 10 - how’d I do that?
or is my approach totally wrong?

Once again, thanks in advance :slight_smile:

You want to print x lines, so you have to use a for loop that runs x times and prints one line everytime it runs.

I think that your problem is that you don’t know what the Lorem Ipsum Text is. It is a text to test printers, and it has commas(","),and points ("."), so you have to consider that when there is a comma, a point or another non-valid character you have to print an interrogation symbol.

Excuse me for my English. :smile:

Excuse me, my code can’t draw out the first three charater (ABC), and draw out several character at the end (WYZ?). my code:

alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ?"
l = int(input())
h = int(input())
t = input().upper()
rows = [input() for i in range(h)]
def gettext(char, row):
    index = alphabet.index(char)
    return rows[row][index*l : index*(l+1)]
for i in range(h):
    print(''.join([gettext(char,i) for char in t]))

I can’t pass the “Lorem Ipsum dolor sit amet.,” test. I tried my version outputs this with the regular character set :

LOREM?IPSUM?DOLOR?SIT?AMET???

(I can’t upload my image because I’m a “new user”…)

Please what am I doing wrong ?? I also tried to add a new alphabet entry for the space character but it didn’t work

The space is a space, isn’t it?

Hello all,

I’m confused here. I use python and so far I only managed to pass the first exercise.
Here is how I do.
I have a variable “alph” containing all the characters.
In the “for” loop, I do this:
print(row[alph.find(t)*l] + row[alph.find(t)*l+1] + row[alph.find(t)*l+2] + row[alph.find(t)*l+3])

It seems like a really ugly way to succeed but is it possible for me to continue with this method and several letters in t?
I think I have to do a row[alph.find(t[x]*l] until x == len(t) and put all that code together but I don’t know how to do this, especially for the “put all that code together” part.

Any help would be appreciated.

I modified my code, now I have a function that gives a list of numbers for each letter of t.
For manhattan I have this : [12, 0, 13, 7, 0, 19, 19, 0, 13]
Now for the loop.

for i in range(h):

row=input()
print(row[my_function[0]l:my_function[0]l+4])

It makes an M appears in ASCII.
How can I do that for all numbers in my_function? Any tips?

Is there any particular specifications for ? or a size limit to handle so the output doesn’t go to next line ? I use javascript and the method to read the input is readLine().

Chez moi tout les caractères qui ne sont pas [a-zA-Z] y compris espaces, points sont représenter par un ?.
Est-ce le comportement attendu ? car le Lorem ipsum ne passe pas.

J’ai vu que pour certain le problème venait de la méthode de lecture de l’entrée qui ne lisait qu’un mot,
cependant dans mon cas j’utilise readLine() fournit par le site en javascript qui lit bien toute la ligne.

Faut-il limiter la taille de la sortie ? ou imprimer chaque mot sur une ligne différente ? Dans l’énoncer il y a 0<N<200 sans qu’il soit fait mention nulle par de ce que N est.

Merci d’avance.

Ok don’t bother, I passed it.

I know that there are more simply and better solution, but this is mine, and i’m so proud because i done it in a day.
If you know how i can do a better solution, you will only write, and i’ll be so happy to listen to another programmer advice :wink: Thank you all!

[EDIT: NO FULL CODE]

Please, no full code, we do not want people to copy/paste your code and not have as much fun as you had :frowning:

Just few tips:
If you can, write your variable names and your comments in English. When this is a personal/school/etc. project writing it in your own language is ok, but when you share it to on international community, you cannot expect them to understand easily your code if they can’t read it.

You do not need to create 26 if statement to write a letter in lowercase (or uppercase). These are things that are really common and you can expect that it already exist. You can go on Google and search " lowercase", i’m sure you’ll find what you need.
For your language, here is the documentation: http://docs.oracle.com/javase/7/docs/api/java/lang/String.html#toLowerCase()
So instead of:

letbylet = T.split("");
for loop over each letter to put it in uppercase

you can do it in one line, writting:

letbylet = T.toUpperCase().split("");

As for your hashmap where each letter is associated to an integer giving its index (A -> 0, B -> 1, …, Z -> 25), you can do the equivalent by creating the following function:

int indexOfLetter (String letter) {
return letter.charAt(0) - ‘A’;
}

As for your hashmap where each letter is associated to an integer giving its index (A -> 0, B -> 1, …, Z -> 25), you can do the equivalent by creating the following function:As for your hashmap where each letter is associated to an integer giving its index (A -> 0, B -> 1, …, Z -> 25), you can do the equivalent by creating the following function:

int indexOfLetter (String letter) {
    return letter.charAt(0) - 'A';
}

This works because letter.charAt(0) return a Character, and ‘A’ is a Character (notice the single quotes). A Character is internally just its ASCII value. In ASCII ‘A’ is 65, ‘B’ is 66, …, ‘Z’ is 90. so ‘Z’ - ‘A’ = 90 - 65 = 25.
This function would save you some lines, and you can add a comment for someone that would read your code and without knowing what happens when you subtract a Character to another Character.

Later in your code, I can see a try catch for a nullPointerException. You should avoid it when possible. Here you can try to better handle your variable to not compute something with a null.

It is hard for me to give you more comments on your code as I do not understand your variable.

By the way, we are working on a way to let you display your code to others on the platform. We would prefer that you wait this feature before publishing your code online (yes, I already said it in the beginning of the message, but it is really important to us).

1 Like

Hey guys, i’m using C to solve this but I have problem: if input is “string”, it returns “string?”.
Even with a single letter. E–>E?.
How is that possible?
the code of the interested part is:

for(int i=0; i<H;i++){
  char *pointer = T;
  int temp, space=32;

  while(*pointer != '\0'){
    (some code)     
    else temp = 26; /*temp is T[i] - 'A' or 'a' */
    int index = temp * L;
    printf("%.*s", L, elements[i]+index);
    pointer++;
  }
  printf("\n");
}  

PLEASE be aware that new to programming and C.

Just a guess: the default code uses something like fgets(buffer, size, stdin) to read the input lines. The final newline is stored in the buffer as well, and you should remove it.

1 Like

Thank you. I have been looking for hours.
Now i need to get test number 6 and 8 right. Test lorem ipsum and the other alphabet in ascii.
Is it possible that i can’t print a space as first character to print?

That’s right. If your first char is an A but if you use the A in any other position the problem will not occur.