Math Is Fun Forum

  Discussion about math, puzzles, games and fun.   Useful symbols: ÷ × ½ √ ∞ ≠ ≤ ≥ ≈ ⇒ ± ∈ Δ θ ∴ ∑ ∫ • π ƒ -¹ ² ³ °

You are not logged in.

#1 Re: Jokes » Things to do in an elevator » 2009-05-21 12:15:28

my usual is to go for the top floor of the building, post something on a board there, get back, go to the next floor down, and repeat... Have actually done this, and it drives people nutty (imagine why)

#2 Re: Dark Discussions at Cafe Infinity » Reaction of alkali metals with water » 2009-05-20 14:23:13

I think it was said that there are less 20 grams of it throughout Earth's crust at any given time... considering how massive the earth is, that's not very much...

#3 Re: Dark Discussions at Cafe Infinity » Reaction of alkali metals with water » 2009-05-19 18:41:22

I know... I'm so sad I don't go to the school he teaches at...

#4 Re: Dark Discussions at Cafe Infinity » Reaction of alkali metals with water » 2009-05-19 14:25:43

My uncle (a high school physics and chemistry teacher) did the following with his senior class:

"Now, I know that all of you are going to want to try to steal some of this sodium so you can have fun with it on your own. Let me show you a few things you don't want to do with it. First, you don't want the piece of sodium to be very large. [cuts off chunk the size of a grapefruit] You also don't want it to be entirely submerged rapidly. [attaches lead weights to piece of sodium] You don't want the water to be at all acidic, either. [pours a quart of citric acid into tub of water]."

He then took the class outside, and held the sodium at the end of a 40-foot pole above the water. He lets go of the rope holding it there. It falls into the water. The class watches as a 20-foot high mushroom-shaped cloud of water and smoke rises from the small hole where the tub had just been.

#7 Jokes » Don't you speak engrish? » 2009-03-03 12:52:10

Laterally Speaking
Replies: 3

yes-i-am.jpg

beware-of-missing-foot.jpg
It's been running around here lately...

health-demolition-tofu.jpg
Always read the fine print... and the not-so-fine print, too...

dead-body-freezer-box.jpg

I think they need a native speaker, not a dictionary...

steict-paeking-sign.jpg

Although sometimes I get the feeling they don't even bother with that...

#8 Re: Jokes » Jokes galore...... » 2009-03-01 07:16:18

I can't believe so few of you appreciate the importance of history! How can you claim to be good citizens without reflecting on the way the institutions came about? Sure, it's important to know where countries are, but knowing the history of the peoples' cultures is far more important...

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

One day, a pastor was giving a sermon on the vices of alcohol and the importance3 of temperance. He said, "If I could have all the whiskey in the world, I would take it and throw it in the river!" A woman stood up and announced, "And if I had all the wine in the world, I would throw it in the river, too!" A man stood up and replied, "And if I could have all the beer in the world, I would throw it all in the river, as well!"

The chorus leader then stood up, and with a small grin, announced: "And for our closing, we will sing hymn #267, 'Let us gather at the river'"

#9 Jokes » Corporate logos... after the economic crisis » 2009-03-01 06:40:22

Laterally Speaking
Replies: 0

Found these the other day... figured you'd appreciate them...

Citi.jpg
xerox.jpg
ford.jpg
Lg.jpg
nike.jpg
PleaseBuy.jpg
ferrari.jpg
Fiasco.jpg
dowjones.jpg
Yahoo.jpg
goodyear.jpg
nokia.jpg
dell.jpg
Crisisler.jpg
3m.jpg
apple.jpg

#11 Re: Dark Discussions at Cafe Infinity » Fake Science ramphant in commercials » 2008-07-25 12:01:21

A very thorough examination, Ricky.

In any case, the majority of bad breath comes from the food you have consumed since the last time you brushed your teeth, as this food will be all over the surface of your teeth, gums, tongue, and pallet, decaying fairly rapidly under the effect of the resident bacteria. The only exception to this would be if your teeth themselves are decaying, in which case they contribute quite a bit, whether you've eaten anything recently or not.

