예제 #1
0
 /// <summary>
 /// Entry Point for the Challenge
 /// </summary>
 /// <param name="args">Command line Arguments</param>
 public static void Main(string[] args)
 {
     string[] lines = File.ReadAllLines(args[0]);
     foreach (var line in lines)
     {
         var display = new SegmentDisplay();
         display.Display(line);
     }
 }
예제 #2
0
    private void UpdateSegment(GameObject segment, int digit)
    {
        bool[]     states          = SegmentDisplay.getStatesForDigit(digit);
        Material[] segmentMaterial = segment.GetComponent <Renderer>().materials;

        for (int i = 0; i < segmentMaterial.Length; i++)
        {
            segmentMaterial[i] = states[i] ? SegmentOnMaterial : SegmentOffMaterial;
        }

        segment.GetComponent <Renderer>().materials = segmentMaterial;
    }
예제 #3
0
    private IEnumerator ClearCorrectNumbers(SegmentDisplay display)
    {
        yield return(new WaitUntil(() => !coroutineInProgress));

        SetSpecificDisplayOneColor(display, Color.black);
        yield return(new WaitForSeconds(.2f));

        SetSpecificDisplayOneColor(display, Color.green);
        yield return(new WaitForSeconds(.1f));

        SetSpecificDisplayOneColor(display, Color.black);

        coroutineInProgress = false;
    }
예제 #4
0
            public int Run(string input = Input)
            {
                var memory = Input.Split(',').Select(s => BigInteger.Parse(s)).ToArray();

                memory[0] = 2; // to play for free!
                var cpu = new IntCodeStateMachine(memory);

                var scoreView = new ScoreView();
                var gameView  = new SegmentDisplay(scoreView, new ConsoleGameView());
                var gameInput = new AiGameInput(cpu);

                var game = new ArcadeProgram(cpu, gameView, gameInput);

                cpu.RunAll();

                Console.Clear();

                return(scoreView.FinalScore);
            }
예제 #5
0
    public static void UpdateSegment(GameObject segment, int digit, Material onMatieral, Material offMaterial)
    {
        int previousDigit = SegmentPreviousDigit.GetOrDefault(segment, -1);

        if (digit != previousDigit || previousDigit == -1)
        {
            bool[] currentStates = previousDigit == -1 ? null : SegmentDisplay.getStatesForDigit(previousDigit);
            bool[] digitStates   = SegmentDisplay.getStatesForDigit(digit);

            Material[] segmentMaterial = segment.GetComponent <Renderer>().materials;
            for (int i = 0; i < segmentMaterial.Length; i++)
            {
                if (currentStates == null || digitStates[i] != currentStates[i])
                {
                    segmentMaterial[i] = digitStates[i] ? onMatieral : offMaterial;
                }
            }

            segment.GetComponent <Renderer>().materials = segmentMaterial;
        }

        SegmentPreviousDigit[segment] = digit;
    }
예제 #6
0
 void SetSpecificDisplayOneColor(SegmentDisplay display, Color color)
 {
     display.SetColor(color);
 }
예제 #7
0
 private static Boolean KawigiEdit_RunTest(int testNum, int p0, Boolean hasAnswer, int p1)
 {
     Console.Write("Test " + testNum + ": [" + p0);
     Console.WriteLine("]");
     SegmentDisplay obj;
     int answer;
     obj = new SegmentDisplay();
     DateTime startTime = DateTime.Now;
     answer = obj.howManyNumbers(p0);
     DateTime endTime = DateTime.Now;
     Boolean res;
     res = true;
     Console.WriteLine("Time: " + (endTime - startTime).TotalSeconds + " seconds");
     if (hasAnswer) {
         Console.WriteLine("Desired answer:");
         Console.WriteLine("\t" + p1);
     }
     Console.WriteLine("Your answer:");
     Console.WriteLine("\t" + answer);
     if (hasAnswer) {
         res = answer == p1;
     }
     if (!res) {
         Console.WriteLine("DOESN'T MATCH!!!!");
     } else if ((endTime - startTime).TotalSeconds >= 2) {
         Console.WriteLine("FAIL the timeout");
         res = false;
     } else if (hasAnswer) {
         Console.WriteLine("Match :-)");
     } else {
         Console.WriteLine("OK, but is it right?");
     }
     Console.WriteLine("");
     return res;
 }
예제 #8
0
 public override void SetFont(SpriteFont font)
 {
     SegmentDisplay.SetFont(font);
 }
예제 #9
0
 public override void SetTextures(Texture2D onTexture, Texture2D offTexture)
 {
     SegmentDisplay.SetTextures(onTexture, offTexture);
 }
예제 #10
0
 public override void Draw(SpriteBatch spriteBatch)
 {
     SegmentDisplay.Draw(spriteBatch);
 }
예제 #11
0
 public ConfigurationFibonacci(ReadonlyMemory memory, RandomAccessMemory ram, SegmentDisplay segmentDisplay, Accumulator accumulator) : base(memory)
 {
     RAM            = ram;
     SegmentDisplay = segmentDisplay;
     Accumulator    = accumulator;
 }