LOGO
General Discussion Undecided where to post - do it here.

Reply to Thread New Thread
Old 12-01-2006, 10:53 PM   #1
pymnConyelell

Join Date
Nov 2005
Posts
412
Senior Member
Default what's the 5 letter word with the most one-word anagrams?
what is your word you have in mind?
pymnConyelell is offline


Old 12-01-2006, 11:09 PM   #2
Zhgpavye

Join Date
Oct 2005
Posts
538
Senior Member
Default
Does any language count?
Zhgpavye is offline


Old 12-02-2006, 01:24 AM   #3
iDzcs7TU

Join Date
Oct 2005
Posts
442
Senior Member
Default
Originally posted by Ari Rahikkala
Well, hell. I must say that I managed to impress myself with Haskell. Here's mine. A combination of C and bash:

First I took a wordlist (only 5 letter words) with one word on each line. Then I used gedit to add in a series of bash commands (using find/replace on the newlines) so I got a second file like this.

5letscr.sh

Code:
Code
#!/bin/bash  bash jmb2.sh abaca . . . bash jmb2.sh zymes

jmb2.sh

Code:
Code
#!/bin/bash gcc -o jmb2.out jmb2.c echo $1 > jmbtmpfile ./jmb2.out < jmbtmpfile > words2.sh rm jmbtmpfile bash ./words2.sh

jmb2.c

Code: [code]#include #include int rvd5(int a, int b, int c, int d, int e); int rvd6(int a, int b, int c, int d, int e, int f); main() { char word[80]; int count, tag, i, j, k, l, m, n; for (count=0; (word[count] = getchar()) != '\n'; ++count) ; tag = count; printf ("#!/bin/bash\n"); printf ("rm -f jmbtmpfile\n"); if (tag == 5) { for (i = 0; i
iDzcs7TU is offline


Old 12-02-2006, 01:34 AM   #4
tinetttstation

Join Date
Oct 2005
Posts
470
Senior Member
Default
I'm a shitty programmer

tinetttstation is offline


Old 12-02-2006, 01:36 AM   #5
ufUUZCnc

Join Date
Oct 2005
Posts
528
Senior Member
Default
Mine was originally written to cheat on the jumble in the paper. That's why it's roundabout. I already had something written. And that's why it's called jmb2.c and jmb2.sh...
ufUUZCnc is offline


Old 12-02-2006, 01:39 AM   #6
natahololll

Join Date
Oct 2005
Posts
667
Senior Member
Default
You're probably better than I am a bash scripting. I just use linux for Matlab and C.
natahololll is offline


Old 12-02-2006, 01:42 AM   #7
Coededgeme

Join Date
Nov 2005
Posts
334
Senior Member
Default
Originally posted by Kuciwalker
You're probably better than I am a bash scripting. I just use linux for Matlab and C. I wrote my first bash script two days ago
Coededgeme is offline


Old 12-02-2006, 01:43 AM   #8
viagra_generic

Join Date
Oct 2005
Posts
393
Senior Member
Default
I particularly liked how instead of writing something that counted +1 every time it found a match instead I wrote to a temp file and grep -c for 1s in that temp file.

viagra_generic is offline


Old 12-02-2006, 01:47 AM   #9
Obsententicab

Join Date
Oct 2005
Posts
383
Senior Member
Default
I'm lazy and copy-paste is way too easy.
Obsententicab is offline


Old 12-02-2006, 01:51 AM   #10
Lxbsvksl

Join Date
Oct 2005
Posts
472
Senior Member
Default
It took me ~45 seconds to write that function. Thinking would have cost extra time.
Lxbsvksl is offline


Old 12-02-2006, 01:53 AM   #11
Siuchingach

Join Date
Oct 2005
Posts
416
Senior Member
Default
You could cut down the number of permutation that need to be checked by atleast an order of magnitude by forcing two of the letters to be vowels.
Siuchingach is offline


Old 12-02-2006, 01:57 AM   #12
Voitramma