#12 Re: Coder's Corner » Code snippets » 2008-06-29 01:52:11

There's always the method for loading an ini file by calling the Win32 APIs, but that's not exactly short... and, depending on applications, it changes quite a bit. I will work on writing up a simplified and general version, and keep the (numerous) variables named in a self-explanatory way.

Here is a modified module from one of my projects; it has been reduced to the bare minimum, I believe.

Option Explicit

' api declarations for ini services
Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpFileName As String) As Long
Declare Function GetFileAttributes Lib "kernel32" Alias "GetFileAttributesA" (ByVal lpFileName As String) As Long
Declare Function GetFileSize Lib "kernel32" (ByVal hFile As Long, lpFileSizeHigh As Long) As Long
Declare Function WritePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpString As Any, ByVal lpFileName As String) As Long

Global inipath As String

Global Output As String

Global SearchedHeader As String
Global SearchedValue As String

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

Function fullpath(ByVal dirpath As String, ByVal fileName As String) As String
'
' Purpose: Returns full path
'
' Inputs: dirpath and filename strings
'
' Outputs: string representing the full path including the filename
'
' Globals:
'
' Modifications:
'
' Comments:

If (Right$(dirpath, 1) = "") Then
fullpath = dirpath & fileName
Else
fullpath = dirpath & "" & fileName
End If

End Function

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

Function getprivateprofile(ByVal section As String, ByVal KeyName As String, ByVal default As String) As String
'
' Purpose: Low level driver interface to obtain .ini info
'
' Inputs: section,keyname and default strings
'
' Outputs: String representing requested .ini item
'
' Globals:None
'
' Modifications:
'
' Comments:


Dim buffer As String
Dim i As Integer

buffer = String$(512, 0)

If (Len(KeyName) = 0) Then
i = GetPrivateProfileString(section, ByVal 0&, default, buffer, 512, inipath)
Else
i = GetPrivateProfileString(section, ByVal KeyName, default, buffer, 512, inipath)
End If
getprivateprofile = Left$(buffer, i)

End Function

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

Sub OnStartup()
'
' Purpose: Loads data from ini file
'
' Inputs: None
'
' Outputs:None
'
' Globals:
'
' Modifications:
'
' Comments:

Dim dummy As String
Dim errmsg As String
Dim tempport As String
Dim tempsettings As String
Dim inierrormsg As String

'frmmain.txtinstructions

inipath = fullpath("C:\Documents and Settings\new user\My Documents", "Document") & ".txt"

SearchedHeader = "Names"
SearchedValue = "Name1"
dummy = (getprivateprofile(SearchedHeader, SearchedValue, ""))
Output(cycler) = dummy

Exit Sub

fferr:

MsgBox errmsg
'SetFail

End Sub

Sub OnExit()
'
' Purpose: Close comm ports and exit loops
'
' Inputs: None
'
' Outputs: None
'
' Globals:
'
' Modifications:
'
' Comments:


' update ini file
UPdateIni

End Sub

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

Function WriteProfileStuff(KeyName As String, KeyValue As String, Optional AppName As String = "?", Optional IniLoc As String = "?") As Boolean
'
' Purpose: Low level ini file write function
'
' Inputs: keyname = ini entry definition, KeyValue = value to be written, AppName = ini file section name
'
' Outputs: flag = pass/fail
'
' Globals:
'
' Modifications:
'
' Comments:

Dim retval As Long
Dim ibuf As Long
Dim DefValue As String
Dim Results As String

On Error GoTo WriteprofileStuff_Error

' Inilialize varables
ibuf = 255                   'Set buffer length for API code

If IniLoc = "?" Then IniLoc = "C:\Documents and Settings\new user\My Documents\Document.txt"


retval = WritePrivateProfileString(AppName, KeyName, KeyValue, IniLoc)

' Return back to calling procedure with INI file infomation/
If retval = 1 Then
    WriteProfileStuff = True
Else
    WriteProfileStuff = False
End If

Exit Function

   ' Return back to calling procedure with Error measage
