<< Back to Off-topic Forum   Search

Posts 1 - 13 of 13   
Forum Challange: Aplhabetical Order: 7/18/2015 01:48:04


Benjamin628 
Level 60
Report
Order this list in alphabetical order. (I understand the title is spelled wrong).

Rules:

- No troll moves
- No Double posting, one post per 6 hours.
- You may only swap two letters (Put a * by the most recent two changes)
- Use [*code] and [*/code] brackets
- Put your move number in your post.

Here is an example:

c
a
b

Move 1:

c
b*
a*

Move 2 (Solution):

a*
b
c*

Ok here we go with a randomized list:

s
u
n
l
g
f
b
x
v
z
q
y
c
d
h
w
o
p
j
t
a
r
e
k
i
m


Edited 7/18/2015 14:46:16
Forum Challange: Aplhabetical Order: 7/18/2015 01:49:30


Benjamin628 
Level 60
Report
Move 1:

a*
u
n
l
g
f
b
x
v
z
q
y
c
d
h
w
o
p
j
t
s*
r
e
k
i
m
Forum Challange: Aplhabetical Order: 7/18/2015 01:50:30


Thomas 633
Level 56
Report
s
u
n
l
g
f
b
x
v
z
q
y
c
d
h
w
o
j*
p*
t
a
r
e
k
i
m
Forum Challange: Aplhabetical Order: 7/18/2015 01:59:14


Benjamin628 
Level 60
Report
Thomas, I hope you realized that move that absolutely nothing...

also, you forgot to have the a-s switch.
Forum Challange: Aplhabetical Order: 7/18/2015 02:16:03


The Count
Level 16
Report
Move 3:

a
b
n
l
g
f
u
x
v
z
q
y
c
d
h
w
o
j
p
t
s
r
e
k
i
m
Forum Challange: Aplhabetical Order: 7/18/2015 02:35:07


l4v.r0v 
Level 59
Report
This might help: https://en.wikipedia.org/wiki/Sorting_algorithm

Ben, since you asked earlier for a quick CS task so you could learn Python: automate this alphabet game and have it show an animation on Tkinter that depicts the most efficient way to alphabetically sort some letter soup you feed it based on whichever sorting algorithm you (or the user) picks. Maybe start with just selection sort. And of course, maintain the same rules as this game- so for selection sort you have to move the selected element one position at a time and count each such shift as 1 move.

And maybe for fun you can compare the final # of moves on this thread to the moves taken by particular sorting algorithm, and compare the efficiency of ForumSort to other sorting algorithms. :D
Forum Challange: Aplhabetical Order: 7/18/2015 02:46:16


Benjamin628 
Level 60
Report
@knyte, seems easier than the Elo task of top 50 on the ladder overdog/underdog win % whatever. I had the most trouble with getting rid of the HTML code.

I saw that link on a lesson on 15-112. I would have to learn a few things like randomization of the letters (math.random is what it is in javascript, or I could just input them in the order).
Forum Challange: Aplhabetical Order: 7/18/2015 03:20:11


AWESOMEGUY 
Level 63
Report
f
o
r
u
m
c
h
a
l
l
e
n
g
e
:
a
l*
p*
h
a
b
e
t
i
c
a
l
o
r
d
e
r


It had to be done.
Forum Challange: Aplhabetical Order: 7/18/2015 07:13:47


Benjamin628 
Level 60
Report
AWESOMETROLL pls

Move 4:

a
b
c*
l
g
f
u
x
v
z
q
y
n*
d
h
w
o
j
p
t
s
r
e
k
i
m
Forum Challange: Aplhabetical Order: 7/18/2015 07:47:29


l4v.r0v 
Level 59
Report
@Ben (sorry to derail this again): Python has the random library. random.random() is going to give you a value between 0 and 1 (I think the 0 is exclusive, the 1 inclusive, but it could be the other way around). I think the library also has a random sort function, but if not you could just add that to the task >_<.
Forum Challange: Aplhabetical Order: 7/18/2015 09:50:59


Ox
Level 58
Report
Move 5:

a
b
c
d*
g
f
u
x
v
z
q
y
n
l*
h
w
o
j
p
t
s
r
e
k
i
m
Forum Challange: Aplhabetical Order: 7/18/2015 14:42:44


Benjamin628 
Level 60
Report
@knyte I was just messing around with it and I made a random number 1-5 but it was really inefficient, So I thought of something that would print a random number 1-100

import random 
randomVar = round(random.random() * 100) 
print randomVar

Move 6:

a
b
c
d
e*
f
u
x
v
z
q
y
n
l
h
w
o
j
p
t
s
r
g*
k
i
m


Edited 7/18/2015 14:52:09
Forum Challange: Aplhabetical Order: 7/20/2015 01:28:54


Benjamin628 
Level 60
Report
Currently not working, I will update it when it is :)

#Create border and import Tkinter
from Tkinter import *
root = Tk()
canvas = Canvas(root, width=600, height=300)
canvas.pack()
canvas.create_rectangle(0,0,600,300,fill="red")
canvas.create_rectangle(25,25,575,275,fill="black")
#Import random and randomize alphabet                        
import random
a = [65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,89,90,91]
random.shuffle(a)
#Selection Sort alg
def selectionSort(a):
    n = len(a)
    moves = 0
    for startIndex in xrange(n):
        minIndex = startIndex
        for i in xrange(startIndex, n):
            if (a[*i] < a[minIndex]):
                minIndex = i
        #Logging it to Tkinter       
        a[startIndex], a[minIndex] = a[minIndex], a[startIndex]
        b = [chr(x) for x in a]
        canvas.create_text(100,150,text=b,fill="white",font="Helvetica 18 bold")
        canvas.create_text(225,150,text="Moves:" + " " + str(moves + 1),font="Helvetica 18 bold")
        moves += 1
selectionSort(a)
root.mainloop()


Edited 7/20/2015 01:29:39
Posts 1 - 13 of 13