Join Date
Nov 2005
Posts
316
Senior Member
Default
Never mind that n is completely unused, that it always returns 0, and this:

i+1

I'm not sure why n went there.

Anyway, it's easier to detect bugs in mine than his, since his could be missing a line and you wouldn't notice.
Voitramma is offline


Old 12-02-2006, 02:48 AM   #13
boanuatiguali

Join Date
Oct 2005
Posts
479
Senior Member
Default
- it can deal with types for which equality is defined but order isn't, that is, you can pass it stuff like complex numbers

You can order complex numbers
boanuatiguali is offline


Old 12-02-2006, 04:10 AM   #14
SmuffNuSMaxqh

Join Date
Oct 2005
Posts
587
Senior Member
Default
I didn't say it was an ordered field
SmuffNuSMaxqh is offline


Old 12-02-2006, 05:04 AM   #15
kristloken

Join Date
Oct 2005
Posts
475
Senior Member
Default
Good idea . It took the execution time of my Haskell program for going through /usr/share/dict/words (234937 lines, 2486824 bytes) from ~1.7 seconds to ~1.5 seconds. Perhaps you can go even further, how do these ideas sound to you.

- drop all matching vowels
- drop very rare consinents like x and z
- restrict the 3 other letters to consinents only
- drop all matching consinents

The base posibilities are 26^5th power = 11,881,376

With agressive culling its 5 * 4 * 19 * 18 * 17 = 116,280

A full two orders of magnitude reduction
kristloken is offline


Old 12-02-2006, 08:21 AM   #16
Zoxeeoy

Join Date
Oct 2005
Posts
480
Senior Member
Default
Radix sort. Order them first by real part, then imaginary
Zoxeeoy is offline


Old 12-02-2006, 11:47 AM   #17
WFSdZuP3

Join Date
Oct 2005
Posts
428
Senior Member
Default
Originally posted by Kuciwalker
Radix sort. Order them first by real part, then imaginary Does not obey rules of total order.
WFSdZuP3 is offline


Old 12-02-2006, 03:25 PM   #18
Ettiominiw

Join Date
Oct 2005
Posts
697
Senior Member
Default
Nerds...
Ettiominiw is offline


Old 12-02-2006, 06:58 PM   #19
egexgfczc

Join Date
Oct 2005
Posts
422
Senior Member
Default
So we've seen Linux geek code (Ari), physicist/mathematician code (KH), and now for some software engineer code (in Java for variety):

Code:
Code
import java.io.IOException;  public class Anagram  {   int size, count;   char[] arr;    public static void main(String[] args) throws IOException    {     String input = args[0];     size = input.length();     count = 0;     arr = new char[size];     for (int i = 0; i < size; i++)     	arr[i] = input.charAt(i);     anagram(size);   }          public static void rotate(int anagramSize)    {     int i;     int position = size - anagramSize;     char temp = arr[position]; // 1st letter      for (i = position + 1; i < size; i++) // push the rest left       arr[i - 1] = arr[i];      arr[i - 1] = temp; // now put the 1st on the end   }     public static void anagram(int anagramSize) {     int limit;     if (anagramSize != 1) // if 1, this is useless this is useless so don't do anything     { 	for (int i = 0; i < anagramSize; i++) { 	      anagram(anagramSize - 1); // anagram the last bits 	      if (anagramSize == 2) // the innermost anagram 	      { 	      	for (int i = 0; i < size; i++) // display it 		     System.out.print(arr[i]); 		System.out.println(); 	      } // end if 	     else 	      	rotate(anagramSize); // rotate word 	} // end for     }  // end if   } // end anagram() }

egexgfczc is offline


Old 12-02-2006, 07:16 PM   #20
bertanu

Join Date
Oct 2005
Posts
403
Senior Member
Default
^^Asher

The right way to do it
bertanu is offline



Reply to Thread New Thread

« Previous Thread | Next Thread »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

All times are GMT +1. The time now is 01:53 PM.
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 PL2
Design & Developed by Amodity.com
Copyright© Amodity