WriteprofileStuff_Error:
    MsgBox "System error attempting to write ini file data " & Err.Description, vbCritical
    WriteProfileStuff = False
End Function

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

Function UPdateIni() As Boolean
'
' Purpose: Updates ini entries
'
' Inputs: None
'
' Outputs: None
'
' Globals:
'
' Modifications:
'
' Comments:

Dim retval As Boolean
Dim msg As String

retval = WriteProfileStuff(WriteValue, msg, WriteGroup)
If retval = False Then GoTo errr

UPdateIni = True

Exit Function

errr:

UPdateIni = False

End Function

Note that this was written in VB 5.0

#13 Re: Dark Discussions at Cafe Infinity » Where can I practice my cryptology? » 2008-05-13 22:57:52

I've written about a dozen different encryption/decryption programs... also found a way of calculating very large numbers (which is necessary for RSA, where a thousand-digit number is raised to another thousand-digit power). I mostly use ASCII character values to do the encryption, as this allows full sentences with punctuation. Haven't used any of them recently... not much need for me, really.

I would certainly agree that most of the time that is spent decrypting something is spent using the wrong methods... people don't generally attach the exact algorithm to their message.

There are also some systems that cannot be decrypted, because you cannot be certain that you have obtained the correct message, rather than another set of characters of the same length that happens to make sense. I am referring to what is known as a onetime pad, which is actually relatively simple to implement.

#14 Re: Dark Discussions at Cafe Infinity » Whats everyone's background? » 2008-02-27 06:35:36

I am From Portland (Oregon, not Maine), but am currently living in the Eastern Pyrenees. I am currently working on several projects, one of which I am having a bit of trouble with. I kinda like to mix mathematics and programming, as the two are quite useful when merged.

I am also quite interested in energy sources and vectors other than hydrocarbons. This may be in no small part due to the fact that there are 2 large solar research centers within 15 minutes' drive, and that said centers are the reason of us coming here.

I also am quite exasperated at the lack of attention given by people to language, and, more specifically, spelling, grammar, and punctuation.

#15 Re: This is Cool » Will this plane take off? » 2008-02-17 19:40:47

After more reflection, I think that, as it was said earlier, the only way it could take off is if the thrust provided were enough to break the static friction between the runway and the wheels; that is to say, it would have to be enough to drag the wheels along the runway at speeds sufficient to take off.

#16 Re: Dark Discussions at Cafe Infinity » An ambitious plan » 2008-02-12 06:30:52

I think the lowest known lower bound for the solution is 6, so it could be said that the premise of G is rather flawed, but it is an upper bound to the problem.

However, I don't quite think you've got the entire concept; then again, nobody really does.

#17 Re: Coder's Corner » One-way function; VB » 2008-01-30 05:40:54

Nah. You can always brute-force it, but it takes a lot longer.

Here is what makes it impossible to do by any other means than brute-force:
The result is the concatenation of the previous result and the sum of the ASCII values of two characters in the string, the first one cycling through the entire length of said string, the other's position defined by the square root of the length of the previous result.

#18 Re: Coder's Corner » One-way function; VB » 2008-01-30 05:14:58

The entered strings can contain any ASCII characters, as well as numbers. It seems that I did forget the following:

Dim CompiledString As String
Dim Output As String
Dim x As Integer

#19 Re: Coder's Corner » One-way function; VB » 2008-01-30 02:30:53

All right; I'll simplify the challenge: could you simply deduce the concatenated string from the end result?

#20 Re: Coder's Corner » One-way function; VB » 2008-01-29 23:58:02

Unless I made some huge mistake, which is possible, the only way to get back to the original string is the good ol' brute-force method.

#21 Re: This is Cool » Will this plane take off? » 2008-01-29 08:38:19

It would obviously take off. The force generated by the engine is pushing the plane forward through the air, not turning the wheels. Therefore, if you take the option of poorly lubricated wheels out of the picture, there is no difference that the moving runway should make.

The only purpose of the landing gear is to reduce the amount of damage caused by the ground (otherwise, the belly of the plane would be torn to shreds by that force), by keeping the plane off the ground.

