Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 428539
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T19:41:10+00:00 2026-05-12T19:41:10+00:00

I am doing project euler question 33 and have divised a refactor to solve

  • 0

I am doing project euler question 33 and have divised a refactor to solve it but I can’t think of how to remove the digit if it is the same across both x and y.
I got this far:

import Ratio
import List
p33 =  [ (x%y) | y <- [10..99] , x <- [10..y], (x `rem` 10) /= 0 , (y `rem` 10) /= 0 , x /= y , (length $ nub $ concat $ map decToList [x,y]) == 3 , [numerator(x%y),denominator(x%y)] == WHAT GOES HERE? ]

The cancelling of 0’s is not allowed.
What it should do is:

49/98 {cancel the 9's}

to get:

4/8 as the result. But I can’t think of how to remove the common digits from each number.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T19:41:10+00:00Added an answer on May 12, 2026 at 7:41 pm

    Let x and y be the two numbers. Then one can remove the digits in x which it has in common with y like this:

    Prelude> import Data.List
    Prelude Data.List> let x = 68
    Prelude Data.List> let y = 76
    Prelude Data.List> read (show x \\ show y) :: Int
    8
    

    Flip x and y to remove digits from y. This uses xsData.List.(\\)ys, which removes the first occurrence of each element in ys from xs.


    Edit: you may have solved problem 33 by now. If not, let me give you some more hints:

    The code which I gave above, i.e. read (show x \\ show y) is not really suitable for this problem. What happens if x equals ab and y equals ba, for some digits a and b?

    The solution to this problem can be written as a single list comprehension. You may want to use Data.List.intersect and Data.List.nub to create the following term in your list comprehension:

    s <- nub $ intersect (show x) (show y)
    

    Now s ranges over the digits that x and y have in common. You can remove these from x and y using

    map (read . delete s . show) [x, y]
    

    I cannot be more explicit without solving the exercise for you, but I’ll leave you with two more hints:

    • In your code you write y <- [10..99], x <- [10..y], x /= y. Observe that this can be written more succinctly as y <- [10..99], x <- [10..y-1].
    • Have a look at Data.Ratio, which provides an easy way to test the equality of rational numbers and automatically calculates the numerator and denominator of a fraction in its reduced form.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 231k
  • Answers 231k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Use the following function like this: Image('/path/to/original.image', '1/1', '150*', './thumb.jpg');… May 13, 2026 at 2:13 am
  • Editorial Team
    Editorial Team added an answer Check you database schema to see if the field (referenced… May 13, 2026 at 2:13 am
  • Editorial Team
    Editorial Team added an answer I figured out the problem - there was a session… May 13, 2026 at 2:13 am

Related Questions

I am doing project euler question 224 . And whipped up this list comprehension
I am doing project euler question 63 where I must find the amount of
I am doing another Project Euler problem and I need to find when the
I am doing yet another Project Euler problem - Problem 38 . I have

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.