Schrift
[thread]6533[/thread]

QOTW 22 'expert' quiz



<< >> 6 Einträge, 1 Seite
Crian
 2004-08-26 14:46
#49628 #49628
User since
2003-08-04
5866 Artikel
ModeratorIn
[Homepage]
user image
Klingt spannend. Ob das für Deutsch auch geht?

Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
IMPORTANT: Please do not post solutions, hints, or other spoilers
       until at least 60 hours after the date of this message.
       Thanks.

IMPORTANT: S'il vous plaît, attendez au minimum 60 heures après la
       date de ce message avant de poster solutions, indices ou autres
       révélations. Merci.

BELANGRIJK: Stuur aub geen oplossingen, hints of andere tips in de
       eerste 60 uur na het verzendingstijdstip van dit
       bericht. Waarvoor dank.

Qing3 Zhu4Yi4: Qing3 Ning2 Deng3Dao4 Jie1Dao4 Ben3 Xin4Xi2 Zhi1Hou4 60
       Xiao3Shi2, Zai4 Fa1Biao3 Jie3Da2, Ti2Shi4, Huo4 Qi2Ta1 Hui4
       Xie4Lou4 Da2An4 De5 Jian4Yi4.  Xie4Xie4.

----------------------------------------------------------------

Write a program, 'wordladder', which gets two arguments, which are
words of the same length, and which constructs and prints a "word
ladder" from the first word to the second word.

A word ladder from word AAA to word BBB is a sequence of dictionary
words such that:

1. the first word in the sequence is word AAA
2. each word in the sequence after the first differs from the previous
  word in exactly one letter position
3. the last word in the sequence is word BBB

For example, given the two words "love" and "hate", the program might
print the word ladder:

       love
       hove
       have
       hate

Or it might print:

       love
       lave
       have
       hate

It might also print a longer word ladder, such as

       love
       lore
       lobe
       robe
       role
       rose
       lose
       lost
       most
       mosh
       moth
       math
       hath
       hate

If the program is unable to find a word ladder, it should print an
appropriate error message to the standard error, and exit with a
failure status.

The program should also accept an optional third argument, which, if
specified, is the name of a dictionary file which contains the
permissible words.  If the third argument is omitted, the program
should use a default dictionary.

Sample word lists are available from
       [URL=http://perl.plover.com/qotw/words/]http://perl.plover.com/qotw/words/[/URL]


Timestamp der Mail: Wed, 25 Aug 2004 23:26:57 -0400

Bitte auch hier vor Ablauf der 60 Stunden keine Lösungen oder Spoiler schreiben.\n\n

<!--EDIT|Crian|1093517199-->
s--Pevna-;s.([a-z]).chr((ord($1)-84)%26+97).gee; s^([A-Z])^chr((ord($1)-52)%26+65)^gee;print;

use strict; use warnings; Link zu meiner Perlseite
Taulmarill
 2004-08-26 15:08
#49629 #49629
User since
2004-02-19
1750 Artikel
BenutzerIn

user image
hm, wo bekommt man für deutsch passende wortlisten?
$_=unpack"B*",~pack"H*",$_ and y&1|0& |#&&print"$_\n"for@.=qw BFA2F7C39139F45F78
0A28104594444504400 0A2F107D54447DE7800 0A2110453444450500 73CF1045138445F4800 0
F3EF2044E3D17DE 8A08A0451412411 F3CF207DF41C79E 820A20451412414 83E93C4513D17D2B
Gast Gast
 2004-08-27 00:25
#49630 #49630
Hi,
hier ist eine mögliche, allerdings sehr eingeschränkte (da nur neue Rechtschreibung) Wortliste.
Auf duden.de soll es ebenfalls eine Wortliste geben, ich habe sie allerdings nicht gefunden.

greetz, anti
Gast Gast
 2004-08-27 00:33
#49631 #49631
Das Thema klingt wirklich interessant!
Diese Wortliste ist, etwas aufbereitet, perfekt geeignet.
DS
 2004-08-27 03:21
#49632 #49632
User since
2003-08-04
247 Artikel
BenutzerIn
[default_avatar]
So, meine Lösung ist fertig... hab' noch eine zweite gemacht, die zu einem bestimmten Wörterlist und einer bestimmten Wortlänge solche Ketten findet, indem einfach für eine bestimmte Anzahl von Versuchen je bei 2 zufällig ausgewählten Wörtern aus der Liste diese getestet werden... lustige Sachen findet man da... :p
DS
 2004-08-30 15:52
#49633 #49633
User since
2003-08-04
247 Artikel
BenutzerIn
[default_avatar]
Falls es jemanden interessiert:

Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#!perl

use strict;
use warnings;

++$|;

################################################################################

my $wl_standard = 'englisch2.wl';

################################################################################

my ($wort_start,$wort_ziel,$wl) = @ARGV;
$wort_start = ($wort_start ne '') ? lc $wort_start : die 'Es muss ein Startwort übergeben werden!';
$wort_ziel = ($wort_ziel ne '') ? lc $wort_ziel : die 'Es muss ein Zielwort übergeben werden!';
die 'Start und Zielwort müssen die selbe Länge haben!' if length $wort_start != length $wort_ziel;
$wl ||= $wl_standard;

print "
Startwort: $wort_start
Zielwort: $wort_ziel
Wörterliste: $wl

";

################################################################################

print "Wörterliste einlesen...";
open (DATEI,$wl) || die 'Wörterbuchdatei konnte nicht geöffnet werden!';
chomp (my @w = <DATEI>);
close (DATEI);
my $l = length $wort_start;
my %w = map { lc($_) => 1 } grep { length $_ == $l } @w;
print " fertig\n";

################################################################################

die 'Das Startwort kommt im Wörterbuch nicht vor!' unless $w{$wort_start};
die 'Das Zielwort kommt im Wörterbuch nicht vor!' unless $w{$wort_ziel};

################################################################################

my @zw = (([]) x length $wort_start);
$zw[0] = [$wort_start];

my %von;

print "Suche starten...";
while (1) {
my $wort;
foreach (0..$#zw) {
next unless @{$zw[$_]};
$wort = shift @{$zw[$_]};
last;
}
unless ( defined $wort ) {
print " fertig\n\n";
print "Keine Lösung möglich!\n";
exit;
}
foreach my $foo (&foo($wort)) {
$von{$foo} = $wort;
my $u = &bar($foo);
if ( $u == 0 ) {
print " fertig\n\n";
my @weg = ($foo);
while ( $foo ne $wort_start ) {
$foo = $von{$foo};
unshift @weg, $foo;
}
print (join(' -> ',@weg), "\n");
exit;
}
push @{$zw[$u]}, $foo;
}
}

################################################################################
################################################################################
################################################################################

sub foo {
my $wort = shift;
my @m;
foreach my $i (0..length($wort)-1) {
foreach my $v ('a'..'z') {
next if substr($wort,$i,1) eq $v;
my $m = substr($wort,0,$i).$v.substr($wort,$i+1);
next unless $w{$m};
next if $von{$m};
push @m, $m;
}
}
return @m;
}

sub bar {
my $wort = shift;
my $unterschied = length($wort);
foreach my $i (0..length($wort)-1) {
--$unterschied if substr($wort,$i,1) eq substr($wort_ziel,$i,1);
}
return $unterschied;
}
<< >> 6 Einträge, 1 Seite



View all threads created 2004-08-26 14:46.