August 03, 2020, 12:32:25 pm

You can help CodeWalrus stay online by donating here.

 WARNING: DO NOT UPGRADE your TI-83 Premium CE or TI-84 Plus CE to OS 5.5.1 and higher. It removes all compatibility with most games and removes ASM/C programming! DOWNGRADING IS IMPOSSIBLE. BE WARNED! Likewise, do NOT update your TI-Nspire CX past OS 4.5.0, else using Ndless and ASM/C programs will be impossible.

## Code Golf Belgium Numbers

Started by PT_, August 16, 2017, 06:37:13 pm

0 Members and 1 Guest are viewing this topic.

#### PT_

##### August 16, 2017, 06:37:13 pm

It was a rather long time ago that Code Golf - The Reboot was active, and I enjoyed it so much, that I decided it would be fun to pick that up again. So here I am with a new task. Don't know what Code Golf is? Check some old topics. You have one week to complete this task, and entries should be submitted by sending a PM to me. Without any further ado, here is your task:

Write a program that inputs a positive integer and outputs the Belgium k-number of the input. Of course, you have no idea what a Belgium k-number is, so let me explain that first. Let k be one of the integers 0-9. The input N has the Belgium k-number, if N occurs in the increasing sequence which starts with k, and the difference between 2 consecutive numbers in the sequence are the same as the digits of N. See this for a better explanation. Let me give an example.

`k = 7, N = 85Sequence starts with 77  + 8 = 1515 + 5 = 2020 + 8 = 2828 + 5 = 3333 + 8 = 4141 + 5 = 4646 + 8 = 5454 + 5 = 5959 + 8 = 6767 + 5 = 7272 + 8 = 8080 + 5 = 85STOP`
As you can see, 85 is in the sequence (7, 15, 20, 28, 33..), which means 85 as Belgium k-number 7.

Other example:
`k = 7, N = 152Sequence starts with 77  + 1 = 88  + 5 = 1313 + 2 = 1515 + 1 = 1616 + 5 = 2121 + 2 = 2323 + 1 = 24...`

Providing that ANY input N has at least 1 Belgium k-number, find one of the Belgium k-numbers with any input.

Good luck!

I've no idea if this is a simple or a hard task, we will see later!

Sorry, didn't realize there are already 2 open contests at CW

#### c4ooo

##### August 16, 2017, 06:54:41 pm #1
You should change the name of the thread to "code golf - the reboot - the reboot #1"

Anyways, I don't remember you participating in codegolf on omninaga? Lol

#### Yuki

##### August 16, 2017, 06:59:36 pm #2 Last Edit: August 16, 2017, 07:10:36 pm by Juju
And I rebooted the concept just yesterday, what a coincidence? Eh, I dunno, you should had seen it. Anyway. Good to have some contests here. I'll try to do something.

EDIT: What about Code Golf: The CWreboot #2? (#1 is mine, hehe)
YUKI-CHAAAANNNN
In the beginning there was walrii. In the end there will be walrii. All hail our supreme leader --Snektron

if you wanna throw money at me and/or CodeWalrus monthly it's here

#### _iPhoenix_

##### August 16, 2017, 08:08:33 pm #3
I'm at 51 bytes, which I suspect is the absolute minimum.

(This is TI-BASIC only, btw)

"walruses are better than tuxedo chickens, all hail the great " ~ me
Evolution of my avatar:

#### Yuki

##### August 17, 2017, 05:24:31 am #4 Last Edit: August 17, 2017, 06:53:45 am by Juju
Okay, so if I understand, for any input N, find the k number(s), if there's any?

Edit: I'm at 95 bytes in Ruby (or 87 in Ruby 2.4). Cool and good.
YUKI-CHAAAANNNN
In the beginning there was walrii. In the end there will be walrii. All hail our supreme leader --Snektron

if you wanna throw money at me and/or CodeWalrus monthly it's here

#### PT_

##### August 17, 2017, 07:43:54 am #5
Exactly. The only difference is that you can assume there is always at least 1 Belgium-k number.

#### Yuki

##### August 17, 2017, 07:47:03 am #6
Eh, as I wrote it I'm not assuming anything, it just outputs nothing if it's not a Belgium-k number.

(Also, standings?)
YUKI-CHAAAANNNN
In the beginning there was walrii. In the end there will be walrii. All hail our supreme leader --Snektron

if you wanna throw money at me and/or CodeWalrus monthly it's here

#### kotu

##### August 17, 2017, 08:06:23 am #7
quote #3
SUBSCRIBE TO THE FUTURERAVE.UK MAILING LIST
http://futurerave.uk

#### PT_

##### August 17, 2017, 01:25:38 pm #8
Sorry if I was not clear, but your program should input the variable, you can't assume N (or any other variable) is set before the program runs. In TI-BASIC, it looks like `Input N` or something similar. With Assembly, you are allowed to fetch the input from Ans. It should display/set in Ans at least one k-number.