ASCII art puzzle discussion

my code pass all the test on submission save for the Lorem Ipsum one. I am testing for a space character and filling the respective output length with the same character. This is driving me crazy. :frowning:

1 Like

I didn’t have to test for a space, hyphen, or any non [a-zA-Z] character at all for that matter.

I basically parsed the testWord to chars, then during conversion to decimal ASCII, fettered out the non-alpha characters.I then used the decimal values as beginning indices for substrings, which I pulled from the ascii-art String input. These substrings got concatenated & became my output.

No need to search for non-alpha characters, as anything that wasn’t alpha got its substring index pointed to the “?” at the end.No need to search the ascii-art input either, as it’s really nothing more than a series of “images” the substrings point to.

For me, the biggest problem with the “another ascii/lorem” tests was remembering NOT to hard code the widths & lengths or the formulas that use them (failed the first few times before I finally figured out what I was doing wrong).

So basically, for the cranky test that has spaces in it, don’t think too hard. The question never said to handle spaces, so spaces should show up as question marks. I special formatted my text to handle spaces at first, got it wrong, checked here, then changed it, and it works.

Good luck!

1 Like

I must say that this challenge isn’t algorithmically though but it either has a bug or isn’t completely well explained or both.
Bottom line: the “lorem ipsum 
” challenge doesn’t pass. My solution is identical to the one described by @pegleg. (I have an array whose keys are the askii codes of the [a-zA-Z] codes, and they store the position on the alphabet (in input file) corresponding to the char they represent - on top of it when reading the file, I use dynamically the H,L and the dictionary described to locate the askii sequence needed, and then concatenate the sequence with former chars of T already parsed and part of the sequence). Every non [a-zA-Z] code, gets mapped to and index containing the pos of ‘?’ on the input alphabet, so basically as some of u already commented spaces are not an issue, as they just get mapped to a ‘?’ 
 Neverttheles

1 - Lorem opossum still doesn’t work
2 - the person that proposed testing locally on your pc, ignores that we don’t know all the input params (L,H and askii alphabet), so testing locally is a weak test bc it does’ represent real conditions.
3 - there are definitely bugs on the software analysing the results (I’m 100% sure of this bc by deleting a variable definition that is NOT used at all on my program), causes the failure of another 3 tests. YES, I repeat; deleting an old variable which is not used at all, will cause my program to fail extra tests @ submitting time. I saw a bug similar to this on the example #1. Up until now , using 6 languages, I’ve had bugs only when programming in C, so it seems the analysing software for C is particular error prone.

Any new info - particularly if u used C, would be nice. Thx

THIS IS THE REAL PROBLEM:

Ok, I’m sorry if this seems arrogant,but after suffering HOURS with C (and having a solution that completely follows the spec), the problem making the ‘lorem ipsum’ test fail is the presence of the character ‘0’ (askii 0 == Null char) on T. Remember how the instructions say that you should map all non [a-zA-Z] to ‘?’ ? Well, that isn’t completely true, as with a 0, you have to terminate the sequence, basically 0 is here your EOF - finito - fertig - don’t go ahead.

@antonioiturriza
the character you are speaking of is ‘\0’, and in C, it means the end of the char*, and is a norm for c-string. if you use strlen for example, it will return the length of the string up to that character, so it is not a strange behavior

@CvxFous, Hi; thx for your comment, you are completely right. It ist not a problem on the spec of this problem; and this a standard chracteristic of Strings termination.

Aside from that, when I’m coding here in C (here at codingame); I don’t have access to such standard string C functions (like strlen or strcpy - and yes, the #include <string.h> is there); allways receiving: “[NAME OF FUNCTION] was not declared in this scope” 
 So, I did assume we aren’t intended to use them, and did it manually. Since that end of String ‘problem’ was causing my solution to fail the lorem itsum test, I wanted to share that with the ppl here that seemed to struggle with the same.

Bottom line, thanks; you are right, there is not a problem on the spec; nevertheless there is a reason why 80% of this blog is related to ppl failing just that test (lorem itsum), and wanted to share that with them, so that they’ll save time.

1 Like

I like how you answer nice and politely, that’s really cool :wink:

That’s clearly isn’t normal, what include are you using? if you type “man strlen” on a term, you should see you need to do #include < string.h>. if you are using C inside C++ code, you should use #include < cstring>.

Either way, you definitly have access to all the standard library!
Tell me if you have any more trouble and keep coding :wink:

1 Like

Well, now that you mention it, it is kinda weird
 Upon closer inspection, I am running C code in a C++ project (how embarrasing is that XD) so the #include should have been string.h instead of string.

Thaks again, my faith on the standard lib is recovered! :wink:

@antonioiturriza actually, my post was badly edited, in your case, the code you are looking for is

# include <cstring>

Every C library in C++ need to be prefixed by the character ‘c’, example for stdio.h:

#include <cstdio>

The following test cases do not show:

Test AB!!CD (100 pts)
Test Lorem ipsum dolor sit amet,
 (100 pts)

C’est assez difficile de solutionner le Lorem Ipsum, mon programme passe tous les tests sans problĂšme mais celui ci, non. Les espaces sont remplacĂ©s par des “?” et tout est ok.
Le Lorem Ipsum Ă©tant un texte complet de test de mise en forme connu, j’ai fait un gros copy/paste de tout le texte que j’ai simulĂ© en input, et ce que mon code renvoie est totalement dĂ©structurĂ©, par contre si j’envoie la phrase uniquement en 2moitiĂ© ou en 3tiers, tout passe correctement.
Une idée ?

Tu utilises quel langage ? Si les tableaux ont besoin d’une taille prĂ©dĂ©finie comme en C, le bugue est peut-ĂȘtre lĂ .
En Python, ce n’est pas le cas sauf en interne (dans la tambouille de l’interprĂ©teur) et mon code est passĂ© sans problĂšme.

1 Like

Aucune idĂ©e pour moi. En plus j’ai plus accĂšs aux tests validateurs maintenant sigh

Tu peux m’envoyer ton code à comtealexis[at]gmail[dot]com si tu veux que je t’aide.

1 Like

Ne me linchez pas, j’utilise VB.Net 
 Je vais me renseigner sur la taille maxi des Arrays, bien vu.

C’est sĂ»rement temporaire, j’ai rencontrĂ© la mĂȘme blague avec le TEADS.

Tu parles des tests validateurs?
Je ne sais pas s’ils sont accessibles Ă  la soumission, mais ce que je voulais dire c’est que quand j’étais en stage Ă  Codingame, je pouvais voir les entrĂ©es exactes donnĂ©es par ces tests, et donc plus facilement deviner d’oĂč pouvait provenir les bugs.

Ha OK, je ne savais pas que tu avais un accĂšs interne.

my solution works for every test except “Test HELLO with another ASCII representation (100 pts)”. Don’t really understand it either. Any help?

1 Like

Try to debug with the error output?