#22 Re: Coder's Corner » One-way function; VB » 2008-01-29 08:24:36

In VB, if the strings are numbers, the string + string adds the numbers, but, if they aren't numbers, it "concatenates" them.
Thus, for strings, in VB, the + and & operators do the same thing.

Note that I am not using VB.net, but VB 5.0. There is a world of difference between the two. VB.net is similar to Java. Standard VB is an older language, much less strict as far as syntax goes.

#23 Re: Coder's Corner » One-way function; VB » 2008-01-29 07:50:32

string & string -> puts the two strings together, in the order they are typed, to form one longer string
Asc(string) -> gives the ASCII value of the first character in the string
Mid(string, integer, [integer]) -> returns the section of the string starting at the position defined by the first integer, and of length defined by the second integer (if it is not present, it returns the text from the starting point to the end of the string)
sqr(integer) -> returns the square root of the number

VB does have a few nice things about it: It isn't case-sensitive, you can leave out spaces, etc., and it corrects it without prompting; furthermore, there are no compilers for Java that have as much freedom for the user interface. There are also many different ways of achieving the same result, from simple to complex, long to short.

I have to agree, however, that there could be some improvements.

#24 Coder's Corner » One-way function; VB » 2008-01-29 05:43:38

Laterally Speaking
Replies: 14
For x = 0 To 1
    CompiledString = CompiledString & Password(x).Text
Next

CompiledString = CompiledString & UserName.Text

For x = 1 To Len(CompiledString)
    Output = Output & Int(Asc(Mid(CompiledString, x, 1)) + Asc(Mid(CompiledString, Int(((x + Sqr(Len(Output))) Mod (Len(CompiledString) - 1)) + 1), 1)))
Next

I will give high praise to anyone who thinks they know how to retrieve the original information and actually can.

For those without VB 5.0 compilers, here are the results:

UserName.text = afoiadfjanwief
Password(0).Text = wedraixdn
Password(1).Text = rhescaiufenxe
Output = 21320613321521521313720022519321622014020622920020522023114221614781235202229213137230211142153220216199211202222221210230215201203226196197207223199211229225203216203211219194205222206211214220220200199224218202224217206217202221219201201217196207224222203212212152217201203210216206212207214198224203209206134
UserName.text = aerjxosadmxxicwwmdxMALW
Password(0).Text = adxneuXddwriox
Password(1).Text = XAwjixnckefexnIXern
Output = 21320613321521521313720022519321622014020622920020522023114221614781235202229213137230211142153220216199211202222221210230215201203226196197207223199211229225203216203211219194205222206211214220220200199224218202224217206217202221219201201217196207224222203203207220221207203199205185165221212202230229204208204198220230183189218202210185166233226216235207199216221222206219229192197221191175173188211206240221216214188209185239211204239229208207221179166196197170201234220198218202206208176234203205229230219206220221210220230150153177201207197221224207208211203162219215225240215198226220211201240187153177201207197221224207237199215185165228226225225229218216201222178185186160185201234220198218202206185230221202220219219227206201220239219173208178179186188211206240221216214188209208185224205224239219199227178178188217210193198202231198197201233220225222235185165228225240215198226220211201240187138164188211210217211215223208215197219223225231225187184238215205240187164183188199201240220190176201214229211206225226208176234203205229230219212200221220219173208178179186184198214226230212232185200209239234210210239207165239183170196221201139217206202152209184197213219218198215198210225143220212132225221235221131229230141149239178165190184

What gave

Output = 1811291842231331601942231331901811982221911291831291921982151981692092151401201292322052191872062231402101551412332202062296421515764156213212213233232205215133212139147172125199213206224148181218228215199218147227172207225216185205140184149211230198235116171219211142191208211

#25 Re: Dark Discussions at Cafe Infinity » Wrapping Your Christmas Presents » 2007-12-08 06:03:22

Also, finding out the area is not much use. You would be better off just finding out the hight and width of paper needed, instead of finding the area, then trying to backtrack to the dimensions.

Board footer

Powered by FluxBB