Off-topic Talk Where overpaid, underworked S2000 owners waste the worst part of their days before the drive home. This forum is for general chit chat and discussions not covered by the other off-topic forums.

Can all the computer programmers please read!!! I have a question for you.

Thread Tools
 
Old Jan 31, 2002 | 10:58 AM
  #31  
josh3io's Avatar
Registered User
25 Year Member
 
Joined: Oct 2000
Posts: 2,584
Likes: 0
From: Mountain View
Default

Originally posted by moonpie
Here it is in perl:

#!/usr/bin/perl
print "Enter the temperature in Fahrenheitn";
chomp($fah = <STDIN>);
$cel = ($fah - 32) * (5/9);
print "The temperature in Celcius is $celn";
bahh, too long!!
try this:

perl -pe 'print"Celcius:".($_-32)*(5/9);$_="";print"nEnter Farenheit:"'

61 characters

or without prompting,
perl -pe '$_=(($_-32)*5/9)."n"'
that's 21 characters
Reply
Old Jan 31, 2002 | 11:06 AM
  #32  
Shinji's Avatar
Thread Starter
Registered User
 
Joined: Jul 2001
Posts: 1,985
Likes: 0
Default

This is crazy guys! It's like everyones posting their own language here. Haha
Reply
Old Jan 31, 2002 | 11:11 AM
  #33  
josh3io's Avatar
Registered User
25 Year Member
 
Joined: Oct 2000
Posts: 2,584
Likes: 0
From: Mountain View
Default

noone did php for the web:

<?php?>
<FORM ACTION='post' METHOD='<?echo $PHP_SELF?>'>
Farenheit: <INPUT TYPE='text' NAME='f' VALUE='<?echo $f?>'><?if ($c) { echo "is $c Celcius"; }?>
<INPUT TYPE='submit' NAME='s' VALUE='convert farenheit to celcius'>
Reply
Old Jan 31, 2002 | 11:11 AM
  #34  
chroot's Avatar
Registered User
 
Joined: Aug 2001
Posts: 1,607
Likes: 0
From: Santa Clara
Default

Ya done made me bust out the lisp.

(DEFUN F-TO-C (TEMPERATURE)
(- (/ (+ TEMPERATURE 40)
1.8)
40))

(DEFUN C-TO-F (TEMPERATURE)
(- (* (+ TEMPERATURE 40)
1.8)
40))



- Warren
Reply
Old Jan 31, 2002 | 11:11 AM
  #35  
tantheman's Avatar
Registered User
 
Joined: Jun 2001
Posts: 7,279
Likes: 1
From: Fountain Valley, CA
Default

Maybe this should go into pocket protector forum...

Tan
Reply
Old Jan 31, 2002 | 11:13 AM
  #36  
KaiWang's Avatar
25 Year Member
 
Joined: Oct 2000
Posts: 1,736
Likes: 0
From: DC
Default

better think about another major....
Reply
Old Jan 31, 2002 | 11:24 AM
  #37  
josh3io's Avatar
Registered User
25 Year Member
 
Joined: Oct 2000
Posts: 2,584
Likes: 0
From: Mountain View
Default

or a shell script

#!/bin/sh

echo "Enter Farenheit: "
read f
a=`expr $f - 32`
a=`expr $a * 5`
a=`expr $a / 9`
echo "Celcius is $a"
Reply
Old Jan 31, 2002 | 11:25 AM
  #38  
krhorrocks's Avatar
Registered User
 
Joined: Feb 2001
Posts: 627
Likes: 0
From: Seattle, WA
Default

here's MSIL

.method private hidebysig static void Main(string[] args) cil managed
{
.entrypoint
// Code size 66 (0x42)
.maxstack 3
.locals ([0] float64 f,[1] float64 c)
IL_0000: ldstr "Enter temp in F :"
IL_0005: call void [mscorlib]System.Console::WriteLine(string)
IL_000a: call string [mscorlib]System.Console::ReadLine()
IL_000f: call float64 [mscorlib]System.Double::Parse(string)
IL_0014: stloc.0
IL_0015: ldc.r8 0.55555555555555558
IL_001e: ldloc.0
IL_001f: ldc.r8 32.
IL_0028: sub
IL_0029: mul
IL_002a: stloc.1
IL_002b: ldstr "Celsius temperature is {0}"
IL_0030: ldloc.1
IL_0031: box [mscorlib]System.Double
IL_0036: call void [mscorlib]System.Console::WriteLine(string,object)
IL_003b: call string [mscorlib]System.Console::ReadLine()
IL_0040: pop
IL_0041: ret
}
Reply
Old Jan 31, 2002 | 11:30 AM
  #39  
moonpie's Avatar
Registered User
 
Joined: Oct 2001
Posts: 1,611
Likes: 0
From: Melbourne
Default

[QUOTE]Originally posted by josh3io
[B]

bahh, too long!!
try this:

perl -pe 'print"Celcius:".($_-32)*(5/9);$_="";print"nEnter Farenheit:"'

61 characters

or without prompting,
Reply
Old Jan 31, 2002 | 11:34 AM
  #40  
chroot's Avatar
Registered User
 
Joined: Aug 2001
Posts: 1,607
Likes: 0
From: Santa Clara
Default

It seems we're one step away from making this the first annual OOULS2KIFCCC...

"The Obfuscated or Otherwise Useless Language S2000 International Fahrenheit-to-Celsius Converter Contest."

WHO WILL WIN??

- Warren
Reply



All times are GMT -8. The time now is 03:54 AM.