#124272 - 2004-08-02 03:20 PM
Re: KiXgolf: Vigenere Cipher - Public coding
|
Lonkero
KiX Master Guru
   
Registered: 2001-06-05
Posts: 22346
Loc: OK
|
k, here is a fixed one. checked from non-matching tests that jens' cipher is screwed up. second test, not lcase chars: K+K-first word = W not 5 I+I-first word = S not 1
so, this seemed to work correctly: Code:
function vigenere($t,$k,optional $d) dim $j,$r,$,$p,$o,$y for $j = 65 to 90 $ = chr($j)+$+chr($j+32) next $p = "0123456789"+$ for $j = 1 to len($t) do $ = left($k,1) $k = substr($k,2)+$ $y = instr($p,$) until $y $ = substr($t,$j,1) $o = $o+($=" ") -$o*(0 $r = instr($p,$) if $r $ = 62 - (ucase($t+$k)=$t+$k)*26 $ = substr($p,1+($+$r+(2*($d=0)-1)*($y-$o-2)-1) mod $,1) endif $vigenere = $vigenere + $ next endfunction
KiXtart KiXtart Version = 4.22 KiXforms Version = KiXGolf Script = kixgolf_vigenere.kix Computer OS = Windows 2000 Professional CPU = Intel Pentium III Mobile Speed = 933 MHz Memory = 256 MB KiXGolf Scoring Engine Scoring Engine = 3.0.3 KiXtart Golf Score Tournament = KiXtart Golf: Vigenere Cipher Valid Cipher Ops = 7 (64%) Processing Start = 2004/08/02 16:03:15.847 Processing End = 2004/08/02 16:03:19.973 Duration = 0000/00/00 00:00:04.125 KiXGolf Score = 367 Thank you for participating in KiXtart Golf! press any key to close
_________________________
!download KiXnet
|
|
Top
|
|
|
|
#124273 - 2004-08-02 03:21 PM
Re: KiXgolf: Vigenere Cipher - Public coding
|
Richard H.
Administrator
   
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
Quote:
Are we three the only ones that even gave this shot?
Sadly I was in Marbella last week. I tried to convince the missus that the golf was more important, but she couldn't see it
|
|
Top
|
|
|
|
#124275 - 2004-08-02 08:06 PM
Re: KiXgolf: Vigenere Cipher - Public coding
|
MightyR1
MM club member
   
Registered: 1999-09-09
Posts: 1264
Loc: The Netherlands
|
569, no word shift:
Code:
Function Vigenere($a,$b, optional $c) Dim $t,$u,$i,$j $t='0123456789ZYXWVUTSRQPONMLKJIHGFEDCBA' $u='abcdefghijklmnopqrstuvwxyz' ;remove wrong chars in key For $i=1 to Len($b) If InStr($t+$u,SubStr($b,$i,1)) $j=$j+SubStr($b,$i,1) EndIf Next
$b=$j ;check for lowercase in string/key, if so expand tableau $j=Len($a)+Len($b) For $i=1 to $j If InStr($u,SubStr($a,$i,1)) OR InStr($u,SubStr($b,$i,1)) $t=$t+$u $i=$j EndIf Next ;double the tableau $t=$t+$t ;make the key larger than the string While Len($b) < Len($a) $b=$b+$b Loop For $i=1 to Len($a) $j=SubStr($a,$i,1) $u=SubStr($b,$i,1) If InStr($t,$j) If $c $j=SubStr($t,InStrRev($t,$j)+Len($t)/2-InStrRev($t,$u)+1,1) Else $j=SubStr($t,InStr($t,$j)+InStr($t,$u)-1,1) EndIf EndIf $vigenere=$vigenere+$j Next EndFunction
_________________________
Greetz, Patrick Rutten
- We'll either find a way or make one... - Knowledge is power; knowing how to find it is more powerful... - Problems don't exist; they are challenges...
|
|
Top
|
|
|
|
#124276 - 2004-08-02 10:27 PM
Re: KiXgolf: Vigenere Cipher - Public coding
|
MightyR1
MM club member
   
Registered: 1999-09-09
Posts: 1264
Loc: The Netherlands
|
WRONG WRONG WRONG - see later for explanations - current score is stil 367!!!
Code:
Function vigenere($t,$k,optional $d)
DIM $j,$r,$,$p,$o,$y
For $j=65 To 90
$=CHR($j)+$+CHR($j+32)
Next
$p = "0123456789"+$
For $j = 1 To Len($t)
Do
$ = Left($k,1)
$k = SubSTR($k,2)+$
; $y = InSTR($p,$)
; Until $y
Until InSTR($p,$)
$ = SubSTR($t,$j,1)
$o = $o+($=" ") -$o*(0<InSTR('!.?',$)) $r = InSTR($p,$)
If $r
$ = 62 - (UCase($t+$k)=$t+$k)*26
$ = SubSTR($p,1+($+$r+(2*($d=0)-1)*($y-$o-2)-1) mod $,1)
EndIf
$vigenere = $vigenere + $
Next
EndFunction
Gives:
KiXtart
KiXtart Version = 4.22
KiXforms Version =
KiXGolf Script = KIXGOL~1.KIX
Computer
OS = Windows XP Professional
CPU = Intel Pentium II
Speed = 448 MHz
Memory = 384 MB
KiXGolf Scoring Engine
Scoring Engine = 3.0.3
KiXtart Golf Score
Tournament = KiXtart Golf: Vigenere Cipher
Valid Cipher Ops = 10 (100%)
Processing Start = 2004/08/02 22:13:45.220
Processing End = 2004/08/02 22:13:45.481
Duration = 0000/00/00 00:00:00.260
KiXGolf Score = 362
Thank you for participating in KiXtart Golf!
Edited by MightyR1 (2004-08-02 10:40 PM)
_________________________
Greetz, Patrick Rutten
- We'll either find a way or make one... - Knowledge is power; knowing how to find it is more powerful... - Problems don't exist; they are challenges...
|
|
Top
|
|
|
|
#124277 - 2004-08-02 10:33 PM
Re: KiXgolf: Vigenere Cipher - Public coding
|
Howard Bullock
KiX Supporter
   
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
Patrick, how can you do that? Something is not right.
You remove $y as a valid var...
; $y = InSTR($p,$)
; Until $y
then try to use it ...
$ = SubSTR($p,1+($+$r+(2*($d=0)-1)*($y-$o-2)-1) mod $,1)
do you have the latest download test code?
Edited by Howard Bullock (2004-08-02 10:34 PM)
|
|
Top
|
|
|
|
#124286 - 2004-08-04 02:48 PM
Re: KiXgolf: Vigenere Cipher - Public coding
|
Lonkero
KiX Master Guru
   
Registered: 2001-06-05
Posts: 22346
Loc: OK
|
what about this then?
function vigenere($t,$k,optional $d)
dim $j,$r,$,$p,$o,$y
for $j = 65 to 90
$ = chr($j)+$+chr($j+32)
next
$p = "0123456789"+$
for $j = 1 to len($t)
do
$ = left($k,1)
$k = right($k,-1)+$
$y = instr($p,$)
until $y
$ = substr($t,$j,1)
$o = $o+($=" ") -$o*($=!|$='?'|$='.')
$r = instr($p,$)
if $r
$ = 62 - (ucase($t+$k)=$t+$k)*26
$ = substr($p,1+($+$r+(2*($d=0)-1)*($y-$o-2)-1) mod $,1)
endif
$vigenere = $vigenere + $
next
endfunction
KiXtart
KiXtart Version = KiXtart 2001 4.22 Release Candidate 1
KiXforms Version =
KiXGolf Script = kixgolf_vigenere.kix
Computer
OS = Windows 2000 Professional
CPU = Intel Pentium II
Speed = 398 MHz
Memory = 384 MB
KiXGolf Scoring Engine
Scoring Engine = 3.0.3
KiXtart Golf Score
Tournament = KiXtart Golf: Vigenere Cipher
Valid Cipher Ops = 7 (64%)
Processing Start = 2004/08/04 15:31:23.896
Processing End = 2004/08/04 15:31:24.246
Duration = 0000/00/00 00:00:00.349
KiXGolf Score = 366
Thank you for participating in KiXtart Golf!
_________________________
!download KiXnet
|
|
Top
|
|
|
|
Moderator: Arend_, Allen, Jochen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Mart
|
1 registered
(Allen)
and 1198 anonymous users online.
|
|
|