mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Feb 2003
Posts: 12
M
monk Offline OP
Pikka bird
OP Offline
Pikka bird
M
Joined: Feb 2003
Posts: 12
alias -l plot {
if ($1 >= 100) { return $2- }
var %hintc, %i = 1, %j = 0, %rnum = $int($calc(($regsub($2-,$nonpunct,@,%hintc) / 100) * $1))
while (%i <= %rnum) {
if (!$regex(%hintc, /(?:^|\s)[^\s@]{ $+ %j $+ }(@)/)) {
inc %j
!.echo -q $regex(%hintc, /(?:^|\s)[^\s@]{ $+ %j $+ }(@)/)
}
%hintc = $+($left(%hintc,$calc($regml(1).pos - 1)), $mid($2-,$regml(1).pos,1),$right(%hintc,$calc($regml(1).pos * -1)))
inc %i
}
return $replace(%hintc,@,$trivchar)
}

trivchar { return * }
nonpunct { return /([^';:"\s\xA0\,\?\<\>\|\\\/\[\]\!\@\#\$\%\^\&\*\(\)\{\}\-])/g }


msg $chan hint1: $plot(20, %ansnum)
msg $chan hint2: $plot(40, %ansnum)
msg $chan hint3: $plot(60, %ansnum)

le big mac

It gives incorrecly form of plot hint like this:


%ansnum le big mac

hint1: l* *** ***
hint2: le *** **
hint3: le b** **


What is wrong? It suppose to give first couple letters each word, and , and it loses some * at the end too. Please help me solve this issue. Thank you!

Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
Well I've made you a little something, it might be useful for you.

Usage: $plot(string,N,char)

The N stands for the amount of first characters you want to be visible from each word.

Examples:

$plot(this is a test,0,*) -> **** ** * ****
$plot(this is a test,1,*) -> t*** i* a t***
$plot(this is a test,2,*) -> th** is a te**
$plot(this is a test,3,*) -> thi* is a tes*
...

alias plot {
var %a, %b = $regsub($1,/(?<=\S{ $+ $2})\S/g,$replace($$3,\,\\,$,\$),%a)
return %a
}


Gone.
Joined: Feb 2003
Posts: 12
M
monk Offline OP
Pikka bird
OP Offline
Pikka bird
M
Joined: Feb 2003
Posts: 12
Fiber, how do i check if the length between each word is greater than 10. it'd give more letters in the hint?

Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
I can't help you if you keep it so vague.

How much is "more"? I'm sure you have a picture in your head of what you want this to be, but I'm not a mind reader. What is the algorithm that decides how much there should be shown in what exact occurences?

Look at it like this: You are the architect who draws plans for a house, and I build your house. If your plan is vague about the measurements and requirements, then I can't build your house for you.

Greets


Gone.
Joined: Feb 2003
Posts: 12
M
monk Offline OP
Pikka bird
OP Offline
Pikka bird
M
Joined: Feb 2003
Posts: 12
Something like this:

42. Who advocated the planting peanuts and sweet potatoes to replace cotton and tobacco (i.e. crop rotation)?
Answer: George Washington Carver
Ge**** W********* C*****
Geo*** Was******* Ca****
Georg* Wash****** Carv**



And also, in your script can ya make it ignores the space?

Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
My original code already ignores spaces, did you really try it?

That's not an algorithm, but a random example which is useless.

An algorithm means you explain how the function that is to be coded, decides how to act in what circumstance, along with the limitations.

Example would be:

"I want to have the following with strings with less than 3 words:

1 letter in first word
2 letters in all the following words
1 letter in last word

this will increment with each try, meaning

2 in first word
3 in rest except last
2 in last

When there are more than 3 words, then I would like the following:

I want to show 10% of the first word, but only if the word is shorter than 6 chars, otherwise I want to show 15%
...

When there are over 7 words, I want to show the first 2 letters of each word, and increment with a random number between 1 and 2 with each try, on each word.
etc etc etc"

Do you see the difference with what you gave me and what I just did?

Btw you first said you wanted to show more in case of 10 letter words or something, but strangely enough in your example, the longest word has less letters shown than the first one which is shorter... the last word is of same length as the first, yet surprisingly it shows less letters...

I'm going to leave the help with this to someone else, atleast until you have made up your mind and did some work yourself, being thinking up an algorithm to fit your needs.

Greets


Gone.

Link Copied to Clipboard