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

  • SEARCH
  • Home
  • 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 6706591
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T07:32:18+00:00 2026-05-26T07:32:18+00:00

I am working on the software for a machine that will automatically trim toenails,

  • 0

I am working on the software for a machine that will automatically trim toenails, so that users can simply put their feet in it and run it instead of having to manually do it by biting them or using nail clippers.

A sizeable percentage of our potential user base will likely be Jewish, and, evidently, there is a tradition about not trimming toenails (or fingernails) in sequential order

There seems to be dissenting opinion on the precise application of this tradition, but we think that the following rules are sufficient to accomodate people whose religious practices prohibit cutting toenails in order:

  • No two adjacent toenails should be cut consecutively
  • The cutting sequence on the left foot should not match the sequence on the right foot
  • The cutting sequence on two consecutive runs should not be the same. The sequences shouldn’t be easily predictable, so hardcoding an alternating sequence does not work.

This is how we have decided to number the toes:

5 4 3 2 1  1 2 3 4 5
Left foot  Right foot

I have written code to solve the problem, but the algorithm used is sub-optimal: in fact, the worst case performance is O(∞). The way it works is comparable to bogosort. Here is a pseudocode simplification of the actual code used:

function GenerateRandomSequence
   sequence = Array[5]
   foreach (item in sequence)
       item = RandomNumberBetween(1,5)
   return sequence

function GetToenailCuttingOrder
   while (true)
      sequence = GenerateRandomSequence()
      if (!AllItemsAreUnique(sequence))
         continue
      if (NoTwoAdjacentItemsHaveConsecutiveNumbers(sequence))
         return sequence

do
    leftFootSequence = GetToenailCuttingOrder()
    rightFootSequence = GetToenailCuttingOrder()
until (leftFootSequence != rightFootSequence &&
       leftFootSequence != leftFootSequenceFromLastRun &&
       rightFootSequence != rightFootSequenceFromLastRun)

Basically, it generates random sequences and checks if they meet the criteria. If it doesn’t meet the criteria, it starts over. It doesn’t take a ridiculously long amount of time, but it is very unpredictable.

I realize that the way I am currently doing it is pretty terrible, but I’m having trouble coming up with a better way. Can any of you suggest a more elegant and performant algorithm?

  • 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-26T07:32:19+00:00Added an answer on May 26, 2026 at 7:32 am

    You could generate all possible toenail cutting sequences with no restrictions, and then filter out all sequences that violate the jewish rule. Luckily, humans only have five toes per foot*, so there are only 5! = 120 unrestricted sequences.

    Python example:

    #seq is only valid when consecutive elements in the list differ by at least two.
    def isValid(seq):
        for i in range(len(seq)-1):
            a = seq[i]
            b = seq[i+1]
            if abs(a-b) == 1:
                return False
        return True
    
    
    from itertools import ifilter, permutations
    validseqs = ifilter(isValid, permutations([1,2,3,4,5]))
    for i in validseqs:
        print i
    
    (1, 3, 5, 2, 4)
    (1, 4, 2, 5, 3)
    (2, 4, 1, 3, 5)
    (2, 4, 1, 5, 3)
    (2, 5, 3, 1, 4)
    (3, 1, 4, 2, 5)
    (3, 1, 5, 2, 4)
    (3, 5, 1, 4, 2)
    (3, 5, 2, 4, 1)
    (4, 1, 3, 5, 2)
    (4, 2, 5, 1, 3)
    (4, 2, 5, 3, 1)
    (5, 2, 4, 1, 3)
    (5, 3, 1, 4, 2)
    

    To enforce your “no repeats of the same sequence” rule, you can just choose four of the above sequences, and use them alternately. The only catch here is that if you count the two big toes as “consecutive”, then you can’t choose two sequences that end and begin with 1, respectively.

    *You may want to make a numberOfToesPerFoot variable, so you can easily change it later if any of your clients turn out to have less toes than you expect, or more.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on a software development project that uses code written primarily in
A software application that I'm working on needs to be able to assign tasks
We are working with some new Cutting Tools that can have it's hardware parameters
I'm working on a .net application that will be used for auditing the configuration
We've inherited some legacy software that we need to run quite urgently. It was
I am using and working on software which uses MySQL as a backend engine
The software company I'm working for builds software for schools, and so our client
I'm working on a software project which several members are working from home and
I am working on a software-as-a-service (SaaS) application and I am looking for a
My co-workers rarely (if ever) use XML Comments when working on our software (I

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.