<commit_before>﻿//We are given numbers N and M and the following operations:
//  * `N = N+1`
//  * `N = N+2`
//  * `N = N*2`

//  - Write a program that finds the shortest sequence of operations from the list above that starts from `N` and finishes in `M`.
//  - _Hint_: use a queue.
//  - Example: `N = 5`, `M = 16`
//  - Sequence: 5 &rarr; 7 &rarr; 8 &rarr; 16

namespace SequenceOfOperations
{
    using System;
    using System.Collections.Generic;
    using System.Linq;

    internal class Program
    {
        public static void Main()
        {
            int start = 5;
            int end = 26;

            var sequence = GetShortestSequence(start, end);

            Console.WriteLine(string.Join(" -> ", sequence));
        }

        private static IEnumerable<int> GetShortestSequence(int start, int end)
        {
            var sequence = new Queue<int>();

            while (start <= end)
            {
                sequence.Enqueue(end);

                if (end / 2 >= start)
                {
                    if (end % 2 == 0)
                    {
                        end /= 2;
                    }
                    else
                    {
                        end--;
                    }
                }
                else
                {
                    if (end - 2 >= start)
                    {
                        end -= 2;
                    }
                    else
                    {
                        end--;
                    }
                }
            }
            return sequence.Reverse();
        }
    }
}<commit_msg>Fix bug from 1 to 3<commit_after>﻿//We are given numbers N and M and the following operations:
//  * `N = N+1`
//  * `N = N+2`
//  * `N = N*2`

//  - Write a program that finds the shortest sequence of operations from the list above that starts from `N` and finishes in `M`.
//  - _Hint_: use a queue.
//  - Example: `N = 5`, `M = 16`
//  - Sequence: 5 &rarr; 7 &rarr; 8 &rarr; 16

namespace SequenceOfOperations
{
    using System;
    using System.Collections.Generic;
    using System.Linq;

    internal class Program
    {
        public static void Main()
        {
            int start = 5;
            int end = 26;

            var sequence = GetShortestSequence(start, end);

            Console.WriteLine(string.Join(" -> ", sequence));
        }

        private static IEnumerable<int> GetShortestSequence(int start, int end)
        {
            var sequence = new Queue<int>();

            while (start <= end)
            {
                sequence.Enqueue(end);

                if (end / 2 > start)
                {
                    if (end % 2 == 0)
                    {
                        end /= 2;
                    }
                    else
                    {
                        end--;
                    }
                }
                else
                {
                    if (end - 2 >= start)
                    {
                        end -= 2;
                    }
                    else
                    {
                        end--;
                    }
                }
            }

            return sequence.Reverse();
        }
    }
}
{'fraction_non_alphanumeric': 0.10049474335188621, 'fraction_numerical': 0.012987012987012988, 'mean_word_length': 0.8797210923881464, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4672415', 'n_tokens_mistral': 905, 'n_tokens_neox': 800, 'n_words': 247}