Search Results

Search found 6 results on 1 pages for 'mian'.

Page 1/1 | 1 

  • [Python] Tips for making a fraction calculator code more optimized (faster and using less memory)

    - by Logic Named Joe
    Hello Everyone, Basicly, what I need for the program to do is to act a as simple fraction calculator (for addition, subtraction, multiplication and division) for the a single line of input, for example: -input: 1/7 + 3/5 -output: 26/35 My initial code: import sys def euclid(numA, numB): while numB != 0: numRem = numA % numB numA = numB numB = numRem return numA for wejscie in sys.stdin: wyjscie = wejscie.split(' ') a, b = [int(x) for x in wyjscie[0].split("/")] c, d = [int(x) for x in wyjscie[2].split("/")] if wyjscie[1] == '+': licz = a * d + b * c mian= b * d nwd = euclid(licz, mian) konA = licz/nwd konB = mian/nwd wynik = str(konA) + '/' + str(konB) print(wynik) elif wyjscie[1] == '-': licz= a * d - b * c mian= b * d nwd = euclid(licz, mian) konA = licz/nwd konB = mian/nwd wynik = str(konA) + '/' + str(konB) print(wynik) elif wyjscie[1] == '*': licz= a * c mian= b * d nwd = euclid(licz, mian) konA = licz/nwd konB = mian/nwd wynik = str(konA) + '/' + str(konB) print(wynik) else: licz= a * d mian= b * c nwd = euclid(licz, mian) konA = licz/nwd konB = mian/nwd wynik = str(konA) + '/' + str(konB) print(wynik) Which I reduced to: import sys def euclid(numA, numB): while numB != 0: numRem = numA % numB numA = numB numB = numRem return numA for wejscie in sys.stdin: wyjscie = wejscie.split(' ') a, b = [int(x) for x in wyjscie[0].split("/")] c, d = [int(x) for x in wyjscie[2].split("/")] if wyjscie[1] == '+': print("/".join([str((a * d + b * c)/euclid(a * d + b * c, b * d)),str((b * d)/euclid(a * d + b * c, b * d))])) elif wyjscie[1] == '-': print("/".join([str((a * d - b * c)/euclid(a * d - b * c, b * d)),str((b * d)/euclid(a * d - b * c, b * d))])) elif wyjscie[1] == '*': print("/".join([str((a * c)/euclid(a * c, b * d)),str((b * d)/euclid(a * c, b * d))])) else: print("/".join([str((a * d)/euclid(a * d, b * c)),str((b * c)/euclid(a * d, b * c))])) Any advice on how to improve this futher is welcome. Edit: one more thing that I forgot to mention - the code can not make use of any libraries apart from sys.

    Read the article

  • cli commands not working asterisk on ubuntu

    - by Mian Khurram Ijaz
    hi guys today my first day on asterisk on ubuntu. I installed vmware and then ubuntu and then on ubuntu i am running asterisk. i started the asterisk server successfully by following a tutorial. After making few changes into the sip.conf i want to reload the sip.conf i issue the command sip reload and nothing happens neither the commands to restart the asterisk server work actually the commands do not exists can some please throw light or point to right direction. thanks

    Read the article

  • How to use join in EntityQuery,.. using RIA and Entities

    - by mian
    Hi i use the following patterh for fetching data using RIA objTestAppContext is an instance of LinqToEntitiesDomainService class EntityQuery query = from tmpTable in objTestAppContext.GteOrdrs() where tmpTable.orderID == d select tmpTable; Now scenerio is ,, that I also have a OrderDetail entity in EDMS which is attached to he Order as orderID in OrderDetails which is managed by the association set named as FK_orderdetals_orders. Please tell how can i use join in the "query"

    Read the article

  • Scala passing type parameters to object

    - by Shahzad Mian
    In Scala v 2.7.7 I have a file with class Something[T] extends Other { } object Something extends OtherConstructor[Something] { } This throws the error: class Something takes type parameters object Something extends OtherConstructor[Something] { However, I can't do this object Something[T] extends OtherConstructor[Something[T]] { } It throws an error: error: ';' expected but '[' found. Is it possible to send type parameters to object? Or should I change and simply use Otherconstructor

    Read the article

  • C# beginner help

    - by ThickBook
    Can you help in this example? I am a beginner. Thanks using System; class Program { public static void Mian(string[] args) { Console.Write("Your Name?: "); string name = Console.Read(); Console.WriteLine("Welcome {0}", name); } }

    Read the article

  • how to find by date from timestamp column in JPA criteria

    - by Kre Toni
    I want to find a record by date. In entity and database table datatype is timestamp. I used Oracle database. @Entity public class Request implements Serializable { @Id private String id; @Version private long version; @Temporal(TemporalType.TIMESTAMP) @Column(name = "CREATION_DATE") private Date creationDate; public Request() { } public Request(String id, Date creationDate) { setId(id); setCreationDate(creationDate); } public String getId() { return id; } public void setId(String id) { this.id = id; } public long getVersion() { return version; } public void setVersion(long version) { this.version = version; } public Date getCreationDate() { return creationDate; } public void setCreationDate(Date creationDate) { this.creationDate = creationDate; } } in mian method public static void main(String[] args) { RequestTestCase requestTestCase = new RequestTestCase(); EntityManager em = Persistence.createEntityManagerFactory("Criteria").createEntityManager(); em.getTransaction().begin(); em.persist(new Request("005",new Date())); em.getTransaction().commit(); Query q = em.createQuery("SELECT r FROM Request r WHERE r.creationDate = :creationDate",Request.class); q.setParameter("creationDate",new GregorianCalendar(2012,12,5).getTime()); Request r = (Request)q.getSingleResult(); System.out.println(r.getCreationDate()); } in oracle database record is ID CREATION_DATE VERSION 006 05-DEC-12 05.34.39.200000 PM 1 Exception is Exception in thread "main" javax.persistence.NoResultException: getSingleResult() did not retrieve any entities. at org.eclipse.persistence.internal.jpa.EJBQueryImpl.throwNoResultException(EJBQueryImpl.java:1246) at org.eclipse.persistence.internal.jpa.EJBQueryImpl.getSingleResult(EJBQueryImpl.java:750) at com.ktrsn.RequestTestCase.main(RequestTestCase.java:29)

    Read the article

1